#! /usr/bin/python #-*-coding: utf-8 -*- import irclib import ircbot import re from GoogleHash import GoogleHash from hashzor import Hashzor class HashBot(ircbot.SingleServerIRCBot): def __init__(self): ircbot.SingleServerIRCBot.__init__(self, [("irc.freenode.org", 6667)], "hashzor", "Hashzor v3 [steroids edition]") self.re_hashs = re.compile(r'p[0o]wne?[: ]([a-f0-9, ]*)',re.I) self.re_hash = re.compile(r'([a-f0-9]*)',re.I) self.googleHash = GoogleHash() def on_welcome(self, serv, ev): serv.join("#hashzor") def on_pubmsg(self, serv, ev): auteur = irclib.nm_to_n(ev.source()) canal = ev.target() message = ev.arguments()[0] if "help" in message or "h3lp" in message: serv.privmsg(canal, "Hashzor v3 [steroids edition]") serv.privmsg(canal, " usage : just use the keyword pown followed with your md5 hash list") serv.privmsg(canal, "example : p0wn:c93ccd78b2076528346216b3b2f701e6,79c217ec1a40f46ba9c0b004a0416911") serv.privmsg(canal, " or : pown c93ccd78b2076528346216b3b2f701e6 79c217ec1a40f46ba9c0b004a0416912") serv.privmsg(canal, "the bot use the following regexp : p[0o]wne?[: ]([a-f0-9, ]*)") serv.privmsg(canal, "bot source at : http://forge.kasey.fr/projets/hashzor/") for hashs in self.re_hashs.findall(message): for hash in self.re_hash.findall(hashs): if len(hash) == 32: hashzor = Hashzor(hash,'/home/hashzor/dico/') result = hashzor.pown_hash() if result[0] == 0: # hash found serv.privmsg(canal, "%s is %s (local DB)" % (hash,result[1])) else: result = self.googleHash.find_hash(hash) if result[0] == 0: # hash found serv.privmsg(canal, "%s is %s (Google)" % (result[1],result[2])) elif result[0] == -3 : # hash not found serv.privmsg(canal, "%s not found" % hash) elif result[0] != 0 or result[0] != -3 :# script error serv.privmsg(canal, "%s script error :( ping kasey- on irc (code : %s)" % (hash,result[0])) elif len(hash) >= 2: serv.privmsg(canal, "%s ne semble pas ĂȘtre un MD5" % hash) if __name__ == "__main__": HashBot().start()