""" @ Base: https://app.khoj.dev/ @ Author: Shannz @ Note: Signup script to get cookie for khojai. """ import requests import time import re import sys HEADERS = { 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Mobile Safari/537.36', 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json', 'Origin': 'https://app.khoj.dev', 'Referer': 'https://app.khoj.dev/?v=app', 'sec-ch-ua-platform': '"Android"', 'sec-ch-ua-mobile': '?1', 'sec-fetch-site': 'same-origin', 'sec-fetch-mode': 'cors', 'sec-fetch-dest': 'empty', 'accept-language': 'id,en-US;q=0.9,en;q=0.8', } CONFIG = { 'KHOJ_MAGIC': 'https://app.khoj.dev/auth/magic', 'MAIL_LIST': 'https://akunlama.com/api/v1/mail/list', 'MAIL_HTML': 'https://akunlama.com/api/v1/mail/getHtml' } def get_input(prompt): return input(f"\n[?] {prompt}") def print_status(msg, type="info"): if type == "info": print(f"[*] {msg}") elif type == "success": print(f"\n[+] {msg}") elif type == "error": print(f"\n[!] {msg}") elif type == "process": sys.stdout.write(f"\r[~] {msg}") sys.stdout.flush() class KhojAuth: def __init__(self): self.session = requests.Session() self.session.headers.update(HEADERS) def request_otp(self, email): print_status(f"Mengirim kode login ke: {email}", "info") try: payload = {"email": email} resp = self.session.post(CONFIG['KHOJ_MAGIC'], json=payload) if resp.status_code == 200: print_status("Request berhasil dikirim.", "success") return True else: print_status(f"Gagal request. Status: {resp.status_code}", "error") return False except Exception as e: print_status(f"Error Request: {e}", "error") return False def get_verification_code(self, username): print_status("Menunggu email masuk...", "info") attempts = 0 max_attempts = 30 while attempts < max_attempts: try: resp = requests.get(f"{CONFIG['MAIL_LIST']}?recipient={username}") inbox = resp.json() if inbox and len(inbox) > 0: latest_mail = inbox[0] subject = latest_mail.get('message', {}).get('headers', {}).get('subject', '') if "Khoj" in subject or "Login" in subject: storage = latest_mail.get('storage', {}) key = storage.get('key') region = storage.get('region') if key and region: html_resp = requests.get(CONFIG['MAIL_HTML'], params={'key': key, 'region': region}) html_content = html_resp.text match = re.search(r'