This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bumper.py
305 lines (234 loc) · 10.1 KB
/
bumper.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
import os
import time
import threading
import json
import random
# only enable if other mode doesn't work
quickReplyEnabled = False
# login page
turnstileSelector = 'document.querySelector("#cf-stage > div.ctp-checkbox-container > label")?.click()'
usernameSelector = '#fullcontainment > div > form:nth-child(2) > div > div.container.mt-4 > div > div.col-md-6.bg-container.py-4.px-5.rounded-right.rounded-xs > div > span > div:nth-child(1) > span > label > input'
passwordSelector = '#fullcontainment > div > form:nth-child(2) > div > div.container.mt-4 > div > div.col-md-6.bg-container.py-4.px-5.rounded-right.rounded-xs > div > span > div:nth-child(3) > label > input'
mfaFieldSelector = '#fullcontainment > div > form:nth-child(2) > div > div.container.mt-4 > div > div.col-md-6.bg-container.py-4.px-5.rounded-right.rounded-xs > div > span > div:nth-child(5) > label > input'
loginButtonSelector = '#fullcontainment > div > form:nth-child(2) > div > div.container.mt-4 > div > div.col-md-6.bg-container.py-4.px-5.rounded-right.rounded-xs > div > span > button'
# logged in
vouchesSelector = '#fullcontainment > div.wraps > div.forum_sidebar > div.responsivehide.sidebarstats.drop-shadow-lg > div:nth-child(2) > div:nth-child(2) > strong > a'
repSelector = '#fullcontainment > div.wraps > div.forum_sidebar > div.responsivehide.sidebarstats.drop-shadow-lg > div:nth-child(2) > div:nth-child(1) > strong > a'
loggedInUsernameSelector = '#fullcontainment > div.wraps > div.forum_sidebar > div.responsivehide.sidebarstats.drop-shadow-lg > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > a'
likesSelector = '#fullcontainment > div.wraps > div.forum_sidebar > div.responsivehide.sidebarstats.drop-shadow-lg > div:nth-child(2) > div:nth-child(3) > strong'
# quick reply
replyMessageSelector = '#message'
postReplySelector = '#quick_reply_submit'
# regular reply
toggleCodeEditorSelector = '#fullcontainment > div.wraps > form > table > tbody > tr:nth-child(4) > td > div > div.sceditor-toolbar > div:nth-child(8) > a.sceditor-button.sceditor-button-source'
replyTextAreaSelector = '#fullcontainment > div.wraps > form > table > tbody > tr:nth-child(4) > td > div > textarea'
regularReplyPostSelector = '#fullcontainment > div.wraps > form > div.responsivehide > input:nth-child(1)'
with open('config.json') as f:
config = json.load(f)
if len(config['threads']) == 0:
print('No threads to bump')
exit()
for x in range(3):
print('DO NOT TOUCH THE BROWSER WINDOW!')
thread_ids = []
msg_index = 0
def get_message():
global msg_index
messages = config['messages']
msg_index += 1
if msg_index >= len(messages):
msg_index = 0
msg = messages[msg_index]
msg += f' [{random.randint(1000, 9999)}]'
return msg
def log(msg: str):
t = time.strftime('%H:%M:%S', time.localtime())
print(f'[{t}] {msg}')
def login():
global thread_ids
# check if custom chrome driver exists
path = None
if os.path.exists('chromedriver.exe'):
path = 'chromedriver.exe'
elif os.path.exists('chromedriver'):
path = 'chromedriver'
elif os.path.exists('/usr/bin/chromedriver'):
path = '/usr/bin/chromedriver'
options = uc.ChromeOptions()
if 'user_agent' in config:
options.add_argument(f'user-agent={config["user_agent"]}')
# set window to 1920x1080
options.add_argument('--window-size=10,10')
options.add_argument('--disable-gpu')
options.add_argument('--disable-extensions')
binary_locations = [
'/snap/bin/brave',
'/usr/bin/chromium-browser',
'C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe',
]
for loc in binary_locations:
if os.path.exists(loc):
options.binary_location = loc
break
driver = uc.Chrome(driver_executable_path=path, options=options)
log('Driver started')
def set_size():
# force window size
driver.set_window_size(1920, 1080)
set_size()
# i was jsut testing. i dont think setting this does anything meaningful
if 'clearance' in config:
# get flipd to apply the clearance cookie
driver.get('https://flipd.gg')
driver.add_cookie({
'domain': '.flipd.gg',
'hostOnly': False,
'httpOnly': True,
'name': 'cf_clearance',
'path': '/',
'sameSite': 'None',
'secure': True,
'value': config['clearance'],
})
log('Applied clearance cookie')
# very hit or miss. doesnt seem to bypass turnstile always
def check_turnstile():
try:
# get all frames
frames = driver.find_elements(By.TAG_NAME, 'iframe')
if len(frames) == 0:
return
for frame in frames:
src = frame.get_attribute('src')
log(f'Found iframe: {src}')
# make sure its a turnstile iframe
if not 'challenges.cloudflare.com' in src:
continue
log('Found turnstile iframe')
# switch to frame
driver.switch_to.frame(frame)
# click checkbox
driver.execute_script(turnstileSelector)
log('Clicked turnstile checkbox')
time.sleep(0.5)
# save screenshot for debug
driver.save_screenshot('turnstile.png')
driver.switch_to.default_content()
return
except:
pass
driver.switch_to.default_content()
driver.get('https://flipd.gg/member.php?action=login')
log('Opened login page')
def restart():
driver.quit()
time.sleep(2)
threading.Thread(target=login).start()
start = time.time()
found = False
while time.time() - start < 60:
try:
driver.find_element(By.CSS_SELECTOR, usernameSelector).send_keys(config['username'])
found = True
break
except:
# take screenshot
driver.save_screenshot('error.png')
check_turnstile()
time.sleep(1)
if not found:
log('Could not find username field')
restart()
return
log('Found username field')
# if username field exists password field should also exist
try:
driver.find_element(By.CSS_SELECTOR, passwordSelector).send_keys(config['password'])
except:
log('Could not find password field')
restart()
return
if config['2fa']:
code = input('Enter 2FA code: ')
try:
driver.find_element(By.CSS_SELECTOR, mfaFieldSelector).send_keys(code)
except:
log('Could not find 2FA field')
restart()
return
log('Logging in...')
try:
driver.find_element(By.CSS_SELECTOR, loginButtonSelector).click()
except:
log('Could not find login button')
restart()
return
log('Logged in')
try:
username = driver.find_element(By.CSS_SELECTOR, loggedInUsernameSelector).text
rep = driver.find_element(By.CSS_SELECTOR, repSelector).text
vouches = driver.find_element(By.CSS_SELECTOR, vouchesSelector).text
likes = driver.find_element(By.CSS_SELECTOR, likesSelector).text
print(f'[{username}] Rep: {rep} | Vouches: {vouches} | Likes: {likes}')
except:
log('Could not find username, vouches or rep. Most likely an invalid login')
restart()
return
try:
# find all thread ids
if len(thread_ids) < len(config['threads']):
for thread in config['threads']:
# allow for inputting thread ids straight into config
if type(thread) == int:
thread_ids.append(thread)
continue
raw_thread = thread.lower().replace('https://flipd.gg/thread-', '')
thread = 'https://flipd.gg/thread-' + raw_thread
driver.get(thread)
source = driver.page_source
if not 'https://flipd.gg/showthread.php?tid=' in source:
log(f'Invalid thread: {thread}')
continue
id = source.split('https://flipd.gg/showthread.php?tid=')[1].split('"')[0]
thread_ids.append(id)
log(f'[{raw_thread}] Thread ID: {id}')
log('Starting bumper...')
total_errors = 0
while True:
for id in thread_ids:
# ogu rate limit
if id != thread_ids[0]:
time.sleep(15)
set_size()
try:
msg = get_message()
if quickReplyEnabled:
driver.get('https://flipd.gg/showthread.php?tid=' + str(id))
msg = get_message()
driver.find_element(By.CSS_SELECTOR, replyMessageSelector).send_keys(msg)
driver.find_element(By.CSS_SELECTOR, postReplySelector).click()
total_errors = 0
else:
driver.get('https://flipd.gg/newreply.php?tid=' + str(id))
driver.find_element(By.CSS_SELECTOR, toggleCodeEditorSelector).click()
driver.find_element(By.CSS_SELECTOR, replyTextAreaSelector).send_keys(msg)
driver.find_element(By.CSS_SELECTOR, regularReplyPostSelector).click()
total_errors = 0
log(f'[{id}] Bumped thread: {msg}')
except Exception as e:
print(e)
check_turnstile()
total_errors += 1
if total_errors >= 10:
print('Too many errors, restarting')
restart()
return
time.sleep(int(config['interval']) * 60)
except Exception as e:
log(e)
restart()
return
if __name__ == '__main__':
login()