[REVS] Introduction to Shellcoding - How to Exploit Buffer Overflows

From: SecuriTeam (support_at_securiteam.com)
Date: 10/20/04

  • Next message: SecuriTeam: "[NT] Microsoft's 'Fight Spyware' Information Center"
    To: list@securiteam.com
    Date: 20 Oct 2004 18:51:05 +0200
    
    

    The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
    - - promotion

    The SecuriTeam alerts list - Free, Accurate, Independent.

    Get your security news from a reliable source.
    http://www.securiteam.com/mailinglist.html

    - - - - - - - - -

      Introduction to Shellcoding - How to Exploit Buffer Overflows
    ------------------------------------------------------------------------

    SUMMARY

    The paper provides a tutorial on how to write shellcodes for the Windows
    and Unix environments, with a focus on Linux shellcodes.
    The paper starts from a simple buffer overflow scenario, and explains how
    to detect the vulnerability and how to write an appropriate shellcode for
    it.

    DETAILS

    What Is a Shellcode?
    Shellcode is a piece of machine-readable code, or script code that has
    just one mission; to open up a command interpreter (shell) on the target
    system so that an attacker can type in commands in the same fashion as a
    regular authorized user or system administrator of that system can do
    (with a few not-so-important exceptions of course). However, in order to
    get remote access to the shell, you're going to need some kind of
    networking support in that shellcode too. There's more to shellcoding than
    just having a program execute /bin/sh or cmd.exe. This white paper will
    introduce you to shellcodes, how they're used in practice, and how they
    are used with buffer overflow vulnerabilities.
    Since it's important that the shellcode is very small, the shellcode
    hacker usually writes the code in the assembly programming language. In
    this white paper I will be using x86 Intel syntax assembly under Linux.
    The GNU compiler (gcc) uses AT&T syntax, which is somewhat different from
    Intel syntax. All assembly examples can be compiled with Netwide Assembler
     <http://nasm.sourceforge.net> nasm a portable Intel syntax assembler
    available for a wide variety of operating systems. nasm is readily
    available in most GNU/Linux distributions.

    What About the Code in Shellcode?
    Shellcode is primarily used to exploit buffer overflows (including heap
    overflows) or format string bugs in binary, machine-readable software. In
    these software, the shellcode has to be machine-readable too, and to make
    things more complicated it can't contain any null bytes (0x00). Null (0)
    is a string delimiter which instructs all C string functions (and other
    implementations) to, once found, stop processing the string (thus, a
    null-terminated string). There are other delimiters like linefeed (0x0A),
    carriage return (0x0D), 0xFF, and others. Some depend on how the
    programmer wrote the program (or the vulnerable function that handles
    input) and other implementations depend on underlying C library functions
    or 3rd party libraries, etc.

    ADDITIONAL INFORMATION

    The original article can be found at:
    <http://tigerteam.se/dl/papers/intro_to_shellcoding.pdf>
    http://tigerteam.se/dl/papers/intro_to_shellcoding.pdf

    ========================================

    This bulletin is sent to members of the SecuriTeam mailing list.
    To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
    In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

    ====================
    ====================

    DISCLAIMER:
    The information in this bulletin is provided "AS IS" without warranty of any kind.
    In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.


  • Next message: SecuriTeam: "[NT] Microsoft's 'Fight Spyware' Information Center"

    Relevant Pages