Giter Site home page Giter Site logo

aslray's Introduction

ASLRay

Linux ELF x32 and x64 ASLR bypass exploit with stack-spraying

Properties:

  • ASLR bypass
  • Cross-platform
  • Minimalistic
  • Simplicity
  • Unpatchable

Dependencies:

  • Linux 2.6.12+ - will work on any x86-64 Linux-based OS
    • BASH - the whole script

Limitations:

  • Stack needs to be executable (-z execstack)
  • Binary has to be exploited through arguments locally (not file, socket or input)
  • No support for other architectures and OSes (TODO)
  • Need to know the buffer limit/size

How it works

You might have heard of Heap Spraying attack? Well, Stack Spraying is similar, however, it was considered unpractical for most cases, especially ASLR on x86-64.

My work will prove the opposite.

For 32-bit, there are 2^32 (4 294 967 296) theoretical addresses, nevertheless, the kernel will allow to control about only half of bits (2^(32/2) = 65 536) for an execution in a virtualized memory, which means that if we control more that 50 000 characters in stack, we are almost sure to point to our shellcode, regardless the address, thanks to kernel redirection and retranslation.

This can be achieved using shell variables, which aren't really limited to a specific length, but practical limit is about one million, otherwise it will saturate the TTY.

So, in order to exploit successfully, we need to put a NOP sled following the shellcode into a shell variable and just exploit the binary with a random address.

In 64-bit system the situation is different, but not so much as of my discovery.

Of course, you wouldn't have to cover all 2^64 possibilities, in fact, the kernel allows only 48 bits, plus a part of them are predictable and static, which left us with about 2^(4x8+5) (137 438 953 472) possibilities.

I have mentioned the shell variables size limit, but there is also a count limit, which appears to be about 10, thus allowing us to stock a 10 000 000 character shellcode, living us with just a tenth of thousand possibilities that can be tested rapidly and automatically.

That said, ASLR on both 32 and 64-bits can be easily bypassed in few minutes and with few lines of shell...

HowTo

If you have exploited at least one buffer overflow in your life, you can skip, but just in case:

apt install gcc || kill -9 $$
chmod u+x ASLRay.sh
sudo gcc -z execstack test.c -o test
sudo gcc -m32 -z execstack test.c -o test32
sudo chmod +s test test32
source ASLRay.sh test32 1024
source ASLRay.sh test 1024

Don't forget to check stack execution and ASLR both set:

scanelf -e test | grep RWX
or
readelf -l test | grep RWE
cat /proc/sys/kernel/randomize_va_space

Notes

Always rely on multiple protections and not on a single one.

We need new system security mechanisms.

"From where we stand the rain seems random. If we could stand somewhere else, we would see the order in it. "

Tony Hillerman, Coyote Waits

aslray's People

Contributors

cryptolok avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.