亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1621 | 回復(fù): 5
打印 上一主題 下一主題

請教各位一個(gè)溢出的問題。 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-07-24 10:14 |只看該作者 |倒序?yàn)g覽
問題描述:主函數(shù)調(diào)用一個(gè)子函數(shù)test(), 該子函數(shù)包含有一個(gè)局部shellcode[]數(shù)組,該數(shù)組內(nèi)容為實(shí)現(xiàn)execle("/bin/csh", "/bin/csh", (char *)0, (char *)0);功能的代碼段。我能夠保證已經(jīng)修改了test()函數(shù)stack frame中的RET返回地址,使其值為shellcode數(shù)組地址,但是當(dāng)test()返回時(shí),出現(xiàn)段錯(cuò)誤而非執(zhí)行shellcode[]數(shù)組中調(diào)用 execle()的代碼。我的問題是:出現(xiàn)段錯(cuò)誤是不是因?yàn)閘inux通過MMU設(shè)置對(duì)stack進(jìn)行了保護(hù),例如不可像代碼段一樣可執(zhí)行。使我產(chǎn)生這樣想法的原因在于,當(dāng)我修改test()函數(shù)stack frame中的RET返回地址使其為程序中的某一其它子函數(shù)入口地址時(shí)(例如:我自己定義的myoverflow()函數(shù)),當(dāng)從test()函數(shù)返回時(shí),是可以返回到myoverflow()函數(shù)去執(zhí)行的,而非返回調(diào)用test()函數(shù)的main()主函數(shù)。麻煩各位兄弟指點(diǎn)。

my machine info: $ uname -a
Linux localhost.localdomain 2.6.18-92.el5 #1 SMP Tue Jun 10 18:49:47 EDT 2008 i686 i686 i386 GNU/Linux

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2008-07-24 10:45 |只看該作者
收藏了 等大牛

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-07-24 13:24 |只看該作者
是因?yàn)閿?shù)據(jù)段的屬性造成的segment fault;
可以考慮用attribute把數(shù)組放在.text段中。

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2008-07-24 15:42 |只看該作者

回復(fù) #3 haohao06 的帖子

查了手冊,__attribute__((section()))確實(shí)可以把一個(gè)全局變量設(shè)置為不同的section中,但沒有像section("text")這樣的例子,而且我試了還是segment fault 。 樓上的兄弟,能否給個(gè)例子。

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2008-07-24 17:05 |只看該作者
#include <stdio.h>
char inc[] __attribute__((section(".text")))
&nbsp;&nbsp;&nbsp;&nbsp;= {&nbsp;&nbsp;&nbsp;&nbsp;0x55,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x89, 0xe5,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0xff, 0x45, 0x08,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0x8b, 0x45, 0x08,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0xc9,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0xc3
&nbsp;&nbsp;&nbsp;&nbsp;};

typedef int (*incr)(int);
int main()
{
&nbsp;&nbsp;&nbsp;&nbsp;int x = ((incr)inc)(0);
&nbsp;&nbsp;&nbsp;&nbsp;printf("b=%d\n", x);
&nbsp;&nbsp;&nbsp;&nbsp;return 0;
}


試試這個(gè)~~呵呵現(xiàn)學(xué)現(xiàn)賣

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2008-07-24 17:56 |只看該作者

回復(fù) #5 haohao06 的帖子

哈哈。thanks very much!!!!
原來是.text,,少寫個(gè).
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP