Skip to content

Instantly share code, notes, and snippets.

@staccDOTsol
Created July 30, 2022 02:05
Show Gist options
  • Save staccDOTsol/77a111ed9fd9e9a93dccd738ba287ce9 to your computer and use it in GitHub Desktop.
Save staccDOTsol/77a111ed9fd9e9a93dccd738ba287ce9 to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from selenium.webdriver.common.keys import Keys
import os
from selenium.webdriver.chrome.options import Options
import re
import pytesseract
from selenium.webdriver.common.by import By
import random
import cv2
from PIL import Image
from Screenshot import Screenshot_Clipping
ss = Screenshot_Clipping.Screenshot()
import numpy as np
PATH = "\\Bruno\\"
url = "https://www.breakbitz.com/"
pytesseract.pytesseract.tesseract_cmd = r"tesseract"
options = webdriver.ChromeOptions()
options.headless = False
options.add_argument("--start-maximized");
options.add_argument(r"--user-data-dir=/Users/jarettdunn/google") #e.g. C:\Users\You\AppData\Local\Google\Chrome\User Data
driver = webdriver.Chrome('./chromedriver',options=options)
URL = url
driver.get(URL)
driver.maximize_window()
redacc = "redacc"
sleep(5)
elem = driver.switch_to.active_element
elem.send_keys(redacc)
elem.send_keys(Keys.RETURN)
sleep(5)
driver.find_element(By.XPATH,'//*[@id="game-container"]/button').click()
sleep(15)
while True:
sleep(0.01)
ranran = random.randint(1,10000)
acanvas = driver.find_element(By.XPATH,"//canvas")
acanvas.screenshot('./web_screenshot' + str(ranran) + '.png')
img = cv2.imread('./web_screenshot' + str(ranran) + '.png')
print(img.shape) # Print image shape
path = img[50:80, 50:400]
cv2.imwrite('./path.png', path)
path2 = img[550:580, 50:400]
cv2.imwrite('./path2.png', path2)
# reading the image in grayscale mode
gray = cv2.imread('./path.png', 0)
# threshold
th, threshed = cv2.threshold(gray, 100, 255,
cv2.THRESH_BINARY|cv2.THRESH_OTSU)
# findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)[-2]
# filter by area
s1 = 1800
s2 = 1980
xcnts = []
for cnt in cnts:
print(cv2.contourArea(cnt))
if cv2.contourArea(cnt)!=17101.0:
xcnts.append(cnt)
# printing output
print("\nDots number1: {}".format(len(xcnts)))
if len(xcnts) > 0:
acanvas.click()
# reading the image in grayscale mode
gray = cv2.imread('./path2.png', 0)
# threshold
th, threshed = cv2.threshold(gray, 100, 255,
cv2.THRESH_BINARY|cv2.THRESH_OTSU)
# findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)[-2]
# filter by area
s1 = 1800
s2 = 1980
xcnts = []
for cnt in cnts:
print(cv2.contourArea(cnt))
if cv2.contourArea(cnt)!=2443.0:
xcnts.append(cnt)
# printing output
print("\nDots number2: {}".format(len(xcnts)))
if len(xcnts) > 0:
acanvas.click()
#funny funny
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from selenium.webdriver.common.keys import Keys
import os
from selenium.webdriver.chrome.options import Options
import re
import pytesseract
from selenium.webdriver.common.by import By
import random
import cv2
from PIL import Image
from Screenshot import Screenshot_Clipping
ss = Screenshot_Clipping.Screenshot()
import numpy as np
PATH = "\\Bruno\\"
url = "https://www.breakbitz.com/"
pytesseract.pytesseract.tesseract_cmd = r"tesseract"
options = webdriver.ChromeOptions()
options.headless = False
options.add_argument("--start-maximized");
options.add_argument(r"--user-data-dir=/Users/jarettdunn/google") #e.g. C:\Users\You\AppData\Local\Google\Chrome\User Data
driver = webdriver.Chrome('./chromedriver',options=options)
URL = url
driver.get(URL)
driver.maximize_window()
redacc = "redacc"
sleep(5)
elem = driver.switch_to.active_element
elem.send_keys(redacc)
elem.send_keys(Keys.RETURN)
sleep(5)
driver.find_element(By.XPATH,'//*[@id="game-container"]/button').click()
sleep(15)
while True:
sleep(0.01)
ranran = random.randint(1,10000)
acanvas = driver.find_element(By.XPATH,"//canvas")
#acanvas.screenshot('./web_screenshot' + str(ranran) + '.png')
ss.full_Screenshot(driver, save_path=r'.' , image_name='./web_screenshot' + str(ranran) + '.png')
img = cv2.imread('./web_screenshot' + str(ranran) + '.png')
print(img.shape) # Print image shape
path = img[300:330, 780:1150]
cv2.imwrite('./path.png', path)
path2 = img[780:820, 750:1150]
cv2.imwrite('./path2.png', path2)
# reading the image in grayscale mode
gray = cv2.imread('./path.png', 0)
# threshold
th, threshed = cv2.threshold(gray, 100, 255,
cv2.THRESH_BINARY|cv2.THRESH_OTSU)
# findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)[-2]
# filter by area
s1 = 1800
s2 = 1980
xcnts = []
for cnt in cnts:
print(cv2.contourArea(cnt))
if cv2.contourArea(cnt)!=17101.0:
xcnts.append(cnt)
# printing output
print("\nDots number1: {}".format(len(xcnts)))
if len(xcnts) > 0:
acanvas.click()
# reading the image in grayscale mode
gray = cv2.imread('./path2.png', 0)
# threshold
th, threshed = cv2.threshold(gray, 100, 255,
cv2.THRESH_BINARY|cv2.THRESH_OTSU)
# findcontours
cnts = cv2.findContours(threshed, cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)[-2]
# filter by area
s1 = 1800
s2 = 1980
xcnts = []
for cnt in cnts:
print(cv2.contourArea(cnt))
if cv2.contourArea(cnt)!=2443.0:
xcnts.append(cnt)
# printing output
print("\nDots number2: {}".format(len(xcnts)))
if len(xcnts) > 0:
acanvas.click()
#funny funny
I'm bored
the problem: Narfs and team have made the thing click if it detects a selenium screenshot (fair play, anticipating my first move)
full screen ss behaves better doesn't trigger their weird epileptic seizure bullshit
meh
I'm bored good luck everybody:
thoughts
1. do it in an iframe lol see if it still detec (fuck cors)
2. do it in a vm and
ah yeh that ain't a bad idea, do it in a vm and vnc via web browser then watch that -kek-
not a bad idea
good luck kiddos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment