From 7919d1ed0e8ee64190d5891e189dc832e3f04e8f Mon Sep 17 00:00:00 2001 From: Connor Nelson Date: Fri, 21 Feb 2025 11:50:52 -0700 Subject: [PATCH] Update level 2 of intercepting communication --- dojo.yml | 3 +-- .../level-1/DESCRIPTION.md | 2 +- intercepting-communication/level-2/.config | 1 - intercepting-communication/level-2/.init | 1 + .../level-2/DESCRIPTION.md | 1 + intercepting-communication/level-2/run | 27 ++++++++++++++++++- 6 files changed, 30 insertions(+), 5 deletions(-) delete mode 100644 intercepting-communication/level-2/.config create mode 120000 intercepting-communication/level-2/.init create mode 100644 intercepting-communication/level-2/DESCRIPTION.md mode change 120000 => 100755 intercepting-communication/level-2/run diff --git a/dojo.yml b/dojo.yml index e0fa77c6..357a3bdb 100644 --- a/dojo.yml +++ b/dojo.yml @@ -25,8 +25,7 @@ modules: - id: level-1 name: Connect - id: level-2 - name: level2 - description: Listen for a connection from a remote host + name: Listen - id: level-3 name: level3 description: Find and connect to a remote host diff --git a/intercepting-communication/level-1/DESCRIPTION.md b/intercepting-communication/level-1/DESCRIPTION.md index a663d953..1c2b4d84 100644 --- a/intercepting-communication/level-1/DESCRIPTION.md +++ b/intercepting-communication/level-1/DESCRIPTION.md @@ -1 +1 @@ -From your host at 10.0.0.1, connect to the target server at 10.0.0.2 on port 31337. +From your host at 10.0.0.1, connect to the remote host at 10.0.0.2 on port 31337. diff --git a/intercepting-communication/level-2/.config b/intercepting-communication/level-2/.config deleted file mode 100644 index 0cfbf088..00000000 --- a/intercepting-communication/level-2/.config +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/intercepting-communication/level-2/.init b/intercepting-communication/level-2/.init new file mode 120000 index 00000000..ea4ba499 --- /dev/null +++ b/intercepting-communication/level-2/.init @@ -0,0 +1 @@ +../.init \ No newline at end of file diff --git a/intercepting-communication/level-2/DESCRIPTION.md b/intercepting-communication/level-2/DESCRIPTION.md new file mode 100644 index 00000000..1889b55f --- /dev/null +++ b/intercepting-communication/level-2/DESCRIPTION.md @@ -0,0 +1 @@ +From your host at 10.0.0.1, listen on port 31337 for a connection from the remote host at 10.0.0.2. diff --git a/intercepting-communication/level-2/run b/intercepting-communication/level-2/run deleted file mode 120000 index 84ba55b9..00000000 --- a/intercepting-communication/level-2/run +++ /dev/null @@ -1 +0,0 @@ -../run \ No newline at end of file diff --git a/intercepting-communication/level-2/run b/intercepting-communication/level-2/run new file mode 100755 index 00000000..aa824c28 --- /dev/null +++ b/intercepting-communication/level-2/run @@ -0,0 +1,26 @@ +#!/usr/bin/exec-suid --real -- /usr/bin/python -I + +import socket +from dojjail import Host, Network +import time + +flag = open("/flag").read() + +class ClientHost(Host): + def entrypoint(self): + while True: + try: + client_socket = socket.socket() + client_socket.connect(("10.0.0.1", 31337)) + client_socket.sendall(flag.encode()) + client_socket.close() + time.sleep(1) + except (ConnectionError, TimeoutError): + continue + +user_host = Host("ip-10-0-0-1") +server_host = ClientHost("ip-10-0-0-2") +network = Network(hosts=[user_host, server_host]) +network.run() + +user_host.interact()