From e846bf82e8b9994f032b541446e805434ff6b780 Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 24 Feb 2025 01:39:03 -0700 Subject: [PATCH] udp1 --- intercepting-communication/module.yml | 4 +++ intercepting-communication/sniff-cookie/run | 1 - intercepting-communication/udp-1/.init | 1 + .../udp-1/DESCRIPTION.md | 1 + intercepting-communication/udp-1/run | 33 +++++++++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 120000 intercepting-communication/udp-1/.init create mode 100644 intercepting-communication/udp-1/DESCRIPTION.md create mode 100755 intercepting-communication/udp-1/run diff --git a/intercepting-communication/module.yml b/intercepting-communication/module.yml index 43171c53..8fd934b7 100644 --- a/intercepting-communication/module.yml +++ b/intercepting-communication/module.yml @@ -29,6 +29,10 @@ challenges: name: TCP - id: level-11 name: TCP Handshake +- id: udp-1 + name: UDP + visibility: + start: "2029-11-04T13:00:00-07:00" - id: level-12 name: ARP - id: level-13 diff --git a/intercepting-communication/sniff-cookie/run b/intercepting-communication/sniff-cookie/run index 39572475..1e078490 100755 --- a/intercepting-communication/sniff-cookie/run +++ b/intercepting-communication/sniff-cookie/run @@ -3,7 +3,6 @@ import requests import random import psutil -import socket import string import flask import time diff --git a/intercepting-communication/udp-1/.init b/intercepting-communication/udp-1/.init new file mode 120000 index 00000000..ea4ba499 --- /dev/null +++ b/intercepting-communication/udp-1/.init @@ -0,0 +1 @@ +../.init \ No newline at end of file diff --git a/intercepting-communication/udp-1/DESCRIPTION.md b/intercepting-communication/udp-1/DESCRIPTION.md new file mode 100644 index 00000000..5c5c2517 --- /dev/null +++ b/intercepting-communication/udp-1/DESCRIPTION.md @@ -0,0 +1 @@ +You've used TCP, diff --git a/intercepting-communication/udp-1/run b/intercepting-communication/udp-1/run new file mode 100755 index 00000000..6e41ca4e --- /dev/null +++ b/intercepting-communication/udp-1/run @@ -0,0 +1,33 @@ +#!/usr/bin/exec-suid --real -- /usr/bin/python -I + +import psutil +import socket +import os + +from dojjail import Host, Network + +flag = open("/flag").read() +parent_process = psutil.Process(os.getppid()) + +class ServerHost(Host): + def entrypoint(self): + server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + server_socket.bind(("0.0.0.0", 31337)) + while True: + try: + client_message, (client_host, client_port) = server_socket.recvfrom(1024) + while True: + if not client_message: + break + if client_message == "Hello, World!\n": + server_socket.sendto(flag.encode(), (client_host, client_port)) + break + except ConnectionError: + continue + +user_host = Host("ip-10-0-0-1", privileged_uid=parent_process.uids().effective) +server_host = ServerHost("ip-10-0-0-2") +network = Network(hosts={user_host: "10.0.0.1", server_host: "10.0.0.2"}, subnet="10.0.0.0/24") +network.run() + +user_host.interactive(environ=parent_process.environ())