Merge pull request #348 from BasaiCorp/main

Comprehensive Enhancements to Cursor AI Reset and Registration Automation Scripts
This commit is contained in:
Pin Studios 2025-03-22 11:05:13 +08:00 committed by GitHub
commit 225a24aad5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 231 additions and 86 deletions

View File

@ -8,29 +8,44 @@ import requests
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
import logging
# Set up logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
def generate_temp_email(): def generate_temp_email():
"""Generates a temporary email and returns the email and inbox ID.""" """Generates a temporary email using 1secmail API."""
try:
response = requests.get("https://www.1secmail.com/api/v1/?action=genRandomMailbox&count=1") response = requests.get("https://www.1secmail.com/api/v1/?action=genRandomMailbox&count=1")
response.raise_for_status()
email = response.json()[0] email = response.json()[0]
print(f"✅ Generated temp email: {email}") logging.info(f"Generated temp email: {email}")
return email return email
except requests.RequestException as e:
logging.error(f"Failed to generate temp email: {e}")
raise
def extract_inbox(email, retries=5): def extract_inbox(email, retries=5, wait_time=10):
"""Extracts the inbox for the temp email with retries.""" """Extracts the inbox for the temp email with retries."""
domain = email.split('@')[1] domain = email.split('@')[1]
login = email.split('@')[0] login = email.split('@')[0]
inbox_url = f"https://www.1secmail.com/api/v1/?action=getMessages&login={login}&domain={domain}" inbox_url = f"https://www.1secmail.com/api/v1/?action=getMessages&login={login}&domain={domain}"
for attempt in range(retries): for attempt in range(retries):
time.sleep(10) # Allow email to arrive time.sleep(wait_time)
try:
messages = requests.get(inbox_url).json() messages = requests.get(inbox_url).json()
if messages: if messages:
print(f"Inbox found on attempt {attempt + 1}") logging.info(f"Inbox found on attempt {attempt + 1}: {messages[0]['id']}")
return messages[0]['id'] return messages[0]['id']
print(f"🔄 Retry {attempt + 1}/{retries}: No email yet...") logging.info(f"Retry {attempt + 1}/{retries}: No email yet...")
except requests.RequestException as e:
logging.error(f"Error fetching inbox: {e}")
logging.warning("No messages found after retries.")
return None return None
def get_verification_link(email, message_id): def get_verification_link(email, message_id):
@ -38,21 +53,35 @@ def get_verification_link(email, message_id):
domain = email.split('@')[1] domain = email.split('@')[1]
login = email.split('@')[0] login = email.split('@')[0]
msg_url = f"https://www.1secmail.com/api/v1/?action=readMessage&login={login}&domain={domain}&id={message_id}" msg_url = f"https://www.1secmail.com/api/v1/?action=readMessage&login={login}&domain={domain}&id={message_id}"
try:
message = requests.get(msg_url).json() message = requests.get(msg_url).json()
for line in message['body'].splitlines(): for line in message['body'].splitlines():
if "https://github.com/" in line: if "https://github.com/" in line:
print(f"Verification link found: {line}") logging.info(f"Verification link found: {line}")
return line.strip() return line.strip()
logging.warning("Verification link not found in email.")
return None
except requests.RequestException as e:
logging.error(f"Failed to fetch email message: {e}")
return None return None
def reset_machine_id(): def reset_machine_id():
"""Resets the machine ID to bypass Cursor AI's free trial detection.""" """Resets the machine ID to bypass trial detection."""
new_id = str(uuid.uuid4()) new_id = str(uuid.uuid4())
try:
if os.name == 'nt': # Windows if os.name == 'nt': # Windows
os.system(f'reg add "HKLM\SOFTWARE\Microsoft\Cryptography" /v MachineGuid /d {new_id} /f') os.system(f'reg add "HKLM\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid /d {new_id} /f')
else: # Linux/macOS logging.info(f"Machine ID reset on Windows: {new_id}")
elif os.name == 'posix': # Linux/macOS
if os.path.exists("/etc/machine-id"):
os.system(f'echo {new_id} | sudo tee /etc/machine-id') os.system(f'echo {new_id} | sudo tee /etc/machine-id')
print(f"✅ Machine ID reset: {new_id}") logging.info(f"Machine ID reset on Linux: {new_id}")
else:
logging.info("Machine ID reset skipped (macOS or no /etc/machine-id)")
else:
logging.warning("Unsupported OS for machine ID reset.")
except Exception as e:
logging.error(f"Failed to reset machine ID: {e}")
def register_github(email): def register_github(email):
"""Automates GitHub registration with temp email.""" """Automates GitHub registration with temp email."""
@ -61,34 +90,64 @@ def register_github(email):
options.add_argument('--no-sandbox') options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage') options.add_argument('--disable-dev-shm-usage')
driver = None
try:
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://github.com/join") driver.get("https://github.com/join")
# Fill in the registration form # Generate random credentials
username = ''.join(random.choices(string.ascii_letters + string.digits, k=10)) username = ''.join(random.choices(string.ascii_letters + string.digits, k=10))
password = ''.join(random.choices(string.ascii_letters + string.digits, k=15)) password = ''.join(random.choices(string.ascii_letters + string.digits, k=15))
# Fill in the registration form
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "user_login")))
driver.find_element(By.ID, "user_login").send_keys(username) driver.find_element(By.ID, "user_login").send_keys(username)
driver.find_element(By.ID, "user_email").send_keys(email) driver.find_element(By.ID, "user_email").send_keys(email)
driver.find_element(By.ID, "user_password").send_keys(password) driver.find_element(By.ID, "user_password").send_keys(password)
driver.find_element(By.ID, "signup_button").click() driver.find_element(By.ID, "signup_button").click()
# Wait for page transition (GitHub might redirect or show CAPTCHA)
time.sleep(5) time.sleep(5)
logging.info(f"GitHub account created: {username} | {email}")
return username, password
except Exception as e:
logging.error(f"GitHub registration failed: {e}")
raise
finally:
if driver:
driver.quit() driver.quit()
print(f"✅ GitHub account created: {username} | {email}") def register_cursor_with_github(github_username, github_password):
return username, password
def register_cursor_with_github(driver):
"""Logs into Cursor AI using GitHub authentication.""" """Logs into Cursor AI using GitHub authentication."""
options = Options()
options.add_argument('--headless')
driver = None
try:
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://cursor.sh") driver.get("https://cursor.sh")
time.sleep(5)
driver.find_element(By.LINK_TEXT, "Sign in with GitHub").click() # Sign in with GitHub
time.sleep(5) WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(text(), 'Sign in with GitHub')]")))
print("✅ Registered Cursor with GitHub") driver.find_element(By.XPATH, "//a[contains(text(), 'Sign in with GitHub')]").click()
# GitHub login page
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "login_field")))
driver.find_element(By.ID, "login_field").send_keys(github_username)
driver.find_element(By.ID, "password").send_keys(github_password)
driver.find_element(By.NAME, "commit").click()
time.sleep(5) # Wait for login to complete
logging.info("Registered Cursor with GitHub")
except Exception as e:
logging.error(f"Cursor registration failed: {e}")
raise
finally:
if driver:
driver.quit()
def save_credentials(email, github_username, github_password): def save_credentials(email, github_username, github_password):
"""Saves the credentials in a log file.""" """Saves the credentials in a log file."""
try:
with open("github_cursor_accounts.txt", "a") as f: with open("github_cursor_accounts.txt", "a") as f:
f.write(json.dumps({ f.write(json.dumps({
"email": email, "email": email,
@ -96,14 +155,58 @@ def save_credentials(email, github_username, github_password):
"github_password": github_password, "github_password": github_password,
"timestamp": time.strftime('%Y-%m-%d %H:%M:%S') "timestamp": time.strftime('%Y-%m-%d %H:%M:%S')
}) + "\n") }) + "\n")
print("✅ Credentials saved") logging.info("Credentials saved to github_cursor_accounts.txt")
except Exception as e:
logging.error(f"Failed to save credentials: {e}")
def display_features_and_warnings():
"""Displays features and warnings before proceeding."""
print("\n🚀 GitHub + Cursor AI Registration Automation")
print("=====================================")
print("Features:")
print(" - Generates a temporary email using 1secmail.")
print(" - Registers a new GitHub account with random credentials.")
print(" - Verifies the GitHub email automatically.")
print(" - Logs into Cursor AI using GitHub authentication.")
print(" - Resets the machine ID to bypass trial detection.")
print(" - Saves all credentials to a file.")
print("\n⚠️ Warnings:")
print(" - This script automates account creation, which may violate GitHub/Cursor terms of service.")
print(" - Requires internet access and administrative privileges.")
print(" - CAPTCHA or additional verification may interrupt automation.")
print(" - Use responsibly and at your own risk.")
print("=====================================\n")
def get_user_confirmation():
"""Prompts the user for confirmation to proceed."""
while True:
response = input("Do you want to proceed with GitHub + Cursor AI registration? (yes/no): ").lower().strip()
if response in ['yes', 'y']:
return True
elif response in ['no', 'n']:
return False
else:
print("Please enter 'yes' or 'no'.")
def main(): def main():
print("\n🚀 Automating GitHub + Cursor AI Registration...\n") logging.info("Starting GitHub + Cursor AI Registration Automation")
# Display features and warnings
display_features_and_warnings()
if not get_user_confirmation():
logging.info("Operation cancelled by user.")
print("❌ Operation cancelled.")
return
try:
# Step 1: Generate temp email
email = generate_temp_email() email = generate_temp_email()
# Step 2: Register GitHub account
github_username, github_password = register_github(email) github_username, github_password = register_github(email)
# Step 3: Extract and verify email
inbox_id = extract_inbox(email) inbox_id = extract_inbox(email)
if inbox_id: if inbox_id:
verify_link = get_verification_link(email, inbox_id) verify_link = get_verification_link(email, inbox_id)
@ -111,25 +214,32 @@ def main():
options = Options() options = Options()
options.add_argument('--headless') options.add_argument('--headless')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
try:
driver.get(verify_link) driver.get(verify_link)
print("✅ Verified GitHub Email") logging.info("GitHub email verified")
finally:
driver.quit() driver.quit()
else: else:
print("❌ Verification link not found") logging.error("Verification link not found")
return
else: else:
print("❌ Email verification failed") logging.error("Email verification failed")
return
# Automate Cursor AI registration with GitHub # Step 4: Register Cursor with GitHub
options = Options() register_cursor_with_github(github_username, github_password)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
register_cursor_with_github(driver)
# Reset Machine ID # Step 5: Reset Machine ID
reset_machine_id() reset_machine_id()
# Save credentials # Step 6: Save credentials
save_credentials(email, github_username, github_password) save_credentials(email, github_username, github_password)
logging.info("All steps completed successfully!")
print("✅ All steps completed!") print("✅ All steps completed!")
except Exception as e:
logging.error(f"Script failed: {e}")
print(f"❌ An error occurred: {e}")
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -52,11 +52,38 @@ def reset_machine_id():
except Exception as e: except Exception as e:
print(f"❌ Failed to reset machine ID at {path}: {e}") print(f"❌ Failed to reset machine ID at {path}: {e}")
elif platform.system() == "Darwin": # macOS elif platform.system() == "Darwin": # macOS
# macOS typically doesn't use a machine-id file like Linux
print(" macOS does not use a machine-id file. Skipping machine ID reset.") print(" macOS does not use a machine-id file. Skipping machine ID reset.")
else: else:
print("❌ Unsupported operating system for machine ID reset.") print("❌ Unsupported operating system for machine ID reset.")
def display_features_and_warnings():
"""Displays features and warnings before proceeding."""
print("\n🚀 Cursor AI Reset Script")
print("=====================================")
print("Features:")
print(" - Removes Cursor AI configuration directories and files.")
print(" - Cleans up cache, preferences, and application data.")
print(" - Performs a deep scan for hidden Cursor-related files.")
print(" - Resets the machine ID to a new UUID (where applicable).")
print(" - Supports Windows, Linux, and macOS.")
print("\n⚠️ Warnings:")
print(" - This action is IRREVERSIBLE. All Cursor AI data will be deleted.")
print(" - Requires administrative privileges for some operations (e.g., machine ID reset on Windows/Linux).")
print(" - May disrupt Cursor AI functionality until reinstalled or reconfigured.")
print(" - Backup any important Cursor data before proceeding.")
print("=====================================\n")
def get_user_confirmation():
"""Prompts the user for confirmation to proceed."""
while True:
response = input("Do you want to proceed with resetting Cursor AI? (yes/no): ").lower().strip()
if response in ['yes', 'y']:
return True
elif response in ['no', 'n']:
return False
else:
print("Please enter 'yes' or 'no'.")
def reset_cursor(): def reset_cursor():
print("\n🚀 Resetting Cursor AI...\n") print("\n🚀 Resetting Cursor AI...\n")
@ -133,9 +160,17 @@ def reset_cursor():
def main(): def main():
start_time = time.time() start_time = time.time()
# Display features and warnings
display_features_and_warnings()
# Get user confirmation
if get_user_confirmation():
reset_cursor() reset_cursor()
end_time = time.time() end_time = time.time()
print(f"\n⏱️ Completed in {end_time - start_time:.2f} seconds.") print(f"\n⏱️ Completed in {end_time - start_time:.2f} seconds.")
else:
print("\n❌ Operation cancelled by user.")
if __name__ == '__main__': if __name__ == '__main__':
main() main()