-
Notifications
You must be signed in to change notification settings - Fork 2
/
nonmitm-testscript.template
54 lines (45 loc) · 1.11 KB
/
nonmitm-testscript.template
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
#!/usr/bin/python
from network import *
from config import *
from watchlog import *
from binascii import *
import signal
global terminate_s
terminate_s = False
def receive_signal(signum, stack):
global terminate_s
terminate_s=True
$quit_if_server
signal.signal(signal.SIGTERM, receive_signal)
config = ${Me}Config()
f = open_input(config.input, config)
if config.fuzz:
f=Fuzzer(f, config.out_dir)
$ufuzzb
$ufuzza
$valid_msg
$resending
$if_connect
while True:
if terminate_s:
quit()
$valid_case
$if_reconnect
# Get a new test case or resending case
case=f.next()
# Remove the last newline from the end, if any
if not resending:
case = case.rstrip('0a'.decode('hex'))
$wait_for_connection_or_send
reply=myself.$peer.receive($timeout)
if reply is Timeout:
watchLog('No response for fuzzed message','w')
if os.path.isfile('.target_resp'):
os.remove('.target_resp')
else:
watchLog(reply,'r',False,$trunca)
with open('.target_resp','w') as af:
pass
$server_send
$if_reclose
time.sleep($sleeptime)