geprofile.py
· 3.2 KiB · Python
Исходник
#!/usr/bin/env python
import socket
import struct
import time
import sys
import os
import binascii
from prime import *
import struct
import pysodium
LAST_NOUNCE = "\x00" * 24
# Just run sudo pip install pysodium
# And then python getprofile.py profile.bin
# With the file that you put on the USB drive
# Prime Server Public Key
pk = "\xB0\xEB\x81\x47\x51\x0A\x2E\x20\x32\xED\x2F\xC0\xF9\xD4\xEB\x88\xB0\xCA\x2D\xBD\xE7\xD6\x4E\xE2\xD0\x83\x4C\x3B\xB6\xFB\x31\x55"
# Prime Server Private Key
sk = "\x93\xB2\xF8\xA0\xE0\x95\x49\xDF\xAF\xFE\x36\x56\xE6\xAD\x9C\x9A\x53\x9B\xF6\x63\xD3\x7C\x08\xF0\xA4\xE6\x29\x3C\xBF\xFA\x64\x56"
try:
os.mkdir('profiles')
except:
pass
if len(sys.argv) == 2:
if ".bin" in sys.argv[1]:
print "File Access Key Mode"
f = open(sys.argv[1], "rb")
data = f.read()
f.close()
ACCESS_KEY = binascii.hexlify(data)
if len(ACCESS_KEY) != 32:
print "Invalid Access Key!"
exit(1)
print "Read access key from %s is %s" %(sys.argv[1],ACCESS_KEY)
else:
ACCESS_KEY = sys.argv[1].lower().replace(" ","")
if len(ACCESS_KEY) != 32:
print "Invalid Access Key: %s (parsed to: %s)" %(sys.argv[1], ACCESS_KEY)
exit(1)
IP = "115.68.108.183"
#IP = "127.0.0.1"
PORT = 60000
accesscode = ACCESS_KEY.lower().replace(" ","")
ProfileID = 0
MachineID = 1154
login = LoginPacket()
login.AccessCode = accesscode
login.MachineID = MachineID
login.PlayerID = 0
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
dest = (OFICIAL_SERVER_IP, 60000)
tcp.connect(dest)
data = EncryptPacket(login.ToBinary(), pk, sk)
tcp.send (data)
time.sleep(0.01)
gprof = None
msg = ""
profile = ""
while True:
msg += tcp.recv(4)
if len(msg) > 0:
size = struct.unpack("<I", msg[:4])[0]
msg = msg[4:]
msg += tcp.recv(size-4-len(msg))
while len(msg) < size-4:
msg += tcp.recv((size-4) - len(msg))
data = DecryptPacket(msg, pk, sk)
msg = ""
try:
packtype = struct.unpack("<I",data[4:8])[0]
if packtype == ProfilePacket.PacketType:
profile = ProfilePacket()
profile.FromBinary(data)
f = open ("profiles/%s" %accesscode, "wb")
f.write(data)
f.close()
gprof = profile
break
elif packtype == KeepAlivePacket.PacketType:
#print "Received KeepAlive"
pass
elif packtype == ProfileBusyPacket.PacketType:
break
else:
#print "PacketType: %s (%x)" %(packtype, packtype)
f = open("pack-%s-%x.bin"%(packtype,packtype),"wb")
f.write(data)
f.close()
except Exception,e:
print "Error: %s" %e
tcp.close()
if gprof == None:
print '{}'
else:
print '{"avatar":"%s","name":"%s"}' % (gprof.Avatar, gprof.Nickname)
else:
print "{}"
| 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import socket |
| 4 | import struct |
| 5 | import time |
| 6 | import sys |
| 7 | import os |
| 8 | import binascii |
| 9 | from prime import * |
| 10 | |
| 11 | import struct |
| 12 | import pysodium |
| 13 | |
| 14 | LAST_NOUNCE = "\x00" * 24 |
| 15 | |
| 16 | # Just run sudo pip install pysodium |
| 17 | # And then python getprofile.py profile.bin |
| 18 | # With the file that you put on the USB drive |
| 19 | |
| 20 | # Prime Server Public Key |
| 21 | pk = "\xB0\xEB\x81\x47\x51\x0A\x2E\x20\x32\xED\x2F\xC0\xF9\xD4\xEB\x88\xB0\xCA\x2D\xBD\xE7\xD6\x4E\xE2\xD0\x83\x4C\x3B\xB6\xFB\x31\x55" |
| 22 | # Prime Server Private Key |
| 23 | sk = "\x93\xB2\xF8\xA0\xE0\x95\x49\xDF\xAF\xFE\x36\x56\xE6\xAD\x9C\x9A\x53\x9B\xF6\x63\xD3\x7C\x08\xF0\xA4\xE6\x29\x3C\xBF\xFA\x64\x56" |
| 24 | |
| 25 | try: |
| 26 | os.mkdir('profiles') |
| 27 | except: |
| 28 | pass |
| 29 | |
| 30 | if len(sys.argv) == 2: |
| 31 | |
| 32 | if ".bin" in sys.argv[1]: |
| 33 | print "File Access Key Mode" |
| 34 | f = open(sys.argv[1], "rb") |
| 35 | data = f.read() |
| 36 | f.close() |
| 37 | ACCESS_KEY = binascii.hexlify(data) |
| 38 | if len(ACCESS_KEY) != 32: |
| 39 | print "Invalid Access Key!" |
| 40 | exit(1) |
| 41 | print "Read access key from %s is %s" %(sys.argv[1],ACCESS_KEY) |
| 42 | else: |
| 43 | ACCESS_KEY = sys.argv[1].lower().replace(" ","") |
| 44 | if len(ACCESS_KEY) != 32: |
| 45 | print "Invalid Access Key: %s (parsed to: %s)" %(sys.argv[1], ACCESS_KEY) |
| 46 | exit(1) |
| 47 | |
| 48 | IP = "115.68.108.183" |
| 49 | #IP = "127.0.0.1" |
| 50 | PORT = 60000 |
| 51 | |
| 52 | accesscode = ACCESS_KEY.lower().replace(" ","") |
| 53 | |
| 54 | |
| 55 | ProfileID = 0 |
| 56 | MachineID = 1154 |
| 57 | |
| 58 | login = LoginPacket() |
| 59 | login.AccessCode = accesscode |
| 60 | login.MachineID = MachineID |
| 61 | login.PlayerID = 0 |
| 62 | |
| 63 | tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 64 | dest = (OFICIAL_SERVER_IP, 60000) |
| 65 | tcp.connect(dest) |
| 66 | data = EncryptPacket(login.ToBinary(), pk, sk) |
| 67 | tcp.send (data) |
| 68 | time.sleep(0.01) |
| 69 | |
| 70 | gprof = None |
| 71 | |
| 72 | msg = "" |
| 73 | profile = "" |
| 74 | while True: |
| 75 | msg += tcp.recv(4) |
| 76 | if len(msg) > 0: |
| 77 | size = struct.unpack("<I", msg[:4])[0] |
| 78 | msg = msg[4:] |
| 79 | msg += tcp.recv(size-4-len(msg)) |
| 80 | while len(msg) < size-4: |
| 81 | msg += tcp.recv((size-4) - len(msg)) |
| 82 | |
| 83 | data = DecryptPacket(msg, pk, sk) |
| 84 | msg = "" |
| 85 | try: |
| 86 | packtype = struct.unpack("<I",data[4:8])[0] |
| 87 | if packtype == ProfilePacket.PacketType: |
| 88 | profile = ProfilePacket() |
| 89 | profile.FromBinary(data) |
| 90 | f = open ("profiles/%s" %accesscode, "wb") |
| 91 | f.write(data) |
| 92 | f.close() |
| 93 | gprof = profile |
| 94 | break |
| 95 | |
| 96 | elif packtype == KeepAlivePacket.PacketType: |
| 97 | #print "Received KeepAlive" |
| 98 | pass |
| 99 | |
| 100 | elif packtype == ProfileBusyPacket.PacketType: |
| 101 | break |
| 102 | |
| 103 | else: |
| 104 | #print "PacketType: %s (%x)" %(packtype, packtype) |
| 105 | f = open("pack-%s-%x.bin"%(packtype,packtype),"wb") |
| 106 | f.write(data) |
| 107 | f.close() |
| 108 | except Exception,e: |
| 109 | print "Error: %s" %e |
| 110 | tcp.close() |
| 111 | if gprof == None: |
| 112 | print '{}' |
| 113 | else: |
| 114 | print '{"avatar":"%s","name":"%s"}' % (gprof.Avatar, gprof.Nickname) |
| 115 | else: |
| 116 | print "{}" |
| 117 |