SlideShare ist ein Scribd-Unternehmen logo
1 von 6
===================================
EXPLOIT TECHNIQUES - A QUICK REVIEW
===================================

Last Modify: 08/12/2011
Author:     luca.mella@studio.unibo.it


Thanks to Corelan Team :)

************************************************************************
*** jmp2reg based exploit *********************************************
************************************************************************

jump (or call) a register that points to the shellcode:
      With this technique, you basically use a register that contains the address
where the shellcode resides and put that address in EIP.
      You try to find the opcode of a jump or call to that register in one of the
dlls that is loaded when the application runs.
      When crafting your payload, instead of overwriting EIP with an address in
memory,
      you need to overwrite EIP with the address of the jump to the register.
      Of course, this only works if one of the available registers contains an
address that points to the shellcode.
      This is how we managed to get our exploit to work in part 1, so I'm not going
to discuss this technique in this post anymore.
      [CLASSICAL]

pop return :
      If none of the registers point directly to the shellcode, but you can see an
address on the stack
      (first, second, address on the stack) that points to the shellcode, then you
can load that value into EIP by first putting
      a pointer to pop ret, or pop pop ret, or pop pop pop ret (all depending on
the location of where the address is found on the stack)
      into EIP.

push return :
      this method is only slightly different than the call register technique.
      If you cannot find a <jump register> or <call register> opcode anywhere, you
could simply put the address on the
      stack and then do a ret.
      So you basically try to find a push <register>, followed by a ret [ ROP
GADGET ? ].
      Find the opcode for this sequence, find an address that performs this
sequence, and overwrite EIP with this address.
      [NICE :D]

jmp [reg + offset] :
      If there is a register that points to the buffer containing the shellcode,
but it does not point at the beginning of the shellcode,
      you can also try to find an instruction in one of the OS or application dlls,
which will add the required bytes to the register and then jumps to the register.
      I'll refer to this method as jmp [reg]+[offset] blind return : in my previous
post I have explained that ESP points to the current stack position (by
definition).
      A RET instruction will pop the last value (4bytes) from the stack and will
put that address in ESP.
      So if you overwrite EIP with the address that will perform a RET instruction,
you will load the value stored at ESP into EIP.
      If you are faced with the fact that the available space in the buffer (after
the EIP overwrite) is limited, but you have plenty of space before overwriting EIP,
then you could use jump code in the smaller buffer to jump to the main shellcode in
the first part of the buffer.

========================================================================
References:
      http://www.corelan.be/index.php/2009/07/23/writing-buffer-overflow-exploits-
a-quick-and-basic-tutorial-part-2/

************************************************************************
*** SEH based exploit *************************************************
************************************************************************

TODO: no time to summarize it :(

User exception handler in the stack:
      http://www.corelan.be:8800/wp-content/uploads/2009/07/image25.png
Detail on the exception handler's list (chain):
      http://www.corelan.be:8800/wp-content/uploads/2009/07/image45.png
SEH exploiting technique (keep in mind the ESP position for understanding it):
      http://www.corelan.be:8800/wp-content/uploads/2010/08/image13.png
========================================================================
References:
      http://www.corelan.be/index.php/2009/07/25/writing-buffer-overflow-exploits-
a-quick-and-basic-tutorial-part-3-seh/

************************************************************************
*** Bypass ALSR+DEP - ROP based exploit *******************************
************************************************************************

Windows DEP options:
      OptIn : Only a limited set of Windows system modules/binaries are protected
by DEP.
      OptOut : All programs, processes, services on the Windows system are
protected, except for processes in the exception list
      AlwaysOn : All programs, processes, services, etc on the Windows system are
protected. No exceptions
      AlwaysOff : DEP is turned off.
      +
      MS Permanent DEP : uses SetProcessDEPPolicy(PROCESS_DEP_ENABLE) to make sure
processes are DEP enabled.

Windows DEP defaults:
      Windows XP SP2, XP SP3, Vista SP0 : OptIn
      Windows Vista SP1 : OptIn + Permanent DEP
      Windows 7: OptIn + Permanent DEP
      Windows Server 2003 SP1 and up : OptOut
      Windows Server 2008 and up : OptOut + Permanent DEP

Change DEP behavior:
      XP and 2003 server                              via boot.ini parameter
            /noexecute=[OptIn|OptOut|AlwaysOn|lwaysOff]
      Vista/Windows 2008/Windows 7        via bcdedit command
            bcdedit.exe /set nx [OptIn|OptOut|AlwaysOn|AlwaysOff]

Windows API functions for bypassing DEP
      VirtualAlloc(MEM_COMMIT + PAGE_READWRITE_EXECUTE) + copy memory : new
executable memory region, copy shellcode, execute
      HeapCreate(HEAP_CREATE_ENABLE_EXECUTE) + HeapAlloc() + copy memory
      SetProcessDEPPolicy()
      : Vista SP1, XP SP3, Server 2008, only if DEP Policy=OptIn|OptOut
      VirtualProtect(PAGE_READ_WRITE_EXECUTE)                               :
change the access protection level of a given memory page
      WriteProcessMemory()
      : the target location must be writable and executable

NOTE :      Each one of those functions requires the stack or registers to be set
up in a specific way.
            Parameters to the function are placed at the top of the stack (= at
ESP).

Primary goal: craft these values on the stack, in a generic and reliable way,
without executing any code from the stack itself.
After crafting the stack, you will most likely end up calling the API. ESP must
point at the API function parameters.
      ---------------------------------------------------------
      |           junk
      |
      |           rop gadgets to craft the stack                             |
      |ESP->      function pointer (to one of the Windows APIs) |
      |           junk (4 bytes)
      |
      |           Function parameter
      |
      |           Function parameter
      |
      |           Function parameter
      |
      |           Maybe some more rop gadgets                                |
      |           nops
      |
      |           shellcode
      |
      |           more data on the stack                                     |
      ---------------------------------------------------------
At that time, a simple "RET" instruction will jump to that address. This will call
the function and will make ESP shift with 4 bytes.
If all goes well, the top of the stack (ESP) points at the function parameters,
when the function is called.

Example:
VirtualAlloc + memcpy. Part of crafted stack..
      ----------------------------------------------------------------------------
      [..]
      |     Pointer to VirtualAlloc |    ESP points here for start the call.
      |     4 bytes junk                 |     Necessary because when entering in
VirtualAlloc, VirtualAlloc will PUSH EIP. He think it is a regular call.
      |     pointer to memcpy       |    Return address field of VirtualAlloc()).
When VirtualAlloc ends, it will return to this address
      |     lpAddress                    |     arbitrary address (where to
allocate new memory. Example 0×00200000)
      |     size                         |     (how big should new memory
allocation be)
      |     flAllocationType        |    0×1000 : MEM_COMMIT
      |     flProtect                    |     0×40 : PAGE_EXECUTE_READWRITE
      |     Arbitrary address       |    Return address for memcpy (same as
lpAddress). used to jump to shellcode after memcpy() returns.
      |     4 bytes junk                 |     Necessary because when entering in
memcpy, memcpy will PUSH EIP. He think it is a regular call.
      |     Arbitrary address       |    same address as lpAddress. Parameter here
will be used as destination address for memcpy().
      |     Address of shellcode    |    source parameter for memcpy().
      |     Size                         |     size parameter for memcpy().
      [..]
      ----------------------------------------------------------------------------

NOTE ON PORTABILITY:
It might be a good idea to verify if the application uses the function that you
want to use to bypass DEP, and see if you can call
that functions using an application/module pointer. That way, you can still make
the exploit portable, without having to generate the
function address, and without having to hardcode addresses from an OS dll.

SUMMARY - HOW TO:

What technique?
      (Windows API) used to bypass DEP and what are the consequences in terms of
stack setup/parameters.
What is the current DEP policy?
What are the ROP GADGETS I can use ?
      (This will be your toolbox and will allow you to craft your stack.)
How to start the chain? How to pivot to your controlled buffer ? (stack pivot)
      In a direct RET exploit, you most likely control ESP, so you can simply
overwrite EIP with a pointer to RETN to kick start the chain
How will you craft the stack ?
      As seen before, we will need to pass a number of parameters to this function.
      These parameters need to sit at the top of the stack at the time the function
gets called.
            option 1) Put the required values in registers and then PUSHAD
            option 2) put some of the params (the static ones/the ones without null
bytes) on the stack already, use ROP GADGETS to calculate the other params and
write them onto the stack.

[ROP GADGET = any instruction followed by a RET]

        -----------------------------------------------------------------------------
-----
      |                       |     junk
      |                       |     eip                     eg. points to a RET
instruction (or a stack pivot?)
      |                       |     junk
      |                       |     rop                     pointer to gadgets and
at least jmp to syscall
      |ESP points here|       parameters        parameters that will be popped by
syscall
      |                       |     more rop
      |                       |     padding / nops
      |                       |     shellcode
      |                       |     junk
      -----------------------------------------------------------------------------
-----

>>> ROP EXPLOIT EXAMPLE >>>
      [Watch picture @ http://www.corelan.be:8800/wp-
content/uploads/2010/06/ropstructure1.png]
>>> Stage 1 : SAVE ESP and JMP over the parameters
      2 of our VirtualProtect() function parameters need to point at our shellcode.
      payload is in the stack, so taking the current stack pointer and storing it
in a register is smart.

      Advantages:
            1)    Easily add/sub the value the reg to make it point at your
shellcode. ADD, SUB, INC, DEC instructions are common.
            2)    Initial value points is pretty close to the stack address where
the pointer to VirtualProtect() is located.
            3)    Close to the stack location of the parameter placeholders.
                  "mov dword ptr ds:[register+offset],register" instruction to
overwrite the parameter placeholder.

      # PUSH ESP # MOV   EAX,EDX # POP EDI # RETN ---> MOV ESP, EDI (EDI is uncommon
register, so this is a   good place to store)
      # PUSH EDI # POP   EAX # POP EBP # RETN           ---> MOV EDI,EAX +     POP
Junk (old ESP = EDI =    EAX)

     Now, jump over params with a gadget like # ADD ESP,20 # RETN

>>> Stage 2 : crafting the first parameter of VirtualProtect() [return address]
      Shellcode is right after the nops...

      # ADD EAX,100 # POP EBP # RETN ---> ADD EAX,0x100     ; So eax = old ESP +
0x100 ...hope will hit the nop sled

      # MOV DWORD PTR DS:[ESI+10],EAX # MOV EAX,ESI # POP ESI # RETN    ---> write
this value onto the stack

     [..]

>>> Stage 3 : crafting the second parameter (lpAddress = location that needs to be
marked executable)

     This means that we can - more or less - repeat the entire sequence from stage
2,
     but before we can do this, we need to reset our start values.

       # PUSH EAX # POP ESI # RETN --->    EAX still holds the initial saved stack
pointer. We have to put it back in ESI

     increase the value in EAX again (add 0x100)
     increase the value in ESI with 4 bytes [ # INC ESI # RETN    (4 times)]

>>> Stage 4 and 5 : third and fourth parameter (size and protection flag)

      The technique to write the resulting value as a parameter is exactly the same
as with the other parameters
            Save EAX into ESI
            Change EAX (XOR EAX,EAX : 0x100307A9, and then ADD EAX,100 + RET, 3
times in a row : 0x1002DC4C)
            Increase ESI with 4 bytes
            Write EAX to ESI+0x10

     The fourth parameter (0x40) uses the same principle again :
           Save EAX into ESI
           Set EAX to zero and then add 40 (XOR EAX,EAX + RET : 0x100307A9     /
ADD EAX,40 + RET : 0x1002DC41)
            Increase ESI with 4 bytes
            Write EAX to ESI+0x10

>>> Final stage : jump to VirtualProtect

      All we need to do now is find a way to make ESP point to the location where
the pointer to VirtualProtect() is stored.
      In this eample EAX already points at this address.

      #SUB EAX,4 # RET        --->   just cause eax doesn't point directly @
virtualprotect pointer
      # PUSH EAX # POP ESP # MOV EAX,EDI # POP EDI # POP ESI # RETN    ---> MOV
EAX,ESP           ; GOGOGO!


========================================================================
References:
      https://www.corelan.be/index.php/2010/06/16/exploit-writing-tutorial-part-10-
chaining-dep-with-rop-the-rubikstm-cube/

************************************************************************
*** Egg Hunting *******************************************************
************************************************************************

     Find shellcode into program memory and jump into it.

      TODO: no time to summarize it :(
========================================================================
References:
      http://www.corelan.be/index.php/2010/01/09/exploit-writing-tutorial-part-8-
win32-egg-hunting/
      https://www.corelan.be/index.php/2011/05/12/hack-notes-ropping-eggs-for-
breakfast/

Weitere ähnliche Inhalte

Was ist angesagt?

PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
Runtime Symbol Resolution
Runtime Symbol ResolutionRuntime Symbol Resolution
Runtime Symbol ResolutionKen Kawamoto
 
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練Sheng-Hao Ma
 
Php and threads ZTS
Php and threads ZTSPhp and threads ZTS
Php and threads ZTSjulien pauli
 
2021.laravelconf.tw.slides2
2021.laravelconf.tw.slides22021.laravelconf.tw.slides2
2021.laravelconf.tw.slides2LiviaLiaoFontech
 
SymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesSymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesjulien pauli
 
StackOverflow
StackOverflowStackOverflow
StackOverflowSusam Pal
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS charsbar
 
PHP 7 OPCache extension review
PHP 7 OPCache extension reviewPHP 7 OPCache extension review
PHP 7 OPCache extension reviewjulien pauli
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
Symfony live 2017_php7_performances
Symfony live 2017_php7_performancesSymfony live 2017_php7_performances
Symfony live 2017_php7_performancesjulien pauli
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Moriyoshi Koizumi
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPANcharsbar
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5julien pauli
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machinejulien pauli
 
TDOH x 台科 pwn課程
TDOH x 台科 pwn課程TDOH x 台科 pwn課程
TDOH x 台科 pwn課程Weber Tsai
 

Was ist angesagt? (20)

PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
Runtime Symbol Resolution
Runtime Symbol ResolutionRuntime Symbol Resolution
Runtime Symbol Resolution
 
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
NTUSTxTDOH 資訊安全基礎工作坊 基礎逆向教育訓練
 
Php and threads ZTS
Php and threads ZTSPhp and threads ZTS
Php and threads ZTS
 
2021.laravelconf.tw.slides2
2021.laravelconf.tw.slides22021.laravelconf.tw.slides2
2021.laravelconf.tw.slides2
 
SymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesSymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performances
 
StackOverflow
StackOverflowStackOverflow
StackOverflow
 
Advance ROP Attacks
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacks
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
 
PHP 7 OPCache extension review
PHP 7 OPCache extension reviewPHP 7 OPCache extension review
PHP 7 OPCache extension review
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Symfony live 2017_php7_performances
Symfony live 2017_php7_performancesSymfony live 2017_php7_performances
Symfony live 2017_php7_performances
 
Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
 
Php engine
Php enginePhp engine
Php engine
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machine
 
TDOH x 台科 pwn課程
TDOH x 台科 pwn課程TDOH x 台科 pwn課程
TDOH x 台科 pwn課程
 

Ähnlich wie Exploit techniques - a quick review

Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP ChainsExploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP ChainsAjin Abraham
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit developmentPayampardaz
 
Reversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsReversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsCysinfo Cyber Security Community
 
Quantifying Container Runtime Performance: OSCON 2017 Open Container Day
Quantifying Container Runtime Performance: OSCON 2017 Open Container DayQuantifying Container Runtime Performance: OSCON 2017 Open Container Day
Quantifying Container Runtime Performance: OSCON 2017 Open Container DayPhil Estes
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Pluginsamiable_indian
 
Demystify eBPF JIT Compiler
Demystify eBPF JIT CompilerDemystify eBPF JIT Compiler
Demystify eBPF JIT CompilerNetronome
 
Bypassing DEP using ROP
Bypassing DEP using ROPBypassing DEP using ROP
Bypassing DEP using ROPJapneet Singh
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerMarina Kolpakova
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Elvin Gentiles
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics Abdulrahman Bassam
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploitshughpearse
 
08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen one08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen oneAlexandre Moneger
 
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06ManhHoangVan
 
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation ProcessCyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation ProcessThomas Gregory
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance毅 吕
 

Ähnlich wie Exploit techniques - a quick review (20)

Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP ChainsExploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit development
 
Exploitation Crash Course
Exploitation Crash CourseExploitation Crash Course
Exploitation Crash Course
 
Reversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basicsReversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basics
 
Quantifying Container Runtime Performance: OSCON 2017 Open Container Day
Quantifying Container Runtime Performance: OSCON 2017 Open Container DayQuantifying Container Runtime Performance: OSCON 2017 Open Container Day
Quantifying Container Runtime Performance: OSCON 2017 Open Container Day
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Plugins
 
Demystify eBPF JIT Compiler
Demystify eBPF JIT CompilerDemystify eBPF JIT Compiler
Demystify eBPF JIT Compiler
 
Bypassing DEP using ROP
Bypassing DEP using ROPBypassing DEP using ROP
Bypassing DEP using ROP
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
 
php & performance
 php & performance php & performance
php & performance
 
Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
 
[ASM]Lab6
[ASM]Lab6[ASM]Lab6
[ASM]Lab6
 
OpenMP
OpenMPOpenMP
OpenMP
 
08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen one08 - Return Oriented Programming, the chosen one
08 - Return Oriented Programming, the chosen one
 
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
 
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation ProcessCyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation Process
 
Introduction to OpenMP
Introduction to OpenMPIntroduction to OpenMP
Introduction to OpenMP
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 

Mehr von Ce.Se.N.A. Security

Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route...
 Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route... Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route...
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route...Ce.Se.N.A. Security
 
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...Ce.Se.N.A. Security
 
Msfpayload/Msfencoder cheatsheet
Msfpayload/Msfencoder cheatsheetMsfpayload/Msfencoder cheatsheet
Msfpayload/Msfencoder cheatsheetCe.Se.N.A. Security
 
Analisi sulla sicurezza di una autovettura moderna
Analisi sulla sicurezza di una autovettura modernaAnalisi sulla sicurezza di una autovettura moderna
Analisi sulla sicurezza di una autovettura modernaCe.Se.N.A. Security
 
Monitoraggio di mac address in lan
Monitoraggio di mac address in lanMonitoraggio di mac address in lan
Monitoraggio di mac address in lanCe.Se.N.A. Security
 
Inoltro di pacchetti ip in sistemi linux
Inoltro di pacchetti ip in sistemi linuxInoltro di pacchetti ip in sistemi linux
Inoltro di pacchetti ip in sistemi linuxCe.Se.N.A. Security
 
Crimini informatici e accesso abusivo
Crimini informatici e accesso abusivoCrimini informatici e accesso abusivo
Crimini informatici e accesso abusivoCe.Se.N.A. Security
 

Mehr von Ce.Se.N.A. Security (20)

Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route...
 Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route... Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route...
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per route...
 
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...
Rilevamento di attacchi di rete tramite protocolli di monitoraggio per router...
 
Msfpayload/Msfencoder cheatsheet
Msfpayload/Msfencoder cheatsheetMsfpayload/Msfencoder cheatsheet
Msfpayload/Msfencoder cheatsheet
 
ICTF overview
ICTF overviewICTF overview
ICTF overview
 
Anonymous email
Anonymous emailAnonymous email
Anonymous email
 
Hacking reti wireless
Hacking reti wirelessHacking reti wireless
Hacking reti wireless
 
SELinux - overview
SELinux - overviewSELinux - overview
SELinux - overview
 
Analisi sulla sicurezza di una autovettura moderna
Analisi sulla sicurezza di una autovettura modernaAnalisi sulla sicurezza di una autovettura moderna
Analisi sulla sicurezza di una autovettura moderna
 
Sicurezza delle reti 802.11
Sicurezza delle reti 802.11Sicurezza delle reti 802.11
Sicurezza delle reti 802.11
 
Rilevamento intrusioni in wlan
Rilevamento intrusioni in wlanRilevamento intrusioni in wlan
Rilevamento intrusioni in wlan
 
Rainbow tables
Rainbow tablesRainbow tables
Rainbow tables
 
Network monitoring tramite snmp
Network monitoring tramite snmpNetwork monitoring tramite snmp
Network monitoring tramite snmp
 
Monitoraggio di rete con nagios
Monitoraggio di rete con nagiosMonitoraggio di rete con nagios
Monitoraggio di rete con nagios
 
Monitoraggio di mac address in lan
Monitoraggio di mac address in lanMonitoraggio di mac address in lan
Monitoraggio di mac address in lan
 
Ip sec vulnerability
Ip sec vulnerabilityIp sec vulnerability
Ip sec vulnerability
 
Insider attack
Insider attackInsider attack
Insider attack
 
Inoltro di pacchetti ip in sistemi linux
Inoltro di pacchetti ip in sistemi linuxInoltro di pacchetti ip in sistemi linux
Inoltro di pacchetti ip in sistemi linux
 
Iena
IenaIena
Iena
 
Crimini informatici e accesso abusivo
Crimini informatici e accesso abusivoCrimini informatici e accesso abusivo
Crimini informatici e accesso abusivo
 
Clonare mac os x
Clonare mac os xClonare mac os x
Clonare mac os x
 

Kürzlich hochgeladen

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Exploit techniques - a quick review

  • 1. =================================== EXPLOIT TECHNIQUES - A QUICK REVIEW =================================== Last Modify: 08/12/2011 Author: luca.mella@studio.unibo.it Thanks to Corelan Team :) ************************************************************************ *** jmp2reg based exploit ********************************************* ************************************************************************ jump (or call) a register that points to the shellcode: With this technique, you basically use a register that contains the address where the shellcode resides and put that address in EIP. You try to find the opcode of a jump or call to that register in one of the dlls that is loaded when the application runs. When crafting your payload, instead of overwriting EIP with an address in memory, you need to overwrite EIP with the address of the jump to the register. Of course, this only works if one of the available registers contains an address that points to the shellcode. This is how we managed to get our exploit to work in part 1, so I'm not going to discuss this technique in this post anymore. [CLASSICAL] pop return : If none of the registers point directly to the shellcode, but you can see an address on the stack (first, second, address on the stack) that points to the shellcode, then you can load that value into EIP by first putting a pointer to pop ret, or pop pop ret, or pop pop pop ret (all depending on the location of where the address is found on the stack) into EIP. push return : this method is only slightly different than the call register technique. If you cannot find a <jump register> or <call register> opcode anywhere, you could simply put the address on the stack and then do a ret. So you basically try to find a push <register>, followed by a ret [ ROP GADGET ? ]. Find the opcode for this sequence, find an address that performs this sequence, and overwrite EIP with this address. [NICE :D] jmp [reg + offset] : If there is a register that points to the buffer containing the shellcode, but it does not point at the beginning of the shellcode, you can also try to find an instruction in one of the OS or application dlls, which will add the required bytes to the register and then jumps to the register. I'll refer to this method as jmp [reg]+[offset] blind return : in my previous post I have explained that ESP points to the current stack position (by definition). A RET instruction will pop the last value (4bytes) from the stack and will put that address in ESP. So if you overwrite EIP with the address that will perform a RET instruction,
  • 2. you will load the value stored at ESP into EIP. If you are faced with the fact that the available space in the buffer (after the EIP overwrite) is limited, but you have plenty of space before overwriting EIP, then you could use jump code in the smaller buffer to jump to the main shellcode in the first part of the buffer. ======================================================================== References: http://www.corelan.be/index.php/2009/07/23/writing-buffer-overflow-exploits- a-quick-and-basic-tutorial-part-2/ ************************************************************************ *** SEH based exploit ************************************************* ************************************************************************ TODO: no time to summarize it :( User exception handler in the stack: http://www.corelan.be:8800/wp-content/uploads/2009/07/image25.png Detail on the exception handler's list (chain): http://www.corelan.be:8800/wp-content/uploads/2009/07/image45.png SEH exploiting technique (keep in mind the ESP position for understanding it): http://www.corelan.be:8800/wp-content/uploads/2010/08/image13.png ======================================================================== References: http://www.corelan.be/index.php/2009/07/25/writing-buffer-overflow-exploits- a-quick-and-basic-tutorial-part-3-seh/ ************************************************************************ *** Bypass ALSR+DEP - ROP based exploit ******************************* ************************************************************************ Windows DEP options: OptIn : Only a limited set of Windows system modules/binaries are protected by DEP. OptOut : All programs, processes, services on the Windows system are protected, except for processes in the exception list AlwaysOn : All programs, processes, services, etc on the Windows system are protected. No exceptions AlwaysOff : DEP is turned off. + MS Permanent DEP : uses SetProcessDEPPolicy(PROCESS_DEP_ENABLE) to make sure processes are DEP enabled. Windows DEP defaults: Windows XP SP2, XP SP3, Vista SP0 : OptIn Windows Vista SP1 : OptIn + Permanent DEP Windows 7: OptIn + Permanent DEP Windows Server 2003 SP1 and up : OptOut Windows Server 2008 and up : OptOut + Permanent DEP Change DEP behavior: XP and 2003 server via boot.ini parameter /noexecute=[OptIn|OptOut|AlwaysOn|lwaysOff] Vista/Windows 2008/Windows 7 via bcdedit command bcdedit.exe /set nx [OptIn|OptOut|AlwaysOn|AlwaysOff] Windows API functions for bypassing DEP VirtualAlloc(MEM_COMMIT + PAGE_READWRITE_EXECUTE) + copy memory : new
  • 3. executable memory region, copy shellcode, execute HeapCreate(HEAP_CREATE_ENABLE_EXECUTE) + HeapAlloc() + copy memory SetProcessDEPPolicy() : Vista SP1, XP SP3, Server 2008, only if DEP Policy=OptIn|OptOut VirtualProtect(PAGE_READ_WRITE_EXECUTE) : change the access protection level of a given memory page WriteProcessMemory() : the target location must be writable and executable NOTE : Each one of those functions requires the stack or registers to be set up in a specific way. Parameters to the function are placed at the top of the stack (= at ESP). Primary goal: craft these values on the stack, in a generic and reliable way, without executing any code from the stack itself. After crafting the stack, you will most likely end up calling the API. ESP must point at the API function parameters. --------------------------------------------------------- | junk | | rop gadgets to craft the stack | |ESP-> function pointer (to one of the Windows APIs) | | junk (4 bytes) | | Function parameter | | Function parameter | | Function parameter | | Maybe some more rop gadgets | | nops | | shellcode | | more data on the stack | --------------------------------------------------------- At that time, a simple "RET" instruction will jump to that address. This will call the function and will make ESP shift with 4 bytes. If all goes well, the top of the stack (ESP) points at the function parameters, when the function is called. Example: VirtualAlloc + memcpy. Part of crafted stack.. ---------------------------------------------------------------------------- [..] | Pointer to VirtualAlloc | ESP points here for start the call. | 4 bytes junk | Necessary because when entering in VirtualAlloc, VirtualAlloc will PUSH EIP. He think it is a regular call. | pointer to memcpy | Return address field of VirtualAlloc()). When VirtualAlloc ends, it will return to this address | lpAddress | arbitrary address (where to allocate new memory. Example 0×00200000) | size | (how big should new memory allocation be) | flAllocationType | 0×1000 : MEM_COMMIT | flProtect | 0×40 : PAGE_EXECUTE_READWRITE | Arbitrary address | Return address for memcpy (same as
  • 4. lpAddress). used to jump to shellcode after memcpy() returns. | 4 bytes junk | Necessary because when entering in memcpy, memcpy will PUSH EIP. He think it is a regular call. | Arbitrary address | same address as lpAddress. Parameter here will be used as destination address for memcpy(). | Address of shellcode | source parameter for memcpy(). | Size | size parameter for memcpy(). [..] ---------------------------------------------------------------------------- NOTE ON PORTABILITY: It might be a good idea to verify if the application uses the function that you want to use to bypass DEP, and see if you can call that functions using an application/module pointer. That way, you can still make the exploit portable, without having to generate the function address, and without having to hardcode addresses from an OS dll. SUMMARY - HOW TO: What technique? (Windows API) used to bypass DEP and what are the consequences in terms of stack setup/parameters. What is the current DEP policy? What are the ROP GADGETS I can use ? (This will be your toolbox and will allow you to craft your stack.) How to start the chain? How to pivot to your controlled buffer ? (stack pivot) In a direct RET exploit, you most likely control ESP, so you can simply overwrite EIP with a pointer to RETN to kick start the chain How will you craft the stack ? As seen before, we will need to pass a number of parameters to this function. These parameters need to sit at the top of the stack at the time the function gets called. option 1) Put the required values in registers and then PUSHAD option 2) put some of the params (the static ones/the ones without null bytes) on the stack already, use ROP GADGETS to calculate the other params and write them onto the stack. [ROP GADGET = any instruction followed by a RET] ----------------------------------------------------------------------------- ----- | | junk | | eip eg. points to a RET instruction (or a stack pivot?) | | junk | | rop pointer to gadgets and at least jmp to syscall |ESP points here| parameters parameters that will be popped by syscall | | more rop | | padding / nops | | shellcode | | junk ----------------------------------------------------------------------------- ----- >>> ROP EXPLOIT EXAMPLE >>> [Watch picture @ http://www.corelan.be:8800/wp- content/uploads/2010/06/ropstructure1.png]
  • 5. >>> Stage 1 : SAVE ESP and JMP over the parameters 2 of our VirtualProtect() function parameters need to point at our shellcode. payload is in the stack, so taking the current stack pointer and storing it in a register is smart. Advantages: 1) Easily add/sub the value the reg to make it point at your shellcode. ADD, SUB, INC, DEC instructions are common. 2) Initial value points is pretty close to the stack address where the pointer to VirtualProtect() is located. 3) Close to the stack location of the parameter placeholders. "mov dword ptr ds:[register+offset],register" instruction to overwrite the parameter placeholder. # PUSH ESP # MOV EAX,EDX # POP EDI # RETN ---> MOV ESP, EDI (EDI is uncommon register, so this is a good place to store) # PUSH EDI # POP EAX # POP EBP # RETN ---> MOV EDI,EAX + POP Junk (old ESP = EDI = EAX) Now, jump over params with a gadget like # ADD ESP,20 # RETN >>> Stage 2 : crafting the first parameter of VirtualProtect() [return address] Shellcode is right after the nops... # ADD EAX,100 # POP EBP # RETN ---> ADD EAX,0x100 ; So eax = old ESP + 0x100 ...hope will hit the nop sled # MOV DWORD PTR DS:[ESI+10],EAX # MOV EAX,ESI # POP ESI # RETN ---> write this value onto the stack [..] >>> Stage 3 : crafting the second parameter (lpAddress = location that needs to be marked executable) This means that we can - more or less - repeat the entire sequence from stage 2, but before we can do this, we need to reset our start values. # PUSH EAX # POP ESI # RETN ---> EAX still holds the initial saved stack pointer. We have to put it back in ESI increase the value in EAX again (add 0x100) increase the value in ESI with 4 bytes [ # INC ESI # RETN (4 times)] >>> Stage 4 and 5 : third and fourth parameter (size and protection flag) The technique to write the resulting value as a parameter is exactly the same as with the other parameters Save EAX into ESI Change EAX (XOR EAX,EAX : 0x100307A9, and then ADD EAX,100 + RET, 3 times in a row : 0x1002DC4C) Increase ESI with 4 bytes Write EAX to ESI+0x10 The fourth parameter (0x40) uses the same principle again : Save EAX into ESI Set EAX to zero and then add 40 (XOR EAX,EAX + RET : 0x100307A9 /
  • 6. ADD EAX,40 + RET : 0x1002DC41) Increase ESI with 4 bytes Write EAX to ESI+0x10 >>> Final stage : jump to VirtualProtect All we need to do now is find a way to make ESP point to the location where the pointer to VirtualProtect() is stored. In this eample EAX already points at this address. #SUB EAX,4 # RET ---> just cause eax doesn't point directly @ virtualprotect pointer # PUSH EAX # POP ESP # MOV EAX,EDI # POP EDI # POP ESI # RETN ---> MOV EAX,ESP ; GOGOGO! ======================================================================== References: https://www.corelan.be/index.php/2010/06/16/exploit-writing-tutorial-part-10- chaining-dep-with-rop-the-rubikstm-cube/ ************************************************************************ *** Egg Hunting ******************************************************* ************************************************************************ Find shellcode into program memory and jump into it. TODO: no time to summarize it :( ======================================================================== References: http://www.corelan.be/index.php/2010/01/09/exploit-writing-tutorial-part-8- win32-egg-hunting/ https://www.corelan.be/index.php/2011/05/12/hack-notes-ropping-eggs-for- breakfast/