├── README.md └── old ├── README.md ├── main.py └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 | 2 | ```py 3 | json_data = { 4 | "requests": [{ 5 | "image": { 6 | "content": "base64 encoded image" 7 | }, 8 | "features": [{"type": "TEXT_DETECTION"}] 9 | }] 10 | } 11 | 12 | req = requests.post( 13 | url = 'https://content-vision.googleapis.com/v1/images:annotate', 14 | headers = { 15 | 'x-origin': 'https://explorer.apis.google.com', 16 | }, 17 | params = { 18 | 'alt': 'json', 19 | 'key': 'AIzaSyAa8yy0GdcGPHdtD083HiGGx_S0vMPScDM', 20 | }, 21 | json = json_data 22 | ) 23 | 24 | print(req.json()) 25 | ``` 26 | -------------------------------------------------------------------------------- /old/README.md: -------------------------------------------------------------------------------- 1 |
6 | Zefoy OCR bruteforce captcha solver using cv2, PIL and pytesseract aswell as the Zefoy API 7 |
8 | 9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
127 | README.md inspired from Rdimo 128 |
129 | -------------------------------------------------------------------------------- /old/main.py: -------------------------------------------------------------------------------- 1 | import pytesseract, cv2, requests, os, random, threading, re, sys, time, enchant, shutil, numpy 2 | from PIL import Image 3 | 4 | pytesseract.pytesseract.tesseract_cmd = r"C:/Program Files (x86)/Tesseract-OCR/tesseract.exe" 5 | sys.setrecursionlimit(1500) 6 | 7 | class Solver: 8 | def __init__(self): 9 | self.config = '--psm 6 --oem 3' 10 | self.base_url = "https://zefoy.com/" 11 | 12 | self.start = time.time() 13 | self.reqs = 0 14 | 15 | threading.Thread(target=self.monitor).start() 16 | 17 | while True: 18 | self.solve() 19 | 20 | if threading.active_count() < 2 + 1: 21 | threading.Thread(target=self.solve).start() 22 | 23 | def monitor(self): 24 | while True: 25 | os.system(f'title Captcha Solver ^| Requests ~ {self.reqs} ^| Time Elapsed ~ {round(time.time() - self.start, 1)}s') 26 | time.sleep(0.5) 27 | 28 | 29 | def solve(self): 30 | try: 31 | sess = requests.Session() 32 | num = random.randint(1000, 9999) 33 | 34 | sessid = sess.get( 35 | self.base_url, 36 | headers={ 37 | "origin": "https://zefoy.com", 38 | "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36", 39 | "x-requested-with": "XMLHttpRequest" 40 | } 41 | ).cookies.values()[0] 42 | 43 | response = sess.get( 44 | self.base_url + "a1ef290e2636bf553f39817628b6ca49.php", 45 | headers={ 46 | "origin": "https://zefoy.com", 47 | "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36", 48 | "x-requested-with": "XMLHttpRequest", 49 | "cookie": f"PHPSESSID={sessid}", 50 | }, 51 | params={ 52 | "_CAPTCHA": "", 53 | "t": "0.23092200 1654778649" 54 | } 55 | ) 56 | 57 | with open(f"./captchas/captcha{num}.png", 'wb') as _: 58 | _.write(response.content) 59 | 60 | file = cv2.imread(f"./captchas/captcha{num}.png") 61 | os.remove(f"./captchas/captcha{num}.png") 62 | thresh, im_bw = cv2.threshold(file, 190, 260, cv2.THRESH_BINARY) 63 | _name = f'./captchas/enhanced{num}.png' 64 | b = cv2.imwrite(_name, im_bw) 65 | def bbox(im): 66 | a = numpy.array(im)[:,:,:3] 67 | m = numpy.any(a != [255, 255, 255], axis=2) 68 | coords = numpy.argwhere(m) 69 | y0, x0, y1, x1 = *numpy.min(coords, axis=0), *numpy.max(coords, axis=0) 70 | return (x0, y0, x1+1, y1+1) 71 | 72 | im = Image.open(_name) 73 | im2 = im.crop(bbox(im)) 74 | im2.save(_name) 75 | 76 | ocr = pytesseract.image_to_string(_name, config=self.config) 77 | captcha = str(ocr) 78 | 79 | if captcha != "" and not None or not None: 80 | _captcha = re.compile('[^a-zA-Z]').sub('', captcha).lower() 81 | 82 | d = enchant.Dict("en_US") 83 | if d.check(_captcha) == False: 84 | _captcha = d.suggest(_captcha)[0] 85 | 86 | if len(_captcha) > 2: 87 | 88 | print(_captcha) 89 | 90 | shutil.copy(f"./captchas/enhanced{num}.png", f"./solved/{_captcha}.png") 91 | 92 | _response = sess.post( 93 | "https://zefoy.com", 94 | data={ 95 | "captcha_secure": _captcha, 96 | "r75619cf53f5a5d7aa6af82edfec3bf0": "" 97 | }, 98 | headers={ 99 | "cookie": f"PHPSESSID={sessid}", 100 | "origin": "https://zefoy.com", 101 | "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36", 102 | "x-requested-with": "XMLHttpRequest" 103 | } 104 | ) 105 | 106 | if "c2VuZF9mb2xsb3dlcnNfdGlrdG9r" in _response.text: 107 | print(f"SOLVED | Time: {time.time() - self.start}s | Trials: {self.reqs} | Sessid: {sessid}") 108 | sys.exit('solved successfully') 109 | else: 110 | pass 111 | 112 | self.reqs += 1 113 | 114 | os.remove(f'./captchas/enhanced{num}.png') 115 | 116 | except Exception as e: 117 | try: 118 | os.remove(f'./captchas/enhanced{num}.png') 119 | os.remove(f"./captchas/captcha{num}.png") 120 | except: 121 | pass 122 | 123 | 124 | if __name__ == "__main__": 125 | os.system("cls" if os.name == 'nt' else 'clear') 126 | Solver() 127 | -------------------------------------------------------------------------------- /old/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy==1.22.3 2 | opencv-python==4.6.0.66 3 | pyenchant==3.2.2 4 | pytesseract==0.3.9 5 | requests==2.27.1 6 | PIL-Tools==1.1.0 7 | --------------------------------------------------------------------------------