Skip to content

Instantly share code, notes, and snippets.

@kkrypt0nn
Created April 3, 2022 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkrypt0nn/a616bab5b17ec8533dac4036fe855a56 to your computer and use it in GitHub Desktop.
Save kkrypt0nn/a616bab5b17ec8533dac4036fe855a56 to your computer and use it in GitHub Desktop.
Solution for challenge Strange Traffic at the Space Heroes 2022 CTF
import pyshark, binascii
capture = pyshark.FileCapture("strangetraffic.pcap")
# Map the entire keyboard
map = {
"1": "`",
"2": "1",
"3": "2",
"4": "3",
"5": "4",
"6": "5",
"7": "6",
"8": "7",
"9": "8",
"10": "9",
"11": "0",
"12": "-",
"13": "=",
"14": "<-",
"15": "tab",
"16": "q",
"17": "w",
"18": "e",
"19": "r",
"20": "t",
"21": "y",
"22": "u",
"23": "i",
"24": "o",
"25": "p",
"26": "[",
"27": "]",
"28": "enter",
"29": "caps",
"30": "a",
"31": "s",
"32": "d",
"33": "f",
"34": "g",
"35": "h",
"36": "j",
"37": "k",
"38": "l",
"39": ";",
"40": "'",
"41": "#",
"42": "shift",
"43": "\\",
"44": "z",
"45": "x",
"46": "c",
"47": "v",
"48": "b",
"49": "n",
"50": "m",
"51": ",",
"52": ".",
"53": "/",
"54": "ctrl",
"55": "win",
"56": "alt",
"57": "space",
"58": "alt",
"59": "win",
"60": "menu",
"61": "ctrl",
}
flag = []
for packet in capture:
payload = packet.layers[2]._all_fields["udp.payload"][75:].split(":") # Ignore the fist 75 characters from the payload
for i in range(0, len(payload)):
payload[i] = str(binascii.unhexlify(payload[i]), "ascii") # Coinvert to ASCII representation
flag.append("".join(payload))
res = ""
for f in flag:
res += map[str(f)]
print(res.replace("shift[", "{").replace("shift]", "}").replace("enter", "").replace("space", "_")) # Description said we can swap spaces with underscores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment