Particle42
  • šŸ”¬Network Enumeration
    • NMAP
    • TCPdump
  • šŸ”­Website Enumeration
    • Passive Information Gathering
    • Subdomain Enumeration
  • šŸ–„ļøWeb Application
    • URL & App Scan
    • Subdomain/Vhost Fuzz
    • Login Hack
    • Cross Site Scripting
    • Directory Traversal
    • Local File Inclusion
    • Remote File Inclusion
    • PHP Wrappers
    • SQL Injection
      • Bypass Authentication
      • Database Enumeration
      • Code Execution Via Injection
      • SQL Injection Tools
      • Other Resources
    • NOSQL Injection
      • Bypass Authentication
    • WordPress Scanner
    • Hints & Easter Eggs
  • šŸŽ£Phishing
    • Client Info Gathering
    • HTA
    • Word Macros
    • Windows Library Files
  • 🪟Windows
    • Enumeration & PE Quick Ref
    • Enumeration
      • Users
      • Powershell History
      • System Details
      • Applications & Services
      • Files & Filesystems
      • Cached Creds
    • Windows PE
      • Windows PE Checklist
      • Service Binary Hijacking
      • Important Files
      • Service DLL Hijacking
      • Unquoted Service Paths
      • Other PE Methods
      • Finding PE Vulns
      • SeImpersonatePrivilege
      • Bypassuac using Bypassuac.exe
      • Bypassuac using eventviewer.exe
      • Rasta Watson
    • Windows Remote Access
  • šŸ“‚Active Directory
    • About
    • Important Definitions
    • Exploitation Methodology
    • AD Kerberos
      • Invoke-Kerberoast - Shortcut
    • Domain Recon
      • Auto Recon
    • AD Authentication Attacks
      • Password Guessing
      • Creating & Cracking TGS
      • Kerberoasting
    • Lateral Movement
      • Pass the Hash
      • Overpass the Hash
      • Pass the Ticket
      • Distributed Component Object Model
      • Golden Ticket
      • Shadow Copy
      • Domain Controller Sync
      • Windows Management Instrumentation
      • PowerShell Remoting
    • All Commands, Tools & Scripts
      • Using Crackmapexec
      • Using Powerview
      • Important Scripts & Links
  • šŸŗBuffer Over Flow
    • Finding EIP Position
    • Eliminating Bad Characters
    • Finding Return Address
    • Payload for BOF
  • 🐧Linux
    • Enumeration
      • Users
      • Encrypted Files
      • System Info
      • Files & Filesystems
      • Applications & Services
    • Attack Vectors
      • Authorised Keys
    • Linux PE
      • Enumeration Commands
      • Finding PE Vulns
      • Check Sudo List
      • Add User to Passwd File
      • SUIDs
      • Tasks with Wildcard
      • Dirty Cow
      • DirtyPipe
      • Insecure File Permissions
      • Enumerating Processes
    • Quick Commands
  • Services
    • SMB
      • Find Server Version
      • Directory Traversal using Symlink
      • Enable Passwordless SMB Access
    • MSSQL
    • MYSQL
    • PHPLiteAdmin
    • SSH
      • Limited Keys Issue
    • SMTP
      • Sending Email
    • Webdav
    • DNS
      • DNS Recon
  • ā†—ļøPivoting
    • Bringing Internet Access
    • Port Forwarding
      • Local Port Forwarding
      • Remote Port Forwarding
      • Dynamic Port Forwarding
    • HTTP Tunnel-ing
    • DNS Tunneling
    • Chisel
    • Ligolo-NG
  • šŸ”‘Passwords
    • Wordlist Generation
    • HTTP Applications
    • OS Login
    • Password Cracking
      • Using Hashes Directly
      • Cracking Hashes
    • SAM & System
  • šŸ› ļøPractical Tools
    • Remote Shell
      • Alternate Reverse Shells
      • Move to Interactive Shell
    • File Transfers
      • Quick Webservers
    • CURL
    • Payloads
      • MSFVenom
      • Veil Framework
    • Crafty Executable
    • Metasploit
      • Discovery
    • IMPACKET
      • MSSQL-Client
    • Clever Alternatives
  • šŸš€Privilege Escalation
    • General Info
  • ⚔Resources
    • Exploits
Powered by GitBook
On this page

Was this helpful?

  1. Buffer Over Flow

Finding Return Address

In a buffer overflow attack, the malicious code is usually placed within the stack that is pointed to by the ESP. In order to execute the code present in the ESP we need the EIP, instruction pointer, to point to the ESP. Unfortunately, the ESP keeps changing as the stack keeps changing every time with the execution of an application.

The next best thing to do is make an indirect jump, where the EIP points to an address within a dll that contains a "JMP ESP". The "JMP ESP" instructs to jump to the ESP address despite it being dynamic.

The following process can be followed to identify the address to the JMP ESP.

Once the application being tested for BOF is attached to the immunity debugger, use the command "!mona modules" to list the dlls loaded by the application. Look out for the dll that has "SafeSEH", "ASLR" and "NXCompat" (DEP Protection) disabled. Make sure none of the bad characters are present as part of the address.

Now we have to search for the "JMP ESP" within the code for which we will need the text in hex string. We can convert it using the following command in linux,

msf-nasm_shell
jmp esp

It should generate an output 0xFFE4. The following command can be used within the immunity debugger to search for the address,

!mona find -s ā€œ\xff\xe4ā€ -m ā€œ<dll name>ā€

The JMP ESP address found can be used in the exploitation process by including it in the EIP. Because of the endian format the address has to be used in reverse order. For e.g,

JMP ESP Address - 0x90108202, has to be used as "\x02\x82\x10\x90".

Note

The payload is prepended with a stud that is used for decoding the encoded reverse shell script. During the process of decoding the stub gathers its addresses in memory and from there look for the encoded shell. As part of the process of gathering the decoder's stub's location in memory, the code performs a series of assembly instructions, called as the GetPC routince. This routince writes data in and around the stack, resulting in messing up with the data at the ESP. In order to avoid this situation, we can prepend the payload with No Operation (NoP). This instructions do nothing but pass on execution to the next instruction. So it is good to prepend the shell with few NoPs and careful enough not to exhaust the space available for the shell code.

PreviousEliminating Bad CharactersNextPayload for BOF

Last updated 2 years ago

Was this helpful?

šŸŗ