This repository has been archived by the owner on May 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.py
198 lines (181 loc) · 6.11 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# coding=utf-8
import requests, json, time, random, datetime, threading, pickle, os
from termcolor import colored
sitekey = "6LfYhz0UAAAAAJFKp28Sg0NnAEIPMfKI1RJSGsdB"
def log(event):
d = datetime.datetime.now().strftime("%H:%M:%S")
print("Raffle SJS by Azerpas :: " + str(d) + " :: " + event)
"""
def notify(title, subtitle, message, sound):
t = '-title {!r}'.format(title)
s = '-subtitle {!r}'.format(subtitle)
m = '-message {!r}'.format(message)
so = '-sound {!r}'.format(sound)
os.system('terminal-notifier {}'.format(' '.join([m, t, s, so])))
"""
class Raffle(object):
def __init__(self):
self.s = requests.session()
self.shoes = [
#{"shoe_id":"5","shoe_name":"AIR FORCE 1","raffle_id":"8"},
#{"shoe_id":"6","shoe_name":"AIR JORDAN 1","raffle_id":"19"},
#{"shoe_id":"7","shoe_name":"PRESTO","raffle_id":"10"},
#{"shoe_id":"8","shoe_name":"AM90","raffle_id":"11"},
#{"shoe_id":"9","shoe_name":"AM97","raffle_id":"12"},
#{"shoe_id":"10","shoe_name":"VAPORMAX","raffle_id":"13"},
#{"shoe_id":"13","shoe_name":"VAPORFLY","raffle_id":"16"},
{"shoe_id":"45","shoe_name":"AIR JORDAN 1 WHITE","raffle_id":"49"},
]
self.url = "https://slamjamsocialism-drops.com/graphql"
def register(self,identity,proxy):
# register to each shoes.
for dshoes in self.shoes:
print('------------------------')
print("Signin: "+identity['mail'])
print("for: " + dshoes['shoe_name'])
print('------------------------')
d = datetime.datetime.now().strftime('%H:%M')
log("Getting Captcha")
flag = False
while flag != True:
d = datetime.datetime.now().strftime('%H:%M')
try:
file = open(str(d)+'.txt','r') #r as reading only
flag = True
except IOError:
time.sleep(2)
log("No captcha generated for this minute")
flag = False
flag2 = False
while flag2 != True:
try:
d = datetime.datetime.now().strftime('%H:%M')
file = open(str(d)+'.txt','r')
FileList = pickle.load(file) #FileList the list where i want to pick out the captcharep
flag2 = True
except Exception as e:
#log("Can't open file")
#print(e)
time.sleep(0.2)
while len(FileList) == 0: #if len(FileList) it will wait for captcha scraper
d = datetime.datetime.now().strftime('%H:%M')
try:
file = open(str(d)+'.txt','r')
print('debug 2')
FileList = pickle.load(file)
if FileList == []:
log("No captcha available(2)")
time.sleep(3)
except IOError as e:
log("No file, waiting...")
print(e)
time.sleep(3)
captchaREP = random.choice(FileList)
FileList.remove(captchaREP)
file = open(str(d)+'.txt','w')
pickle.dump(FileList,file)
log("Captcha retrieved")
headers = {
":authority":"slamjamsocialism-drops.com",
":method":"POST",
":path":"/graphql",
":scheme":"https",
"accept":"*/*",
"accept-encoding":"gzip, deflate, br",
"accept-language":"fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7",
"authorization":"null",
"content-length":"840",
"content-type":"application/json",
"origin":"https://slamjamsocialism-drops.com",
"referer":"https://slamjamsocialism-drops.com/drops/"+dshoes['shoe_id'],
"user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36",
"x-requested-with":"XMLHttpRequest",}
"""
if identity['shoesize'] == "18":
identity['shoesize'] = random.choice(['3 ½','4','4 ½','5','5 ½','6','6 ½','7','7 ½','8','9','9 ½','10 ½','11','11 ½','12','12 ½'])
log("Changed size to: " + identity['shoesize'])
#################
"""
dateSJS = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S+01:00")
# 2018-02-27T16:12:28+01:00
payload = {"query":"mutation RequestOrdertMutation($data: OrderRequestInput!) {\n requestOrder(data: $data)\n}\n",
"operationName":"RequestOrdertMutation",
"variables":{
"data":{
"firstName":identity['fname'],
"lastName":identity['lname'],
"email":identity['mail'],
"phone":identity['phone'],
"country":"250",
"city":"Paris",
"order":[{"product":dshoes['shoe_id'],"size":identity['shoesize']}],
"raffle":dshoes['raffle_id'],
"captcha":captchaREP,
"date":dateSJS
}
}
}
req = self.s.post(self.url,headers=headers,data=payload,proxies=proxy)
print(req)
jsonn = json.loads(req.text)
if req.status_code == 200:
if jsonn['errors']:
try:
print(jsonn['errors'])
except:
print("ERROR 2302")
raise ValueError('ERROR 200 BUT CANT ENTER')
else:
print(colored('Successfully entered','red', attrs=['bold']))
if req.status_code == 400:
raise ValueError('ERROR 400')
sleep = random.uniform(2.3,2.9)
log("Sleeping: " + str(sleep) + " seconds")
time.sleep(sleep)
self.s.cookies.clear()
if __name__ == "__main__":
ra = Raffle()
accounts = [
# sizes = ['3 ½','4','4 ½','5','5 ½','6','6 ½','7','7 ½','8','9','9 ½','10 ½','11','11 ½','12','12 ½']
# Check the sizes on the site first
{"fname":"Mike","lname":"VanCappel","mail":"mikevancap@gmail.com","phone":"+33612345678","shoesize":"11",},
]
# catpcha
proxies = [
"username:password@host:port"
]
errors = []
index = 0
regis = 0
for i in accounts:
print("\n\n-------------------------")
print('NEW TASK')
print("-------------------------\n")
p = random.choice(proxies)
proxies.remove(p)
if '@' in p:
proxy = { 'https' : 'https://{}'.format(p) }
log('Using proxy:')
print(colored(proxy,'red', attrs=['bold']))
else:
proxy = {'http':p,
'https':p}
log('Using proxy:')
print(colored(proxy['https'],'red', attrs=['bold']))
try:
ra.register(i,proxy)
regis += 1
except Exception as e:
print(e)
if e == "local variable 'FileList' referenced before assignment":
try:
ra.register(i,proxy)
except:
pass
errors.append(i)
print(errors)
print("-------------------------")
print("-------------------------")
print("-------------------------")
print(accounts)
print("Nb of accounts registered: " + str(regis))