Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Push Multi-architecture Docker Image

on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4

-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: netwatchteam/netwatch_telnet-attackpod

-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./src/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
.vscode/
__pycache__/
*.py[cod]
.pytest_cache/
.env
43 changes: 43 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# NetWatch Telnet-AttackPod - Improvements

This document describes the improvements made to the Telnet-AttackPod codebase.

## Changes Made

### 1. Fixed Missing Import
- Added missing `import random` to resolve error in line 393
- This ensures proper functioning of the randomized delay between login attempts

### 2. Enhanced Docker Multi-architecture Support
- Updated Dockerfile with `--platform=linux/amd64` to ensure correct base image selection
- Created `build.sh` script for building multi-architecture images (amd64 and arm64)
- Modified docker-compose.yml to properly reference the Dockerfile location

### 3. Improved API Communication
- Added User-Agent header to requests for better identification
- Maintained existing authentication approach with Authorization header

## Architecture Support

The updated build system now supports building images for:
- AMD64 (x86_64)
- ARM64 (arm64/aarch64)

This enables running the AttackPod on various hardware platforms including Raspberry Pi and servers.

## Build Instructions

1. **Normal Build:**
```bash
docker compose build --no-cache
```

2. **Multi-architecture Build (Recommended):**
```bash
./build.sh
```

3. **Run the Container:**
```bash
docker compose up --force-recreate -d && docker compose logs -tf
```
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ telnet localhost 23

Enter any username and password when prompted. You should see the attack captured in the logs.

## Running Tests

Unit tests can be run with pytest:

```bash
cd src/
pip install -r requirements-test.txt
pytest tests.py -v
```

## RFC 1918 Private IP Filtering

The Telnet-AttackPod automatically filters out attacks involving private/local IP addresses to prevent false positives and reduce backend processing load. Attacks are **not reported** to the NetWatch collector if either the source IP or destination IP is a private/non-routable address.
Expand Down Expand Up @@ -126,9 +136,7 @@ The NetWatch backend frequently updates lists of IP addresses that have been ide

To get direct access to the data that your sensor submitted to the NetWatch backend, you can use the Community API. You can find the API documentation at: https://community-api.netwatch.team. Currently, the API allows you to retrieve the raw data that your sensor submitted to the NetWatch backend, as well as correlated data from other sensors and customized block lists for your environment. (Please be aware that there is a fair use policy in place for the Community API.)

### Daily Attack Summary

On the Daily Attack Summary GitHub repository, you can find a daily export of all abusive IPs and unique credentials seen by all sensors. You can find the repository at: https://github.com/NetWatch-team/Daily-Attack-Summary

### Research & Collaboration

Expand Down Expand Up @@ -173,6 +181,14 @@ If you want to build Telnet-AttackPod from source you can do so by:
docker compose build --no-cache
```

To build for multiple CPU architectures:

```bash
./build.sh
```

This will create images for both AMD64 and ARM64 architectures.

#### Advanced Configuration

##### Manual IP Configuration
Expand Down
20 changes: 20 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Multi-architecture Docker build script for NetWatch Telnet-AttackPod

echo "Building multi-architecture Docker image for Telnet-AttackPod..."

# Create a builder instance if it doesn't exist
if ! docker buildx ls | grep -q "multiarch"; then
echo "Creating multi-architecture builder..."
docker buildx create --name multiarch --use
fi

# Build for multiple platforms
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag netwatchteam/netwatch_telnet-attackpod:v0.2 \
--output "type=image,push=false" \
-f src/Dockerfile .

echo "Multi-architecture build complete!"
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
services:
NetWatchTelnetAttackPod:
build: .
build:
context: .
dockerfile: src/Dockerfile
image: netwatchteam/netwatch_telnet-attackpod:0.2
container_name: netwatch_telnet-attackpod
environment:
Expand Down
8 changes: 8 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__/
.idea/
.venv/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.vscode
2 changes: 1 addition & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM --platform=linux/amd64 python:3.10-slim

# Create a non-root user
RUN groupadd -r appuser && useradd -r -g appuser -m appuser
Expand Down
Loading
Loading