Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # old m3
- # re-released because fuck hann
- # "You sit here locking away other lifeforms
- # like some kind of king! That's nobody's
- # limitation but your own!" -Simon, TTGL
- # ,-----.
- # |M3Ch3|
- # ,--| XiX |-.
- # __,----| | | |
- # ,;:: | `_____' |
- # `._______| i^i |
- # `----| |---'| .
- # ,-------._| |== ||//
- # | |_|P`. /'/
- # `-------' 'Y Y/'/'
- # .== /_
- # / /'| `i
- # /' / | |
- # /' / | `i
- # ___,;`----'.___L_,-'`__
- # i_____;----.____i""____
- #
- # DEV:
- # - XiX : Dev
- # - e : Grouping implementation, BOPM scan
- # - venuism : Core distribution, testing
- # - Xero : Testing
- #
- # TODO:
- # - [4] Fix BOPM scan
- # - [4] Multiserver support
- # - [4] Protect vs bruting admin pass
- # - [4] User object instead of dictionary
- # - [4] On a connection to the network privmsg question to recieve ProtectedUser status
- # - [4] Regex engage using WHO
- # - [4] Error logging
- # - [5] Additional scanning methods, reorganize code for structured scan types, modular, interface
- # - [?] Mech 'forgets' admin (???) need more information on this
- #
- # LICENSE:
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 1, or (at your option)
- # any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- # General config
- server="IRC.NIGGERS.COM"
- port=6667
- channels=["#CHANNEL"]
- # SHA512 of a SHA512
- adminpass="cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
- # NickServ pass (optional)
- nspass=""
- # O-Line is required
- oper="OPER user oper"
- # Don't edit past here unless you know what you're doing
- from twisted.words.protocols import irc
- from twisted.internet import reactor, protocol, defer
- from twisted.names.client import lookupAddress
- from twisted.internet.task import LoopingCall
- from collections import defaultdict
- import re, os, sys, hashlib, time, random
- # Lists
- verifiedadmins=[]
- tempid=[]
- wusers=[]
- userdb=[]
- corelist=[]
- bopmList = ['rbl.efnet.org', 'tor.efnet.org', 'tor.dnsbl.sectoor.de', 'xbl.spamhaus.org', 'sbl.spamhaus.org', 'tor.ahbl.org', 'ircbl.ahbl.org', 'dnsbl.njabl.org', 'cbl.abuseat.org']
- bopmusers=[]
- bots=[]
- protectedusers=["Mech"]
- corebots=[]
- # Vars
- corelevel=0
- removecore=0
- autoscan_enabled=False
- autoscan_bopm_enabled=False
- autoengage_drones_enabled=False
- autoengage_bopm_enabled=False
- ## PREDEFINED FUNCTIONS ##
- def shutdown():
- reactor.stop()
- def restart():
- python = sys.executable
- os.execl(python, python, * sys.argv)
- def reg(user):
- if user in tempid:
- return True
- else:
- return False
- def group(iterable, range):
- iterable.sort()
- next = iter(iterable)
- def iterate():
- prev = next.next()
- new_list = [prev]
- append = new_list.append
- for cur in next:
- if cur-prev > range:
- yield new_list
- new_list = []
- append = new_list.append
- append(cur)
- prev = cur
- yield new_list
- return list(iterate())
- ## IRC CLIENT ##
- class IRCClient(irc.IRCClient):
- nickname = 'Mech'
- username = 'mech'
- realname = '\xf0\x9d\x97\xa0\xf0\x9d\x97\xb2\xf0\x9d\x97\xb0\xf0\x9d\x97\xb5 \xf0\x9d\x9f\xaf \xf0\x9d\x97\x94\xf0\x9d\x97\xbb\xf0\x9d\x98\x81\xf0\x9d\x97\xb6\xf0\x9d\x97\xaf\xf0\x9d\x97\xbc\xf0\x9d\x98\x81'
- password = nspass
- versionName = ":: \xf0\x9d\x97\xa0\xf0\x9d\x97\xb2\xf0\x9d\x97\xb0\xf0\x9d\x97\xb5 \xf0\x9d\x9f\xaf \xf0\x9d\x97\x94\xf0\x9d\x97\xbb\xf0\x9d\x98\x81\xf0\x9d\x97\xb6\xf0\x9d\x97\xaf\xf0\x9d\x97\xbc\xf0\x9d\x98\x81 \x02|\x02 \xf0\x9d\x97\xab\xf0\x9d\x97\xb6\xf0\x9d\x97\xab "
- sourceURL = "http://mech.pastebay.org/131442"
- lineRate = 0.05
- def signedOn(self):
- print "[*] Mech connected to %s" % server
- self.sendLine("MODE Mech +TpBRiwx-s")
- self.sendLine(oper)
- for channel in self.factory.channels:
- self.join(channel)
- self.msg(channel,"\xee\x80\x91 \xf0\x9d\x97\xa0\xf0\x9d\x97\xb2\xf0\x9d\x97\xb0\xf0\x9d\x97\xb5 \xf0\x9d\x97\xbc\xf0\x9d\x97\xbb\xf0\x9d\x97\xb9\xf0\x9d\x97\xb6\xf0\x9d\x97\xbb\xf0\x9d\x97\xb2.")
- def update():
- global userdb
- userdb=[]
- self.sendLine("LUSERS")
- self.sendLine("WHO")
- self.sendLine("LIST")
- try:
- repeater.stop()
- repeater.start(15, now=False)
- except:
- repeater = LoopingCall(update)
- repeater.start(15, now=False)
- def privmsg(self, user, channel, msg):
- nickname = user[:user.find('!')]
- if nickname == "NickServ" and msg.startswith("STATUS"):
- status = msg.split()
- if status[2] == '3':
- tempid.append(status[1])
- self.notice(status[1], "\xee\x80\x91 You are now authenticated %s\x0f." % status[1])
- else:
- self.notice(status[1], "\xee\x80\x91 Authentication failed. You must be registered with NickServ.")
- try:
- params = msg.split()
- cmd = params[0]
- if cmd.startswith('>'):
- cb = getattr(self, 'CMD_%s' % cmd[1:].lower(), None)
- if cb is not None:
- cb(nickname, channel, msg, params)
- except IndexError:
- pass
- except Exception, e:
- print e
- # Commands #
- ## IDENTIFICATION ##
- def CMD_login(self, nickname, channel, msg, params):
- if len(params)==2:
- if hashlib.sha512(hashlib.sha512(params[1]).hexdigest()).hexdigest()==adminpass:
- if nickname not in tempid:
- tempid.append(nickname)
- verifiedadmins.append(nickname)
- self.notice(nickname,"\xee\x80\x91 You are now authenticated %s\x0F." % nickname)
- else:
- self.notice(nickname,"\xee\x80\x91 You have already authenticated %s." % nickname)
- else:
- self.notice(nickname,"\xee\x80\x91 Authentication failed.")
- print "[*] Authentication failure for user '%s' using password '%s'" % (nickname,params[1])
- else:
- if nickname in tempid:
- self.notice(nickname,"\xee\x80\x91 You have already authenticated %s." % nickname)
- else:
- self.msg("NickServ","STATUS %s" % nickname)
- ## GENERAL / STATISTICAL COMMANDS ##
- # Help
- def CMD_help(self, nickname, channel, line, params):
- self.notice(nickname,"\xee\x80\x91 \xf0\x9d\x97\xa0\xf0\x9d\x97\xb2\xf0\x9d\x97\xb0\xf0\x9d\x97\xb5 \xf0\x9d\x9f\xaf \xf0\x9d\x97\x94\xf0\x9d\x97\xbb\xf0\x9d\x98\x81\xf0\x9d\x97\xb6\xf0\x9d\x97\xaf\xf0\x9d\x97\xbc\xf0\x9d\x98\x81")
- self.notice(nickname,"General commands: >help, >login")
- self.notice(nickname,"Statistical commands: >hosts, >idle, >signon")
- self.notice(nickname,"Admin commands: >shutdown, >restart, >dump, >raw, >analyze, >scan, >scan_bopm, >autoscan, >autoscan_bopm, >engage_drones, >engage_bopm, >autoengage_drones, >autoengage_bopm, >logflag")
- # Shutdown
- def CMD_shutdown(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- shutdown()
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Restart
- def CMD_restart(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- restart()
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Raw
- def CMD_raw(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- self.sendLine(line.replace(">raw ",""))
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Dump
- def CMD_dump(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- self.notice(nickname,"\xee\x80\x91 Length of UserDB: %i" % len(userdb))
- for x in userdb:
- self.msg(nickname,x)
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Host frequency
- def CMD_hosts(self, nickname, channel, line, params):
- if nickname in tempid:
- self.notice(nickname,"\xee\x80\x91 Dumping host frequency (clones)..")
- hosts=list(x['HOSTMASK'] for x in userdb)
- d=defaultdict(int)
- for x in hosts:
- d[x]+=1
- for x in d.items():
- self.msg(nickname,"The\x035 %s \x0Fhostmask has %s known clone(s) including the user(s):\x035 %s" % (x[0], x[1], "\x0F,\x035 ".join([ d['NICK'] for d in userdb if d['HOSTMASK'] == x[0] ])))
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Idle frequency
- def CMD_idle(self, nickname, channel, line, params):
- if nickname in tempid:
- self.notice(nickname,"\xee\x80\x91 Dumping idle frequency..")
- times=list(x['IDLE'] for x in userdb if x != None)
- d=defaultdict(int)
- for x in times:
- d[x]+=1
- for x in d.items():
- self.msg(nickname,"Idle:\x035 %s\x0F second(s) | %s User(s):\x035 %s" % (x[0],x[1],"\x0F,\x035 ".join([ d['NICK'] for d in userdb if d['IDLE'] == x[0] ])))
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Sign-on frequency
- def CMD_signon(self, nickname, channel, line, params):
- if nickname in tempid:
- self.notice(nickname,"\xee\x80\x91 Dumping sign-on frequency..")
- signons=list(x['SIGNON'] for x in userdb if x != None)
- d=defaultdict(int)
- for x in signons:
- d[x]+=1
- for x in d.items():
- if x[0] != None:
- self.msg(nickname,"Signon:\x035 %s\x0F | %s User(s):\x035 %s" % (time.ctime(float(x[0])),x[1],"\x0F,\x035 ".join([ d['NICK'] for d in userdb if d['SIGNON'] == x[0] ])))
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Analyze
- def CMD_analyze(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- if len(params)==2:
- usr=params[1]
- if usr in wusers:
- self.notice(nickname,"User cannot be analyzed (umode +W)")
- elif usr in list(x['NICK'] for x in userdb):
- self.notice(nickname,"\xee\x80\x91 Analyzing %s" % usr)
- self.notice(nickname,"Nick:\x035 %s " % usr)
- self.notice(nickname,"IP:\x035 %s" % list(z['IP'] for z in userdb if (z['NICK']==usr))[0])
- self.notice(nickname,"Hostmask:\x035 %s@%s" % (list(z['IDENT'] for z in userdb if (z['NICK'] == usr))[0],list(z['HOSTMASK'] for z in userdb if (z['NICK'] == usr))[0]))
- self.notice(nickname,"Signon:\x035 %s" % time.ctime(float(list(z['SIGNON'] for z in userdb if (z['NICK']==usr))[0])))
- self.notice(nickname,"Idle:\x035 %s \x0Fsecond(s)" % list(z['IDLE'] for z in userdb if (z['NICK'] == usr))[0])
- self.notice(nickname,"Channels:\x035 %s" % "\x0F,\x035 ".join(list(z['CHANNELS'] for z in userdb if (z['NICK'] == usr))[0]))
- else:
- self.notice(nickname,"User does not exist in the database")
- else:
- self.notice(nickname,"\xee\x80\x91 Usage: >analyze [user]")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- ## DEFENSE ##
- # Scan function
- def scan(self):
- signons=list(int(x['SIGNON']) for x in userdb if (x['SIGNON'] is not None) and (x['IP'] is not None))
- idles=list(int(x['IDLE']) for x in userdb if (x['IDLE'] is not None) and (x['IP'] is not None))
- signons_grouped=group(signons,4)
- idles_grouped=group(idles,4)
- signons_elim=[]
- idles_elim=[]
- for x in signons_grouped:
- if len(x)>=5:
- for y in x:
- signons_elim.append(str(y))
- for x in idles_grouped:
- if len(x)>=5:
- for y in x:
- idles_elim.append(str(y))
- idleset=set(idles_elim)
- signonset=set(signons_elim)
- botlist1=[]
- botlist2=[]
- for x in idleset:
- for y in list(z['NICK'] for z in userdb if (z['IDLE'] == x)):
- botlist1.append(y)
- for x in signonset:
- for y in list(z['NICK'] for z in userdb if (z['SIGNON'] == x)):
- botlist2.append(y)
- global bots
- bots=set(botlist1)&set(botlist2)
- # Scan
- def CMD_scan(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- self.scan()
- if len(bots)>0:
- self.msg(channel,"\xee\x80\x91 There are\x035 %i \x0Fbot(s) on the network." % len(bots))
- self.msg(channel,"Nicks:\x035 %s\x0F.." % "\x0F,\x035 ".join(list(bots)[0:10]))
- elif len(bots)==0:
- self.msg(channel,"\xee\x80\x91 There are no bots on the network.")
- else:
- self.msg(channel,"\xee\x80\x91 \x035Error.")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Autoscan function
- def autoscan_update(self, channel):
- self.scan()
- if len(bots)>0:
- print "[*] Autoscan report: %i bot(s) detected" % len(bots)
- self.msg(channel,"\xee\x80\x91 Notice:\x035 %i \x0Fbot(s) detected on the network" % len(bots))
- self.msg(channel,"Nicks:\x035 %s\x0F.." % "\x0F,\x035 ".join(list(bots)[0:10]))
- else:
- print "[*] Autoscan report: No bots detected"
- # Autoscan
- def CMD_autoscan(self, nickname, channel, line, params):
- global autoscan_enabled
- global autoscanloop
- if "autoscanloop" not in globals():
- autoscanloop = LoopingCall(self.autoscan_update, channel)
- if nickname in verifiedadmins:
- if autoscan_enabled is False:
- autoscanloop.start(15, channel)
- autoscan_enabled=True
- self.msg(channel,"\xee\x80\x91 Autoscan active")
- elif autoscan_enabled is True:
- autoscanloop.stop()
- autoscan_enabled=False
- self.msg(channel,"\xee\x80\x91 \x035Autoscan disabled")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Logflag
- def CMD_logflag(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- try:
- self.msg(channel,"\xee\x8e\xaa Adding all detected drones to local DroneBL")
- ips=[]
- for x in bots:
- for y in list(z['IP'] for z in userdb if (z['NICK'] == x)):
- ips.append(y)
- ips_elim=set(ips)
- try:
- file=open('dronebl.txt','r+')
- except IOError:
- print "[*] DroneBL file not found, creating one.."
- file=open('dronebl.txt','w+')
- file.write("DroneBL file created on %s\n" % time.ctime())
- file.closed
- file=open('dronebl.txt','r+')
- dronelist=file.readlines()
- file.closed
- file=open('dronebl.txt','w+')
- for x in dronelist:
- if x in ips_elim:
- pass
- else:
- file.write(x)
- file.closed
- file=open('dronebl.txt','a+')
- for x in ips_elim:
- file.write("%s\n" % x)
- file.closed
- self.msg(channel,"\xee\x80\x91 Success.")
- except:
- self.notice(nickname,"\xee\x80\x91 You must scan for active drones first (>scan).")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Engage drones
- def CMD_engage_drones(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- try:
- self.msg(channel,"\xee\x80\x91 \x035Engaging all drones..")
- for y in set(x['IP'] for x in userdb if (x['NICK'] in bots and x['NICK'] not in verifiedadmins and x['NICK'] not in protectedusers and x['NICK'] not in corebots and x['NICK'] not in wusers)):
- self.sendLine("GLINE +*@%s 1800 :\x035Drone\x0F" % y)
- except:
- self.notice(nickname,"\xee\x80\x91 You must scan for active drones first (>scan).")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # BOPM function
- def bopm(self):
- global bopmusers
- bopmusers=[]
- for y in set(x['IP'] for x in userdb if x['IP'] is not None):
- name, original = '.'.join(y.split('.')[::-1]), y
- hit=[lookupAddress('%s.%s' % (name, bopm)) for bopm in bopmList]
- d = defer.DeferredList(hit, fireOnOneCallback=1, consumeErrors=1)
- def result(h, ip):
- h = list(h)
- if h[0][0] is False:
- pass
- else:
- for z in [u['NICK'] for u in userdb if u['IP']==ip]:
- bopmusers.append(z)
- d.addCallback(result, original)
- # BOPM Scan
- def CMD_scan_bopm(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- self.bopm()
- if len(bopmusers)>0:
- self.msg(channel,"\xee\x80\x91 There are\x035 %i \x0Fuser(s) listed in drone banlists." % len(bots))
- self.msg(channel,"Nicks:\x035 %s\x0F.." % "\x0F,\x035 ".join(list(bots)[0:10]))
- elif len(bopmusers)==0:
- self.msg(channel,"\xee\x80\x91 There are no users listed in drone banlists.")
- else:
- self.msg(channel,"\xee\x80\x91 \x035Error.")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Autoscan BOPM function
- def autoscan_bopm_update(self, channel):
- self.bopm()
- if len(bopmusers)>0:
- print "[*] BOPM Autoscan report: %i user(s) listed in drone banlists" % len(bopmusers)
- self.msg(channel,"\xee\x80\x91 Notice:\x035 %i \x0Fuser(s) detected in drone banlists" % len(bopmusers))
- self.msg(channel,"Nicks:\x035 %s\x0F.." % "\x0F,\x035 ".join(bopmusers[0:10]))
- else:
- print "[*] BOPM Autoscan report: No users listed in drone banlists"
- # Autoscan BOPM
- def CMD_autoscan_bopm(self, nickname, channel, line, params):
- global autoscan_bopm_enabled
- global autoscan_bopmloop
- if "autoscan_bopmloop" not in globals():
- autoscan_bopmloop = LoopingCall(self.autoscan_bopm_update, channel)
- if nickname in verifiedadmins:
- if autoscan_bopm_enabled is False:
- autoscan_bopmloop.start(15, channel)
- autoscan_bopm_enabled=True
- self.msg(channel,"\xee\x80\x91 BOPM Autoscan active")
- elif autoscan_bopm_enabled is True:
- autoscan_bopmloop.stop()
- autoscan_bopm_enabled=False
- self.msg(channel,"\xee\x80\x91 \x035BOPM Autoscan disabled")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Engage BOPM
- def CMD_engage_bopm(self, nickname, channel, line, params):
- if nickname in verifiedadmins:
- self.msg(channel,"\xee\x80\x91 \x035Engaging all listed proxies..")
- try:
- for y in set(x['IP'] for x in userdb if (x['NICK'] in bopmusers and x['NICK'] not in verifiedadmins and x['NICK'] not in protectedusers and x['NICK'] not in corebots and x['NICK'] not in wusers)):
- self.sendLine("GLINE +*@%s 1800 :\x035Listed in drone banlists\x0F" % y)
- except:
- self.msg(channel,"\xee\x80\x91 You must scan for active BOPM users first (>scan_bopm).")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Autoengage Drones function
- def autoengage_drones_update(self, channel):
- self.scan()
- if len(bots)>0:
- for y in set(x['IP'] for x in userdb if (x['NICK'] in bots and x['NICK'] not in verifiedadmins and x['NICK'] not in protectedusers and x['NICK'] not in corebots and x['NICK'] not in wusers)):
- self.sendLine("GLINE +*@%s 1800 :\x035Drone\x0F" % y)
- # Autoengage Drones
- def CMD_autoengage_drones(self, nickname, channel, line, params):
- global autoengage_drones_enabled
- global autoengage_dronesloop
- if "autoengage_dronesloop" not in globals():
- autoengage_dronesloop = LoopingCall(self.autoengage_drones_update, channel)
- if nickname in verifiedadmins:
- if autoengage_drones_enabled is False:
- autoengage_dronesloop.start(15, channel)
- autoengage_drones_enabled=True
- self.msg(channel,"\xee\x80\x91 \x035DRONE AUTOENGAGE ACTIVE")
- elif autoengage_drones_enabled is True:
- autoengage_dronesloop.stop()
- autoengage_drones_enabled=False
- self.msg(channel,"\xee\x80\x91 \x035DRONE AUTOENGAGE DISABLED")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- # Autoengage BOPM function
- def autoengage_bopm_update(self, channel):
- self.bopm()
- if len(bopmusers)>0:
- for y in set(x['IP'] for x in userdb if (x['NICK'] in bopmusers and x['NICK'] not in verifiedadmins and x['NICK'] not in protectedusers and x['NICK'] not in corebots and x['NICK'] not in wusers)):
- self.sendLine("GLINE +*@%s 1800 :\x035Listed in drone banlists\x0F" % y)
- # Autoengage BOPM
- def CMD_autoengage_bopm(self, nickname, channel, line, params):
- global autoengage_bopm_enabled
- global autoengage_bopmloop
- if "autoengage_bopmloop" not in globals():
- autoengage_bopmloop = LoopingCall(self.autoengage_bopm_update, channel)
- if nickname in verifiedadmins:
- if autoengage_bopm_enabled is False:
- autoengage_bopmloop.start(15, channel)
- autoengage_bopm_enabled=True
- self.msg(channel,"\xee\x80\x91 \x035BOPM AUTOENGAGE ACTIVE")
- elif autoengage_bopm_enabled is True:
- autoengage_bopmloop.stop()
- autoengage_bopm_enabled=False
- self.msg(channel,"\xee\x80\x91 \x035BOPM AUTOENGAGE DISABLED")
- else:
- self.notice(nickname,"\xee\x80\x91 You must be authenticated to use this command")
- ## OTHER HANDLERS ##
- def userLeft(self, user, channel):
- if user in tempid:
- tempid.remove(user)
- if user in verifiedadmins:
- verifiedadmins.remove(user)
- def userQuit(self, user, quitMessage):
- if user in tempid:
- tempid.remove(user)
- if user in verifiedadmins:
- verifiedadmins.remove(user)
- def userKicked(self, kickee, channel, kicker, message):
- if kickee in tempid:
- tempid.remove(kickee)
- if kickee in verifiedadmins:
- verifiedadmins.remove(kickee)
- def userRenamed(self, oldname, newname):
- if oldname in tempid:
- tempid.remove(oldname)
- if oldname in verifiedadmins:
- verifiedadmins.remove(oldname)
- def kickedFrom(self, channel, kicker, message):
- self.join(channel)
- tempid=[]
- def irc_unknown(self, prefix, command, params):
- global corelevel
- global removecore
- #print prefix,command,params
- if command == "266":
- print params[1].split()
- globalusers=int(params[1].split()[0])
- if globalusers > corelevel:
- if corelevel == 0:
- print "[*] Spawning initial core"
- reactor.connectTCP(server, port, IRCCoreFactory())
- corelevel+=200
- else:
- factor=((globalusers+200)-corelevel)/200
- print "[*] Core(s) overloaded, adding %i core(s)" % factor
- for x in range(factor):
- reactor.connectTCP(server, port, IRCCoreFactory())
- corelevel+=200
- if corelevel > globalusers+200:
- factor=(corelevel-globalusers)/200
- if factor >= 1:
- print "[*] Core(s) underloaded, removing %i core(s)" % factor
- for x in range(factor):
- removecore+=1
- corelevel-=200
- if command == "RPL_WHOREPLY":
- userdb.append({"NICK":params[5],"IDENT":params[2],"HOSTMASK":params[3],"SIGNON":None,"CHANNELS":None,"IDLE":None,"IP":None})
- if params[5] not in wusers:
- corelist.append(params[5])
- if command == "RPL_LIST":
- if (int(params[2]) >= 5) and ("L" not in str(re.findall("\[(.*?)\]", params[3]))[0]):
- self.join(params[1])
- class IRCCore(irc.IRCClient):
- def _get_nickname(self):
- return self.factory.nickname
- nickname = property(_get_nickname)
- username = 'mech'
- realname = '\xf0\x9d\x97\xa0\xf0\x9d\x97\xb2\xf0\x9d\x97\xb0\xf0\x9d\x97\xb5 \xf0\x9d\x97\x96\xf0\x9d\x97\xbc\xf0\x9d\x97\xbf\xf0\x9d\x97\xb2'
- versionName = ":: \xf0\x9d\x97\xa0\xf0\x9d\x97\xb2\xf0\x9d\x97\xb0\xf0\x9d\x97\xb5 \xf0\x9d\x9f\xaf \xf0\x9d\x97\x94\xf0\x9d\x97\xbb\xf0\x9d\x98\x81\xf0\x9d\x97\xb6\xf0\x9d\x97\xaf\xf0\x9d\x97\xbc\xf0\x9d\x98\x81 \xf0\x9d\x97\x96\xf0\x9d\x97\xbc\xf0\x9d\x97\xbf\xf0\x9d\x97\xb2"
- sourceURL = "http://mech.pastebay.org/131442"
- def signedOn(self):
- corename=self.factory.nickname
- print "[*] Core connected to %s" % server
- corebots.append(corename)
- self.sendLine("MODE %s +TpBRiwx-s" % corename)
- self.sendLine(oper)
- def update(corename):
- global removecore
- if removecore > 0:
- removecore-=1
- corebots.remove(corename)
- self.transport.loseConnection()
- if len(corelist) > 0:
- whoisusr=corelist[0]
- corelist.remove(whoisusr)
- self.sendLine("WHOIS %s %s" % (whoisusr,whoisusr))
- try:
- repeater.stop()
- repeater.start(0.01)
- except:
- repeater = LoopingCall(update,corename)
- repeater.start(0.01)
- def irc_unknown(self, prefix, command, params):
- if command == "379":
- if "W" in params[2].split("+")[1][:-1]:
- wusers.append(params[1])
- if command == "378":
- for d in userdb:
- if d["NICK"] == params[1]:
- try:
- d["IP"] = params[2].split()[4]
- except:
- pass
- if command == "RPL_WHOISIDLE":
- for d in userdb:
- if d["NICK"] == params[1]:
- d["SIGNON"] = params[3]
- d["IDLE"] = params[2]
- if command == "RPL_WHOISCHANNELS":
- for d in userdb:
- if d["NICK"] == params[1]:
- d["CHANNELS"] = params[2].split()
- class IRCCoreFactory(protocol.ClientFactory):
- protocol = IRCCore
- def __init__(self):
- self.nickname = 'Mech_CORE[%i]' % random.randint(1,99)
- def clientConnectionFailed(self, connector, reason):
- print "[*] Core connection failed:", reason
- print "[*] Retrying.."
- connector.connect()
- class IRCFactory(protocol.ClientFactory):
- protocol = IRCClient
- def __init__(self, channels):
- self.channels = channels
- def clientConnectionLost(self, connector, reason):
- connector.connect()
- def clientConnectionFailed(self, connector, reason):
- print "[*] Connection failed:", reason
- reactor.stop()
- reactor.connectTCP(server, port, IRCFactory(channels))
- reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement