예제 #1
0
def main(torBool, sslBool):
    global shodanAPI
    global irc
    global botNick
    global channel
    global botPassword
    global email

    ##Shodan
    shodanAPI = shodan.Shodan(shodanKey)

    ##TOR
    if (False):
        tor = TOR(controlPort, torKey)
        tor.torConnect()

    ##IRC
    irc = IRC(serverAddress, ircPort, True, True, socksPort)
    irc.bootStrap(botNick, channel, True, True)

    flag = True
    while flag:
        text = irc.getText()
        if (text != None):
            print text

            if ("NOTICE" in text and "This nickname is registered" in text):
                irc.send('NickServ', 'VERIFY REGISTER PikeBot iwwxzqbtrwsc')
                irc.nickServIdentify(botPassword)
            elif ("NickServ" in text and "PRIVMSG" in text
                  and "is not a registered nickname" in text):
                irc.nickServRegister(botPassword, email)
            elif ("PRIVMSG" in text and channel in text and "?help" in text):
                irc.send(channel, "?help, ?about, ?shodan host")
            elif ("PRIVMSG" in text and channel in text
                  and "?shodan host" in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    host = re.search(r'\?shodan host (.*)\r\n', text).group(1)
                    print '[+] User:'******'[+] URL: ' + host
                except AttributeError:
                    pass
                shodanHost(host, user)
            elif (("JOIN :" + channel + "\r\n") in text
                  and "NOTICE" not in text and botNick not in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    #irc.send(channel, "hey " + user + ". " + "how's it going?")
                except AttributeError:
                    pass
            elif ("PRIVMSG" in text and channel in text and "?about" in text):
                irc.send(channel, "PikeBot V0.1 By:NotPike")
            elif ("PRIVMSG" in text and channel in text
                  and "Nickname is already in use" in text):
                botNick = "IfNot" + botNick
                irc.bootStrap(botNick, channel, True, True)
            elif ("ERROR :Closing link:" in text):
                irc.close()
                print "[!] Reconnecting..."
                time.sleep(5)
                irc.bootStrap(botNick, channel, True, True)
            elif ("JOIN :You have not registered\r\n" in text):
                irc.nickServRegister(botPassword, email)
                irc.nickServIdentify(botPassword)
                irc.nick(botNick)
                irc.join(channel)

        else:
            irc.close()
            print "[!] Reconnecting..."
            time.sleep(5)
            irc.bootStrap(botNick, channel, True, True)
def main(torBool, sslBool):
    global shodanAPI
    global irc
    global botNick
    global channel
    global botPassword
    global email

    ##Shodan
    shodanAPI = shodan.Shodan(shodanKey)

    ##TOR
    if (False):
        tor = TOR(controlPort, torKey)
        tor.torConnect()

    ##IRC
    irc = IRC(serverAddress, ircPort, True, True, socksPort)
    irc.bootStrap(botNick, channel)

    flag = True
    while flag:
        text = irc.getText()
        if (text != None):
            print text

            #NickServ and Bot Name
            if ("NOTICE" in text and "This nickname is registered" in text):
                irc.nickServIdentify(botPassword)
            elif ("NickServ" in text and "PRIVMSG" in text
                  and "is not a registered nickname" in text):
                irc.nickServRegister(botPassword, email)
            elif ("JOIN :You have not registered\r\n" in text):
                irc.nickServRegister(botPassword, email)
                irc.nickServIdentify(botPassword)
                irc.nick(botNick)
                irc.join(channel)
            elif ("PRIVMSG" in text and channel in text
                  and "Nickname is already in use" in text):
                botNick = "IfNot" + botNick
                irc.nick(botNick)

            #Bot Functions
            elif ("PRIVMSG" in text and channel in text and "?help" in text):
                irc.send(channel, "?help, ?about, ?shodan host")
            elif ("PRIVMSG" in text and channel in text
                  and "?shodan host" in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    host = re.search(r'\?shodan host (.*)\r\n', text).group(1)
                    print '[+] User:'******'[+] URL: ' + host
                except AttributeError:
                    pass
                shodanHost(host, user)
            elif (("JOIN :" + channel + "\r\n") in text
                  and "NOTICE" not in text and botNick not in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    irc.send(channel, "hey " + user)
                except AttributeError:
                    pass
            elif ("PRIVMSG" in text and channel in text and "?about" in text):
                irc.send(channel, "PikeBot V0.1 By:NotPike")
            elif ("PRIVMSG" in text and channel in text and killWord in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    if (user == ownerNick):
                        flag = False
                        irc.part(channel, partMsg)
                        irc.close()
                        sys.exit(0)
                    else:
                        irc.send(channel, "try harder")
                except AttributeError:
                    pass

            #Error handling
            elif ("ERROR :Closing link:" in text):
                print "[!] Reconnecting..."
                irc.close()
                irc.restart()
                irc.bootStrap(botNick, channel)

        else:
            print "[!] Reconnecting..."
            irc.close()
            irc.restart()
            irc.bootStrap(botNick, channel)