From d7c4f81a14a02935849f1344c5d68891ba2cc65b Mon Sep 17 00:00:00 2001 From: pythonkoft Date: Thu, 6 Nov 2025 14:18:41 +0000 Subject: [PATCH] Update main.py version2 --- main.py | 1805 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 1078 insertions(+), 727 deletions(-) diff --git a/main.py b/main.py index 5e45740..3d02712 100644 --- a/main.py +++ b/main.py @@ -40,6 +40,7 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains import pyotp + import os import psycopg2 from psycopg2.pool import SimpleConnectionPool @@ -79,7 +80,17 @@ import logging import json from datetime import datetime import os +import os +import json +import time +import re +from pathlib import Path +from camoufox.sync_api import Camoufox +import pdb + +#from playwright.sync_api import Keys +import time def get_tehran_time(): tehran_tz = pytz.timezone('Asia/Tehran') tehran_time = datetime.now(tehran_tz) @@ -105,6 +116,99 @@ def kill_tor_browser(): pass # اگر دسترسی نداریم یا پروسه دیگه‌ای از بین رفته باشه، نادیده می‌گیریم print("تمام پروسه‌های مرتبط با تور بررسی شدند.") +import time +import platform + +def minimize_camoufox(title_hint=None, profile_path=None, wait=0.3): + """ + ویندوز: پنجره Camoufox/Firefox را مینی‌مایز می‌کند. + - title_hint: رشته‌ای از عنوان پنجره (مثلاً "Camoufox" یا نام پروفایل) + - profile_path: اگر مسیر پروفایل را می‌دانی، کمک می‌کند PID درست پیدا شود (اختیاری) + خروجی: True اگر موفق شود، وگرنه False + """ + if platform.system().lower() != "windows": + return False + + # سعی 1: با عنوان پنجره (سریع و ساده) + try: + import pygetwindow as gw + titles = gw.getAllTitles() + if title_hint: + candidates = [t for t in titles if t and title_hint.lower() in t.lower()] + else: + # اگر هینت ندادید، «Camoufox» را هدف می‌گیرد + candidates = [t for t in titles if t and "camoufox" in t.lower()] + + for t in candidates: + try: + w = gw.getWindowsWithTitle(t)[0] + w.minimize() + time.sleep(wait) + return True + except Exception: + continue + except Exception: + # pygetwindow نصب نیست یا مشکلی داشت -> میریم سراغ روش بعدی + pass + + # سعی 2: با PID پروسه و مینیمایز همه‌ی hwndهای مربوط (پایدارتر) + try: + import psutil + import win32gui, win32con, win32process + + target_pids = set() + + # پیدا کردن پروسه‌ها از روی نام/cmdline + for proc in psutil.process_iter(['pid','name','cmdline']): + try: + name = (proc.info.get('name') or '').lower() + cmd = ' '.join(proc.info.get('cmdline') or []).lower() + + good_name = ('camoufox' in name) or ('camoufox' in cmd) or ('firefox' in name) + good_profile = (profile_path and profile_path.lower() in cmd) + + # اگر نام درست بود، یا مسیر پروفایل در cmdline دیده شد، این PID را هدف بگیر + if good_name or good_profile: + target_pids.add(proc.info['pid']) + except (psutil.NoSuchProcess, psutil.AccessDenied): + continue + + if not target_pids: + return False + + hwnds = [] + + def enum_handler(hwnd, result_list): + try: + _, pid = win32process.GetWindowThreadProcessId(hwnd) + if pid in target_pids and win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd): + result_list.append(hwnd) + except Exception: + pass + + win32gui.EnumWindows(enum_handler, hwnds) + if not hwnds: + time.sleep(0.5) + win32gui.EnumWindows(enum_handler, hwnds) + + if not hwnds: + return False + + ok = False + for h in hwnds: + try: + win32gui.ShowWindow(h, win32con.SW_MINIMIZE) + ok = True + except Exception: + continue + + time.sleep(wait) + return ok + + except Exception: + return False + + file_data={} @@ -687,6 +791,10 @@ class ea_fucking(): def load_browser_windows(self,path): # print(codex,'--------------') print(path) + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") path=rf'C:\Users\{user_sys}\Desktop\Browser\firefox.exe' subprocess.Popen([path]) time.sleep(6) @@ -711,17 +819,36 @@ class ea_fucking(): time.sleep(4) for i in range(5): print(os.path.join(self.path_png_file,r'1_dcuk_clik.PNG')) + ##import pdb;pdb.set_trace() try: try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'1_dcuk_clik.PNG'), confidence=0.8) + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'2_dcuk_clik.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + return True except: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'1_1_dcuk_clik.PNG'), confidence=0.8) - #https://e1_1_dcuk_clik.PNG + if location: + pyautogui.click(pyautogui.center(location)) + + return True + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'1_dcuk_clik.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + return True + except: + pass + + except Exception as e: + print(e) time.sleep(5) continue - + #import pdb;pdb.set_trace() if location: pyautogui.click(pyautogui.center(location)) @@ -743,7 +870,7 @@ class ea_fucking(): location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'accept.PNG'), confidence=0.8) except: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'accept.PNG'), confidence=0.8) - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -761,7 +888,7 @@ class ea_fucking(): location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'True.PNG'), confidence=0.8) except: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'true2.PNG'), confidence=0.8) - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -777,7 +904,7 @@ class ea_fucking(): pyautogui.write("https://myaccount.ea.com/cp-ui/security/index") pyautogui.press("enter") - time.sleep(5) + time.sleep(15) for i in range(20): print(os.path.join(self.path_png_file,r'click_gmail.PNG')) try: @@ -796,7 +923,7 @@ class ea_fucking(): pyautogui.click(pyautogui.center(location)) time.sleep(10) return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -816,7 +943,7 @@ class ea_fucking(): chek=True break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -837,7 +964,7 @@ class ea_fucking(): pyautogui.click(pyautogui.center(location)) chek2=True break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -859,7 +986,7 @@ class ea_fucking(): pyautogui.click(pyautogui.center(location)) chek3=True break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -881,7 +1008,7 @@ class ea_fucking(): pyautogui.click(pyautogui.center(location)) chek4=True break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(6) continue @@ -914,7 +1041,7 @@ class ea_fucking(): pyautogui.click(pyautogui.center(location)) chek45=True break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -952,16 +1079,25 @@ class ea_fucking(): if location: pyautogui.click(pyautogui.center(location)) return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue return 'click_gmail' def chek_logo(self): cont=0 + sleep(30) + #input('2222') for i in range(15): #fail_mail.PNG print(os.path.join(self.path_png_file,r'ea_logo.PNG')) + try: + print('start chek') + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'chalenge1_find_next.PNG'), confidence=0.8) + if location: + return 'jump_to_sec' + except: + pass try: print('start chek') location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'fail_mail.PNG'), confidence=0.8) @@ -985,7 +1121,7 @@ class ea_fucking(): if location: pyautogui.click(pyautogui.center(location)) break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(1) try: @@ -1010,7 +1146,7 @@ class ea_fucking(): except: pass - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() sleep(6) pyautogui.press('tab')#, sleep(1) @@ -1047,7 +1183,7 @@ class ea_fucking(): if location: pyautogui.click(pyautogui.center(location)) return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(4) continue @@ -1065,7 +1201,7 @@ class ea_fucking(): if location: pyautogui.click(pyautogui.center(location)) return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -1083,7 +1219,7 @@ class ea_fucking(): if location: pyautogui.click(pyautogui.center(location)) return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -1118,7 +1254,7 @@ class ea_fucking(): if location: pyautogui.click(pyautogui.center(location)) break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -1172,7 +1308,7 @@ class ea_fucking(): if location: pyautogui.click(pyautogui.center(location)) return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -1190,7 +1326,7 @@ class ea_fucking(): pyautogui.click(pyautogui.center(location)) time.sleep(15) return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -1211,7 +1347,7 @@ class ea_fucking(): location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'accept.PNG'), confidence=0.8) except: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'accept.PNG'), confidence=0.8) - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(3) continue @@ -1229,7 +1365,7 @@ class ea_fucking(): location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'false2.PNG'), confidence=0.8) except: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'false.PNG'), confidence=0.8) - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -1257,7 +1393,7 @@ class ea_fucking(): sleep(1) pyautogui.press("enter") return True - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue @@ -1275,13 +1411,14 @@ class ea_fucking(): except: pass - for i in range(4): + for i in range(9): print(os.path.join(self.path_png_file,r'chalenge1_find_next.PNG')) try: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'chalenge1_find_next.PNG'), confidence=0.8) pyautogui.click(pyautogui.center(location)) print(' ok >>> chalenge1_find_next') + #return 'ea_created__app_code_nead!!' except: print(' eror >>> chalenge1_find_next') @@ -1299,8 +1436,8 @@ class ea_fucking(): if location: return True except:pass - codex.end() - codex=Gmail(value,val2,browser_proxy=browser_proxy) + # codex.end() + # codex=Gmail(value,val2,browser_proxy=browser_proxy) codes='' for isx in range(4): if self.dicline()=='Internal Server Error':return 'Internal Server Error'#=='Internal Server Error':return 'Internal Server Error' @@ -1327,7 +1464,7 @@ class ea_fucking(): codex.end() codex=Gmail(value,val2,browser_proxy=browser_proxy) print('eror') - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() print('break_one') if codes==True: pass @@ -1524,7 +1661,7 @@ class ea_fucking(): sleep(0.5) pyautogui.press('enter') # return True - #https://e1_1_dcuk_clik.PNG + sleep(10) for i in range(10): try: @@ -1542,48 +1679,37 @@ class ea_fucking(): continue return 'fail_15_send_sec_code_app_code' # https://myaccount.ea.com/cp-ui/aboutme/index - def handel_page_and_code(self,codex,value,val2): + def handel_page_and_code_send_code(self,codex,value,val2): sleep(30) - codex.end() - codex=Gmail(value,val2,browser_proxy=browser_proxy) codes='' for i in range(2): try: - code=codex.get_code()#str(re.findall(pattern=r'Your EA Security Code is: \w*',string=copied_text)[0]).replace('Your EA Security Code is: ','') if 'ALERT_to_mnay_code_chek'==code: return 'ALERT_to_mnay_code_chek' if code=='continue': codex.end() codexs=Gmail(value,val2,browser_proxy=browser_proxy) - - - - code=codexs.get_code() if 'ALERT_to_mnay_code_chek'==code: return 'ALERT_to_mnay_code_chek' if code=='continue': codexs.end() continue - codes=True - codes=True - + return code + codes=True + return code except: codex.end() codex=Gmail(value,val2,browser_proxy=browser_proxy) print('eror') - #import pdb;pdb.set_trace() - - if codes==True: - pass - else: + ##import pdb;pdb.set_trace() return 'fail_get_code' - + + + def handel_page_and_code_write_code(self,code): chek='' for i in range(30): - - print(os.path.join(self.path_png_file,r'veryfy_idyntt.PNG')) try: try: @@ -1609,7 +1735,7 @@ class ea_fucking(): sleep(0.5) for i_code in code: - pyautogui.write(i_code) + pyautogui.write(i_code.replace('EA','')) print('handel_page_and_code mission 21 next !!!!') pyautogui.press('tab') pyautogui.press('enter') @@ -1671,189 +1797,285 @@ class ea_fucking(): try: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'chek_tow_factor_1.PNG'), confidence=0.8) chek=True - break + return True except: pass try: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'one_trn.PNG'), confidence=0.8) chek=True - break + return True except: - pass + pass + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'tow_factor__.PNG'), confidence=0.8) + chek=True + return True + except: + pass + #tow_factor__.PNG if chek==True: - break + return True else: return 'faill_all_code' except Exception as e: time.sleep(5) continue - if chek==True: - pass - else: - return 'input_bouten2' - sleep(10) - chek22='' + + def handel_page_and_code_one_trn(self): for i in range(30): if self.dicline()=='Internal Server Error':return 'Internal Server Error' print(os.path.join(self.path_png_file,r'one_trn.PNG')) try: try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'one_trn.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek22=True + return True except: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'one_trn.PNG'), confidence=0.8) + try: + + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'one_trn.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + return True + + except: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'tow_factor__.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + pyautogui.press('tab') + pyautogui.press('enter') + pyautogui.press('enter') + print('handel_page_and_code mission 3 next !!!!') + chek22=True + return True + if location: pyautogui.click(pyautogui.center(location)) print('handel_page_and_code mission 3 next !!!!') - chek22=True + return True break - #https://e1_1_dcuk_clik.PNG + except Exception as e: time.sleep(5) continue - - sleep(10) - if chek22==True: - pass - else: - return 'Two-factor authentication' - chek3='' + + + return 'Two-factor authentication' + + + + def handel_page_and_codeapp_authentctor(self): for i in range(30): - if self.dicline()=='Internal Server Error':return 'Internal Server Error' + #if self.dicline()=='Internal Server Error':return 'Internal Server Error' print(os.path.join(self.path_png_file,r'17_app_authentctor.PNG')) try: - try: - - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'17_app_authentctor.PNG'), confidence=0.8) - except: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'17_app_authentctor.PNG'), confidence=0.8) + location = pyautogui.locateOnScreen(os.path.join(path_png_file,r'app_authentctor__komaki.PNG'), confidence=0.8) if location: pyautogui.click(pyautogui.center(location)) - print('handel_page_and_code mission 3 next !!!!') - chek3=True - break - #https://e1_1_dcuk_clik.PNG + pyautogui.press('tab') + sleep(1) + pyautogui.press('tab') + sleep(1) + pyautogui.press('right') + sleep(1) + pyautogui.press('tab') + sleep(1) + pyautogui.press('enter') + sleep(15) + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'19_continue.PNG'), confidence=0.8) + if location: + print('handel_page_and_code mission 3 next !!!!') + chek3=True + return True + except: + pass + try: + + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'19_continue__.PNG'), confidence=0.8) + if location: + print('handel_page_and_code mission 3 next !!!!') + chek3=True + return True + except: + pass + + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'18_send_code.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek3=True + return True + except: + pass + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'18_send_code_1.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek3=True + return True + except: + pass + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'18_send_code_1.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek3=True + return True + except: + pass + #!!!!!!!!!!!!!!!!!! + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'19_continue.PNG'), confidence=0.8) + if location: + print('handel_page_and_code mission 3 next !!!!') + chek3=True + return True + except: + pass + try: + + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'19_continue__.PNG'), confidence=0.8) + if location: + print('handel_page_and_code mission 3 next !!!!') + chek3=True + return True + except: + pass + #!!!!!!!!!!!!!!!!!! + '''try: + try: + + location = pyautogui.locateOnScreen(os.path.join(path_png_file,r'17_app_authentctor.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek3=True + break + except: + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'17_app_authentctor.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek3=True + break + except: + pass + + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'17_3app_authentctor.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek3=True + break + except: + pass + try: + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'17_2app_authentctor.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + + print('handel_page_and_code mission 3 next !!!!') + chek3=True + break + except: + pass''' except Exception as e: time.sleep(5) continue - #sleep(10) - if chek3==True: - pass - else: - return '17_app_authentctor' - chek4='' - self.dicline() - for i in range(30): - if self.dicline()=='Internal Server Error':return 'Internal Server Error' - print(os.path.join(self.path_png_file,r'18_send_code.PNG.PNG.PNG')) - try: - try: - - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'18_send_code.PNG'), confidence=0.8) - if location: - pyautogui.click(pyautogui.center(location)) - print('handel_page_and_code mission 3 next !!!!') - chek4=True - break - except: - pass - try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'18_send_code.PNG'), confidence=0.8) - if location: - pyautogui.click(pyautogui.center(location)) - print('handel_page_and_code mission 3 next !!!!') - chek4=True - break - except: - pass - try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'18_send_code_1.PNG'), confidence=0.8) - if location: - pyautogui.click(pyautogui.center(location)) + return '17_app_authentctor' - print('handel_page_and_code mission 3 next !!!!') - chek4=True - break - except: - pass - try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'18_send_code_1.PNG'), confidence=0.8) - if location: - pyautogui.click(pyautogui.center(location)) - print('handel_page_and_code mission 3 next !!!!') - chek4=True - break - except: - pass + def handel_page_and_code_19_continue(self): - - #https://e1_1_dcuk_clik.PNG - except Exception as e: - time.sleep(5) - continue - if chek4==True: - pass - else: - return '18_send_code' sleep(10) - chek5='' for i in range(30): - if self.dicline()=='Internal Server Error':return 'Internal Server Error' + # if self.dicline()=='Internal Server Error':return 'Internal Server Error' print(os.path.join(self.path_png_file,r'19_continue.PNG.PNG.PNG.PNG')) try: - try: + #try:#19_continue__.PNG - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'19_continue.PNG'), confidence=0.8) - except: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'19_continue.PNG'), confidence=0.8) - if location: - pyautogui.click(pyautogui.center(location)) + # location = pyautogui.locateOnScreen(os.path.join(path_png_file,r'19_continue.PNG'), confidence=0.8) + #if location: + #pyautogui.click(pyautogui.center(location)) + #print('handel_page_and_code mission 3 next !!!!') + #chek5=True + #eturn True + #except: + #pass + try: - print('handel_page_and_code mission 3 next !!!!') - chek5=True - break - #https://e1_1_dcuk_clik.PNG + location = pyautogui.locateOnScreen(os.path.join(path_png_file,r'19_continue__.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + print('handel_page_and_code mission 3 next !!!!') + + return True + except: + pass + try: + + location = pyautogui.locateOnScreen(os.path.join(path_png_file,r'su_contuinue.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + print('handel_page_and_code mission 3 next !!!!') + + return True + except: + pass except Exception as e: time.sleep(5) continue - if chek5==True: - pass - else: - return '19_continue' - sleep(15) + + return '19_continue' + + + def handel_page_and_code_komaki_write_code(self): tot=self.qr_code() + self.tot=tot sleep(3) totx=self.top(tot) - #import pdb;pdb.set_trace() - # ea_png/input_bouten1.PNG ea_png/input_bouten2.PNG ea_png/input_for_end.PNG - if chek5==True: - pass - else: - return 'click_code' - chek6='' for i in range(30): - if self.dicline()=='Internal Server Error':return 'Internal Server Error' + #if self.dicline()=='Internal Server Error':return 'Internal Server Error' print(os.path.join(self.path_png_file,r'komaki.PNG.PNG.PNG.PNG.PNG')) try: try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'komaki.PNG'), confidence=0.8) + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'komaki__1.PNG'), confidence=0.8) if location: pyautogui.click(pyautogui.center(location)) pyautogui.press('tab') pyautogui.press('tab') pyautogui.press('tab') pyautogui.write(totx) + pyautogui.press('tab') + pyautogui.press('enter') print('handel_page_and_code mission 3 next !!!!') chek6=True - break + return True except: pass try: @@ -1865,9 +2087,11 @@ class ea_fucking(): pyautogui.press('tab') pyautogui.press('tab') pyautogui.write(totx) + pyautogui.press('tab') + pyautogui.press('enter') print('handel_page_and_code mission 3 next !!!!') chek6=True - break + return True except: pass try: @@ -1879,68 +2103,153 @@ class ea_fucking(): pyautogui.press('tab') pyautogui.press('tab') pyautogui.write(totx) + pyautogui.press('tab') + pyautogui.press('enter') print('handel_page_and_code mission 3 next !!!!') chek6=True - break + return True except: pass - #https://e1_1_dcuk_clik.PNG - except Exception as e: - time.sleep(5) - continue - if chek6==True: - pass - else: - return 'input_bouten1' - chek7='' - #spam = pyperclip.paste() - for i in range(30): - print(os.path.join(self.path_png_file,r'20_turn_on_login.PNG.PNG.PNG.PNG')) - try: - try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'20_turn_on_login.PNG'), confidence=0.8) - except: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'20_turn_on_login.PNG'), confidence=0.8) - if location: - pyautogui.click(pyautogui.center(location)) - chek7=True - print('handel_page_and_code mission 3 next !!!!') - break - #https://e1_1_dcuk_clik.PNG except Exception as e: time.sleep(5) continue - if chek7==True: - pass - else: - return '20_turn_on_login' - time.sleep(5) - chek8='' - #spam = pyperclip.paste() + + return 'input_bouten1' + + + def handel_page_and_code_vew_back_up(self): for i in range(30): print(os.path.join(self.path_png_file,r'vew_back_up.PNG.PNG.PNG.PNG.PNG')) try: try: - location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'vew_back_up.PNG'), confidence=0.8) + location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'ttttte.PNG'), confidence=0.8) + if location: + pyautogui.click(pyautogui.center(location)) + pyautogui.press('tab') + sleep(1) + pyautogui.press('tab') + sleep(1) + pyautogui.press('enter') + sleep(5) + return True + except: location = pyautogui.locateOnScreen(os.path.join(self.path_png_file,r'vew_back_up.PNG'), confidence=0.8) - if location: - pyautogui.click(pyautogui.center(location)) - chek8=True - print('handel_page_and_code mission 3 next !!!!') - break - #https://e1_1_dcuk_clik.PNG + if location: + pyautogui.click(pyautogui.center(location)) + return True + + except Exception as e: time.sleep(5) continue - if chek8==True: - pass - else: - return 'vew_back_up' + + return 'vew_back_up' + def handel_page_and_code(self,codex,value,val2): + + + # 1 + try: + r = self.handel_page_and_code_send_code(codex,value,val2) + except Exception as e: + print(f"[ERROR] handel_page_and_code_send_code: {e}") + return "handel_page_and_code_send_code", f"exception: {e}" + # if r is not True: + # print(f"[ERROR] handel_page_and_code_send_code: {r}") + # return "handel_page_and_code_send_code", str(r) + # time.sleep(10) + + # 2 + try: + r = self.handel_page_and_code_write_code(r) + except Exception as e: + print(f"[ERROR] handel_page_and_code_write_code: {e}") + return "handel_page_and_code_write_code", f"exception: {e}" + if r is not True: + print(f"[ERROR] handel_page_and_code_write_code: {r}") + return "handel_page_and_code_write_code", str(r) + time.sleep(10) + + # 3 + try: + pyautogui.hotkey('ctrl', '-') + except Exception as e: + print(f"[ERROR] pyautogui ctrl- #1: {e}") + return "pyautogui_ctrl_minus_1", f"exception: {e}" + time.sleep(10) + + # 4 + try: + pyautogui.hotkey('ctrl', '-') + except Exception as e: + print(f"[ERROR] pyautogui ctrl- #2: {e}") + return "pyautogui_ctrl_minus_2", f"exception: {e}" + time.sleep(10) + + # 5 + try: + r = self.handel_page_and_code_one_trn() + except Exception as e: + print(f"[ERROR] handel_page_and_code_one_trn: {e}") + return "handel_page_and_code_one_trn", f"exception: {e}" + if r is not True: + print(f"[ERROR] handel_page_and_code_one_trn: {r}") + return "handel_page_and_code_one_trn", str(r) + time.sleep(10) + + # 6 + try: + r = self.handel_page_and_codeapp_authentctor() + except Exception as e: + print(f"[ERROR] handel_page_and_codeapp_authentctor: {e}") + return "handel_page_and_codeapp_authentctor", f"exception: {e}" + if r is not True: + print(f"[ERROR] handel_page_and_codeapp_authentctor: {r}") + return "handel_page_and_codeapp_authentctor", str(r) + time.sleep(10) + + # 7 + try: + r = self.handel_page_and_code_19_continue() + except Exception as e: + print(f"[ERROR] handel_page_and_code_19_continue: {e}") + return "handel_page_and_code_19_continue", f"exception: {e}" + if r is not True: + print(f"[ERROR] handel_page_and_code_19_continue: {r}") + return "handel_page_and_code_19_continue", str(r) + time.sleep(10) + + # 8 + try: + r = self.handel_page_and_code_komaki_write_code() + except Exception as e: + print(f"[ERROR] handel_page_and_code_komaki_write_code: {e}") + return "handel_page_and_code_komaki_write_code", f"exception: {e}" + if r is not True: + print(f"[ERROR] handel_page_and_code_komaki_write_code: {r}") + return "handel_page_and_code_komaki_write_code", str(r) + time.sleep(10) + + # 9 + try: + r = self.handel_page_and_code_vew_back_up() + except Exception as e: + print(f"[ERROR] handel_page_and_code_vew_back_up: {e}") + return "handel_page_and_code_vew_back_up", f"exception: {e}" + if r is not True: + print(f"[ERROR] handel_page_and_code_vew_back_up: {r}") + return "handel_page_and_code_vew_back_up", str(r) + + + + + + + time.sleep(10) pyautogui.hotkey('ctrl', 'a') pyautogui.hotkey('ctrl', 'c') @@ -1951,7 +2260,7 @@ class ea_fucking(): #\d+\.\d+ try: - return [tot,'$$',codes] + return [self.tot,'$$',codes] except: return 'tot' def chek_by_pdb(self,name): @@ -2005,502 +2314,373 @@ class ea_fucking(): pass + class Gmail: - def __init__(self, name, pasword, browser_proxy): - self.flag_exit = None + def __init__(self, name, password, browser_proxy=None): self.name = name - self.pasword = pasword - - os.makedirs('profile', exist_ok=True) - os.makedirs('picher', exist_ok=True) + self.password = password + self.browser_proxy = browser_proxy + self.flag='' + self.flag_user='' + self.flag_user_sg='' + self.profile_dir = Path('profile') + self.picher_dir = Path('picher') + self.profile_dir.mkdir(exist_ok=True) + self.picher_dir.mkdir(exist_ok=True) + self.user_data_dir = self.profile_dir / self.name + self.is_new_profile = not self.user_data_dir.exists() user_data_dir = os.path.join(os.getcwd(), 'profile', name) if name not in os.listdir(os.path.join(os.getcwd(), 'profile')): - self.flag_exit = True - - - chromium_args = ["--remote-debugging-port=9222",] - - if self.flag_exit is not True: - print() - print() - print() - print() - print() - print('wwwwwwwww$$$$$$$$$$$$$$$$$--window-position=--remote-debugging-port=9222') - print() - print() - print() - print() - print() - chromium_args.append("--window-position=-32000,-32000") - - - - #if browser_proxy==None: - # print('proxy_not_set and exit',browser_proxy) - # sys.exit() - self.driver = Driver( - uc=True, - user_data_dir=user_data_dir, - chromium_arg=chromium_args - ) - - self.driver.get("https://accounts.google.com/servicelogin?service=mail") - - def check_cookies(self): - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - time.sleep(5) - - if 'https://mail.google.com/mail/u/0/' in self.driver.current_url: - - self.driver.get('https://accounts.google.com/v3/signin/') - time.sleep(5) - if 'To help keep your account secure, Google needs to verify it’s you. Please sign in again to continue to Gmail.'in self.driver.page_source: - return 'help keep your account secure' - - cookies = self.driver.execute_cdp_cmd("Network.getAllCookies",{}) - - cookies_json = json.dumps(cookies, indent=4, ensure_ascii=False) - cookies_json = cookies.get("cookies", []) - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - self.driver.execute_script("window.open('https://www.google.com', '_blank');") - time.sleep(2) - - - self.driver.switch_to.window(self.driver.window_handles[1]) - - - self.driver.switch_to.window(self.driver.window_handles[0]) - - - - self.driver.switch_to.window(self.driver.window_handles[0]) - if "Verify" in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}verify.png")) - return 'robot' - if "Verify it" in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}verify.png")) - return 'robot' - if 'Wrong password. Try again or click Forgot password to reset it.' in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_pasword_eror.png")) - return 'pas_eror' - if 'Confirm you’re not a robot' in self.driver.page_source: - return 'robot' - return cookies_json + self.flag=True + print(f"[INFO] No profile found for {self.name}. Browser will be visible.") else: - self.driver.get("https://accounts.google.com/servicelogin?service=mail") - sleep(8) - if 'To help keep your account secure, Google needs to verify it’s you. Please sign in again to continue to Gmail.'in self.driver.page_source: - return 'help keep your account secure' - d=self.send_username(self.name) - sleep(8) + browser_args.append("--window-position=-32000,-32000") + print(f"[INFO] Profile found for {self.name}. Hiding browser window.") + self.flag=False + + browser_args = [] + #if not self.is_new_profile: + # browser_args.append("--window-position=-32000,-32000") + # print(f"[INFO] Profile found for {self.name}. Hiding browser window.") + # self.flag=False + # else: + #print(f"[INFO] No profile found for {self.name}. Browser will be visible.") + #self.flag=True - if 'find your Google Account'in self.driver.page_source: - return 'userx' - if 'Couldn’t find your Google Account'in self.driver.page_source: - return 'userx' - if 'To help keep your account secure, Google needs to verify it’s you. Please sign in again to continue to Gmail.'in self.driver.page_source: - return 'help keep your account secure' - print(d) - # input('>>>>>>1') - if 'To help keep your account secure, Google needs to verify it’s you. Please sign in again to continue to Gmail.'in self.driver.page_source: - return 'help keep your account secure' - # @#input('>>>>>>2') - if 'To help keep your account secure, Google needs to verify it’s you. Please sign in again to continue to Gmail.'in self.driver.page_source: - return 'help keep your account secure' - # input('>>>>>>3') - if 'Confirm you’re not a robot' in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_old.png")) - return 'robot' - # input('>>>>>>4') - if "Verify" in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}verify.png")) - return 'robot' - if "Verify it" in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}verify.png")) - return 'robot' - if 'Wrong password. Try again or click Forgot password to reset it.' in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_pasword_eror.png")) - return 'pas_eror' - if 'Confirm you’re not a robot' in self.driver.page_source: - return 'robot' - sleep(8) - if 'To help keep your account secure, Google needs to verify it’s you. Please sign in again to continue to Gmail.'in self.driver.page_source: - return 'help keep your account secure' - # input('>>>>>>5') - if 'Confirm you’re not a robot' in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_old.png")) - return 'robot' - - #print(self.pasword) - #input('?????') - sleep(8) - try: - fx=self.driver.find_element(By.XPATH, "//input") - print('userx!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') - fx=self.driver.find_element(By.XPATH, "//input").send_key('helooooooooooooooooo') - print('userx!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') - return 'userx' - except: - pass - # input('>>>>>>') - sleep(8) - w=self.send_pasword(self.pasword) - sleep(9) - #if self.driver.current_url=='https://support.google.com/accounts/answer/40039?p=mail': - # return 'block_acses' - #if 'https://support.google.com/accounts/answer/40039?p=mail' in self.driver.current_url: - #return 'block_acses' - if "Unable to access a Google product" in self.driver.page_source: - return 'block_acses' - # i#f "Unable" in self.driver.page_source: - # return 'block_acses' - - if "Unable to access" in self.driver.page_source: - return 'block_acses' - - try: - fx=self.driver.find_element(By.XPATH,'//*[@id="phoneNumberId"]') - print('find ************* phoneNumberId') - return 'robot' - except: - pass - ''' if "Verify" in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}verify.png")) - return 'robot' - if "Verify it" in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}verify.png")) - return 'robot' - ''' - if 'Wrong password. Try again or click Forgot password to reset it.' in self.driver.page_source: - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_pasword_eror.png")) - return 'pas_eror' - if 'Confirm you’re not a robot' in self.driver.page_source: - return 'robot' - try: - fx=self.driver.find_element(By.XPATH, "//input[@name='Passwd']") - return 'userx2' - except: - pass - if w=='username_eror': - #self.driver.save_screenshot(f"_{self.name}_old.png") - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_old.png")) - return 'fail_cookes' - if 'robot' in str(d): - #self.driver.save_screenshot(f"_{self.name}_old.png") - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_old.png")) - return 'robot' - time.sleep(5) - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_old.png")) - #self.driver.save_screenshot(f"_{self.name}_old.png") - - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - time.sleep(5) - self.driver.save_screenshot(os.path.join(os.getcwd(),'picher',f"_{self.name}_old.png")) - status = self.status() - print('status >>>>>>>>>>', status) - - if not status: - - return 'fail_cookes' + self.ctx_manager = Camoufox( + persistent_context=True, + user_data_dir=str(self.user_data_dir), + headless=False, + geoip=False, + enable_cache=True, + humanize=True, + args=browser_args + ) + + self.browser_context = self.ctx_manager.start() + self.page = self.browser_context.new_page() + if self.flag==True: + user=self.send_username(name) + if user==True: + time.sleep(8) + self.send_pasword(password) + time.sleep(9) + print('changelanggggggggggggggggggggggggg',self.change_lang()) else: - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - time.sleep(5) - if 'https://mail.google.com/mail/u/0/' in self.driver.current_url: - self.driver.get('https://accounts.google.com/v3/signin/') - time.sleep(5) - cookies = self.driver.execute_cdp_cmd("Network.getAllCookies",{}) - cookies_json = json.dumps(cookies, indent=4, ensure_ascii=False) - cookies_json = cookies.get("cookies", []) - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - self.driver.execute_script("window.open('https://www.google.com', '_blank');") - time.sleep(2) - - # سوییچ به تب جدید - self.driver.switch_to.window(self.driver.window_handles[1]) - - # بستن تب قبلی - self.driver.switch_to.window(self.driver.window_handles[0]) - self.driver.close() - - # سوییچ مجدد به تب جدید - self.driver.switch_to.window(self.driver.window_handles[0]) - - return cookies_json + self.flag_user=False + self.flag_user_sg=user - def get_code_1(self): - code=[] - for i in range(3): - try: - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - time.sleep(7) - elements = self.driver.find_elements(By.XPATH, "//*[contains(text(), 'Your EA Security Code is:')]")#.text - print(elements) - for i in elements: - print(i.text) - data=i.text.replace('Your EA Security Code is: ', '') - if len(data)==0: - continue - code.append(data) - print(code) - #input('>>') - if len(code)==0: - return 'continue' - if len(code)>7: - return 'ALERT_to_mnay_code_chek' - if len(code)==7: - return 'ALERT_to_mnay_code_chek' - if len(code)==6: - return 'ALERT_to_mnay_code_chek' - if len(code)==8: - return 'ALERT_to_mnay_code_chek' - if len(code)==9: - return 'ALERT_to_mnay_code_chek' - return code - except Exception as e: - print(e) - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - time.sleep(6) - self.driver.refresh() - time.sleep(6) - return 'continue' - def get_code(self): - code=[] - for i in range(3): - try: - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - time.sleep(7) - elements = self.driver.find_elements(By.XPATH, "//*[contains(text(), 'Your EA Security Code is:')]")#.text - if len(elements)==0: - print('data not fund languge .......') - elements = self.driver.find_elements(By.XPATH, "//*[contains(text(), 'EA')]")#.text - - - for i in elements: - - #print(i.text) - if i in code: - continue - try: - pri=(re.findall(r'EA (.+): (\d+)',i.text)[0][1]) - if pri in code:continue - print(pri) - code.append(re.findall(r'EA (.+): (\d+)',i.text)[0][1]) - except Exception as e: - print(e) - pass - # code=list(set(bb)) - #input('>>>>>>>>>>>>>>>>>') - print(code) - #input('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') - #input('>>') - if len(code)==0: - return 'continue' - - return code - - print(elements) - #import pdb;pdb.set_trace() - for i in elements: - print(i.text) - data=i.text.replace('Your EA Security Code is: ', '') - if len(data)==0: - continue - code.append(data) - print(code) - #input('>>') - if len(code)==0: - return 'continue' - - return code - except Exception as e: - print(e) - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - time.sleep(6) - self.driver.refresh() - time.sleep(6) - return 'continue' + + print(f"[INFO] Browser for {self.name} started.") def end(self): + """این متد را برای بستن مرورگر فراخوانی کنید.""" + if self.browser_context: + self.browser_context.close() + self.browser_context = None + self.page = None + self.ctx_manager = None + print(f"[INFO] Browser context for {self.name} closed.") + + def check_cookies(self): + """ + این تابع فقط وضعیت لاگین را بررسی کرده و کوکی‌ها را برمی‌گرداند. + فرض بر این است که مراحل لاگین از قبل انجام شده است. + """ + try: + # صبر می‌کنیم تا پس از لاگین، صفحه به مقصد برسد + time.sleep(5) + + # به اینباکس می‌رویم تا ببینیم لاگین موفق بوده یا نه + self.page.goto("https://mail.google.com/mail/u/0/#inbox", wait_until="domcontentloaded") + + if "mail.google.com/mail/u/0/" in self.page.url: + print("[INFO] Login successful. Getting cookies.") + return self._get_cookies_or_check_errors() + + # اگر به اینباکس نرفت، یعنی لاگین ناموفق بوده. خطاها را بررسی می‌کنیم. + print("[INFO] Login failed. Checking for errors...") + error = self._check_for_errors() + if error: + return error + + # اگر خطای مشخصی پیدا نشد، یک شکست عمومی را گزارش می‌دهیم + self.page.screenshot(path=self.picher_dir / f"_{self.name}_login_failed.png") + return 'fail_cookes' + + except Exception as e: + print(f"[ERROR] An exception occurred in check_cookies: {e}") + self.page.screenshot(path=self.picher_dir / f"_{self.name}_exception.png") + return 'fail_cookes' + def _get_cookies_or_check_errors(self): + try: + # تلاش برای رفتن به صفحه ورود (مثل کد اصلی) + self.page.goto("https://accounts.google.com/v3/signin/", wait_until="load", timeout=10000) + except Exception as e: + # اگر خطای حلقه رخ داد، نادیده بگیر و ادامه بده + print(f"[WARN] Redirect loop detected. Proceeding anyway. Error: {e}") + pass + + # صبر می‌کنیم تا مطمئن شویم وضعیت پایدار است + time.sleep(2) + + error = self._check_for_errors() + if error: + return error + + # در هر صورت، کوکی‌ها را از محیط اصلی بگیرsameSite + cookies = self.browser_context.cookies() + keys_to_drop = {'sameSite', 'secure', 'httpOnly', 'expires'} + cookies = [{k: v for k, v in c.items() if k not in keys_to_drop} for c in cookies] + # شبیه‌سازی رفتار عجیب کد اصلی برای باز و بسته کردن تب + self.page.goto("https://mail.google.com/mail/u/0/#inbox") + new_page = self.browser_context.new_page() + new_page.goto("https://www.google.com") + time.sleep(2) + new_page.close() + print(cookies) + # self.end() + return json.dumps(cookies, indent=4, ensure_ascii=False) + + def _check_for_errors(self): + """این تابع تمام بررسی‌های خطای متنی و مبتنی بر عنصر کد اصلی را پوشش می‌دهد.""" + page_content = self.page.content() + + if "Verify it" in page_content or "Confirm you’re not a robot" in page_content: + self.page.screenshot(path=self.picher_dir / f"_{self.name}verify.png") + return 'robot' + if 'Wrong password. Try again' in page_content: + self.page.screenshot(path=self.picher_dir / f"_{self.name}_pasword_eror.png") + return 'pas_eror' + if "Unable to access a Google product" in page_content: + return 'block_acses' + if 'To help keep your account secure' in page_content: + return 'help keep your account secure' + if 'Couldn’t find your Google Account' in page_content or 'find your Google Account' in page_content: + return 'userx' try: - - self.driver.quit() + self.page.locator('//*[@id="phoneNumberId"]').wait_for(state="visible", timeout=2000) + print('find ************* phoneNumberId') + return 'robot' except: pass - def send_username(self,user): - if 'Confirm you’re not a robot' in self.driver.page_source: - return 'robot' - self.driver.get("https://accounts.google.com/servicelogin?service=mail") - sleep(10) - sf='' - #if 'https://mail.google.com/mail/u/0/' in self.driver.current_url: - #return 'next' - for i in range(15): - - try: - if 'Confirm you’re not a robot' in self.driver.page_source: - return 'robot' - fx=self.driver.find_element(By.XPATH, "//input")#.click() - sf=True - break - #sf=True - except Exception as e: - print(e) - self.driver.get("https://accounts.google.com/servicelogin?service=mail") - #sleep(10) - sleep(4) - sf=False - if sf==False: - return 'Kill' - fx.click() - fx.send_keys(user) - try: - - self.driver.find_element(By.XPATH, "//div[@id='identifierNext']/div/button/span").click() - return True - except: - for i in self.driver.find_elements(By.XPATH, "//*[contains(text(), 'Next')]"): - i.click()#.text - return True - - #//div[@id='identifierNext']/div/button/span - def send_pasword(self,pasw): - sleep(8) + - - # return 'username_eror' - if 'Confirm you’re not a robot' in self.driver.page_source: - return 'robot' - for i in range(5): - try: - - fx=self.driver.find_element(By.XPATH, "//input[@name='Passwd']")#.click() - sf=True - break - #sf=True - except Exception as e: - print(e) - sleep(4) - sf=False - if sf==False: - return 'Kill' - fx.click() - fx.send_keys(pasw) + + + return None + + def get_code(self): try: - self.driver.find_element(By.XPATH, '//*[@id="passwordNext"]/div/button/span').click() - return True - except: - pass - - try: - - self.driver.find_element(By.XPATH, "//div[@id='identifierNext']/div/button/span").click() - return True - except: try: - - for i in self.driver.find_elements(By.XPATH, "//*[contains(text(), 'Next')]"): - i.click()#.text - return True + + + self.page.goto('https://mail.google.com/mail/u/0/#inbox', wait_until="domcontentloaded") except: pass - #//span[contains(.,'Next')] - def change_lang(self): - # return True - - self.driver.get("https://mail.google.com/mail/u/0/#settings/general") - sleep(10) - #import pdb;pdb.set_trace() - #iframes = self.driver.find_elements(By.TAG_NAME, "iframe") - xx=self.driver.find_element(By.XPATH, "//select") - sleep(5) - xx.click() - xx.send_keys('English (UK)') - xx.click() - xx=self.driver.find_element(By.XPATH, "//td/div/button").click() - sleep(3) - self.driver.get("https://myaccount.google.com/language") - #import pdb;pdb.set_trace() - #https://myaccount.google.com/language - xd='' - for i in range(8): + time.sleep(35) try: - try: - sfg=self.driver.find_element(By.XPATH, "//div/button/div") - sfg.click() - xd=True - break - except: - pass - try: - sfg=self.driver.find_element(By.XPATH, "/html/body/c-wiz/div/div[2]/div[2]/c-wiz/div[1]/div[4]/div/div[1]/ul/li/div/div[2]/div/button/div") - sfg.click() - xd=True - break - except: - pass - try: - sfg=self.driver.find_element(By.XPATH,'/html').click() - sfg=self.driver.find_element(By.XPATH,'/html').send_keys(Keys.TAB) - active_element =self.driver.switch_to.active_element - active_element.click() - xd=True - break - except: - pass - + + self.page.reload(wait_until="domcontentloaded") except: + pass + time.sleep(35) + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + elements = self.page.locator("//*[contains(text(), 'Your EA Security Code is:')]") + if elements.count() > 0: + codes = [] + for i in range(elements.count()): + text = elements.nth(i).inner_text() + data = text.replace('Your EA Security Code is: ', '') + if data: + print(data) + codes.append(data.replace('EA','')) + if codes: + # + print(codes) + # + return codes + + print("[INFO] Full text not found, trying regex...") + elements = self.page.locator("//*[contains(text(), 'EA')]") + codes = [] + if elements.count() > 0: + for i in range(elements.count()): + text = elements.nth(i).inner_text() + try: + match = re.findall(r'EA (.+): (\d+)', text) + if match: + code = match[0][1] + if code not in codes: + print(codes) + codes.append(code.replace('EA','')) + except Exception: + continue + # + print(codes) + return codes if codes else 'continue' + + except Exception as e: + print(f"[ERROR] Failed to get code: {e}") + return 'continue' + + def send_username(self, user): + try: + # #import pdb;pdb.set_trace() + self.page.goto("https://accounts.google.com/servicelogin?service=mail", wait_until="networkidle") + time.sleep(1) + email_input = self.page.locator("input[type='email'], input[type='text']").first + email_input.wait_for(state="visible", timeout=15000) + + #if 'robot' in self.page.content(): + # return 'robot' + + email_input.fill(user) + + try: + self.page.locator("#identifierNext >> text=Next").click() + except: + self.page.locator("//*[contains(text(), 'Next')]").first.click() + alert=self._check_for_errors() + if alert==None: - self.driver.refresh() - sleep(5) - if xd==True: - sleep(1) - try: + return True + else: + return alert + except Exception as e: + print(f"[ERROR] Could not send username: {e}") + return 'Kill' - self.driver.find_element(By.XPATH, "//label/input").send_keys("English") - except: - active_element =self.driver.switch_to.active_element - active_element.send_keys("English") - sleep(1) - try: - - self.driver.find_element(By.XPATH, "//label/input").send_keys(Keys.ARROW_DOWN) - except: - active_element =self.driver.switch_to.active_element - active_element.send_keys(Keys.ARROW_DOWN) - sleep(1) - try: - self.driver.find_element(By.XPATH, "//label/input").send_keys(Keys.ENTER) - except: - active_element =self.driver.switch_to.active_element - active_element.send_keys(Keys.ENTER) + def send_pasword(self, pasw): + try: - sleep(1) - self.driver.find_element(By.XPATH, "//li[58]").click() - self.driver.find_element(By.XPATH, "//div[3]/button/span[5]").click() - sleep(1) + password_input = self.page.locator("input[name='Passwd']").first + # password_input.wait_for(state="visible", timeout=10000) - return True - return True - - - - def status(self): - - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - sleep(8) - if 'https://mail.google.com/mail/u/0/#inbox' in self.driver.current_url: - self.change_lang() + #if 'robot' in self.page.content(): + #return 'robot' + + password_input.fill(pasw) - self.driver.get('https://mail.google.com/mail/u/0/#inbox') - sleep(1) + try: + self.page.locator("#passwordNext >> text=Next").click() + except: + self.page.locator("//*[contains(text(), 'Next')]").first.click() + return True - else: + except Exception as e: + print(f"[ERROR] Could not send password: {e}") + return 'Kill' + + + def change_lang(self): + try: + self.page.goto("https://mail.google.com/mail/u/0/#settings/general") + time.sleep(10) + + + lang_select = self.page.get_by_role("cell", name="Gmail display language:").get_by_role("combobox") + lang_select.select_option(label="English (US)") + try: + + + self.page.get_by_role("button", name="Save Changes").click() + except: + pass + time.sleep(3) + + #self.page.goto("https://myaccount.google.com/language") + self.page.goto("https://myaccount.google.com/language", wait_until="domcontentloaded") + time.sleep(5) + + for i in range(8): + try: + try: + sfg = self.page.locator("xpath=//div/button/div") + sfg.click() + xd = True + break + except: + pass + try: + try: + sfg = self.page.locator("xpath=/html/body/c-wiz/div/div[2]/div[2]/c-wiz/div[1]/div[4]/div/div[1]/ul/li/div/div[2]/div/button/div") + sfg.click() + xd = True + break + + except: + sfg = self.page.locator("xpath=/html/body/c-wiz/div/div[2]/div[2]/c-wiz/div[1]/div[4]/div/div[1]/ul/li/div/div[2]/div/span/button/div") + sfg.click() + xd = True + break + + xd = True + break + except: + pass + # try: + # self.page.locator('html').click() + # self.page.locator('html').press('Tab') + # active_element = self.page.locator(":focus") + ## active_element.click() + # xd = True + # break + # except: + # pass + except: + self.page.reload() + time.sleep(5) + # فقط روی دکمه "Edit" تمرکز می‌کنیم و برایش صبر می‌کنیم + + + + time.sleep(2) + + # بقیه منطق شما که شکننده است ولی حفظ شده + try: + search_input = self.page.locator("input[aria-label*='Search']").first + search_input.fill("English") + search_input.press("ArrowDown") + search_input.press("Enter") + except: + active_element = self.page.locator(":focus") + active_element.fill("English") + active_element.press("ArrowDown") + active_element.press("Enter") + time.sleep(1) + self.page.locator("//li[58]").first.click() + self.page.locator("xpath=//div[3]/button/span[5]").click() + + return True + except Exception as e: + print(f"[ERROR] Could not change language: {e}") + # برای دیباگ کردن، یک اسکرین‌شات بگیر + self.page.screenshot(path=self.picher_dir / f"_{self.name}_lang_error.png") return False + def status(self): + try: + self.page.goto('https://mail.google.com/mail/u/0/#inbox', wait_until="networkidle") + time.sleep(5) + if "mail.google.com/mail/u/0/#inbox" in self.page.url: + self.change_lang() + return True + return False + except Exception as e: + print(f"[ERROR] Status check failed: {e}") + return False + @@ -2549,13 +2729,27 @@ def main(path_png_file, return 'click_gmail Failed' # Click day + sleep(15) + chek_logo = ea.chek_logo() - if chek_logo=='fail_mail': - return 'fail_mail' + + + + print('chek_logo >>>', chek_logo) + + #if isinstance(chek_logo, str):return chek_logo + + + + + send_green_status(server) + if chek_logo=='fail_mail': return 'fail_mail' + + if chek_logo==True: @@ -2582,7 +2776,7 @@ def main(path_png_file, return 'ALERT_to_mnay_code_chek' print('----------//////////',get_turn_on_2) - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() if 'ea_created__app_code_nead!!' in str(get_turn_on_2): return "ea_created__app_code_nead!!" if isinstance(get_turn_on_2, str):return get_turn_on_2 @@ -2599,7 +2793,9 @@ def main(path_png_file, print('ea.get_send_sec_3 Failed!') return 'ea.get_send_sec_3 Failed' sleep(10) + #import pdb;pdb.set_trace() handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() if 'ALERT_to_mnay_code_chek' in handel_page_and_code: return 'ALERT_to_mnay_code_chek' if isinstance(handel_page_and_code, str):return handel_page_and_code @@ -2608,7 +2804,7 @@ def main(path_png_file, print('handel_page_and_code Failed!') return 'handel_page_and_code Failed' ###########################################^^^^ - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() return handel_page_and_code #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ -2627,7 +2823,7 @@ def main(path_png_file, if not contuen_page2: print('contuen_page2 Failed!') return 'contuen_page2 Failed' - # import pdb;pdb.set_trace() + # #import pdb;pdb.set_trace() # Accept buttons next = ea.next() if isinstance(next, str):return next @@ -2641,7 +2837,7 @@ def main(path_png_file, print('accept >>>', accept) if 'make_other_time'==accept: - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() #return 'make_other_time' sleep(10) get_seting_sec_1 = ea.get_seting_sec_1() @@ -2655,7 +2851,7 @@ def main(path_png_file, if 'ALERT_to_mnay_code_chek' in str(get_turn_on_2): return 'ALERT_to_mnay_code_chek' print('----------//////////',get_turn_on_2) - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() if 'ea_created__app_code_nead!!' in str(get_turn_on_2): return "ea_created__app_code_nead!!" if isinstance(get_turn_on_2, str):return get_turn_on_2 @@ -2671,7 +2867,9 @@ def main(path_png_file, print('ea.get_send_sec_3 Failed!') return 'ea.get_send_sec_3 Failed' sleep(10) + #import pdb;pdb.set_trace() handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() if 'ALERT_to_mnay_code_chek' in handel_page_and_code: return 'ALERT_to_mnay_code_chek' if isinstance(handel_page_and_code, str):return handel_page_and_code @@ -2680,7 +2878,7 @@ def main(path_png_file, print('handel_page_and_code Failed!') return 'handel_page_and_code Failed' ###########################################^^^^ - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() return handel_page_and_code if not accept: print('accept Failed!') @@ -2702,7 +2900,7 @@ def main(path_png_file, get_turn_on_2 = ea.get_turn_on_2(codex,value,val2) if 'ALERT_to_mnay_code_chek' in str(get_turn_on_2): return 'ALERT_to_mnay_code_chek' - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() if 'ea_created__app_code_nead!!' in str(get_turn_on_2): return "ea_created__app_code_nead!!" if isinstance(get_turn_on_2, str):return get_turn_on_2 @@ -2718,8 +2916,9 @@ def main(path_png_file, print('ea.get_send_sec_3 Failed!') return 'ea.get_send_sec_3 Failed' sleep(10) - + #import pdb;pdb.set_trace() handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() if 'ALERT_to_mnay_code_chek' in handel_page_and_code: return 'ALERT_to_mnay_code_chek' if isinstance(handel_page_and_code, str):return handel_page_and_code @@ -2728,7 +2927,7 @@ def main(path_png_file, print('handel_page_and_code Failed!') return 'handel_page_and_code Failed' ###########################################^^^^ - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() return handel_page_and_code print('creat >>>', creat) if isinstance(creat, str):return creat @@ -2754,7 +2953,7 @@ def main(path_png_file, get_turn_on_2 = ea.get_turn_on_2(codex,value,val2) if 'ALERT_to_mnay_code_chek' in str(get_turn_on_2): return 'ALERT_to_mnay_code_chek' - # import pdb;pdb.set_trace() + # #import pdb;pdb.set_trace() if 'ea_created__app_code_nead!!' in str(get_turn_on_2): return "ea_created__app_code_nead!!" if isinstance(get_turn_on_2, str):return get_turn_on_2 @@ -2771,7 +2970,9 @@ def main(path_png_file, return 'ea.get_send_sec_3 Failed' sleep(10) send_green_status(server) + #import pdb;pdb.set_trace() handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() if 'ALERT_to_mnay_code_chek' in handel_page_and_code: return 'ALERT_to_mnay_code_chek' if isinstance(handel_page_and_code, str):return handel_page_and_code @@ -2782,7 +2983,9 @@ def main(path_png_file, ###########################################^^^^ # import #pdb;pdb.set_trace() return handel_page_and_code + send_green_status(server) + if chek_logo=='nime': send_green_status(server) next = ea.next() @@ -2794,12 +2997,16 @@ def main(path_png_file, ########################################################## sleep(10) accept = ea.accept() + print('accept >>>', accept) + + + if 'make_other_time'==accept: - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() #return 'make_other_time' - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() #return 'make_other_time' sleep(10) get_seting_sec_1 = ea.get_seting_sec_1() @@ -2813,7 +3020,7 @@ def main(path_png_file, if 'ALERT_to_mnay_code_chek' in str(get_turn_on_2): return 'ALERT_to_mnay_code_chek' print('----------//////////',get_turn_on_2) - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() if 'ea_created__app_code_nead!!' in str(get_turn_on_2): return "ea_created__app_code_nead!!" if isinstance(get_turn_on_2, str):return get_turn_on_2 @@ -2830,7 +3037,9 @@ def main(path_png_file, print('ea.get_send_sec_3 Failed!') return 'ea.get_send_sec_3 Failed' sleep(10) + #import pdb;pdb.set_trace() handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() if 'ALERT_to_mnay_code_chek' in handel_page_and_code: return 'ALERT_to_mnay_code_chek' if isinstance(handel_page_and_code, str):return handel_page_and_code @@ -2839,15 +3048,33 @@ def main(path_png_file, print('handel_page_and_code Failed!') return 'handel_page_and_code Failed' ###########################################^^^^ - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() return handel_page_and_code + + + + if not accept: print('accept Failed!') return 'accept Failed' + + + + + + + + + + + # Click verify sleep(10) + creat = ea.creat() + + if 'make_other_time'==creat: #return 'make_other_time' sleep(10) @@ -2861,7 +3088,7 @@ def main(path_png_file, get_turn_on_2 = ea.get_turn_on_2(codex,value,val2) if 'ALERT_to_mnay_code_chek' in str(get_turn_on_2): return 'ALERT_to_mnay_code_chek' - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() if 'ea_created__app_code_nead!!' in str(get_turn_on_2): return "ea_created__app_code_nead!!" if isinstance(get_turn_on_2, str):return get_turn_on_2 @@ -2877,8 +3104,9 @@ def main(path_png_file, print('ea.get_send_sec_3 Failed!') return 'ea.get_send_sec_3 Failed' sleep(10) - + #import pdb;pdb.set_trace() handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() if 'ALERT_to_mnay_code_chek' in handel_page_and_code: return 'ALERT_to_mnay_code_chek' if 'ALERT_to_mnay_code_chek' in handel_page_and_code: @@ -2889,21 +3117,28 @@ def main(path_png_file, print('handel_page_and_code Failed!') return 'handel_page_and_code Failed' ###########################################^^^^ - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() return handel_page_and_code + print('creat >>>', creat) + if not creat: print('creat Failed!') return 'creat Failed' + sleep(10) + finsh = ea.finsh() + if isinstance(finsh, str):return finsh print('finsh >>>', finsh) + if not finsh: print('finsh Failed!') return 'finsh Failed' #######################################$$$$$ + get_seting_sec_1 = ea.get_seting_sec_1() if isinstance(get_seting_sec_1, str):return get_seting_sec_1 print('ea.get_seting_sec_1 >>>', get_seting_sec_1) @@ -2915,7 +3150,7 @@ def main(path_png_file, if 'ALERT_to_mnay_code_chek' in str(get_turn_on_2): return 'ALERT_to_mnay_code_chek' print('----------//////////',get_turn_on_2) - # import pdb;pdb.set_trace() + # #import pdb;pdb.set_trace() if 'ea_created__app_code_nead!!' in str(get_turn_on_2): return "ea_created__app_code_nead!!" if isinstance(get_turn_on_2, str):return get_turn_on_2 @@ -2932,7 +3167,9 @@ def main(path_png_file, print('ea.get_send_sec_3 Failed!') return 'ea.get_send_sec_3 Failed' sleep(10) + #import pdb;pdb.set_trace() handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() if 'ALERT_to_mnay_code_chek' in handel_page_and_code: return 'ALERT_to_mnay_code_chek' if isinstance(handel_page_and_code, str):return handel_page_and_code @@ -2941,18 +3178,69 @@ def main(path_png_file, print('handel_page_and_code Failed!') return 'handel_page_and_code Failed' ###########################################^^^^ - #import pdb;pdb.set_trace() + ##import pdb;pdb.set_trace() return handel_page_and_code # Open new tab + + + + send_green_status(server) + + if chek_logo=='jump_to_sec': + send_green_status(server) + sleep(10) + get_turn_on_2 = ea.get_turn_on_2(codex,value,val2) + if 'ALERT_to_mnay_code_chek' in str(get_turn_on_2): + return 'ALERT_to_mnay_code_chek' + + print('----------//////////',get_turn_on_2) + ##import pdb;pdb.set_trace() + if 'ea_created__app_code_nead!!' in str(get_turn_on_2): + return "ea_created__app_code_nead!!" + if isinstance(get_turn_on_2, str):return get_turn_on_2 + print('ea.get_turn_on_2 >>>', get_turn_on_2) + if not get_turn_on_2: + print('ea.get_turn_on_2 Failed!') + return 'ea.get_turn_on_2 Failed' + sleep(10) + send_green_status(server) + get_send_sec_3 = ea.get_send_sec_3() + if isinstance(get_send_sec_3, str):return get_send_sec_3 + print('finsh >>>', get_send_sec_3) + if not get_send_sec_3: + print('ea.get_send_sec_3 Failed!') + return 'ea.get_send_sec_3 Failed' + sleep(10) + #import pdb;pdb.set_trace() + handel_page_and_code = ea.handel_page_and_code(codex,value,val2) + #import pdb;pdb.set_trace() + if 'ALERT_to_mnay_code_chek' in handel_page_and_code: + return 'ALERT_to_mnay_code_chek' + if isinstance(handel_page_and_code, str):return handel_page_and_code + print('handel_page_and_code >>>', handel_page_and_code) + if not handel_page_and_code: + print('handel_page_and_code Failed!') + return 'handel_page_and_code Failed' + ###########################################^^^^ + ##import pdb;pdb.set_trace() + return handel_page_and_code + + + + + + + + ###################################### send_green_status(server) if 'click_gmail' in str(get_ea): send_green_status(server) - return 'get_ea Failed' + return 'get_ea Failed___1' else: send_green_status(server) print('get_ea Failed!') - return 'get_ea Failed' + return 'get_ea Failed___2' ######################################################################### def create_session(name,pas): @@ -3151,7 +3439,7 @@ def delete_if_low_disk_space(path_to_check, folder_to_delete, threshold_gb=10): #print(codexs.change_lang()) #input('>>') #check_cookiesx=str(codexs.check_cookies()) -#codexs=Gmail('arzw10053@gmail.com','Shwe65544t',browser_proxy='fuck') +#codexs=Gmail('eatestfornewbot9@gmail.com','Shwe65544t',browser_proxy='fuck') #check_cookiesx=str(codexs.check_cookies()) @@ -3170,9 +3458,20 @@ if __name__ == "__main__": server = os.getenv('SERVER_NAME') print(db_config) manager = EmailGroupManager(db_config) - + #t21993837@gmail.com : xxx093382 + #group_data=[{ + # "id":'2', + # "email":'eatestfornewbot9@gmail.com' , + # "email_password": 'pass:aezakmi90', + # }] + + # group_data=[{ + # "id":'2', + # "email":'tiosondemu1988@gmail.com' , + #@ "email_password": 'jxDPlX7Kb2', + # }] + #tiosondemu1988@gmail.com:jxDPlX7Kb2:tiosondemu1988rc@hotmail.com group_data=[] - while True: try: @@ -3207,6 +3506,7 @@ if __name__ == "__main__": os.system("taskkill /f /im chrome.exe") os.system("taskkill /f /im uc_driver.exe") os.system("taskkill /f /im chromedriver.exe") + os.system("taskkill /f /im Camoufox.exe") #df = pd.read_excel(os.path.join(path_file, ixs), engine='openpyxl') print(ixs) # {'id': 4, 'email': 'sunnmp97667@gmail.com', 'email_password': 'Exgvufc6Rxtf'} @@ -3271,19 +3571,44 @@ if __name__ == "__main__": os.system("taskkill /f /im chrome.exe") os.system("taskkill /f /im uc_driver.exe") os.system("taskkill /f /im chromedriver.exe") - + os.system("taskkill /f /im Camoufox.exe") + #input('>>>') codexs=Gmail(value,val2,browser_proxy=browser_proxy) - - + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + minimize_camoufox(title_hint="Camoufox") + #print(codexs) + # code=codexs.get_code() + # print(code) + # #import pdb;pdb.set_trace() + # input('>>>') try: + if codexs.flag_user==False: + check_cookiesx=codexs.flag_user_sg + else: - check_cookiesx=str(codexs.check_cookies()) - if codexs.flag_exit==True: - codexs.flag_exit=None - codexs.end() - codexs=Gmail(value,val2,browser_proxy=browser_proxy) - check_cookiesx=str(codexs.check_cookies()) - + check_cookiesx=(codexs.check_cookies()) + print(check_cookiesx) + # #import pdb;pdb.set_trace() + # check_cookiesx=str(codexs.check_cookies()) + # if codexs.flag_exit==True: + # codexs.flag_exit=None + # codexs.end() + # codexs=Gmail(value,val2,browser_proxy=browser_proxy) + # check_cookiesx=str(codexs.check_cookies()) + if 'fail' in check_cookiesx: + with open('woring_gmail.txt','a')as gy: + gy.write(f"{str(get_tehran_time())} : {value} : {'passw_eror'}\n") + file_data["username"]=value + file_data["totp"]='passw_eror' + file_data["time"]=get_tehran_time() + + manager.update_login_status( + email_id=id_mail, + success=False, + error_message="passw_eror") + clear_selected_folders([value]) + continue if 'pas_eror' in check_cookiesx: with open('woring_gmail.txt','a')as gy: gy.write(f"{str(get_tehran_time())} : {value} : {'passw_eror'}\n") @@ -3365,12 +3690,33 @@ if __name__ == "__main__": error_message="pasword_eror") clear_selected_folders([value]) continue + if 'fail_cookes' in check_cookiesx: + os.system("taskkill /f /im chrome.exe") + os.system("taskkill /f /im chromedriver.exe") + os.system("taskkill /f /im chrome.exe") + os.system("taskkill /f /im uc_driver.exe") + os.system("taskkill /f /im chromedriver.exe") + os.system("taskkill /f /im Camoufox.exe") + clear_selected_folders([value]) + '''with open('woring_gmail.txt','a')as gy: + gy.write(f"{str(get_tehran_time())} : {value} : {'fail_cookes'}\n") + file_data["username"]=value + file_data["totp"]='fail_cookes' + file_data["time"]=get_tehran_time() - print(check_cookiesx) - check_cookiesxddd=check_cookiesx - check_cookiesx=check_cookiesx.replace('"sameSite": "Lax",','',1000).replace('"sameSite": "None",','',1000) - print(check_cookiesx) + manager.update_login_status( + email_id=id_mail, + success=False, + error_message="fail_cookes") + clear_selected_folders([value]) + continue''' + # fail_cookes + #print(check_cookiesx) + #check_cookiesxddd=check_cookiesx + #check_cookiesx=check_cookiesx.replace('"sameSite": "Lax",','',1000).replace('"sameSite": "None",','',1000) + #print(check_cookiesx) except Exception as e: + print(e) #value=ixs['email'] #val2=ixs['email_password'] fxxxx=str(ixs['email']).split('@')[0] @@ -3384,7 +3730,7 @@ if __name__ == "__main__": with open(f'picher\\chek_it_it_________{fxxxx}.txt','w')as gy: try: - gy.write(str(check_cookiesxddd)) + gy.write(str(check_cookiesx)) except: gy.write(str('check_cookiesxddd')) print('cookes can notloaded no set data base',e) @@ -3425,19 +3771,21 @@ if __name__ == "__main__": clear_selected_folders([value]) continue - try: - data = eval(check_cookiesx) - check_cookiesx = json.dumps(data, indent=4) - except Exception as e: - with open('LOGS_cookes.TXT', 'a', encoding='utf-8') as fs: - fs.write(f"{str(get_tehran_time())} : {value} : {e}\n") - print('fail_cookes') - manager.update_login_status( - email_id=id_mail, - success=False, - error_message="fail_cookes") - clear_selected_folders([value]) - continue + # try: + # #import pdb;pdb.set_trace() + #ظdata = eval(check_cookiesx) + # check_cookiesx = json.dumps(data, indent=4) + # except Exception as e: + # print('eval eror') + # with open('LOGS_cookes.TXT', 'a', encoding='utf-8') as fs: + # fs.write(f"{str(get_tehran_time())} : {value} : {e}\n") + # print('fail_cookes') + # manager.update_login_status( + # email_id=id_mail, + # success=False, + # error_message="fail_cookes") + # clear_selected_folders([value]) + #continue manager.update_login_status( email_id=id_mail, @@ -3445,7 +3793,9 @@ if __name__ == "__main__": send_green_status(server) + # #import pdb;pdb.set_trace() result=main(path_png_file,browser,os.path.join(path_file,value),get_cookes=check_cookiesx,codex=codexs,value=value, val2=val2,browser_proxy=browser_proxy) + #import pdb;pdb.set_trace() ################### # fail_15_send_sec_code_app_code # if '11111111' in result: @@ -3565,3 +3915,4 @@ if __name__ == "__main__": print(e) with open('exitlogs.txt','a')as fxs: fxs.write(str(e)+'\n') +