This repository contains 2 projects: a backend written in Golang, and a frontend written with ReactJS. This project is a school project in order to learn how to use docker and scaling services in docker. The goal of this project is to have a backend that communicates with "slaves" that will bruteforce in order to find the given md5 hash. In order to do that we split an alphabet in the number of slave connected and tells to each slave what range of letters he should try.
A docker-compose.yaml file is given for a fast usage. In order to use it, clone the project and run
docker-compose up -d
You will then be able to navigate to the frontend page at 127.0.0.1
This project has CI that generates three docker images, one for the frontend, one for the backend, and one for the slave.
Port that the server should be running on, default is 80
Path or the route to the websocket, default is /ws
Redis host with port, default is redis:6379
Username used for redis, default is void
Password used for redis, default is void
Database used for redis, must be an int, default is 0
Host where the backend websocket is hosted to with port, default is go
Route where the websocket is, default is /ws
You can use the slave for your project, for that pull the image
docker pull ghcr.io/mikedevresse/md5-cracker-slave:main
You can also use it in your docker compose:
slave:
image: "ghcr.io/mikedevresse/md5-cracker-slave:main"
and you can also add environment variables like this
slave:
image: "ghcr.io/mikedevresse/md5-cracker-slave:main"
environment:
SLAVE_HOST: "go"
SLAVE_PATH: "/ws"
seach hash begin end
Start the brute forcing from the begin parameter to the end one. It will only process the following regex [a-zA-Z0-9]+
stop
Stop the slave from searching
exit
stop the slave process (os.Exit(0))
found hash result
Sent when the slave has found the result
In order to use the backend itself you need to connect to the websocket, the port with the image is 80
but it is mapped to 8080
with the docker-compose.
In order to initiate the client you must first send a message containing client
in order to identify yourself
search md5_hash
This function allows you to add a md5 hash in the queue
Returns:
Added Hash $hash to queue
The hash has been added to the queueError Please provide a valid md5 hash
The provided hash is not a valid md5 hash
stop-all
Stop all the slaves from working, empty the queue
auto-scale true|false
Tells if the server should scale the slaves automatically depending on the queue or not
max-search limitForSearching
Sets the limit to which the word can be possible, must follow the regex ^[9]{2,8}$
Returns:
Error max-search argument must follow the regex: ^[9]{2,8}$
The provided limit does not follow the required regex
max-slaves-per-request numberOfSlaves
Tells how many slaves at the max should be working a search request for instance if we have 16 slaves but this option to 4, only 4 slaves will be working on the next search request. But if we have only 2 slaves available and this option to 4, the 2 slaves available will work on the search request
Returns:
Error max-slaves-per-request expects a number as second parameter
The given parameter was not a numberError max-slaves-per-request must be greater than 0
The given parameter is less or equal than 0
slaves numberOfSlaves
Allows you to scale the number of slaves that are working from 1 to 16
Returns:
Scaling
The application is getting scaledError An error occurred while trying to scale the application.
An unknown error occurred while scaling the applicationError slaves expects a number as second parameter
The given parameter was not a numberError slaves must be between 1 and 16
The given parameter is not between 1 and 16
queue queue_size search_request_being_handled
When the queue size or the number of request being handled gets updated, the websocket sends a queue message followed with the queue size and the number of search request being handled
slaves slave_count available_slaves working_slaves
When the slave count gets updated, the websocket sends a slaves message followed by the slave count, the number of slaves not working and the number of slaves working
max-search max_search_value
When configuration is updated, the server sends the current state
max-slaves-per-request number_of_slaves_per_request
When configuration is updated, the server sends the current state
auto-scale true|false
When configuration is updated, the server sends the current state
found md5_hash result
When you send a search request, when it will be resolved a found response will be given with the md5 hash and the result that have been found
Command "commandName" with numberOfArgs arguments not found
Occurs when a given request does not correspond to any known command