diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..234e929 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +__pycache__ +dist +.gitignore +.dockerignore +Dockerfile diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 0000000..bfb0aea --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,29 @@ +name: Publish Docker image + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: kryptolyser/recool:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..281b19d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# docker build -t recool . +# docker run -it --rm --net=host -v ./recool-output:/recool/dist kryptolyser/recool -I eth0 + +FROM golang:1.22.0-bullseye + +WORKDIR /recool + +# Install dependencies +RUN apt-get update \ + && apt-get install -y \ + python3 \ + python3-pip \ + nmap \ + ipv6toolkit \ + sudo \ + && apt-get clean +RUN go install github.com/richartkeil/nplan@latest + +# Python dependencies +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +# Install recool +COPY recool.py . +COPY ip_tools.py . + +# Run recool +ENTRYPOINT ["python3", "recool.py"] diff --git a/Readme.md b/Readme.md index efa6549..935482d 100644 --- a/Readme.md +++ b/Readme.md @@ -3,6 +3,16 @@ A python script for automatically scanning a network with nmap/scan6 and creatin __Recool__ is short for __Reconnisance Tool__. +## Docker + +The easiest way to scan your network with recool is to use the official docker image. +You can append recool arguments to the docker command as normal. + +```sh +docker pull kryptolyser/recool +docker run -it --rm --net=host -v ./dist:/recool/dist kryptolyser/recool -I eth0 +``` + ## Requirements - Python3.9 (might work with earlier versions) diff --git a/ip_tools.py b/ip_tools.py index 4153a3b..feb10d7 100755 --- a/ip_tools.py +++ b/ip_tools.py @@ -249,7 +249,7 @@ def update_model(self, export=True): if export: self.spinner.text = f'Updating the nplan model...' os.popen(f'{self.args.nplan} -export -nmap {self.args.storage}/scan.xml -json {self.args.storage}/model.json -drawio {self.args.storage}/drawio.drawio > {self.args.storage}/nplan.log').read() - os.system(f'chmod 666 -R {self.args.storage}') + os.system(f'chmod 777 -R {self.args.storage}') # Save current state self.spinner.text = f'Saving the current state... (DO NOT EXIT)' diff --git a/recool.py b/recool.py index 81c1da2..85fee37 100755 --- a/recool.py +++ b/recool.py @@ -50,7 +50,7 @@ def parse_arguments(): args.ip = ip_tools.parse_ip(args.ip) # Create storage folder - args.storage.mkdir(parents=True, exist_ok=True) + args.storage.mkdir(parents=True, exist_ok=True, mode=0o777) # Format nmap speed argument args.speed = '-' + args.speed @@ -124,7 +124,7 @@ def main(): # Check if scan6 is installed if not which('scan6') and not args.no_ipv6: log.error(f'{stylize("ERROR!", STYLE_FAILURE)} {stylize("scan6", STYLE_HIGHLIGHT)} is not installed!') - log.error(f'Run {stylize("sudo apt install ipv6-toolkit", STYLE_HIGHLIGHT)} to install it.') + log.error(f'Run {stylize("sudo apt install ipv6toolkit", STYLE_HIGHLIGHT)} to install it.') log.error(f'Or disable IPv6 scanning with the {stylize("--no-ipv6", STYLE_HIGHLIGHT)} argument.') exit(1)