Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (1)

Powered by Vanilla. Made with Bootstrap.
SHBot
  • s1n4
    Posts: 88
    Hi guys,

    SHBot is the name of an irc bot.
    You can run shell commands from IRC channel with the following code.

    #!/usr/bin/python

    import os, random, socket, sys

    def usage() :
    print 'Usage: %s [Server address] [#Channel]' % sys.argv[0]
    exit()

    def ForK() :
    pid = os.fork()
    if pid != 0 :
    exit()

    def main() :
    num = ''
    for i in range(0, 3) :
    rand = random.randint(0, 10)
    num += str(rand)

    NICK = 'SH[' + num + ']'
    USER = 's1n4zbot'
    SERV = sys.argv[1]
    CHAN = sys.argv[2]
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    try :
    sock.connect((SERV, 6667))

    except :
    exit()

    sock.send('NICK %s\r\n' % NICK)
    sock.send('USER %s %s %s :Bot\r\n' % (USER, USER, SERV))

    while True :
    data = sock.recv(1024)

    if 'End of /MOTD command.' in data :
    sock.send('JOIN %s\r\n' % CHAN)
    break

    while True :
    data = sock.recv(1024)
    args = data.replace(':', '').split()

    if len(args) >= 1 and args[0] == 'PING' :
    sock.send('PONG %s\r\n' % data.split()[1])
    continue

    if len(args) >= 3 and args[1] == 'KICK' and args[3] == NICK :
    sock.send('JOIN %s\r\n' % CHAN)
    continue

    if len(args) >= 5 and args[3] == '!do' :
    command = data[data.find('!do')+4:-2]
    results = os.popen(command).read().splitlines()
    for result in results :
    sock.send('PRIVMSG %s :%s\r\n' % (CHAN, result))
    continue

    if len(args) >= 4 and args[3] == '!quit' :
    QMSG = data[data.find('!quit')+6:-2]
    sock.send('QUIT :%s\r\n' % QMSG)
    exit()


    if len(sys.argv) == 3 :
    ForK()
    main()

    else :
    usage()



    http://s1n4.files.wordpress.com/2011/07/shbot.png?

    http://s1n4.wordpress.com/2011/07/18/shbot/
  • Mr. P-teoMr. P-teo
    Posts: 269
    Looks very good, i dont suppose you want to or would let me submit this thread link to my site - http://www.sourcex.info/
    Skype: mrpt3o
    Twitter: MrPteo


    image
  • s1n4
    Posts: 88
    I let you, you can put it in your site :)
  • Sh3llc0d3
    Posts: 1,910
    Nice bot sin4, nice blog too :)
  • s1n4
    Posts: 88
    Thanks for the compliment Sh3llc0d3 :)