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

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>
            久久精品99无色码中文字幕| 欧美成人精精品一区二区频| 久久国产精品72免费观看| 夜夜嗨av一区二区三区四区 | 国产精品永久免费在线| 国产精品久久久久一区二区| 国产精品国产三级国产aⅴ浪潮| 欧美视频一区二区在线观看 | 国内成人自拍视频| 国产亚洲福利| 在线电影国产精品| 一本色道久久综合亚洲精品不 | 日韩视频免费在线| 99成人精品| 亚洲欧美日韩国产一区| 久久一区国产| 亚洲精品一区二区三区婷婷月| 99av国产精品欲麻豆| 欧美在线free| 欧美乱妇高清无乱码| 国产亚洲高清视频| 夜夜嗨av一区二区三区四区| 先锋影音国产一区| 亚洲国产高清高潮精品美女| 91久久精品国产91久久| 性欧美1819sex性高清| 欧美大色视频| 狠狠色狠狠色综合人人| 亚洲一区二三| 亚洲国产精品久久久久秋霞影院| 亚洲小少妇裸体bbw| 六月丁香综合| 国产一区二区三区无遮挡| 一本色道精品久久一区二区三区| 久久精品免视看| 亚洲久久成人| 蜜臀a∨国产成人精品| 国产一区二区三区视频在线观看 | 先锋影音久久久| 欧美猛交免费看| 亚洲高清不卡av| 久久久久中文| 亚洲一区二区高清| 欧美久久九九| 亚洲日韩欧美视频| 媚黑女一区二区| 欧美在线一级视频| 国产精品爽黄69| 亚洲午夜av| 亚洲美女在线国产| 欧美精品1区2区3区| 亚洲成人在线视频播放| 久久精品国产精品| 性欧美暴力猛交69hd| 国产精品亚洲综合久久| 亚洲色图综合久久| 99国产一区| 国产精品v亚洲精品v日韩精品| 99国产精品久久久久久久| 欧美成人精品影院| 美女精品国产| 亚洲精品久久久久久久久久久久久 | 国产精品羞羞答答| 欧美四级在线| 国产精品99久久久久久久久久久久| 老鸭窝毛片一区二区三区| 午夜视频在线观看一区| 国产伪娘ts一区| 欧美中文日韩| 欧美在线一二三四区| 好吊妞**欧美| 乱人伦精品视频在线观看| 久久精品国产一区二区电影| 国产在线一区二区三区四区| 久久久久一区二区三区| 久久精品国产免费看久久精品| 国产综合激情| 欧美激情第8页| 欧美日韩一二三四五区| 午夜欧美电影在线观看| 久久狠狠一本精品综合网| 亚洲国产精品123| 日韩视频在线观看国产| 国产欧美 在线欧美| 蜜桃av一区| 欧美日韩国内| 久久精品视频在线播放| 免费成人在线视频网站| 亚洲一区二区成人在线观看| 性欧美18~19sex高清播放| 亚洲国产精品欧美一二99| 一本色道综合亚洲| 精久久久久久| 一区二区三区导航| 在线电影院国产精品| 亚洲免费观看高清完整版在线观看熊| 国产精品国产亚洲精品看不卡15 | 久久国产精彩视频| 久久免费视频网| 亚洲一区二区三区在线播放| 欧美在线一区二区| 亚洲在线一区二区| 欧美ed2k| 久久久天天操| 欧美亚韩一区| 欧美激情按摩| 国产欧美日韩麻豆91| 91久久国产综合久久蜜月精品 | 99pao成人国产永久免费视频| 亚洲一区二区三区影院| 亚洲国内自拍| 欧美亚洲综合久久| 亚洲一区不卡| 欧美—级高清免费播放| 免费视频一区| 国产综合亚洲精品一区二| 99精品视频网| 亚洲精选一区二区| 另类图片综合电影| 久久久人人人| 国产手机视频精品| 亚洲永久免费观看| 亚洲高清在线精品| 国产精品免费一区二区三区在线观看 | 亚洲日本黄色| 亚洲国产欧美一区二区三区同亚洲| 亚洲一区二区成人| 一区二区欧美激情| 欧美国产日本在线| 亚洲第一精品久久忘忧草社区| 国产伊人精品| 久久成人综合视频| 久久青草欧美一区二区三区| 国产美女一区二区| 亚洲欧美日产图| 欧美一区二区三区精品| 国产精品二区二区三区| 亚洲免费高清视频| 亚洲一区二区三区四区视频| 欧美精品观看| 亚洲欧洲综合另类| 亚洲毛片av在线| 欧美日韩高清在线播放| 亚洲免费成人av电影| 亚洲婷婷综合色高清在线| 欧美日韩一区二区高清| 一区二区三区日韩欧美精品| 亚洲一区二区三区四区中文| 欧美日韩国产成人在线免费| 日韩西西人体444www| 亚洲欧美成人| 国产欧美一区二区精品性 | 欧美大香线蕉线伊人久久国产精品| 国产亚洲精久久久久久| 久久久久国产精品一区三寸| 欧美国产乱视频| 99综合电影在线视频| 国产精品久久久久一区| 久久精品久久99精品久久| 亚洲高清视频在线观看| 亚洲视频www| 国产日韩亚洲欧美| 卡通动漫国产精品| 亚洲毛片在线看| 欧美一区观看| 亚洲黄色精品| 国产精品私房写真福利视频| 久久精品日韩欧美| 亚洲日本电影| 久久久久久综合网天天| 日韩视频不卡| 国产在线视频欧美一区二区三区| 免费欧美日韩| 亚洲欧美日韩另类| 欧美激情第4页| 欧美在线观看www| 亚洲欧洲另类| 国产一区二区av| 欧美视频久久| 久久婷婷国产麻豆91天堂| 日韩视频在线你懂得| 久久综合导航| 亚洲欧美日韩精品久久奇米色影视| 激情久久婷婷| 国产精品久久久对白| 女人色偷偷aa久久天堂| 午夜久久美女| 99精品视频网| 亚洲国产精品123| 久久久不卡网国产精品一区| 99精品热视频| 久久―日本道色综合久久| 日韩视频在线你懂得| 国产一区二区精品| 欧美日韩爆操| 牛牛精品成人免费视频| 欧美与欧洲交xxxx免费观看| 99伊人成综合| 最新国产の精品合集bt伙计| 久久久伊人欧美|