1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
| void __noreturn child() { HANDLE FileA; int v1; SOCKET v2; bool v3; SOCKET v4; int v5; int v6; __int64 out; __int64 OutBuffer;
FileA = CreateFileA("\\\\.\\BrownProtectorDeviceLink", 0xC0000000, 3u, 0LL, 3u, 4u, 0LL); hDevice = FileA; if ( FileA != (HANDLE)-1LL ) { if ( DeviceIoControl(FileA, 0x224004u, 0LL, 0, &OutBuffer, 8u, 0LL, 0LL) ) { if ( OutBuffer == 0x1337 ) { zero = 1 / zero; out = 0LL; if ( DeviceIoControl(hDevice, 0x22400Cu, 0LL, 0, &out, 8u, 0LL, 0LL) ) { if ( out != 0xDEAD ) { v3 = !vm(); v5 = 2; if ( v3 ) v5 = 3; v6 = v5 % zero; zero = v5 / zero; shutdown(v4, v6); } } } } } shutdown(v2, v1); }
char __fastcall handler(_DEBUG_EVENT *debug_event) { __int128 v1; __int128 v2; __int128 v3; __int128 v4; __int128 v5; __int128 v6; __int128 v7; __int128 v8; __int128 v9; int v10; HANDLE FileA; __int64 v12; _BYTE *v13; _OWORD *v14; _OWORD *v15; __int64 lenth; __int64 OutBuffer; CONTEXT Context; _OWORD v20[4]; _OWORD v21[4]; _OWORD v22[4]; _OWORD v23[4]; _OWORD v24[4]; _OWORD v25[4]; _OWORD v26[4]; _OWORD v27[4]; _OWORD v28[4]; _OWORD v29[4]; _OWORD v30[4]; _OWORD v31[4]; _OWORD v32[4]; _OWORD v33[4]; _OWORD v34[4]; _OWORD v35[4]; _OWORD v36[4]; _OWORD v37[4]; _OWORD v38[4]; _OWORD v39[4];
v1 = *(_OWORD *)&debug_event->u.Exception.ExceptionRecord.ExceptionCode; *(_OWORD *)&Context.P1Home = *(_OWORD *)&debug_event->dwDebugEventCode; v2 = *((_OWORD *)&debug_event->u.RipInfo + 1); *(_OWORD *)&Context.P3Home = v1; v3 = *((_OWORD *)&debug_event->u.RipInfo + 2); *(_OWORD *)&Context.P5Home = v2; v4 = *((_OWORD *)&debug_event->u.RipInfo + 3); *(_OWORD *)&Context.ContextFlags = v3; v5 = *((_OWORD *)&debug_event->u.RipInfo + 4); *(_OWORD *)&Context.SegGs = v4; v6 = *((_OWORD *)&debug_event->u.RipInfo + 5); *(_OWORD *)&Context.Dr1 = v5; v7 = *((_OWORD *)&debug_event->u.RipInfo + 7); *(_OWORD *)&Context.Dr3 = v6; *(_OWORD *)&Context.Dr7 = *((_OWORD *)&debug_event->u.RipInfo + 6); v8 = *((_OWORD *)&debug_event->u.RipInfo + 8); *(_OWORD *)&Context.Rcx = v7; v9 = *((_OWORD *)&debug_event->u.RipInfo + 9); *(_OWORD *)&Context.Rbx = v8; *(_OWORD *)&Context.Rbp = v9; if ( LODWORD(Context.P1Home) != 1 ) { if ( LODWORD(Context.P1Home) == 3 ) { hProcess = (HANDLE)Context.P4Home; hThread = (HANDLE)Context.P5Home; if ( register() ) { v10 = 0; FileA = CreateFileA("\\\\.\\BrownProtectorDeviceLink", 0xC0000000, 3u, 0LL, 3u, 4u, 0LL); hObject = FileA; if ( FileA != (HANDLE)-1LL && DeviceIoControl(FileA, 0x224000u, 0LL, 0, &OutBuffer, 8u, 0LL, 0LL) && OutBuffer == 0x1337 ) { v20[0] = _mm_load_si128((const __m128i *)&xmmword_140005BD0); v21[0] = _mm_load_si128((const __m128i *)&xmmword_140005B20); v22[0] = _mm_load_si128((const __m128i *)&xmmword_140005C10); v23[0] = _mm_load_si128((const __m128i *)&xmmword_140005BE0); v24[0] = _mm_load_si128((const __m128i *)&xmmword_140005B00); v25[0] = _mm_load_si128((const __m128i *)&xmmword_140005AC0); v26[0] = _mm_load_si128((const __m128i *)&xmmword_140005C30); v27[0] = _mm_load_si128((const __m128i *)&xmmword_140005BA0); v28[0] = _mm_load_si128((const __m128i *)&xmmword_140005B80); v29[0] = _mm_load_si128((const __m128i *)&xmmword_140005BC0); v30[0] = _mm_load_si128((const __m128i *)&xmmword_140005BB0); v31[0] = _mm_load_si128((const __m128i *)&xmmword_140005B30); v32[0] = _mm_load_si128((const __m128i *)&xmmword_140005B60); v33[0] = _mm_load_si128((const __m128i *)&xmmword_140005AD0); v34[0] = _mm_load_si128((const __m128i *)&xmmword_140005C40); v35[0] = _mm_load_si128((const __m128i *)&xmmword_140005AE0); memset(&v20[1], 0, 48); memset(&v21[1], 0, 48); memset(&v22[1], 0, 48); memset(&v23[1], 0, 48); memset(&v24[1], 0, 48); memset(&v25[1], 0, 48); memset(&v26[1], 0, 48); memset(&v27[1], 0, 48); memset(&v28[1], 0, 48); memset(&v29[1], 0, 48); memset(&v30[1], 0, 48); memset(&v31[1], 0, 48); memset(&v32[1], 0, 48); memset(&v33[1], 0, 48); memset(&v34[1], 0, 48); memset(&v35[1], 0, 48); Context.P1Home = (DWORD64)v20; v36[0] = _mm_load_si128((const __m128i *)&xmmword_140005B70); v12 = 0LL; Context.P2Home = (DWORD64)v21; Context.P3Home = (DWORD64)v22; Context.P4Home = (DWORD64)v23; Context.P5Home = (DWORD64)v24; Context.P6Home = (DWORD64)v25; *(_QWORD *)&Context.ContextFlags = v26; *(_QWORD *)&Context.SegCs = v27; *(_QWORD *)&Context.SegGs = v28; Context.Dr0 = (DWORD64)v29; Context.Dr1 = (DWORD64)v30; Context.Dr2 = (DWORD64)v31; Context.Dr3 = (DWORD64)v32; Context.Dr6 = (DWORD64)v33; Context.Dr7 = (DWORD64)v34; Context.Rax = (DWORD64)v35; Context.Rcx = (DWORD64)v36; v37[0] = _mm_load_si128((const __m128i *)&xmmword_140005B40); Context.Rdx = (DWORD64)v37; memset(&v36[1], 0, 48); Context.Rbx = (DWORD64)v38; Context.Rsp = (DWORD64)v39; memset(&v37[1], 0, 48); v38[0] = _mm_load_si128((const __m128i *)&xmmword_140005B10); memset(&v38[1], 0, 48); v39[0] = _mm_load_si128((const __m128i *)&xmmword_140005C00); v39[1] = _mm_load_si128((const __m128i *)&xmmword_140005C20); v39[2] = _mm_load_si128((const __m128i *)&xmmword_140005AF0); v39[3] = _mm_load_si128((const __m128i *)&xmmword_140005BF0); while ( 1 ) { v13 = VirtualAlloc(0LL, 0x800uLL, 0x3000u, 4u); (&in)[v12] = v13; if ( !v13 ) break; memset(v13, 0, 0x800uLL); v14 = *(_OWORD **)((char *)&Context.P1Home + v12 * 8); ++v10; v15 = (&in)[v12++]; *v15 = *v14; v15[1] = v14[1]; v15[2] = v14[2]; v15[3] = v14[3]; if ( v10 >= 20 ) return 1; } TerminateProcess(hProcess, 1u); } } } else if ( LODWORD(Context.P1Home) != 5 ) { return 1; } return 0; } if ( LODWORD(Context.P3Home) == 0xC0000094 ) { Context.ContextFlags = 0x10001F; GetThreadContext(hThread, &Context); switch ( Context.Rax ) { case 1uLL: print("Welcome! Give me the key and I will give you the flag: "); input("%128s", in); lenth = -1LL; do ++lenth; while ( in[lenth] ); if ( lenth != 0x40 ) { puts("Wrong1"); TerminateProcess(hProcess, 0); return 0; } DeviceIoControl(hObject, 0x224008u, &in, 0xA0u, 0LL, 0, 0LL, 0LL); break; case 2uLL: puts("Correct. Here is your flag"); decrypt((__int64)in); Context.Rip += 6LL; Context.Rax = 0LL; goto LABEL_29; case 3uLL: puts("Wrong0"); Context.Rip += 6LL; Context.Rax = 0LL; LABEL_29: SetThreadContext(hThread, &Context); return 1; } Context.Rip += 6LL; Context.Rax = 0LL; goto LABEL_29; } if ( LODWORD(Context.P3Home) == 0xC0000005 ) { Context.ContextFlags = 0x10001F; GetThreadContext(hThread, &Context); Context.Rip += 8LL; goto LABEL_29; } return 1; }
int __fastcall main(int argc, const char **argv, const char **envp) { _DEBUG_EVENT v4; struct _PROCESS_INFORMATION ProcessInformation; struct _STARTUPINFOA StartupInfo; _DEBUG_EVENT DebugEvent; CHAR Filename[256];
if ( IsDebuggerPresent() ) child(); GetModuleFileNameA(0LL, Filename, 0x100u); StartupInfo.cb = 0x68; memset(&StartupInfo.cb + 1, 0, 100); memset(&ProcessInformation, 0, sizeof(ProcessInformation)); if ( CreateProcessA(Filename, 0LL, 0LL, 0LL, 0, 2u, 0LL, 0LL, &StartupInfo, &ProcessInformation) ) { while ( WaitForDebugEvent(&DebugEvent, 0xFFFFFFFF) ) { v4 = DebugEvent; if ( !handler(&v4) ) break; ContinueDebugEvent(DebugEvent.dwProcessId, DebugEvent.dwThreadId, 0x10002u); } CloseHandle(hObject); nop_(); nop(); } puts("[!] Can't create child process"); return 0; }
|