Skip to content

Commit

Permalink
Adding dockerfiles and docker compose files for network functions and…
Browse files Browse the repository at this point in the history
… proxy chains respectively
  • Loading branch information
anmolbhatia05 committed Sep 27, 2023
1 parent 6cdd99c commit 27bc870
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Dockerfile.counter
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This Dockerfile is supposed to create a socks proxy server that mimics a firewall.
# This won't build on Mac OS X. Try on Linux or Windows.
FROM ubuntu:20.04

RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install click socksx

COPY ./socksx-py/examples/functions.py /functions.py

EXPOSE 1080
ENTRYPOINT [ "./functions.py" ]
30 changes: 30 additions & 0 deletions Dockerfile.encrypt-decrypt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This Dockerfile is used to build a socks proxy server that can be used to encrypt or decrypt the data
FROM rust:1.72 as build

RUN rustup component add rustfmt

RUN apt-get update && apt-get install -y \
cmake \
make \
&& rm -rf /var/lib/apt/lists/*

# Copy over relevant crates
COPY ./socksx /socksx

# Build an optimized binary
WORKDIR /socksx
RUN cargo build --example functions --release

# Define final image
FROM ubuntu:23.10

RUN apt-get update && apt-get install -y \
libssl3 \
libuv1 \
&& rm -rf /var/lib/apt/lists/*

# Copy `brane-log from the build stage
COPY --from=build /socksx/target/release/examples/functions .

EXPOSE 1080
ENTRYPOINT [ "./functions" ]
87 changes: 87 additions & 0 deletions docker-compose-extensive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Example of two proxy chains simulating a sender node/domain and a receiver node/domains.
# On sender side we have socks proxy, which is connected to a counter (mimicing a firewall) and encrypt
# On receiver side we have socks proxy, which is connected to decrypt and counter
# Communication looks like this:
# sender(client) -> proxy (sender's side) -> counter -> encrypt -> proxy (destination's side) -> decrypt -> counter -> destination

version: '3.8'

services:
proxy-main:
build:
context: .
dockerfile: Dockerfile
ports:
- "1080:1080"
command: "--host 0.0.0.0 --port 1080 --chain socks6://counter-1:1080 --chain socks6://encrypt:1080 --chain socks6://proxy-other:1080"
networks:
net:
ipv4_address: 172.16.238.2

counter-1:
build:
context: .
dockerfile: Dockerfile.counter
command: "--host 0.0.0.0"
networks:
net:
ipv4_address: 172.16.238.3

encrypt:
build:
context: .
dockerfile: Dockerfile.encrypt-decrypt
command: "chacha20"
environment:
- CHACHA20_KEY="123456789012345678901234567890"
networks:
net:
ipv4_address: 172.16.238.4

proxy-other:
build:
context: .
dockerfile: Dockerfile
ports:
- "1081:1080"
command: "--host 0.0.0.0 --port 1080 --chain socks6://decrypt:1080 --chain socks6://counter-2:1080"
networks:
net:
ipv4_address: 172.16.238.5

counter-2:
build:
context: .
dockerfile: Dockerfile.counter
command: "--host 0.0.0.0"
networks:
net:
ipv4_address: 172.16.238.6

decrypt:
build:
context: .
dockerfile: Dockerfile.encrypt-decrypt
command: "chacha20"
environment:
- CHACHA20_KEY="123456789012345678901234567890"
networks:
net:
ipv4_address: 172.16.238.7

netcat:
image: busybox
command: "nc -l -p 12345"
ports:
- "12345:12345"
restart: always
networks:
net:
ipv4_address: 172.16.238.8

networks:
net:
ipam:
driver: default
config:
- subnet: "172.16.238.0/24"
33 changes: 33 additions & 0 deletions docker-compose-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Example of using a standalone proxy to forward traffic to a destination

version: '3.8'

services:
proxy:
build:
context: .
dockerfile: Dockerfile
ports:
- "1080:1080"
command: "--host 0.0.0.0 --port 1080"
networks:
net:
ipv4_address: 172.16.238.2

# this will be the destination
netcat:
image: busybox
command: "nc -l -p 12345"
ports:
- "12345:12345"
restart: always
networks:
net:
ipv4_address: 172.16.238.3

networks:
net:
ipam:
driver: default
config:
- subnet: "172.16.238.0/24"

0 comments on commit 27bc870

Please sign in to comment.