Hacking Blind
-Presented by Nikita Andhale
TY – E - 04
Seminar on….
-Guided by : Prof. Amol Bhilare
Introduction
• Attackers have been highly successful in building exploits with
varying degrees of information on the target.
• To understand an attacker’s limits, we pose the following question:
is it possible for attackers to extend their reach and create
exploits for proprietary services when neither the source nor binary
code is available?
Vulnerabilities
• Stack buffer overflows Present in
• Popular software(nginx)
• Popular open-source library(SSL or PNG)
• After a crash in
• Apache,
• nginx,
• Samba and
• OpenSSH
What is BROP
• Build exploits for proprietary services for which both the binary and source are unknown
• Assumes system is with vulnerability
• Works against 64 bit Linux with ASLR (Address Space Layout Randomization), nonexecutable (NX)
memory, and stack canaries enabled.
• The attack is enabled by two new techniques:
• Generalized stack reading
• Blind ROP
• The Blind Remote Oriented Programming (BROP) attack makes the following assumptions and
requires the following environment:
• A stack vulnerability and knowledge of how to trigger it.
• A server application that restarts after a crash.
BROP Attack Outline
• The BROP attack has the following phases:
• 1] Stack reading
• 2] Blind ROP
• 3] Build the exploit
HISTORY OF BUFFER OVERFLOWS
• Classic vulnerability with a long history of exploits
• Overwrite memory beyond the end of the buffer
• In early days “Code injection” attacks are no longer possible on contemporary machines
• ability to mark data memory pages as non-executable (e.g., NX on x86)
• causes exception only
• Technique to defeat defences based on non-executable memory- ROP was developed.
• Defence techniques such as ASLR(Address space layout randomization)
• and Canaries were developed.
BUFFER OVERFLOWS TODAY
• Attacker must fulfil at least two requirements in order to gain full control of a remote
program’s execution:
• 1. To defeat NX, the attacker must know where gadgets reside inside the
program executable.
• 2. To defeat ASLR, the attacker must derandomize the location at which the
executable’s text segment is actually loaded in memory.
• Hacking without binary knowledge is useful even in the not-
completely-blind case (e.g., open-source)
What is ROP
• Return Oriented Programming.
• The goal of ROP is to build an instruction sequence that typically
spawns a shell (shellcode) based on existing code fragments
(gadgets)
• By chaining enough gadgets, complete shellcode can eventually be
built.
STACK READING: ASLR DE-
RANDOMIZATION
• Generalizes a known technique used for leaking canaries
• The words returned by stack reading give further evidence of the BROP attack working
because the values can be somewhat sanitized.
a typical stack layout.
BROP ATTACK
• The BROP attack enables robust, general-purpose exploits for three new
scenarios:
• 1) Hacking proprietary closed-binary services.
• 2) Hacking a vulnerability in an open-source library thought to be used in
a proprietary closed-binary service.
• 3) Hacking an open-source server for which the binary is unknown.
BROP Attack• It allows writing exploits without possessing the target binary.
• It introduces techniques to find ROP gadgets remotely and optimizations to make the attack practical.
• A. The pieces of the puzzle
• The optimized attack therefore requires:
• 1) Finding the BROP gadget. 2) Finding the PLT.
• Finding the entry for write.
• Finding the entry for strcmp.
• B. Finding gadgets and the stop gadget.
• C. Identifying gadgets
• D. Finding the Procedure Linking Table
• E .Controlling rdx via strcmp
• F .Finding write
• G. Concluding attack.
• H. Attack summary
IMPLEMENTATION
• We implemented the BROP attack in a tool called “Braille” that automatically goes from a crash to a remote
shell.
• It is written in 2,000 lines of Ruby code.
• Braille is essentially a meta-exploit.
• The interface is as simple as:
try_exp(data) -> CRASH, NO_CRASH, INF
• . The NO CRASH def try_exp(data) return code is useful for probing the length of the buffer being overflowed
or when stack reading.
• What about latter phases of attack where data expected from socket?
• The driver code can be as simple as opening a socket to the server, and sending the data over the socket, raw.
IMPLEMENTATION
• Often however, services expect data to be in a certain format. For example, HTTP headers may need to be
present.
• We also implemented a generic IP fragmentation router which is useful in cases where a single large TCP read
is needed to overflow a buffer. For eg. overflowing a 4096-byte buffer with a single non-blocking read may be
impossible with an MTU of 1500, as there may not be enough data queued, making the exploit unreliable.
• Our router instead sends large TCP segments as multiple IP fragments so that read is guaranteed to return a
large packet, triggering the overflow reliably.
• . We implemented it in 300 lines of C code. It creates a virtual tun interface where no TCP segmentation
occurs—a single write is sent as multiple IP fragments and as a single TCP packet.
EVALUATION
• Tested BROP attack in three scenarios:
• 1)An open-source SSL library with a known stack vulnerability (yaSSL).
• 2)An open-source software with a known stack vulnerability (nginx), manually compiled from source.
• 3)A toy closed-binary proprietary service with a stack vulnerability.
• The vulnerabilities were as follows:
• 1)yaSSL
• 2)Nginx
• 3)Proprietary service
• We ran Braille against all three attack scenarios, without any application-specific optimizations, and the attack succeeded in all
cases. We evaluate the following aspects:
• 1)Performance: number of requests and time.
• 2)Stability: how robust the attack is.
• Attack paired with source-code knowledge: whether having access to the source code (but not the binary) can make the attack
better.
LIMITATIONS
• Vulnerabilities are more complex and heap-based.
• Stack reading assumes that the attacker can overflow at a byte granularity and controls
the last byte being overflown (e.g., a zero is not appended by the server).
• The attack assumes that the same machine and process can be hit after each attempt.
Load balancers can cause the attack to fail when PIE is used and canaries cannot be
circumvented.
• The attack also relies on a number of workers being available and not ending up in a
situation where all workers become “stuck” in an infinite loop. This makes the stop
gadget selection very important. Returning to a higher stack frame is a key
optimization here, where the worker is “resumed” rather than caused to hang. If this
cannot be done and there are a limited number of worker processes, and the stop gadget
hangs them indefinitely, the attack may not complete.
Advantages
• A technique to defeat ASLR on servers (generalized stack reading).
• A technique to remotely find ROP gadgets (BROP) so that software can be attacked
when the binary is unknown.
• Braille: a tool that automatically constructs an exploit given input on how to trigger a
stack overflow on a server.
• The first (to our knowledge) public exploit for nginx’s recent vulnerability, that is
generic, 64-bit, and defeats (full/PIE) ASLR, canaries and NX.
• Suggestions for defending against BROP attacks. In summary, ASLR must be applied
to all executable segments (PIE) and re-randomization must occur after each crash (at
odds with fork-only servers). Holding the binary from the attacker or purposefully
altering it may not be an effective security countermeasure.
CONCLUSION
• We show that, under the right conditions, it is possible to write exploits without any knowledge
of the target binary or source code. This works for stack vulnerabilities where the server process
restarts after a crash. Our attack is able to defeat ASLR, NX and stack canaries on modern 64-bit
Linux servers. We present two new techniques: generalized stack reading, which defeats full
ASLR on 64-bit systems, and the BROP attack, which is able to remotely find ROP gadgets. Our
fully automated tool, Braille, can take under 4,000 requests to spawn a shell, under 20 minutes,
tested against real versions of yaSSL+MySQL and nginx with known vulnerabilities, and a toy
proprietary service running an unknown binary.
• We show that design patterns like forking servers with multiple worker processes can be at
odds with ASLR, and that ASLR is only effective when it is applied to all code segments in the
binary (including PIE). Moreover, security through obscurity, where the binary is unknown or
randomized, can only slow but not prevent buffer overflow
REFERENCES
• [1] A. One, “Smashing The Stack For Fun And Profit,” Phrack, vol. 7, no. 49, Nov. 1996.
http://phrack.com/issues.html?issue=49&id=14#article
• [2] IEEE paper.
• [3] Online: www.Quora.com
• [4] P. Bakke, S. Beattie, A. Grier, P. Wagle, and Q. Zhang, “Stackguard: automatic adaptive
detection and prevention of buffer-overflow attacks,” in Proceedings of the 7th conference
on USENIX Security Symposium - Volume 7,
• [5] Peach fuzzer. [Online]. Available: http://peachfuzzer.com/
Thank You!!!