Skip to content

Commit b181a49

Browse files
committed
mitm proxy
1 parent 006a19d commit b181a49

38 files changed

+726
-37
lines changed

dockerfiles/addons/minlog.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from mitmproxy import http
2+
import csv, os
3+
4+
LOG_DIR = os.getenv("MITM_LOG_DIR", "/logs")
5+
os.makedirs(LOG_DIR, exist_ok=True)
6+
7+
LOG_FILE = os.path.join(LOG_DIR, "minlog.csv")
8+
9+
if not os.path.exists(LOG_FILE):
10+
with open(LOG_FILE, "w", newline="", encoding="utf-8") as f:
11+
writer = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC)
12+
writer.writerow(["status_code", "path", "method"])
13+
14+
def response(flow: http.HTTPFlow):
15+
row = [
16+
flow.response.status_code,
17+
flow.request.path,
18+
flow.request.method
19+
]
20+
with open(LOG_FILE, "a", newline="", encoding="utf-8") as f:
21+
writer = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC)
22+
writer.writerow(row)

dockerfiles/bibliothek.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-bibliothek:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-bibliothek
221
sut-bibliothek:
322
build:
423
dockerfile: ./dockerfiles/bibliothek.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/blogapi.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-blogapi:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-blogapi
221
sut-blogapi:
322
build:
423
dockerfile: ./dockerfiles/blogapi.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/catwatch.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-catwatch:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-catwatch
221
sut-catwatch:
322
build:
423
dockerfile: ./dockerfiles/catwatch.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/cwa-verification.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-cwa-verification:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-cwa-verification
221
sut-cwa-verification:
322
build:
423
dockerfile: ./dockerfiles/cwa-verification.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/erc20-rest-service.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-erc20-rest-service:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-erc20-rest-service
221
sut-erc20-rest-service:
322
build:
423
dockerfile: ./dockerfiles/erc20-rest-service.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/familie-ba-sak.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-familie-ba-sak:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-familie-ba-sak
221
sut-familie-ba-sak:
322
build:
423
dockerfile: ./dockerfiles/familie-ba-sak.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/features-service.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-features-service:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-features-service
221
sut-features-service:
322
build:
423
dockerfile: ./dockerfiles/features-service.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/genome-nexus.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-genome-nexus:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-genome-nexus
221
sut-genome-nexus:
322
build:
423
dockerfile: ./dockerfiles/genome-nexus.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

dockerfiles/gestaohospital.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
command: >
8+
mitmdump
9+
--mode reverse:http://sut-gestaohospital:8080
10+
--listen-host 0.0.0.0
11+
--listen-port 8080
12+
--set keep_host_header=true
13+
-s /addons/minlog.py
14+
volumes:
15+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
16+
- ./addons:/addons:ro
17+
ports:
18+
- "${HOST_PORT:-8080}:8080"
19+
depends_on:
20+
- sut-gestaohospital
221
sut-gestaohospital:
322
build:
423
dockerfile: ./dockerfiles/gestaohospital.dockerfile
@@ -8,7 +27,6 @@ services:
827
# TOOL: ${TOOL:-undefined}
928
# RUN: ${RUN:-0}
1029
ports:
11-
- "${HOST_PORT:-8080}:8080"
1230
- "${JACOCO_PORT:-6300}:6300"
1331
# volumes:
1432
# default env does not work on volumes

0 commit comments

Comments
 (0)