使用我用線程代碼時,有一個問題,這個問題顯然是我定義螺紋部以外的變量不在螺紋部內部定義的,這裏是我的代碼:蟒蛇多線程
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()
和我得到這個作爲返回
local variable 'header' referenced before assignment
此代碼爲一些奇怪的原因不會工作,它只是與此錯誤崩潰:導入:無法抓住鼠標':資源暫時不可用@錯誤/ xwindow。 C/XSelectWindow/9052。 from:無法讀取/ var/mail/time 導入:無法抓取鼠標':資源暫時不可用@ error/xwindow.c/XSelectWindow/9052。 (' ./fuzzy.py:line 6:'class ConnectionThread(threading.Thread):' from:can not read/var/mail /時間 ./fuzzy.py:第6行:意外標記附近的語法錯誤'(' ./fuzzy.py:第6行:'ConnectionThread(threading.Thread):' – Ba7a7chy 2012-07-17 09:15:10