i have a problem when using my code with threading, the problem is apparently that the variables i define outside of the threading part aren’t defined inside the threading part, here is my code:
import sys
import socket
from time import sleep
import threading
ip = raw_input ("please insert host ip: ")
port = input ("please insert port to fuzz: ")
header = raw_input ("please enter the header you want to fuzz, put & in the place you want to fuzz: ")
packet = raw_input ("what string would you like to fuzz the header with? : ")
multi = input ("in what jumps would you liike to multiply the string ? : ")
process = input ("please insert number of threads: ")
host = ip, port
char = packet * multi
a = 1
class ConnectionThread ( threading.Thread ):
def run ( self ):
while a > 0:
try:
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
s.connect((host))
header = header.replace("&", packet)
s.send(header)
s.settimeout(7)
data = s.recv(4)
if data > 0:
print "got awnser"
else:
print "no awnser"
sleep(0.1)
print "Fuzzing With:", header
header = header.replace (packet, "&")
packet = char + packet
s.close()
except Exception as e:
print e
s.close()
sys.exit(0)
for x in xrange ( process ):
ConnectionThread().start()
and i get this as return
local variable 'header' referenced before assignment
You will need to give your ConnectionThread class the attributes that you want to pass to it. At the top of the class just put in a init method, this will define the variable that you want to pass to the run method:
have a look at how classes work at:
http://docs.python.org/tutorial/classes.html
for additional information.
Hope this helps 🙂