Skip to content

Development environment

Romke van Dijk edited this page Jun 29, 2022 · 10 revisions

Setup for both server and agent

Server Development

The easiest way to develop for hashtopolis is to use the VSCode development that ships with Hashtopolis. For more details on development containers see: https://code.visualstudio.com/docs/remote/containers

Other methods for developing is just to setup hashtopolis locally and run it directly from the git repo.

Setup

  • Clone the server repo
  • In vscode select 'Open Folder in Container' either by (CTRL + SHIFT + P, type: Open Folder in Container) or press the green extension button in the left bottom and select the option, now select the folder where hashtopolis-server is
  • Optional: set a break point and press F5 (Run -> Start Debugging)
  • Open a browser and visit: http://localhost:8080/
  • Login in with: username: root, password: hashtopolis

Details

How does the vscode dev container work? First off when opening the project from Visual Studio Code using the remote container plugin will scan for the .devcontainer folder inside the project. Next it will check the contents of devcontainer.json inside this folder. This file contains settings like how to mount the project directory inside the container.

Once it has loaded the file it checks what it needs to start. In our case it sees that there is a docker-compose file and it needs to start two services: hashtopolis and db. This will spawn two containers, hashtopolis and db. Hashtopolis container is created using the Dockerfile inside the .devcontainer folder. This basically installs apache2 + php with xdebug and configure hashtopolis. When the hashtopolis container starts it will run the docker-entrypoint.sh script inside the .devcontainer folder. This script does some tricks with setting up the database, an user and creates a voucher for connecting an agent.

Credentials

Hashtopolis user: root
Hashtopolis passsword: hashtopolis
Database user: hashtopolis
Database password: hashtopolis
Database root password: hashtopolis

Connect to the application using: http://127.0.0.1:8080/

To connect to the database spawn a shell inside the development container:

docker exec -it hashtopolis /bin/bash

And connect to the database

mysql -phashtopolis -uroot -hdb -Dhashtopolis

To connect an agent to the development container:

python3 hashtopolis.zip --url http://127.0.0.1:8080/api/server.php --voucher devagent --debug

Agent development

The agent now also contains a devcontainer configuration. Use the same instruction as you can find at the server.

Setup

NOTE: This only work on intel-based devices; no GPU is required.

  • Clone the python-agent repo
  • In vscode select 'Open Folder in Container' either by (CTRL + SHIFT + P, type: Open Folder in Container) or press the green extension button in the left bottom and select the option, now select the folder where python-agent is
  • Start the agent with either pressing F5 or (Run -> Start Debugging)

Details

The agent uses the docker network hashtopolis to connect to the hashtopolis server. In the devcontainer for the server a static voucher is created which is used by the agent. Inside the docker container the intel-opencl runtime is installed. This makes it possible to run Hashcat on a CPU.

To manual start the agent inside the devcontainer first spawn a shell:

docker exec -it hashtopolis_agent /bin/bash

Next start the agent

cd src/
python3 . --url http://hashtopolis/api/server.php --debug --voucher devvoucher

Nvidia support

It is possible to use nvidia devices in the dev container. For this you need to change the container image being used in the devcontainer file. Edit the first line of .devcontainer/Dockerfile to:

FROM nvidia/cuda:11.4.3-devel-ubuntu20.04

Next adding the .devcontainer/docker-compose.yml file. Add the following part to the hashtopolis-agent service:

    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]