forked from OlympicCode/vHackXTBot-Python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
Latest commit
92 lines (76 loc) · 2.19 KB
/
Copy pathutils.py
File metadata and controls
92 lines (76 loc) · 2.19 KB
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
#!/usr/bin/python2.7
#-*- coding: utf-8
importbase64
importcommands
importhashlib
importsys
importtime
importurllib2
fromclassesimportPasswords
classUtils:
defgetTime(self):
returnint(round(time.time()))
defmd5hash(self, txt):
m=hashlib.md5()
m.update(txt)
returnm.hexdigest()
defgenerateUser(self, bArr):
returnbase64.b64encode(bArr).replace("=","")
defgenerateURL(self, format, data, php):
split=format.split("::::")
split2=data.split("::::")
currentTimeMillis=str(self.getTime())
jsonString="{"
fori1inrange(0,len(split)):
jsonString+="\""+split[i1] +"\":"
jsonString+="\""+split2[i1] +"\","
jsonString+="\"time\":\""+currentTimeMillis+"\"}"
a=self.generateUser(jsonString)
a2=self.md5hash(str(len(jsonString)) +self.md5hash(currentTimeMillis))
str5=split2[0] +self.md5hash(self.md5hash(split2[1]))
str6=self.md5hash(currentTimeMillis+jsonString)
a3=self.md5hash(self.secret+self.md5hash(self.md5hash(self.generateUser(a2))))
str9=self.generateUser(str5)
str7=self.generateUser(str6)
str8=self.md5hash(self.md5hash(a3+self.md5hash(self.md5hash(str9) +str7)))
returnself.url+php+"?user="+a+"&pass="+str8
defparse(self,string):
temp=string[1:-1]
temp=temp.replace("\"","")
returntemp.split(",")
defparseMulti(self,string):
temp=string
temp=temp.replace("[","").replace("]","")
temp=temp[len(temp.split(":")[0])+1:-1]
arr=temp.split("},{")
n= []
fori1inarr:
temp=i1
ifnottemp.startswith("{"):
temp="{"+temp
ifnottemp.endswith("}"):
temp+="}"
n.append(self.parse(temp))
returnn
defrequestString(self, format, data, php):
#time.sleep(1)
fori1inrange(0,10):
try:
r=urllib2.urlopen(self.generateURL(format,data,php))
t=r.read()
#print i1
returnt
exceptExceptionaserr:
time.sleep(1)
return"null"
defprintit(self,txt):
printtxt
defrequestArray(self, format, data, php):
temp=self.requestString(format, data, php)
iftemp!="null":
returnself.parse(temp)
else:
return []
def__init__(self):
self.secret="aeffI"
self.url="https://api.vhack.cc/v/4/"