This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathmanual_testbed.py
90 lines (60 loc) · 1.8 KB
/
manual_testbed.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
from covertutils.handlers.impl import SimpleShellHandler, ExtendableShellHandler
from covertutils.handlers import FunctionDictHandler, BaseHandler, StageableHandler
from covertutils.orchestration import SimpleOrchestrator
from covertutils.shells import BaseShell
from covertutils.shells.impl import ExtendableShell
from os import urandom
from time import sleep
import re
out_length = 20
in_length = 20
orch1 = SimpleOrchestrator( "passphrase",
2, out_length, in_length,
# streams = ['main', 'shellcode', 'python']
)
orch2 = SimpleOrchestrator( "passphrase",
2, out_length, in_length,
reverse = True,
# streams = ['main', 'shellcode', 'python'],
)
toAgent = []
toHandler = []
def dummy_receive1( ) :
while not toAgent :
sleep(0.01)
# print( "Receiving" )
return toAgent.pop(0)
def dummy_send1( raw ) :
toHandler.append(raw)
def dummy_receive2( ) :
while not toHandler :
sleep(0.01)
# print( "Receiving" )
return toHandler.pop(0)
def dummy_send2( raw ) :
toAgent.append(raw)
chunks_sent = 0
chunks_received = 0
agent = ExtendableShellHandler( dummy_receive1, dummy_send1, orch1 )
class MyHandler (BaseHandler) :
def onMessage(self, stream, message) :
# global chunks_sent
# print( "Handler: Chunks Received: %d" % chunks_sent )
chunks_sent = 0
# print( message )
pass
def onChunk(self, stream, message) :
# global chunks_sent
# if chunks_sent == 0 :
# print
# chunks_sent += 1logname
# print( "Handler: <Chunk>" )
pass
def onNotRecognised(self, stream, message) :
# print( "Handler: <Unrecognised>" )
pass
handler = MyHandler( dummy_receive2, dummy_send2, orch2 )
# shell = ExtendableShell(handler, output = '/tmp/covertutils_out')
# shell = ExtendableShell(handler, output='/tmp/covertutils_session1')
shell = ExtendableShell(handler, output=True)
shell.start( False )