-
Notifications
You must be signed in to change notification settings - Fork 2
/
getprofile.py
108 lines (88 loc) · 2.78 KB
/
getprofile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python
import socket
import struct
import time
import sys
import binascii
from prime import *
import struct
import pysodium
LAST_NOUNCE = "\x00" * 24
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)
pkf = open("spublick", "rb")
pk = pkf.read()
pkf.close()
skf = open("sprivk", "rb")
sk = skf.read()
skf.close()
#ACCESS_KEY = "e8da 79a5 b000 e910 030b 3bca 3ff9 7ab1" #DSUNA
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)
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 "{}"