The bundle consists of 3 binaries:
- Server
- Client
- Launcher (for updating the client)
The three-way-handshake in normal mode goes as following:
- Client TCP connects to port 1337
- Server answers with b"server"
- Client answers with b"normal"
Schemes for all legal network interactions:
Server also runs a web page via rocket as an interface for adding tasks and viewing their results.
A task consists of a shell script (will be executed) and an optional attachment (a single file).
When a new task is recieved, it is saved and added to a task queue. A separate thread is running to assign tasks in queue to free workers from pool. The task is sent to the worker and is executed. After execution stdout and stdin are sent back to server and saved to add them to the task's web page. The worker is freed ready for new tasks.
Client's routine mainly consists of: 1. Finding the server 2. Connecting to the server 3. Updating 4. Recieving a task 5. Executing the task 6. Sending back results 7. GOTO step 3 Client has a savedata file that contains server ip address. If a connection to the address is unsuccessfull, client invalidates savedata address and bruteforces it. Client tries connecting to random ip's in its subnet. If through TWH it finds a server it succeeds. Otherwise, if it has found another client, it asks via TWH for servers ip and tries it. This feature was implemented specifically for networks with dynamic ip allocation. Client calculates hash of its binary and compares with the latest client hash from server. If hashes don't match client requests a fresh binary. After writing the new binary and checking its hash client terminates falling back to launcher, which finalizes update and restarts client. After results (stoud and stderr of the script) are sent back to server client deletes task files (the script and attachment) if retain_attachment flag is set the attachment is not deleted. Launches the client. Depending on exit code may update it by swapping old client file with a new one (created by client), then restart the client.