-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtrun_fuzzer.py
59 lines (51 loc) · 1.75 KB
/
trun_fuzzer.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
# Python3
from boofuzz import *
import time
# Function for grabbing the banner each time it connects
def get_banner(target, my_logger, session, *args, **kwargs):
# Set the function banner_template as the string we expect to see on connection
banner_template = b"Welcome to Vulnerable Server! Enter HELP for help."
try:
# Recieve buffer from the target
banner = target.recv(10000)
except:
# If nothing recieved from the target, print and exit
print("Unable to connect. Target is down. Exiting.")
exit(1)
# Printing to our log to let us know its recieving something
my_logger.log_check('Receiving banner..')
# Check that what we recieved contains the string we expected
if banner_template in banner:
my_logger.log_pass('banner received')
else:
# If it doesn't contain the string we expected, fail and exit
my_logger.log_fail('No banner received')
print("No banner received, exiting..")
exit(1)
# Main function
def main():
# This is a boofuzz standard piece of code and is on their docs as a template
session = Session(
sleep_time=1,
target=Target(
# This sets the connection host and port for vulnserver
connection=SocketConnection("127.0.0.1", 443, proto='tcp')
),
)
# Setup request
s_initialize(name="Request")
with s_block("Host-Line"):
# Send TRUN command to vulnserver
s_static("TRUN", name='command name')
# Add a space after TRUN
s_delim(" ")
# After TRUN and the space, add the fuzzing payloads
s_string("FUZZ", name='trun variable content')
# Add a new line after the fuzzing payload (so that it sends)
s_delim("\r\n")
# Fuzzing
session.connect(s_get("Request"), callback=get_banner)
session.fuzz()
# Calls main
if __name__ == "__main__":
main()