Advertisement
aaSSfxxx

Andromeda bot panel monitoring

Jan 15th, 2013
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.38 KB | None | 0 0
  1. #!/usr/bin/python
  2. #-*- coding: utf-8 -*-
  3.  
  4. # Andromeda bot panel monitoring
  5. # By aaSSfxxx :þ
  6.  
  7. import sys
  8. import base64
  9. import httplib
  10. import struct
  11.  
  12. # RC4 routines
  13. def initialize(keye):
  14.     """Produce a 256-entry list based on `key` (a sequence of numbers)
  15. as the first step in RC4.
  16. Note: indices in key greater than 255 will be ignored.
  17. """
  18.     key = [ord(i) for i in keye]
  19.     k = range(256)
  20.     j = 0
  21.     for i in range(256):
  22.         j = (j + k[i] + key[i % len(key)]) % 256
  23.         k[i], k[j] = k[j], k[i]
  24.     return k
  25.    
  26. def gen_random_bytes(k):
  27.     """Yield a pseudo-random stream of bytes based on 256-byte array `k`."""
  28.     i = 0
  29.     j = 0
  30.     while True:
  31.         i = (i + 1) % 256
  32.         j = (j + k[i]) % 256
  33.         k[i], k[j] = k[j], k[i]
  34.         yield k[(k[i] + k[j]) % 256]
  35.  
  36. def run_rc4(k, text):
  37.     cipher_chars = []
  38.     random_byte_gen = gen_random_bytes(k)
  39.     for char in text:
  40.         byte = ord(char)
  41.         cipher_byte = byte ^ random_byte_gen.next()
  42.         cipher_chars.append(chr(cipher_byte))
  43.     return ''.join(cipher_chars)
  44.  
  45. # Routine who gives action name with action link
  46. def get_command(id):
  47.     try:
  48.         return {
  49.             1: "Download EXE",
  50.             2: "Install plugin",
  51.             3: "Update bot",
  52.             4: "Install DLL",
  53.             5: "Delete DLLs",
  54.             6: "Delete plugins",
  55.             9: "Kill bot"}[id]
  56.     except Exception:
  57.         return "Do nothing"
  58.  
  59. # Main program
  60.  
  61. if len(sys.argv) != 4:
  62.     print "Andromeda bot panel watcher"
  63.     print "  Usage: %s <panel host> <path> <rc4key>" % sys.argv[0]
  64.     sys.exit(0)
  65.    
  66. connstr = "id:1337|bid:666|bv:518|sv:1281|pa:1|la:42|ar:1"
  67.  
  68. retstr = base64.b64encode(run_rc4(initialize(sys.argv[3]), connstr))
  69. h1 = httplib.HTTPConnection(sys.argv[1])
  70. h1.request("POST", sys.argv[2], retstr, {"User-Agent": "Mozilla/4.0", "Content-type": "application/x-www-form-urlencoded"})
  71. result = h1.getresponse().read()
  72. data = run_rc4(initialize(struct.pack("L", 1337)), result[4:])
  73.  
  74. data = data[4:]
  75. command_id = ord(data[0])
  76. offset_null = data[5:].find("\x00")
  77. while offset_null != -1:
  78.     offset_null = data[5:].find("\x00")
  79.     if offset_null == -1:
  80.         url = data[5:]
  81.     else:
  82.         url = data[5:offset_null+5]
  83.     print "Command: " + get_command(command_id) + " - URL: " + url
  84.     data = data[offset_null+6:]
  85.     command_id = ord(data[0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement