A comprehensive Bash script for creating wireless access points with advanced features including internet sharing, packet capture, DNS spoofing, proxy routing, and monitor mode capabilities.
- Wireless Access Point Creation: Set up secure (WPA2/WPA3) or open WiFi networks
- AP Cloning: Quickly clone existing networks by SSID with automatic configuration
- Internet Sharing: Share internet connection from another interface via NAT
- Real-time Client Monitoring: Track connected devices with MAC, IP, and hostname
- Packet Capture: Real-time traffic monitoring and PCAP export with tshark
- DNS Spoofing: Redirect specific domains to custom IP addresses
- DoH Blocking: Block DNS-over-HTTPS to enforce DNS spoofing
- Proxy Integration: Advanced support for mitmproxy (local/remote) and redsocks
- SSL/TLS Interception: Automatic certificate generation and distribution server
- Monitor Mode: Enable wireless monitoring capabilities
- Interactive & CLI Modes: Flexible configuration options
- Configuration Management: Save and load configurations with CLI argument overrides
- Comprehensive Logging: Detailed operation logs for all services
- Linux system with root access
- Bash version 4.0 or newer
- Wireless network interface capable of AP mode
sudo apt update
sudo apt install hostapd dnsmasq wireless-tools net-tools iptables iproute2# For packet capture
sudo apt install wireshark-common
# For proxy routing
sudo apt install redsocks
# For advanced proxy features
pip install mitmproxy- Clone the repository:
git clone https://github.com/DilshanHarshajith/GhostAP.git
cd GhostAP
chmod +x GhostAP.sh- Run with root privileges:
sudo ./GhostAP.shsudo ./GhostAP.sh --interactivesudo ./GhostAP.sh -i wlan0 -s "MyOpenAP" -c 6 --security opensudo ./GhostAP.sh -i wlan0 -s "MySecureAP" -c 6 --security wpa2 --password "password123" --internet -si eth0sudo ./GhostAP.sh -i wlan0 -s "MonitorAP" --capture --monitorsudo ./GhostAP.sh -i wlan0 -s "ProxyAP" --proxy --proxy-host 127.0.0.1 --proxy-port 8080 --proxy-type httpsudo ./GhostAP.sh -i wlan0 --clone "Target_SSID"sudo ./GhostAP.sh --mitmlocal -s "InterceptAP"| Option | Description |
|---|---|
--int, --interactive |
Start in interactive mode |
--config FILE |
Load configuration from file |
--save NAME |
Save current configuration with name |
--help |
Show help message |
| Option | Description |
|---|---|
-i, --interface IFACE |
Wireless interface to use |
-si, --source-interface IFACE |
Source interface for internet sharing |
--clone SSID |
Clone an existing AP by SSID |
| Option | Description |
|---|---|
-s, --ssid SSID |
Network name (SSID) |
-c, --channel CHANNEL |
WiFi channel (1-14) |
--security TYPE |
Security type (open/wpa2/wpa3) |
--password PASSWORD |
WiFi password (for WPA2/WPA3) |
--subnet OCTET |
Subnet third octet (0-255) |
--dns IP |
DNS server IP address |
| Option | Description |
|---|---|
--monitor |
Enable monitor mode |
--internet |
Enable internet sharing |
--capture |
Enable packet capture |
--spoof "DOMAINS" |
Enable DNS spoofing (Format: `dom.com=1.2.3.4 |
--spoof-target IP |
Default target IP for DNS spoofing (when domain has no explicit IP) |
--block-doh |
Block DNS-over-HTTPS to enforce DNS spoofing |
| Option | Description |
|---|---|
--mitmlocal |
Use mitmproxy locally |
--mitmremote |
Use mitmproxy remotely |
--proxy |
Use redsocks proxy |
--proxy-mode MODE |
Proxy mode (TRANSPARENT_LOCAL/TRANSPARENT_UPSTREAM/REMOTE_DNAT) |
--mitm-auto [true/false] |
Automatically start mitmproxy (default: true) |
--proxy-host HOST |
Proxy server host/IP |
--proxy-port PORT |
Proxy server port |
--proxy-type TYPE |
Proxy type (http/socks4/socks5) |
--proxy-user USER |
Proxy username |
--proxy-pass PASS |
Proxy password |
sudo ./GhostAP.sh --save myconfig -i wlan0 -s "MyAP" --security wpa2 --password "password"sudo ./GhostAP.sh --config /path/to/myconfig.confNote
Command-line arguments always take precedence over configuration file settings.
# Network Configuration
INTERFACE="wlan0"
SSID="MyAccessPoint"
CHANNEL="6"
SUBNET="10"
DNS="8.8.8.8"
SECURITY="wpa2"
PASSWORD="mypassword"
# Features
INTERNET_SHARING="true"
SOURCE_INTERFACE="eth0"
DNS_SPOOFING="false"
PACKET_CAPTURE="true"
# Cloning Options
CLONE="false"
CLONE_SSID=""
# Proxy Options
PROXY_ENABLED="false"
PROXY_MODE="TRANSPARENT_LOCAL"
PROXY_BACKEND=""
MITM_LOCATION=""
START_MITM_AUTO="true"
PROXY_HOST=""
PROXY_PORT=""
PROXY_TYPE=""
PROXY_USER=""
PROXY_PASS=""
# DNS Spoofing Options
SPOOF_DOMAINS=""Redirect specific domains to custom IP addresses:
# Spoof specific domains with explicit IPs
sudo ./GhostAP.sh --spoof "example.com=192.168.1.100|test.com=10.0.0.1"
# Spoof domains to default target (AP IP or custom target)
sudo ./GhostAP.sh --spoof "example.com|test.com" --spoof-target 192.168.1.50
# Mix explicit and default targets
sudo ./GhostAP.sh --spoof "example.com=192.168.1.100|test.com" --spoof-target 10.0.0.1
# Spoof with DoH blocking to prevent DNS bypass
sudo ./GhostAP.sh --spoof "example.com" --block-dohNote
When DNS spoofing is enabled without --spoof-target, domains without explicit IPs default to the AP's IP address (192.168.X.1).
Important
Use --block-doh to block DNS-over-HTTPS traffic and force clients to use your DNS server. This prevents clients from bypassing DNS spoofing by using encrypted DNS services like Google DoH or Cloudflare DoH.
Captured packets are saved to the Output directory with timestamps:
ls -la Output/*.pcapGhostAP supports three advanced proxying modes:
Intercepts HTTP/HTTPS traffic locally using mitmproxy:
- Automatically starts mitmproxy on port 8080
- Launches web interface (mitmweb) for real-time traffic inspection
- Starts certificate distribution server on port 8081
- Traffic flow:
Client → AP (8080) → Internet
sudo ./GhostAP.sh --mitmlocal -s "InterceptAP"
# Access web interface at: http://192.168.X.1:8081
# Download certificate from: http://mitm.it or http://192.168.X.1:8082/certForwards intercepted traffic to an external HTTP or SOCKS proxy using redsocks:
- Transparently redirects traffic to upstream proxy
- Supports HTTP, SOCKS4, and SOCKS5 proxies
- Supports authenticated proxies
- Traffic flow:
Client → AP → Redsocks → External Proxy → Internet
sudo ./GhostAP.sh --proxy --proxy-host 10.0.0.5 --proxy-port 3128 --proxy-type httpSimple DNAT forwarding to a remote IP/Port (useful if mitmproxy runs on another machine):
- Uses iptables DNAT rules
- No local proxy process
- Traffic flow:
Client → AP → Remote Host (DNAT)
sudo ./GhostAP.sh --mitmremote --proxy-host 10.0.0.10 --proxy-port 8080The script monitors connected clients in real-time by watching DHCP leases. It displays:
- MAC Address
- Assigned IP Address
- Device Hostname (if available)
GhostAP uses a modular architecture with separate modules for each feature:
GhostAP/
├── GhostAP.sh # Main entry point
└── src/
├── globals.sh # Global variables and constants
├── utils.sh # Logging, validation, cleanup functions
├── config.sh # Configuration management and argument parsing
├── ui.sh # User interface and status display
├── interface.sh # Wireless interface management
├── hostapd.sh # Access point configuration
├── dnsmasq.sh # DHCP/DNS server and spoofing
├── internet.sh # NAT and internet sharing
├── proxy.sh # Proxy routing (mitmproxy/redsocks)
├── capture.sh # Packet capture with tshark
└── services.sh # Service lifecycle management
GhostAP/
├── Config/ # Saved configuration files
├── Logs/ # Service logs (hostapd, dnsmasq, tshark, etc.)
├── Output/ # Packet capture files (.pcap)
└── Temp/ # Temporary runtime files
tail -f Logs/GhostAP.logLogs/hostapd.log- Access point service logsLogs/dnsmasq.log- DHCP/DNS service logsLogs/tshark.log- Packet capture logsLogs/redsocks.log- Proxy service logs (when applicable)
- Legal Usage: Only use this tool on networks you own or have explicit permission to test
- Monitor Mode: Can interfere with normal wireless operations
- Packet Capture: May capture sensitive information - handle responsibly
- DNS Spoofing: Can redirect legitimate traffic - use carefully
- Proxy Routing: All traffic may be intercepted - ensure proper authorization
# List available wireless interfaces
iw dev# Ensure running as root
sudo ./GhostAP.sh# Check system logs
journalctl -u hostapd
journalctl -u dnsmasq- Verify source interface has internet connectivity
- Check iptables rules:
iptables -L -n -t nat - Ensure IP forwarding is enabled:
cat /proc/sys/net/ipv4/ip_forward
Enable debug logging:
DEBUG=1 sudo ./GhostAP.shPress Ctrl+C to gracefully stop the access point. The script will:
- Terminate all started services
- Remove iptables rules
- Restore interface to managed mode
- Clean up temporary files
- Save packet captures (if enabled)
Contributions are welcome! Please ensure:
- Code follows existing style conventions
- New features include appropriate error handling
- Documentation is updated for new options
- Security implications are considered
Licensed under the Apache License, Version 2.0
For issues and questions:
- Check the troubleshooting section
- Review log files for error details
- Ensure all dependencies are installed
- Verify interface compatibility with AP mode
Disclaimer: This tool is intended for authorized network testing and educational purposes only. Unauthorized access to networks is illegal and unethical. Always obtain proper permission before testing network security.