青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

jans2002的博客

專注 專心 專業

(轉)一個小技巧:SFP Overwrite(以c語言為實例)


SFP Overwrite
I'd like a share a little trick I figured out today. I'm sure it has been done before and probably many times but its new to me so I'll describe it here. I asked myself if anything cool could be achieved by overwriting the Saved Frame Pointer instead of the Return Address. I'm not sure what sort of security-related attacks could be leveraged by doing this, but I did find that its possible to affect the program flow in the calling function. This is just another trick to change the flow of execution and even works on a non-executable stack.
The vulnerable program source code
The attack program source code
EBP and Local Variables
The extended base pointer is a register used by the CPU as base for the current stack frame. As we discussed earlier, the EBP for the function that called the current one is stored in the current function's Saved Frame Pointer. The EBP points to this SFP; in this way, there is a chain of saved EBPs for each stack frame. Check out the EIP Redirection page for more details about this. The location of the current stack frame's SFP is stored in the Extended Base Pointer.名稱:  sfptut3.jpg
查看次數: 22
文件大小:  11.3 KB
Keeping track of the chain of the program's stack frames is not the only purpose of the EBP/SFPs. As the name implies, the Extended Base Pointer register holds an address that is used as the "base" of the current stack frame (this address is the frame's SFP). The code in the current function references local variables using EBP as a base. For example, the C code for setting a variable equal to 3 is myVar = 3;. This might be assembled into something like: MOV SS:[EBP - 4], 0x03. This means that the local variable myVar is referred to as "the address on the stack stored in EBP, minus 4 bytes" by the assembled code. Another variable in the same function called myVar2 might be located at SS:[EBP - 8]. We can see that if an attacker could change the value of EBP, they could also change where the code thinks local variables are.
Using SFP to Modify EBP
名稱:  sfptut1.jpg
查看次數: 23
文件大小:  14.8 KB
Imagine that there is function called FunctionA that is not vulnerable to any sort of buffer overflow. Inside it is a local integer variable that is used by the function later on. Before the variable is used, another function called FunctionB is called. This one happens to be vulnerable to a buffer overflow. Our goal is to trick FunctionA into using a variable that we define instead of the one that it declared.
We wait until the execution reaches FunctionB and we are able to input our malicious buffer. At the beginning we'll have the value of the fake variable that FunctionA will be tricked into using. From there, we pad the buffer with junk until the saved frame pointer is reached. Now we push the address on the stack that is directly below our fake variable. The reason we do this is that FunctionA references its real variable as SS:[ebp - 4]. Therefore, our injected EBP must be 4 bytes beyond our fake variable. By setting it up in this way, if we can manage to get that address into the Extended Base Pointer while FunctionA is executing; our fake variable will be referenced instead of the real one. We are not overwriting the value in the real variable. Instead, we are changing FunctionA's perception of its location to an address inside the buffer that we control.
The Target
Now its time to put our attack into a context. At the top of the source code, you'll notice the vulnerable test() function. All it does is declare a 5 byte buffer and fail to protect it while its being filled with user input. The main() function declares a local integer variable (4 bytes) and feeds the decimal value 3 into it. Main() then calls the test() function which asks the user for input but doesn't do anything with it. After test() returns, a loop is entered. The loop keeping looping as long as the integer c is greater than zero. Each time it repeats, the value of c is decreased by one and "Later" is displayed on the screen. Overall, this thing prints that word c times. Because the value of this integer was set to 3 earlier, this means that "Later" is printed 3 times by this loop. 名稱:  sfptut2.jpg
查看次數: 21
文件大小:  10.9 KB
We will trick this program into thinking that a variable we create using the vulnerable buffer is actually c. By filling this fake variable with the decimal value 500,000,001, we'll make this loop run and print "Later" 500 million and one times instead of the expected three.
Buiding the Attack
As before, we'll be writing a program in C that will feed a malicious string into the input of the vulnerable program. Because our ultimate goal is to overwrite the test() function's SFP, we'll need to pad the string appropriately to get there. The first 4 bytes of the attack string will be the value of our fake variable that main() will eventually use in its loop. These bytes need to equal the goal of 500,000,001 so we'll feed "\x01\x65\xCD\x1D" first. The next four do not matter in this case, but take note that they will become main()'s fake SFP. From here use OllyDbg to find the distance between this fake main() SFP and test()'s SFP. If you are unsure where the test() function's SFP is, you can always step the program until inside test() and check the EBP register. You'll find that the buffer begins at 0x0027FF00 and the test() function's SFP is located at 0x0027FF18. After converting to decimal and subtracting the 8 bytes we already used up so far, it means we'll need to add 16 bytes of padding to reach test()'s SFP.
名稱:  sfptut4.jpg
查看次數: 21
文件大小:  11.1 KB
Next we'll actually overwrite the SFP. Have a look at the main() function and you'll find that the loop references the variable c as SS:[EBP - 4]. This means that if we want it to reference that 4 byte value at the beginning of the buffer instead, we need main()'s EBP to point to the address 4 bytes beyond the beginning of our attack buffer. We've already pointed out that any value we can sneak into test()'s SFP will end up in the EBP when main() returns. So we end the attack string with the following 3 bytes: "\x04\xFF\x27". The value is chosen because 0x0027FF04 - 4 is the address of our fake variable. Writing all four bytes is, again, not necessary because gets() automatically sticks a null byte at the end of the string inputted.
Final Overview
By crafting the above buffer and ensuring that the last 3 bytes overwrite test()'s SFP, we directly control EBP when test() returns back to main(). Because main() uses EBP to reference an important variable c and we control EBP; we make main() think that c is actually where our old overwritten buffer began. The data is still there because there was no reason for the program to erase/modify it. Because c is referenced as SS:[EBP - 4] in main(), we need that overwritten Stack Frame Pointer to point to the address four bytes below the fake variable location on the stack. When main uses our fake EBP to reference variable c is it will subtract 4 from it and find our fake variable value. This was filled in with the decimal value of 500,000,001. Main() runs the loop to print "Later" a number of times determined by c. So by doing all of this trickery we can make the program display "Later" 500,000,001 times instead of 3.

posted on 2009-09-29 09:09 jans2002 閱讀(371) 評論(0)  編輯 收藏 引用

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久综合色天天久久综合图片| 亚洲视频网站在线观看| 亚洲东热激情| 欧美色欧美亚洲另类二区| 亚洲肉体裸体xxxx137| 欧美成人a视频| 亚洲高清不卡| 久久在线免费视频| 久久国产毛片| 亚洲天堂成人在线视频| 欧美性生交xxxxx久久久| 欧美一级专区| 亚洲欧洲精品一区二区| 国产精品美女久久久久久久 | 久久美女性网| 欧美日韩另类一区| 亚洲性感激情| 欧美激情一区二区三区在线视频 | 午夜精品一区二区三区电影天堂| 亚洲欧美区自拍先锋| 久久精品一区二区三区四区| 久久久久久午夜| 亚洲一区二区三区久久| 亚洲人成网站精品片在线观看| 欧美色欧美亚洲另类七区| 欧美韩国日本一区| 久久免费视频网| 亚洲欧美激情一区二区| 欧美第十八页| 亚洲图片在区色| 一区二区三区精品视频在线观看| 久久精品夜色噜噜亚洲a∨ | 一本色道久久| 免费欧美视频| 日韩视频在线你懂得| 91久久香蕉国产日韩欧美9色| 先锋亚洲精品| 欧美国产大片| 亚洲精品国产精品乱码不99| 日韩午夜电影| 一区二区国产日产| 亚洲欧美一区二区三区在线| 亚洲欧美一区二区激情| 美女视频黄a大片欧美| 亚洲国产精品v| 亚洲精华国产欧美| 中文久久精品| 欧美一区二区三区播放老司机| 亚洲图片欧洲图片日韩av| 日韩午夜在线电影| 夜夜爽av福利精品导航| 欧美国产欧美亚州国产日韩mv天天看完整| 免费在线国产精品| 亚洲高清久久久| 午夜一区在线| 欧美日韩国产综合新一区| 国产区精品在线观看| 亚洲狠狠丁香婷婷综合久久久| 亚洲二区视频| 午夜在线观看免费一区| 男女av一区三区二区色多| 亚洲片区在线| 在线免费观看欧美| 久久精品免费观看| 亚洲在线中文字幕| 久久国产乱子精品免费女| 欧美日韩一区视频| 在线观看欧美| 久久xxxx| 午夜精品在线视频| 国产麻豆精品久久一二三| 在线一区视频| 久久成人综合网| 亚洲乱码国产乱码精品精| 欧美亚洲在线播放| 亚洲国产精品成人| 欧美日韩伊人| 久久国产一二区| 欧美国产视频一区二区| 亚洲大胆视频| 午夜电影亚洲| 亚洲电影免费观看高清完整版在线| 亚洲综合日韩| 欧美日韩亚洲视频| 亚洲午夜伦理| 欧美成人综合| 黄色一区二区三区四区| 亚洲欧美日本日韩| 一本久久a久久免费精品不卡| 免费一级欧美片在线观看| 亚洲欧美日韩精品在线| 小黄鸭精品aⅴ导航网站入口| 99国产一区二区三精品乱码| 欧美专区中文字幕| 亚洲免费人成在线视频观看| 香蕉久久a毛片| 亚洲视频一区| 国产精品美女在线| 亚洲精品一区二区三区婷婷月| 亚洲人成网站在线播| 欧美午夜宅男影院在线观看| 欧美一级免费视频| 欧美暴力喷水在线| 嫩草影视亚洲| 国产精品久久久久天堂| 久久久一本精品99久久精品66| 欧美精品一区二区三区在线播放| 亚洲黄色免费电影| 狠狠爱综合网| 亚洲伦理中文字幕| 久久久综合网站| 亚洲精品国精品久久99热一| 老司机aⅴ在线精品导航| 欧美承认网站| 亚洲午夜影视影院在线观看| 久久激情五月丁香伊人| 最新日韩在线视频| 久久综合给合久久狠狠色| 国产美女高潮久久白浆| 亚洲一区二区视频| 欧美在线视频免费播放| 国内精品久久久久久| 久久久精品国产免费观看同学| 欧美中文字幕在线视频| 亚洲精品久久在线| 亚洲福利视频三区| 亚洲精品久久久久| 国产精品亚洲片夜色在线| 久久午夜影视| 久久久一区二区三区| 亚洲一级片在线观看| 亚洲电影在线| 欧美中文字幕在线观看| 亚洲影视综合| 国产一区日韩一区| 国产在线不卡| 中文一区在线| 老司机一区二区三区| 亚久久调教视频| 亚洲欧美日韩高清| 亚洲一区网站| 欧美黄色一区| 免费看av成人| 久久久综合网站| 欧美国产高清| 日韩图片一区| 久久国产一区二区| 老司机精品视频网站| 欧美日精品一区视频| 欧美久久久久久久| 欧美va亚洲va香蕉在线| 久久精品国产99精品国产亚洲性色 | 国产欧美日韩亚洲精品| 欧美女同视频| 老司机一区二区| 国产精品美女久久久久av超清| 欧美体内谢she精2性欧美| 欧美理论电影网| 国产日本欧美一区二区三区| 国产精品久久久久高潮| 国产农村妇女毛片精品久久麻豆 | 久久综合狠狠综合久久综青草| 亚洲天堂av电影| 亚洲精品日本| 另类国产ts人妖高潮视频| 欧美激情免费观看| 欧美一级理论性理论a| 欧美特黄一区| 国产一区二区三区在线播放免费观看| 一区二区欧美在线| 久久久久久久久久久成人| 亚洲一级网站| 欧美日韩精品一区二区| 亚洲一区二区在线看| 亚洲激情视频网站| 久久久精品tv| 国产一区二区黄色| 亚洲一区精品电影| 亚洲国产精品久久人人爱蜜臀 | 久久久久国产成人精品亚洲午夜| 久久夜色精品国产欧美乱极品 | 亚洲自拍偷拍色片视频| 91久久视频| 欧美视频在线看| 亚洲影音一区| 久久久综合视频| 国产精品美女主播| 欧美大胆a视频| 性欧美8khd高清极品| 国产欧美一区二区精品婷婷| 久久亚洲风情| 欧美阿v一级看视频| avtt综合网| 亚洲深夜福利网站| 影音国产精品| 在线视频欧美一区| 亚洲乱码视频| 久久精品视频在线看| 日韩视频―中文字幕| 欧美在线啊v|