From 3a445b57f334d25420f6f90b07162aec29f03a79 Mon Sep 17 00:00:00 2001 From: inivert Date: Wed, 11 Jun 2025 12:47:28 -0400 Subject: [PATCH] feat: Add modular setup system for AutoRecon - Add comprehensive Makefile with setup, clean, update, and Docker commands - Add modular shell scripts for cross-platform installation - Support for Debian/Ubuntu, macOS, Arch Linux, and Docker environments - Automated OS detection and tool installation - Python virtual environment management with global command creation - Docker image building and interactive terminal support - Complete cleanup and update functionality - Extensive documentation and contribution guide Contributor: neur0map --- AUTORECON_CONTRIBUTION_GUIDE.md | 374 +++++++++++++++++++++++++++ Makefile | 56 ++++ REQUIRED_CHANGES_FOR_AUTORECON.md | 412 ++++++++++++++++++++++++++++++ scripts/README.md | 108 ++++++++ scripts/cleanup.sh | 181 +++++++++++++ scripts/detect-os.sh | 29 +++ scripts/install-tools-arch.sh | 23 ++ scripts/install-tools-debian.sh | 67 +++++ scripts/install-tools-macos.sh | 44 ++++ scripts/install-tools.sh | 62 +++++ scripts/setup-docker.sh | 116 +++++++++ scripts/setup-python.sh | 84 ++++++ scripts/system-check.sh | 84 ++++++ scripts/update.sh | 205 +++++++++++++++ 14 files changed, 1845 insertions(+) create mode 100644 AUTORECON_CONTRIBUTION_GUIDE.md create mode 100644 Makefile create mode 100644 REQUIRED_CHANGES_FOR_AUTORECON.md create mode 100644 scripts/README.md create mode 100755 scripts/cleanup.sh create mode 100755 scripts/detect-os.sh create mode 100755 scripts/install-tools-arch.sh create mode 100755 scripts/install-tools-debian.sh create mode 100755 scripts/install-tools-macos.sh create mode 100755 scripts/install-tools.sh create mode 100755 scripts/setup-docker.sh create mode 100755 scripts/setup-python.sh create mode 100755 scripts/system-check.sh create mode 100755 scripts/update.sh diff --git a/AUTORECON_CONTRIBUTION_GUIDE.md b/AUTORECON_CONTRIBUTION_GUIDE.md new file mode 100644 index 0000000..43671b3 --- /dev/null +++ b/AUTORECON_CONTRIBUTION_GUIDE.md @@ -0,0 +1,374 @@ +# AutoRecon Modular Setup System - Contribution Guide + +## Overview + +This document outlines the modular setup system developed by **neur0map** for AutoRecon, providing comprehensive installation, management, and maintenance capabilities across multiple operating systems. The system consists of a Makefile and supporting shell scripts that automate the entire AutoRecon setup process. + +## System Architecture + +### Core Components + +``` +Makefile (Entry Point) +├── scripts/system-check.sh (Prerequisites & OS detection) +├── scripts/detect-os.sh (OS detection helper for Makefile) +├── scripts/install-tools.sh (Installation router) +│ ├── scripts/install-tools-debian.sh (Debian/Ubuntu/Kali/Parrot) +│ ├── scripts/install-tools-macos.sh (macOS with Homebrew) +│ └── scripts/install-tools-arch.sh (Arch Linux/Manjaro) +├── scripts/setup-python.sh (Python environment & command setup) +├── scripts/setup-docker.sh (Docker management) +├── scripts/update.sh (Maintenance & updates) +└── scripts/cleanup.sh (Complete removal) +``` + +### Workflow Dependencies + +``` +make setup: + system-check.sh → detect-os.sh → install-tools.sh → setup-python.sh + +make update: + update.sh → (git pull → python update → tools update → docker rebuild) + +make clean: + cleanup.sh → (remove venv → remove tools → remove docker → cleanup results) +``` + +## Available Commands + +### 1. Primary Setup Commands + +#### `make setup` +**Purpose**: Complete local installation with auto-detected OS support +**When to use**: First-time setup or fresh installation +**What it does**: +- Detects operating system and prerequisites +- Installs security tools based on OS +- Sets up Python virtual environment +- Creates global `autorecon` command +- Provides ready-to-use AutoRecon installation + +**Output Example**: +``` +Setting up AutoRecon... + +🔍 Checking prerequisites... +✅ Python 3.10.12 detected +✅ Detected: ubuntu + +📦 Installing security tools for ubuntu (Debian-based)... +[...tool installation...] + +🐍 Setting up Python environment... +📦 Installing Python dependencies... +🔧 Creating autorecon command... + +✅ Setup complete! +``` + +#### `make setup-docker` +**Purpose**: Docker-based setup with interactive terminal +**When to use**: +- Non-Kali systems requiring full tool support +- Isolated/containerized environment preferred +- Local tool installation not desired + +**What it does**: +- Builds AutoRecon Docker image +- Launches interactive container terminal +- Mounts results directory for persistence +- Provides full security toolkit in container + +#### `make clean` +**Purpose**: Complete removal of AutoRecon installation +**When to use**: +- Uninstalling AutoRecon +- Starting fresh after issues +- Freeing up disk space + +**What it does**: +- Removes Python virtual environment +- Removes installed security tools (with confirmation) +- Removes Docker images +- Removes global commands +- Cleans up temporary files + +### 2. Maintenance Commands + +#### `make update` +**Purpose**: Update all components to latest versions +**When to use**: +- Regular maintenance (weekly/monthly) +- After AutoRecon repository updates +- Before major scanning projects + +**What it does**: +- Updates git repository with latest changes +- Updates Python packages +- Updates system security tools +- Rebuilds Docker image if needed +- Shows summary of changes + +#### `make docker-cmd` +**Purpose**: Launch additional Docker terminal sessions +**When to use**: +- Multiple concurrent scanning sessions +- After `make setup-docker` for additional terminals + +### 3. Help Command + +#### `make help` +**Purpose**: Display comprehensive usage information +**Contains**: +- All available commands +- OS compatibility matrix +- Usage recommendations +- Docker workflow guide + +## Operating System Support + +### Tier 1: Full Support (20+ Security Tools) +- **Kali Linux**: Native security distribution +- **Parrot OS**: Security-focused distribution +- **Ubuntu/Debian**: Comprehensive apt-based installation +- **macOS**: Homebrew-based toolkit (15+ tools) + +### Tier 2: Basic Support +- **Arch/Manjaro**: Core tools only (nmap, curl, wget, git) +- **Other Linux**: Fallback to basic tools + +### Tier 3: Docker Recommended +- **Windows**: Use WSL + Docker +- **Unsupported systems**: Docker provides full functionality + +## Script Details + +### system-check.sh +**Purpose**: Prerequisites validation and OS detection +**Exports**: `OS_ID`, `OS_ID_LIKE`, `WSL_DETECTED` +**Checks**: +- Python 3.8+ availability +- Operating system identification +- WSL environment detection +- Package manager availability + +### install-tools.sh (Router) +**Purpose**: Routes to appropriate OS-specific installer +**Parameters**: `OS_ID`, `OS_ID_LIKE`, `WSL_DETECTED` +**Routes to**: +- `install-tools-debian.sh` for Debian-based systems +- `install-tools-macos.sh` for macOS +- `install-tools-arch.sh` for Arch-based systems + +### install-tools-debian.sh +**Tools Installed**: +```bash +# Core tools +curl wget git nmap nikto whatweb sslscan smbclient + +# Enumeration tools +seclists dnsrecon enum4linux feroxbuster gobuster +impacket-scripts nbtscan onesixtyone oscanner +redis-tools smbmap snmp sipvicious tnscmd10g +``` + +**WSL Compatibility**: Includes snap package fallbacks + +### install-tools-macos.sh +**Tools Installed**: +```bash +# Core network tools +nmap curl wget git gobuster nikto whatweb sslscan + +# Enumeration tools +feroxbuster redis-tools smbclient + +# Additional security tools +hydra john-jumbo hashcat sqlmap exploitdb binwalk exiftool + +# Python tools +impacket crackmapexec enum4linux-ng +``` + +### install-tools-arch.sh +**Limited Installation**: Basic tools only (nmap, curl, wget, git, python) +**Recommendation**: Use Docker for full functionality + +### setup-python.sh +**Functions**: +- Creates Python virtual environment +- Installs requirements.txt dependencies +- Creates `autorecon-cmd` script +- Installs global `/usr/local/bin/autorecon` command +- Handles permission issues gracefully + +### setup-docker.sh +**Functions**: +- Docker availability verification +- AutoRecon image building +- Interactive container launch +- Results directory mounting +- Container session management + +### update.sh +**Update Process**: +1. **Git Update**: Pull latest changes, handle stashes +2. **Python Update**: Upgrade pip and packages +3. **Tools Update**: OS-appropriate tool updates +4. **Docker Update**: Rebuild if Dockerfile changed +5. **Summary**: Show what was updated + +### cleanup.sh +**Removal Process**: +1. **Python Environment**: Remove venv and commands +2. **Security Tools**: OS-specific removal (with confirmation) +3. **Docker Resources**: Remove images and containers +4. **Results**: Clean empty directories +5. **Warning**: Notify about active virtual environments + +## Usage Patterns + +### 1. First Time Setup +```bash +# Clone AutoRecon repository +git clone https://github.com/Tib3rius/AutoRecon.git +cd AutoRecon + +# Full local setup +make setup + +# Test installation +autorecon --help +autorecon 127.0.0.1 +``` + +### 2. Docker-Based Setup +```bash +# Docker setup (recommended for non-Kali) +make setup-docker + +# Inside container: +autorecon --help +autorecon target.com +ls /scans # View results + +# Additional sessions +make docker-cmd +``` + +### 3. Regular Maintenance +```bash +# Weekly/monthly updates +make update + +# Check for issues +autorecon --help + +# If problems occur +make clean +make setup +``` + +### 4. Contributing Development +```bash +# Setup development environment +make setup + +# Make changes to AutoRecon code +# ... + +# Test changes +autorecon test-target + +# Update after pulling latest +make update +``` + +## Integration Notes for AutoRecon + +### Required Changes for Integration + +1. **Project Name References**: Change all instances of "ipcrawler" to "autorecon" in: + - `setup-python.sh` (command creation) + - `setup-docker.sh` (image names and references) + - `cleanup.sh` (removal procedures) + - `Makefile` (help text and commands) + +2. **Global Command**: Scripts create `/usr/local/bin/autorecon` instead of `/usr/local/bin/ipcrawler` + +3. **Docker Integration**: Requires existing `Dockerfile` and `requirements.txt` in repository root + +### File Structure Requirements +``` +AutoRecon/ +├── Makefile +├── scripts/ +│ ├── system-check.sh +│ ├── detect-os.sh +│ ├── install-tools.sh +│ ├── install-tools-debian.sh +│ ├── install-tools-macos.sh +│ ├── install-tools-arch.sh +│ ├── setup-python.sh +│ ├── setup-docker.sh +│ ├── update.sh +│ └── cleanup.sh +├── requirements.txt +├── Dockerfile +└── autorecon.py +``` + +## Benefits for AutoRecon Project + +### 1. User Experience +- **Simplified Installation**: Single `make setup` command +- **Cross-Platform**: Automated OS detection and appropriate tool installation +- **Maintenance**: Easy updates with `make update` +- **Cleanup**: Complete removal with `make clean` + +### 2. Developer Experience +- **Consistent Environment**: Standardized setup across contributors +- **Docker Integration**: Isolated development environments +- **Modular Design**: Easy to modify and extend +- **Error Handling**: Graceful failures with helpful messages + +### 3. Documentation +- **Self-Documenting**: `make help` provides comprehensive guidance +- **Status Messages**: Clear feedback during installation +- **OS-Specific**: Tailored instructions for each platform + +### 4. Maintenance +- **Automated Updates**: Handles git, Python, tools, and Docker +- **Dependency Management**: Ensures all components stay current +- **Clean Removal**: Complete uninstall capability + +## Contribution Guidelines + +### For Pull Request +1. Create feature branch from main AutoRecon repository +2. Update project references from "ipcrawler" to "autorecon" +3. Test on multiple operating systems: + - Ubuntu/Debian + - Kali Linux + - macOS (with Homebrew) + - Arch Linux +4. Verify Docker functionality +5. Update documentation as needed + +### Testing Checklist +- [ ] `make setup` works on supported OS +- [ ] `make setup-docker` builds and runs +- [ ] `make update` updates all components +- [ ] `make clean` removes everything +- [ ] Global `autorecon` command functions +- [ ] Error handling works for unsupported systems +- [ ] WSL compatibility verified + +## Author + +**Contributor**: neur0map +**Original Project**: AutoRecon by Tib3rius +**Fork**: ipcrawler (source of these enhancements) + +This modular setup system significantly enhances AutoRecon's accessibility and maintainability across diverse operating systems and deployment scenarios. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d479994 --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +.PHONY: setup clean setup-docker docker-cmd help update + +setup: + @echo "Setting up autorecon..." && \ + echo "" && \ + ./scripts/system-check.sh && \ + echo "" && \ + . scripts/detect-os.sh && \ + ./scripts/install-tools.sh "$$OS_ID" "$$OS_ID_LIKE" "$$WSL_DETECTED" && \ + echo "" && \ + ./scripts/setup-python.sh + +clean: + @./scripts/cleanup.sh + +setup-docker: + @./scripts/setup-docker.sh + +docker-cmd: + @echo "Starting autorecon Docker container..." + @echo "Results will be saved to: $$(pwd)/results" + @echo "Type 'exit' to leave the container" + @echo "" + docker run -it --rm -v "$$(pwd)/results:/scans" autorecon || true + +help: + @echo "Available make commands:" + @echo "" + @echo " setup - Set up local Python virtual environment + install security tools" + @echo " clean - Remove local setup, virtual environment, and Docker resources" + @echo " setup-docker - Build Docker image + open interactive terminal for autorecon" + @echo " update - Update repository, tools, and Docker image" + @echo " docker-cmd - Run interactive Docker container" + @echo " help - Show this help message" + @echo "" + @echo "Supported Operating Systems:" + @echo " • Kali Linux - Full tool installation (20+ security tools)" + @echo " • Parrot OS - Full tool installation (20+ security tools)" + @echo " • Ubuntu/Debian - Full tool installation (20+ security tools)" + @echo " • macOS (Homebrew) - Comprehensive toolkit (15+ security tools)" + @echo " • Arch/Manjaro - Basic tools (nmap, curl, wget, git)" + @echo " • Other systems - Python setup only (use Docker for full features)" + @echo "" + @echo "Docker Usage (Recommended for non-Kali systems):" + @echo " 1. Install Docker manually for your OS first" + @echo " 2. make setup-docker # Build image + open interactive terminal" + @echo " 3. make docker-cmd # Start additional interactive sessions" + @echo " 4. Inside container: /show-tools.sh or /install-extra-tools.sh" + @echo "" + @echo "Local Usage:" + @echo " 1. make setup # Set up locally with auto tool installation" + @echo " 2. autorecon --help # Use the tool" + @echo " 3. make update # Keep everything updated" + +update: + @./scripts/update.sh diff --git a/REQUIRED_CHANGES_FOR_AUTORECON.md b/REQUIRED_CHANGES_FOR_AUTORECON.md new file mode 100644 index 0000000..2174b69 --- /dev/null +++ b/REQUIRED_CHANGES_FOR_AUTORECON.md @@ -0,0 +1,412 @@ +# Required Changes for AutoRecon Integration + +## CRITICAL: These scripts will NOT work with AutoRecon without the following changes + +### 1. setup-python.sh Changes + +**Line 35**: Change command name reference +```bash +# Current: +echo "🔧 Creating ipcrawler command..." + +# Change to: +echo "🔧 Creating autorecon command..." +``` + +**Line 38**: Change command file name +```bash +# Current: +rm -f ipcrawler-cmd + +# Change to: +rm -f autorecon-cmd +``` + +**Line 41**: Change command script name +```bash +# Current: +cat > ipcrawler-cmd << 'EOF' + +# Change to: +cat > autorecon-cmd << 'EOF' +``` + +**Line 46**: Change Python script reference +```bash +# Current: +source "$DIR/venv/bin/activate" && python3 "$DIR/ipcrawler.py" "$@" + +# Change to: +source "$DIR/venv/bin/activate" && python3 "$DIR/autorecon.py" "$@" +``` + +**Line 50**: Change command file name +```bash +# Current: +chmod +x ipcrawler-cmd + +# Change to: +chmod +x autorecon-cmd +``` + +**Line 54**: Change global command installation +```bash +# Current: +if ! sudo ln -sf "$(pwd)/ipcrawler-cmd" /usr/local/bin/ipcrawler 2>/dev/null; then + +# Change to: +if ! sudo ln -sf "$(pwd)/autorecon-cmd" /usr/local/bin/autorecon 2>/dev/null; then +``` + +**Line 56**: Change usage message +```bash +# Current: +echo "💡 You can still use: ./ipcrawler-cmd or add to PATH manually" + +# Change to: +echo "💡 You can still use: ./autorecon-cmd or add to PATH manually" +``` + +**Lines 68-69**: Change help examples +```bash +# Current: +echo " • Run: ipcrawler --help" +echo " • Test with: ipcrawler 127.0.0.1" + +# Change to: +echo " • Run: autorecon --help" +echo " • Test with: autorecon 127.0.0.1" +``` + +### 2. setup-docker.sh Changes + +**Line 33**: Change Docker image name check +```bash +# Current: +if docker images -q ipcrawler >/dev/null 2>&1 && [ -n "$(docker images -q ipcrawler)" ]; then + +# Change to: +if docker images -q autorecon >/dev/null 2>&1 && [ -n "$(docker images -q autorecon)" ]; then +``` + +**Line 34**: Change success message +```bash +# Current: +echo "✅ ipcrawler Docker image found" + +# Change to: +echo "✅ autorecon Docker image found" +``` + +**Line 37**: Change not found message +```bash +# Current: +echo "ℹ️ ipcrawler Docker image not found" + +# Change to: +echo "ℹ️ autorecon Docker image not found" +``` + +**Line 42**: Change function name +```bash +# Current: +build_ipcrawler_image() { + +# Change to: +build_autorecon_image() { +``` + +**Line 43**: Change build message +```bash +# Current: +echo "🐳 Building ipcrawler Docker image..." + +# Change to: +echo "🐳 Building autorecon Docker image..." +``` + +**Line 47**: Change directory reference +```bash +# Current: +echo "Please run this command from the ipcrawler directory" + +# Change to: +echo "Please run this command from the autorecon directory" +``` + +**Line 51**: Change Docker build command +```bash +# Current: +if docker build -t ipcrawler . ; then + +# Change to: +if docker build -t autorecon . ; then +``` + +**Line 52**: Change success message +```bash +# Current: +echo "✅ ipcrawler Docker image built successfully!" + +# Change to: +echo "✅ autorecon Docker image built successfully!" +``` + +**Line 61**: Change terminal startup message +```bash +# Current: +echo "🚀 Starting ipcrawler Docker terminal..." + +# Change to: +echo "🚀 Starting autorecon Docker terminal..." +``` + +**Lines 64-66**: Change command examples +```bash +# Current: +echo " • ipcrawler --help (Show help)" +echo " • ipcrawler 127.0.0.1 (Test scan)" +echo " • ipcrawler target.com (Scan target)" + +# Change to: +echo " • autorecon --help (Show help)" +echo " • autorecon 127.0.0.1 (Test scan)" +echo " • autorecon target.com (Scan target)" +``` + +**Line 79**: Change working directory (verify AutoRecon Dockerfile) +```bash +# Current: +-w /opt/ipcrawler \ + +# Change to: +-w /opt/autorecon \ +# OR check AutoRecon's Dockerfile for correct path +``` + +**Line 80**: Change container name +```bash +# Current: +--name ipcrawler-session \ + +# Change to: +--name autorecon-session \ +``` + +**Line 81**: Change image name +```bash +# Current: +ipcrawler bash + +# Change to: +autorecon bash +``` + +**Line 84**: Change session end message +```bash +# Current: +echo "👋 ipcrawler session ended" + +# Change to: +echo "👋 autorecon session ended" +``` + +**Line 90**: Change setup title +```bash +# Current: +echo "🐳 ipcrawler Docker Setup" + +# Change to: +echo "🐳 autorecon Docker Setup" +``` + +**Line 102**: Change function call +```bash +# Current: +build_ipcrawler_image + +# Change to: +build_autorecon_image +``` + +### 3. cleanup.sh Changes + +**Line 16**: Change command file name +```bash +# Current: +rm -f ipcrawler-cmd + +# Change to: +rm -f autorecon-cmd +``` + +**Line 19**: Change removal message +```bash +# Current: +echo "🗑️ Removing ipcrawler from /usr/local/bin..." + +# Change to: +echo "🗑️ Removing autorecon from /usr/local/bin..." +``` + +**Line 20**: Change global command removal +```bash +# Current: +sudo rm -f /usr/local/bin/ipcrawler + +# Change to: +sudo rm -f /usr/local/bin/autorecon +``` + +**Lines 112-121**: Change all Docker references +```bash +# Current: +if [ -n "$(docker images -q ipcrawler 2>/dev/null)" ]; then + echo "Stopping any running ipcrawler containers..." + docker ps -aq --filter ancestor=ipcrawler 2>/dev/null | xargs -r docker stop >/dev/null 2>&1 || true + docker ps -aq --filter ancestor=ipcrawler 2>/dev/null | xargs -r docker rm >/dev/null 2>&1 || true + + echo "Removing ipcrawler Docker image..." + docker rmi ipcrawler >/dev/null 2>&1 || true + echo "Docker image removed." +else + echo "No ipcrawler Docker image found." +fi + +# Change to: +if [ -n "$(docker images -q autorecon 2>/dev/null)" ]; then + echo "Stopping any running autorecon containers..." + docker ps -aq --filter ancestor=autorecon 2>/dev/null | xargs -r docker stop >/dev/null 2>&1 || true + docker ps -aq --filter ancestor=autorecon 2>/dev/null | xargs -r docker rm >/dev/null 2>&1 || true + + echo "Removing autorecon Docker image..." + docker rmi autorecon >/dev/null 2>&1 || true + echo "Docker image removed." +else + echo "No autorecon Docker image found." +fi +``` + +**Line 160**: Change cleanup title +```bash +# Current: +echo "Cleaning up ipcrawler installation..." + +# Change to: +echo "Cleaning up autorecon installation..." +``` + +### 4. update.sh Changes + +**Line 125**: Change Docker image check +```bash +# Current: +if [ "$DOCKERFILE_CHANGED" = "true" ] || [ ! -n "$(docker images -q ipcrawler 2>/dev/null)" ]; then + +# Change to: +if [ "$DOCKERFILE_CHANGED" = "true" ] || [ ! -n "$(docker images -q autorecon 2>/dev/null)" ]; then +``` + +**Line 127**: Change Docker build command +```bash +# Current: +if docker build -t ipcrawler .; then + +# Change to: +if docker build -t autorecon .; then +``` + +**Line 167**: Change ready message +```bash +# Current: +echo "🎯 Ready to use updated ipcrawler!" + +# Change to: +echo "🎯 Ready to use updated autorecon!" +``` + +**Line 172**: Change update title +```bash +# Current: +echo "Updating ipcrawler installation..." + +# Change to: +echo "Updating autorecon installation..." +``` + +### 5. Makefile Changes + +**Line 3**: Change setup message +```bash +# Current: +@echo "Setting up ipcrawler..." && \ + +# Change to: +@echo "Setting up autorecon..." && \ +``` + +**Line 19**: Change Docker message +```bash +# Current: +@echo "Starting ipcrawler Docker container..." + +# Change to: +@echo "Starting autorecon Docker container..." +``` + +**Line 23**: Change Docker run command +```bash +# Current: +docker run -it --rm -v "$$(pwd)/results:/scans" ipcrawler || true + +# Change to: +docker run -it --rm -v "$$(pwd)/results:/scans" autorecon || true +``` + +**Line 30**: Change help text +```bash +# Current: +@echo " setup-docker - Build Docker image + open interactive terminal for ipcrawler" + +# Change to: +@echo " setup-docker - Build Docker image + open interactive terminal for autorecon" +``` + +**Line 51**: Change usage example +```bash +# Current: +@echo " 2. ipcrawler --help # Use the tool" + +# Change to: +@echo " 2. autorecon --help # Use the tool" +``` + +### 6. README.md Changes + +**Line 2**: Change description +```bash +# Current: +This directory contains modular scripts that handle different aspects of ipcrawler setup and maintenance. + +# Change to: +This directory contains modular scripts that handle different aspects of autorecon setup and maintenance. +``` + +## Additional Requirements + +### Check AutoRecon Repository Structure +Before implementing changes, verify: +1. **Main script name**: Confirm AutoRecon uses `autorecon.py` +2. **Dockerfile working directory**: Check what path AutoRecon's Dockerfile uses +3. **Requirements file**: Ensure `requirements.txt` exists +4. **Dependencies**: Verify AutoRecon's dependency requirements + +### Testing After Changes +1. Test `make setup` on clean system +2. Test `make setup-docker` builds correctly +3. Test global `autorecon` command works +4. Test `make clean` removes everything +5. Test `make update` functions properly + +## Summary +**73 lines across 6 files** need changes to work with AutoRecon. These are not optional - the scripts will fail without these modifications. \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..dc1ebee --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,108 @@ +# Scripts Directory + +This directory contains modular scripts that handle different aspects of autorecon setup and maintenance. These scripts are called by the Makefile to keep it clean and organized. + +## Script Overview + +| Script | Purpose | Usage | +|--------|---------|-------| +| `system-check.sh` | System prerequisites and OS detection | `./scripts/system-check.sh` | +| `install-tools.sh` | Security tools installation router | `./scripts/install-tools.sh [OS_ID] [OS_ID_LIKE] [WSL_DETECTED]` | +| `install-tools-debian.sh` | Debian/Ubuntu specific tool installation | `./scripts/install-tools-debian.sh [WSL_DETECTED]` | +| `install-tools-macos.sh` | macOS specific tool installation | `./scripts/install-tools-macos.sh` | +| `install-tools-arch.sh` | Arch Linux specific tool installation | `./scripts/install-tools-arch.sh` | +| `setup-python.sh` | Python virtual environment setup | `./scripts/setup-python.sh` | +| `setup-docker.sh` | Docker image building and terminal launch | `./scripts/setup-docker.sh` | +| `cleanup.sh` | Complete installation cleanup | `./scripts/cleanup.sh` | +| `update.sh` | Git, tools, and Docker updates | `./scripts/update.sh` | + +## Dependencies Between Scripts + +``` +system-check.sh + ↓ (exports OS variables) +install-tools.sh → install-tools-debian.sh + → install-tools-macos.sh + → install-tools-arch.sh + ↓ +setup-python.sh + ↓ +[Complete setup] +``` + +For updates: +``` +update.sh → calls → system-check.sh (for OS detection) +``` + +## Script Features + +### Common Features +- **Modular**: Each script has a single responsibility +- **Reusable**: Can be called independently or from Makefile +- **Source-able**: Functions can be sourced by other scripts +- **Self-documenting**: Clear output with emojis and status messages + +### Error Handling +- Graceful failure with informative error messages +- Exit codes properly set for Makefile integration +- Fallback options when primary methods fail + +### OS Support +- **Linux**: Debian/Ubuntu, Arch/Manjaro, Kali/Parrot +- **macOS**: Homebrew-based installation +- **Windows**: WSL detection and compatibility +- **Fallback**: Basic setup for unsupported systems + +## Usage Examples + +### Direct Script Usage +```bash +# Check system requirements +./scripts/system-check.sh + +# Install tools after system check +source ./scripts/system-check.sh +./scripts/install-tools.sh + +# Setup Python environment +./scripts/setup-python.sh + +# Full cleanup +./scripts/cleanup.sh +``` + +### Environment Variable Passing +```bash +# Export variables from system-check +source ./scripts/system-check.sh +export OS_ID OS_ID_LIKE WSL_DETECTED + +# Use in install-tools +./scripts/install-tools.sh "$OS_ID" "$OS_ID_LIKE" "$WSL_DETECTED" +``` + +## Maintenance + +### Adding New Features +1. Keep scripts focused on single responsibilities +2. Use consistent output formatting (emojis + clear messages) +3. Add proper error handling and exit codes +4. Update this README when adding new scripts + +### Testing +Each script should work independently and be testable on various operating systems: +- Test on multiple Linux distributions +- Test on macOS with and without Homebrew +- Test in WSL environments +- Test error conditions and fallbacks + +## Integration with Makefile + +The Makefile calls these scripts to provide a clean interface: +- `make setup` → calls system-check, install-tools (→ OS-specific), setup-python +- `make clean` → calls cleanup.sh +- `make setup-docker` → calls setup-docker.sh (build + launch terminal) +- `make update` → calls update.sh + +This modular approach makes the Makefile much cleaner and easier to maintain while providing the same functionality. \ No newline at end of file diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh new file mode 100755 index 0000000..9757702 --- /dev/null +++ b/scripts/cleanup.sh @@ -0,0 +1,181 @@ +#!/bin/bash + +# Cleanup Script +# Usage: ./scripts/cleanup.sh + +cleanup_python() { + echo "🧹 Removing virtual environment and command..." + + # Check if currently in virtual environment + if [ -n "$VIRTUAL_ENV" ]; then + echo "⚠️ You are currently in a virtual environment" + echo "💡 Please run 'deactivate' after cleanup completes" + fi + + # Remove virtual environments + rm -rf venv .venv + rm -f autorecon-cmd + + # Remove global command + echo "🗑️ Removing autorecon from /usr/local/bin..." + sudo rm -f /usr/local/bin/autorecon +} + +cleanup_tools() { + echo "🗑️ Removing installed security tools..." + + # Detect OS for proper cleanup + if [ -f /etc/os-release ]; then + OS_ID=$(grep '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"') + OS_ID_LIKE=$(grep '^ID_LIKE=' /etc/os-release | cut -d'=' -f2 | tr -d '"' 2>/dev/null || echo "") + + if [ "$OS_ID" = "kali" ] || [ "$OS_ID" = "parrot" ] || echo "$OS_ID_LIKE" | grep -q "debian\|ubuntu"; then + cleanup_debian_tools + elif [ "$OS_ID" = "arch" ] || [ "$OS_ID" = "manjaro" ]; then + echo "ℹ️ Arch-based system detected. Basic tools (nmap, curl, wget, git) left installed." + else + echo "ℹ️ No tools to remove for $OS_ID." + fi + + elif [ "$(uname)" = "Darwin" ]; then + cleanup_macos_tools + else + echo "ℹ️ Unknown OS - no tools to remove." + fi +} + +cleanup_debian_tools() { + echo "Removing security tools for Debian-based system..." + echo "⚠️ Note: This will remove security tools that may be used by other applications" + + # Check if running interactively + if [ -t 0 ]; then + read -p "Remove security tools? [y/N]: " -n 1 -r + echo + else + echo "Reading confirmation from input..." + read -r REPLY + fi + + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "Removing apt-installed security tools..." + local tools="seclists dnsrecon enum4linux feroxbuster gobuster impacket-scripts nbtscan nikto onesixtyone oscanner redis-tools smbclient smbmap snmp sslscan sipvicious tnscmd10g whatweb" + + for tool in $tools; do + if dpkg -l | grep -q "^ii.*$tool" 2>/dev/null; then + echo "Removing $tool..." + sudo apt remove -y $tool 2>/dev/null || echo "Failed to remove $tool" + fi + done + + echo "Core tools (nmap, curl, wget, git) left installed." + else + echo "Skipping tool removal." + fi +} + +cleanup_macos_tools() { + echo "Removing security tools for macOS..." + echo "⚠️ Note: This will remove security tools that may be used by other applications" + + # Check if running interactively + if [ -t 0 ]; then + read -p "Remove security tools? [y/N]: " -n 1 -r + echo + else + echo "Reading confirmation from input..." + read -r REPLY + fi + + if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "Removing Homebrew security tools..." + local tools="gobuster nikto whatweb sslscan feroxbuster redis-tools smbclient hydra john-jumbo hashcat sqlmap exploitdb binwalk exiftool" + + for tool in $tools; do + if brew list | grep -q "^$tool$" 2>/dev/null; then + echo "Removing $tool..." + brew uninstall --ignore-dependencies $tool 2>/dev/null || echo "Failed to remove $tool" + fi + done + + echo "Removing Python security tools..." + python3 -m pip uninstall -y impacket crackmapexec enum4linux-ng 2>/dev/null || echo "Some Python tools couldn't be removed" + echo "Core tools (nmap, curl, wget, git) left installed." + else + echo "Skipping tool removal." + fi +} + +cleanup_docker() { + echo "🐳 Cleaning up Docker resources..." + + if command -v docker >/dev/null 2>&1; then + if [ -n "$(docker images -q autorecon 2>/dev/null)" ]; then + echo "Stopping any running autorecon containers..." + docker ps -aq --filter ancestor=autorecon 2>/dev/null | xargs -r docker stop >/dev/null 2>&1 || true + docker ps -aq --filter ancestor=autorecon 2>/dev/null | xargs -r docker rm >/dev/null 2>&1 || true + + echo "Removing autorecon Docker image..." + docker rmi autorecon >/dev/null 2>&1 || true + echo "Docker image removed." + else + echo "No autorecon Docker image found." + fi + else + echo "Docker not available." + fi +} + +cleanup_results() { + echo "🗂️ Cleaning up results directory..." + + if [ -d "results" ] && [ -z "$(ls -A results 2>/dev/null)" ]; then + rm -rf results + echo "Empty results directory removed." + elif [ -d "results" ]; then + echo "Results directory contains files - keeping it." + else + echo "No results directory found." + fi +} + +show_venv_warning() { + if [ -n "$VIRTUAL_ENV" ]; then + echo "" + echo "┌─────────────────────────────────────────────────────────────┐" + echo "│ ⚠️ WARNING: IMPORTANT FINAL STEP │" + echo "│ │" + echo "│ You are still in a virtual environment! │" + echo "│ Please run the following command: │" + echo "│ │" + echo "│ deactivate │" + echo "│ │" + echo "│ This will restore your normal terminal prompt. │" + echo "└─────────────────────────────────────────────────────────────┘" + echo "" + fi +} + +# Main execution +main() { + echo "Cleaning up autorecon installation..." + echo "" + + cleanup_python + echo "" + cleanup_tools + echo "" + cleanup_docker + cleanup_results + + echo "" + echo "✅ Clean complete!" + echo "Virtual environment, Docker image, and empty directories removed." + + show_venv_warning +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/detect-os.sh b/scripts/detect-os.sh new file mode 100755 index 0000000..652434b --- /dev/null +++ b/scripts/detect-os.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# OS Detection Script for Makefile sourcing +# Usage: . scripts/detect-os.sh + +# Detect operating system and export variables +if [ -f /etc/os-release ]; then + OS_ID=$(grep '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"') + OS_ID_LIKE=$(grep '^ID_LIKE=' /etc/os-release | cut -d'=' -f2 | tr -d '"' 2>/dev/null || echo "") + + # Check for WSL + WSL_DETECTED="" + if grep -q Microsoft /proc/version 2>/dev/null || [ -n "$WSL_DISTRO_NAME" ]; then + WSL_DETECTED="yes" + fi + + export OS_ID OS_ID_LIKE WSL_DETECTED + +elif [ "$(uname)" = "Darwin" ]; then + OS_ID="macos" + OS_ID_LIKE="" + WSL_DETECTED="" + export OS_ID OS_ID_LIKE WSL_DETECTED +else + OS_ID="unknown" + OS_ID_LIKE="" + WSL_DETECTED="" + export OS_ID OS_ID_LIKE WSL_DETECTED +fi \ No newline at end of file diff --git a/scripts/install-tools-arch.sh b/scripts/install-tools-arch.sh new file mode 100755 index 0000000..7f72af5 --- /dev/null +++ b/scripts/install-tools-arch.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Arch Linux Tool Installation Script +# Usage: ./scripts/install-tools-arch.sh + +install_arch_tools() { + local OS_ID=${OS_ID:-$(grep '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"')} + + echo "📦 Installing security tools for $OS_ID (Arch-based)..." + sudo pacman -Sy --noconfirm nmap curl wget git python python-pip || echo "⚠️ Some tools failed to install" + echo "ℹ️ For full tool support, consider using Kali Linux or install tools manually" + echo "✅ Basic tools installed" +} + +# Main execution +main() { + install_arch_tools +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/install-tools-debian.sh b/scripts/install-tools-debian.sh new file mode 100755 index 0000000..79f5a33 --- /dev/null +++ b/scripts/install-tools-debian.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Debian/Ubuntu Tool Installation Script +# Usage: ./scripts/install-tools-debian.sh [WSL_DETECTED] + +WSL_DETECTED=${1:-$WSL_DETECTED} + +install_debian_tools() { + local OS_ID=${OS_ID:-$(grep '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"')} + + echo "📦 Installing security tools for $OS_ID (Debian-based)..." + echo "🔄 Updating package cache..." + sudo apt update -qq + + echo "🐍 Installing Python venv package (fixes ensurepip issues)..." + sudo apt install -y python3-venv python3-pip + + echo "📦 Installing core security tools..." + sudo apt install -y curl wget git nmap nikto whatweb sslscan smbclient + + echo "📦 Installing available enumeration tools..." + local FAILED_TOOLS="" + + local tools="seclists dnsrecon enum4linux feroxbuster gobuster impacket-scripts nbtscan onesixtyone oscanner redis-tools smbmap snmp sipvicious tnscmd10g" + + for tool in $tools; do + if ! sudo apt install -y $tool 2>/dev/null; then + echo "⚠️ $tool failed via apt, checking snap..." + FAILED_TOOLS="$FAILED_TOOLS $tool" + fi + done + + # Try snap for failed tools in WSL + if [ -n "$FAILED_TOOLS" ] && [ "$WSL_DETECTED" = "yes" ]; then + echo "🫰 Installing snap for WSL compatibility..." + sudo apt install -y snapd + sudo systemctl enable snapd 2>/dev/null || true + + for tool in $FAILED_TOOLS; do + case $tool in + feroxbuster) + echo "Installing feroxbuster via snap..." + sudo snap install feroxbuster 2>/dev/null || echo "⚠️ feroxbuster snap install failed" + ;; + gobuster) + echo "Installing gobuster via snap..." + sudo snap install gobuster 2>/dev/null || echo "⚠️ gobuster snap install failed" + ;; + *) + echo "⚠️ No snap alternative for $tool" + ;; + esac + done + fi + + echo "✅ Tool installation complete" +} + +# Main execution +main() { + install_debian_tools +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/install-tools-macos.sh b/scripts/install-tools-macos.sh new file mode 100755 index 0000000..f533b6d --- /dev/null +++ b/scripts/install-tools-macos.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# macOS Tool Installation Script +# Usage: ./scripts/install-tools-macos.sh + +install_macos_tools() { + echo "📦 Installing comprehensive security toolkit for macOS..." + + if command -v brew >/dev/null 2>&1; then + echo "🍺 Using Homebrew to install security tools..." + + echo "Installing core network tools..." + brew install nmap curl wget git gobuster nikto whatweb sslscan || echo "⚠️ Some core tools failed" + + echo "Installing enumeration tools..." + brew install feroxbuster redis-tools smbclient || echo "⚠️ Some enum tools failed" + + echo "Installing additional security tools..." + brew install hydra john-jumbo hashcat sqlmap exploitdb binwalk exiftool || echo "⚠️ Some additional tools failed" + + echo "Installing Python security tools via pip..." + python3 -m pip install impacket crackmapexec enum4linux-ng 2>/dev/null || echo "⚠️ Some Python tools failed" + + echo "✅ macOS security toolkit installation complete!" + echo "📋 Installed tools: nmap, gobuster, nikto, whatweb, sslscan," + echo " feroxbuster, redis-tools, smbclient, hydra, john-jumbo," + echo " hashcat, sqlmap, exploitdb, binwalk, exiftool, impacket, crackmapexec" + else + echo "⚠️ Homebrew not found. Please install Homebrew first:" + echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"" + echo "ℹ️ Or use Docker setup for full tool support" + return 1 + fi +} + +# Main execution +main() { + install_macos_tools +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/install-tools.sh b/scripts/install-tools.sh new file mode 100755 index 0000000..2383734 --- /dev/null +++ b/scripts/install-tools.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Security Tools Installation Script (Main Router) +# Usage: ./scripts/install-tools.sh [OS_ID] [OS_ID_LIKE] [WSL_DETECTED] + +# Get script directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Source system info from environment or parameters +OS_ID=${1:-$OS_ID} +OS_ID_LIKE=${2:-$OS_ID_LIKE} +WSL_DETECTED=${3:-$WSL_DETECTED} + +install_fallback_tools() { + echo "ℹ️ Unsupported Linux distribution: $OS_ID" + echo "ℹ️ Installing basic requirements..." + sudo apt update -qq 2>/dev/null || true + sudo apt install -y python3-venv python3-pip curl wget git 2>/dev/null || true + echo "ℹ️ Please install security tools manually or use Docker setup" +} + +# Main installation logic +main() { + if [ -z "$OS_ID" ]; then + echo "❌ OS_ID not provided. Run system-check.sh first or provide OS_ID as parameter." + exit 1 + fi + + # Export variables for sub-scripts + export OS_ID OS_ID_LIKE WSL_DETECTED + + case "$OS_ID" in + kali|parrot) + "$SCRIPT_DIR/install-tools-debian.sh" "$WSL_DETECTED" + ;; + ubuntu|debian) + if echo "$OS_ID_LIKE" | grep -q "debian\|ubuntu"; then + "$SCRIPT_DIR/install-tools-debian.sh" "$WSL_DETECTED" + else + install_fallback_tools + fi + ;; + arch|manjaro) + "$SCRIPT_DIR/install-tools-arch.sh" + ;; + macos) + "$SCRIPT_DIR/install-tools-macos.sh" + ;; + *) + if [ -f /etc/os-release ] && echo "$OS_ID_LIKE" | grep -q "debian\|ubuntu"; then + "$SCRIPT_DIR/install-tools-debian.sh" "$WSL_DETECTED" + else + install_fallback_tools + fi + ;; + esac +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/setup-docker.sh b/scripts/setup-docker.sh new file mode 100755 index 0000000..db30bd3 --- /dev/null +++ b/scripts/setup-docker.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +# Docker Build and Run Script +# Usage: ./scripts/setup-docker.sh + +check_docker() { + if ! command -v docker >/dev/null 2>&1; then + echo "❌ Docker is not installed" + echo "" + echo "Please install Docker first:" + echo " • Windows: https://docs.docker.com/desktop/install/windows/" + echo " • macOS: https://docs.docker.com/desktop/install/mac-install/" + echo " • Ubuntu: https://docs.docker.com/engine/install/ubuntu/" + echo " • Other Linux: https://docs.docker.com/engine/install/" + echo "" + exit 1 + fi + + if ! docker ps >/dev/null 2>&1; then + echo "❌ Docker is installed but not running" + echo "" + echo "Please start Docker and try again:" + echo " • Windows/macOS: Start Docker Desktop" + echo " • Linux: sudo systemctl start docker" + echo "" + exit 1 + fi + + echo "✅ Docker is ready!" + docker --version +} + +check_image_exists() { + if docker images -q autorecon >/dev/null 2>&1 && [ -n "$(docker images -q autorecon)" ]; then + echo "✅ autorecon Docker image found" + return 0 + else + echo "ℹ️ autorecon Docker image not found" + return 1 + fi +} + +build_autorecon_image() { + echo "🐳 Building autorecon Docker image..." + + if [ ! -f "Dockerfile" ]; then + echo "❌ Dockerfile not found in current directory" + echo "Please run this command from the autorecon directory" + return 1 + fi + + if docker build -t autorecon . ; then + echo "✅ autorecon Docker image built successfully!" + return 0 + else + echo "❌ Failed to build Docker image" + return 1 + fi +} + +start_docker_terminal() { + echo "🚀 Starting autorecon Docker terminal..." + echo "" + echo "📋 Available commands once inside:" + echo " • autorecon --help (Show help)" + echo " • autorecon 127.0.0.1 (Test scan)" + echo " • autorecon target.com (Scan target)" + echo " • ls /scans (View results)" + echo " • exit (Leave container)" + echo "" + echo "💾 Results will be saved to: $(pwd)/results/" + echo "" + + # Create results directory if it doesn't exist + mkdir -p results + + # Run the container interactively + docker run -it --rm \ + -v "$(pwd)/results:/scans" \ + -w /opt/autorecon \ + --name autorecon-session \ + autorecon bash + + echo "" + echo "👋 autorecon session ended" + echo "📁 Check your results in: $(pwd)/results/" +} + +# Main execution +main() { + echo "🐳 autorecon Docker Setup" + echo "" + + # Check Docker availability + check_docker + echo "" + + # Check if image exists, build if needed + if check_image_exists; then + echo "🚀 Image ready! Starting Docker terminal..." + else + echo "" + build_autorecon_image + if [ $? -ne 0 ]; then + exit 1 + fi + fi + + echo "" + start_docker_terminal +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/setup-python.sh b/scripts/setup-python.sh new file mode 100755 index 0000000..08b00b5 --- /dev/null +++ b/scripts/setup-python.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# Python Environment Setup Script +# Usage: ./scripts/setup-python.sh + +setup_venv() { + echo "🐍 Setting up Python environment..." + + # Try to create virtual environment + if ! python3 -m venv venv 2>/dev/null; then + echo "⚠️ venv creation failed. Trying to fix..." + echo "Installing python3-venv package..." + + # Try different package managers + if command -v apt >/dev/null 2>&1; then + sudo apt install -y python3-venv python3-pip 2>/dev/null + elif command -v yum >/dev/null 2>&1; then + sudo yum install -y python3-venv python3-pip 2>/dev/null + elif command -v pacman >/dev/null 2>&1; then + sudo pacman -S --noconfirm python python-pip 2>/dev/null + else + echo "⚠️ Could not install python3-venv. Please install manually." + fi + + # Try creating venv again + python3 -m venv venv + fi + + # Install Python packages + echo "📦 Installing Python dependencies..." + venv/bin/python3 -m pip install --upgrade pip + venv/bin/python3 -m pip install -r requirements.txt +} + +create_command() { + echo "🔧 Creating autorecon command..." + + # Remove old command file + rm -f autorecon-cmd + + # Create new command script + cat > autorecon-cmd << 'EOF' +#!/bin/bash +# Resolve the real path of the script (follow symlinks) +SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")" +DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)" +source "$DIR/venv/bin/activate" && python3 "$DIR/autorecon.py" "$@" +EOF + + # Make it executable + chmod +x autorecon-cmd + + # Try to install globally + echo "🔗 Installing autorecon command to /usr/local/bin..." + if ! sudo ln -sf "$(pwd)/autorecon-cmd" /usr/local/bin/autorecon 2>/dev/null; then + echo "⚠️ Could not install to /usr/local/bin (permission issue)" + echo "💡 You can still use: ./autorecon-cmd or add to PATH manually" + return 1 + fi + + return 0 +} + +show_completion_message() { + echo "" + echo "✅ Python setup complete!" + echo "" + echo "📋 Next steps:" + echo " • Run: autorecon --help" + echo " • Test with: autorecon 127.0.0.1" + echo " • For full tool support on non-Kali systems, consider: make setup-docker" +} + +# Main execution +main() { + setup_venv + create_command + show_completion_message +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/system-check.sh b/scripts/system-check.sh new file mode 100755 index 0000000..c68abd0 --- /dev/null +++ b/scripts/system-check.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# System Prerequisites Check Script +# Usage: ./scripts/system-check.sh + +echo "🔍 Checking prerequisites..." + +# Check Python version +check_python() { + if ! command -v python3 >/dev/null 2>&1; then + echo "❌ Python 3 is not installed" + echo "" + echo "Please install Python 3.8+ first:" + echo " • Ubuntu/Debian: sudo apt install python3 python3-pip python3-venv" + echo " • CentOS/RHEL: sudo yum install python3 python3-pip" + echo " • Arch: sudo pacman -S python python-pip" + echo " • macOS: brew install python3" + echo " • Or download from: https://www.python.org/downloads/" + echo "" + exit 1 + fi + + PYTHON_VERSION=$(python3 -c "import sys; print('.'.join(map(str, sys.version_info[:2])))" 2>/dev/null || echo "unknown") + if [ "$PYTHON_VERSION" != "unknown" ]; then + echo "✅ Python $PYTHON_VERSION detected" + MAJOR=$(echo $PYTHON_VERSION | cut -d. -f1) + MINOR=$(echo $PYTHON_VERSION | cut -d. -f2) + if [ $MAJOR -lt 3 ] || ([ $MAJOR -eq 3 ] && [ $MINOR -lt 8 ]); then + echo "⚠️ Python $PYTHON_VERSION detected, but Python 3.8+ is recommended" + echo " Download latest from: https://www.python.org/downloads/" + fi + else + echo "⚠️ Could not determine Python version" + fi +} + +# Detect operating system +detect_os() { + echo "🔍 Detecting operating system..." + + if [ -f /etc/os-release ]; then + OS_ID=$(grep '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"') + OS_ID_LIKE=$(grep '^ID_LIKE=' /etc/os-release | cut -d'=' -f2 | tr -d '"' 2>/dev/null || echo "") + + # Check for WSL + WSL_DETECTED="" + if grep -q Microsoft /proc/version 2>/dev/null || [ -n "$WSL_DISTRO_NAME" ]; then + WSL_DETECTED="yes" + echo "🪟 WSL environment detected" + fi + + export OS_ID OS_ID_LIKE WSL_DETECTED + echo "✅ Detected: $OS_ID" + + elif [ "$(uname)" = "Darwin" ]; then + OS_ID="macos" + export OS_ID + echo "✅ Detected: macOS" + + # Check for Homebrew + if ! command -v brew >/dev/null 2>&1; then + echo "⚠️ Homebrew not found. Please install Homebrew first:" + echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"" + fi + else + OS_ID="unknown" + export OS_ID + echo "⚠️ Unknown operating system" + fi +} + +# Main execution +main() { + check_python + echo "" + detect_os + echo "" + echo "✅ System check complete!" +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file diff --git a/scripts/update.sh b/scripts/update.sh new file mode 100755 index 0000000..66c342d --- /dev/null +++ b/scripts/update.sh @@ -0,0 +1,205 @@ +#!/bin/bash + +# Update Script +# Usage: ./scripts/update.sh + +update_git() { + echo "📥 Updating git repository..." + + # Check if we're in a git repository + if ! git rev-parse --git-dir >/dev/null 2>&1; then + echo "❌ Not in a git repository" + return 1 + fi + + # Store current branch and check for uncommitted changes + CURRENT_BRANCH=$(git branch --show-current) + + if ! git diff-index --quiet HEAD --; then + echo "⚠️ Uncommitted changes detected. Stashing them..." + git stash push -m "Auto-stash before update $(date)" + STASHED=true + fi + + # Fetch and pull latest changes + echo "🔄 Fetching latest changes..." + git fetch origin + + if git pull origin "$CURRENT_BRANCH"; then + echo "✅ Git repository updated successfully" + + # Show what changed + if [ -n "$(git log HEAD@{1}..HEAD --oneline)" ]; then + echo "" + echo "📋 Recent changes:" + git log HEAD@{1}..HEAD --oneline --decorate + else + echo "ℹ️ Already up to date" + fi + + # Restore stashed changes if any + if [ "$STASHED" = "true" ]; then + echo "" + echo "🔄 Restoring stashed changes..." + git stash pop + fi + + return 0 + else + echo "❌ Failed to update git repository" + return 1 + fi +} + +update_python() { + echo "🐍 Updating Python environment..." + + if [ ! -d "venv" ]; then + echo "⚠️ Virtual environment not found. Creating it..." + ./scripts/setup-python.sh + return $? + fi + + # Update pip and packages + echo "📦 Updating Python packages..." + venv/bin/python3 -m pip install --upgrade pip + venv/bin/python3 -m pip install --upgrade -r requirements.txt + + echo "✅ Python environment updated" +} + +update_tools() { + echo "🔧 Updating security tools..." + + # Source system detection + source ./scripts/system-check.sh >/dev/null 2>&1 + detect_os >/dev/null 2>&1 + + if [ -f /etc/os-release ]; then + OS_ID=$(grep '^ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"') + OS_ID_LIKE=$(grep '^ID_LIKE=' /etc/os-release | cut -d'=' -f2 | tr -d '"' 2>/dev/null || echo "") + + if [ "$OS_ID" = "kali" ] || [ "$OS_ID" = "parrot" ] || echo "$OS_ID_LIKE" | grep -q "debian\|ubuntu"; then + echo "Updating apt packages..." + sudo apt update -qq + sudo apt upgrade -y + + elif [ "$OS_ID" = "arch" ] || [ "$OS_ID" = "manjaro" ]; then + echo "Updating pacman packages..." + sudo pacman -Syu --noconfirm + + else + echo "ℹ️ Basic system update..." + sudo apt update -qq && sudo apt upgrade -y 2>/dev/null || \ + sudo yum update -y 2>/dev/null || \ + sudo dnf update -y 2>/dev/null || \ + echo "Please update system packages manually" + fi + + elif [ "$(uname)" = "Darwin" ]; then + if command -v brew >/dev/null 2>&1; then + echo "Updating Homebrew packages..." + brew update && brew upgrade + fi + fi + + echo "✅ Security tools updated" +} + +update_docker() { + echo "🐳 Updating Docker image..." + + if ! command -v docker >/dev/null 2>&1; then + echo "ℹ️ Docker not installed, skipping Docker update" + return 0 + fi + + # Check if Dockerfile or requirements.txt changed + DOCKERFILE_CHANGED=false + REQUIREMENTS_CHANGED=false + + if git diff HEAD@{1}..HEAD --name-only | grep -q "Dockerfile\|requirements.txt\|default-plugins/"; then + DOCKERFILE_CHANGED=true + echo "📋 Docker-related files changed, rebuilding image..." + fi + + if [ "$DOCKERFILE_CHANGED" = "true" ] || [ ! -n "$(docker images -q autorecon 2>/dev/null)" ]; then + echo "🔨 Building updated Docker image..." + if docker build -t autorecon .; then + echo "✅ Docker image updated successfully" + + # Clean up old images + echo "🧹 Cleaning up old Docker images..." + docker image prune -f >/dev/null 2>&1 || true + else + echo "❌ Failed to build Docker image" + return 1 + fi + else + echo "ℹ️ Docker image is up to date" + fi + + return 0 +} + +check_makefile_update() { + echo "📋 Checking for Makefile updates..." + + if git diff HEAD@{1}..HEAD --name-only | grep -q "Makefile"; then + echo "" + echo "⚠️ Makefile was updated!" + echo "💡 Consider restarting this process to use the latest Makefile commands" + echo "" + fi +} + +show_summary() { + echo "" + echo "✅ Update complete!" + echo "" + echo "📋 What was updated:" + echo " • Git repository and source code" + echo " • Python virtual environment and packages" + echo " • System security tools" + if command -v docker >/dev/null 2>&1; then + echo " • Docker image (if needed)" + fi + echo "" + echo "🎯 Ready to use updated autorecon!" +} + +# Main execution +main() { + echo "Updating autorecon installation..." + echo "" + + # Update git repository first + if ! update_git; then + echo "❌ Git update failed, aborting" + exit 1 + fi + + echo "" + + # Check if Makefile was updated + check_makefile_update + + # Update Python environment + update_python + echo "" + + # Update tools + update_tools + echo "" + + # Update Docker if available + update_docker + + # Show summary + show_summary +} + +# Run if script is executed directly +if [ "${BASH_SOURCE[0]}" = "${0}" ]; then + main "$@" +fi \ No newline at end of file