|
1 | 1 | <p align="center"> |
2 | 2 | <img alt="Phantom" src="https://raw.githubusercontent.com/CyberRoute/phantom/main/images/phantom_logo.png"/> |
3 | | - <p align="center"> |
4 | | - </p> |
5 | 3 | </p> |
6 | 4 |
|
7 | 5 | --- |
8 | 6 |
|
9 | 7 | # Phantom |
10 | 8 |
|
11 | 9 | ## Overview |
12 | | -Phantom is an **ARP Scanner** mostly designed to detect directly connected IoT devices. The tool provides details like IP addresses, MAC addresses, hostnames, and the manufacturers of the devices based on their MAC addresses. |
13 | | -The tool features a graphical user interface (GUI) built with **PySide6** (Qt framework) and utilizes **scapy** for ARP scanning. |
14 | 10 |
|
15 | | ---- |
| 11 | +Phantom is a **network reconnaissance and security auditing tool** designed for directly connected networks. It discovers devices via ARP scanning, tracks their history, detects ARP spoofing attacks, and can perform MITM interception with live packet analysis powered by a local LLM. |
| 12 | + |
| 13 | +The GUI is built with **PySide6** (Qt framework) and uses **Scapy** for all packet-level operations. |
16 | 14 |
|
17 | | -## Features |
18 | | -- **Network Scanning**: Identifies devices on the network via ARP requests. |
19 | | -- **Device Details**: Displays IP address, MAC address, hostname, and vendor information. |
20 | | -- **Graphical User Interface**: Easy-to-use UI to display the scanned devices and packet information. |
21 | | -- **Multithreading**: Ensures non-blocking scans using Python's `QThread`. |
22 | | -- **C extension**: for MacOSX there is a C extension that allows slow sequential but very accurate arp scanning |
23 | 15 | --- |
24 | 16 |
|
25 | | -## Prerequisites |
| 17 | +## Features |
26 | 18 |
|
27 | | -Ensure the following dependencies are installed: |
| 19 | +- **ARP Network Scanning**: Discovers devices via ARP requests, displaying IP, MAC, hostname, and vendor. |
| 20 | +- **Device History & Persistence**: Stores scan results in a local SQLite database; previously seen devices are shown on startup. |
| 21 | +- **New Device & MAC Change Detection**: Highlights new devices (green) and IP-to-MAC binding changes (red) — a classic ARP spoofing indicator. |
| 22 | +- **ARP Spoof Detection**: Passive background sniffer that alerts on conflicting ARP bindings and gateway MAC changes. |
| 23 | +- **MITM Interception**: ARP-spoof a target to intercept its traffic; captured packets are displayed in real time with a full layer-by-layer breakdown. |
| 24 | +- **LLM Packet Analysis**: Send any captured packet to a local [Ollama](https://ollama.com) instance for AI-assisted analysis (protocol identification, risk assessment, credential spotting). |
| 25 | +- **PCAP Export**: Save captured packets from a MITM session as a `.pcap` file for offline analysis in Wireshark. |
| 26 | +- **Scan Export**: Export scan results to JSON or CSV. |
| 27 | +- **Progress Bar**: Live progress feedback during scanning. |
| 28 | +- **Custom CIDR Target**: Scan a specific subnet instead of the local interface network. |
| 29 | +- **Multithreading**: All network operations run in `QThread` workers — the UI stays responsive throughout. |
| 30 | +- **C Extension (macOS)**: A native C extension provides accurate, sequential ARP scanning on macOS where Scapy bulk-send is unreliable. |
28 | 31 |
|
29 | | -1. **Python 3.12 or higher** |
30 | | -2. **scapy**: Used for ARP scanning. |
31 | | -3. **PySide6**: For building the GUI. |
32 | | -4. **netifaces**: To retrieve network interface details. |
| 32 | +--- |
33 | 33 |
|
34 | 34 | ## Requirements |
35 | 35 |
|
36 | 36 | - **Python 3.12+** |
37 | | -- **scapy**: For ARP scanning and packet manipulation. |
38 | | -- **PySide6**: For building the graphical user interface. |
39 | | -- **netifaces**: To retrieve network interface details. |
| 37 | +- **scapy** — ARP scanning and packet manipulation |
| 38 | +- **PySide6** — graphical user interface |
| 39 | +- **netifaces** — network interface introspection |
| 40 | +- **requests** — Ollama API streaming |
| 41 | +- **Ollama** (optional) — local LLM for packet analysis (`ollama serve`) |
40 | 42 |
|
41 | 43 | --- |
42 | 44 |
|
43 | 45 | ## Installation |
44 | 46 |
|
45 | 47 | 1. **Clone the repository**: |
46 | 48 |
|
47 | | - Clone the repository to your local machine: |
48 | | - |
49 | 49 | ```bash |
50 | 50 | git clone https://github.com/CyberRoute/phantom.git |
51 | 51 | cd phantom |
52 | 52 | ``` |
53 | 53 |
|
54 | | -2. **Install the dependencies with Pipenv**: |
55 | | - |
56 | | - Install `pip` if it's not already installed: |
| 54 | +2. **Create a virtual environment and install dependencies**: |
57 | 55 |
|
58 | 56 | ```bash |
59 | 57 | virtualenv env |
60 | 58 | source env/bin/activate |
61 | 59 | pip install -r requirements.txt |
62 | 60 | ``` |
63 | 61 |
|
64 | | -3. **Run the application**: |
65 | | -
|
66 | | - Run the ARP Scanner using the following command. You need to provide the network interface (like `eth0`, `wlan0`, or `wlp0s20f3`) for your system: |
| 62 | +3. **(macOS only) Build the native C extension**: |
67 | 63 |
|
68 | 64 | ```bash |
69 | | - sudo `which python3` main.py --interface <interface> --timeout 500 |
70 | | - ``` |
71 | | -
|
72 | | - On Ubuntu in case you run into this error: |
73 | | - ``` |
74 | | - (env) alessandro@alessandro-XPS-9315:~/Development/phantom$ sudo /home/alessandro/Development/phantom/env/bin/python3 main.py --interface wlp0s20f3 |
75 | | - qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin. |
76 | | - qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. |
77 | | - This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. |
78 | | - Available platform plugins are: eglfs, minimal, wayland, vkkhrdisplay, offscreen, linuxfb, xcb, wayland-egl, minimalegl, vnc. |
79 | | - ``` |
80 | | - Solution: |
81 | | - ``` |
82 | | - sudo apt install libxcb-cursor0 |
83 | | - ``` |
84 | | - On Macos there is a C extension that allows accurate but slow arpscan. To build and install the extension: |
85 | | - ``` |
86 | 65 | pip install setuptools |
87 | 66 | cd c_extension |
88 | 67 | python setup.py build |
89 | 68 | python setup.py install |
| 69 | + cd .. |
90 | 70 | ``` |
91 | 71 |
|
92 | | -## Usage Instructions |
| 72 | +4. **Run the application** (root/sudo is required for raw packet operations): |
93 | 73 |
|
94 | | -1. **Start the Application**: |
| 74 | + ```bash |
| 75 | + sudo `which python3` main.py --interface <interface> --timeout 500 |
| 76 | + ``` |
| 77 | + |
| 78 | + Optional arguments: |
95 | 79 |
|
96 | | - After running the application with the correct interface, the GUI will launch. |
| 80 | + | Argument | Default | Description | |
| 81 | + |---|---|---| |
| 82 | + | `--interface` | *(required)* | Network interface name (e.g. `eth0`, `wlan0`) | |
| 83 | + | `--timeout` | `1000` | ARP scan timeout in milliseconds | |
| 84 | + | `--target` | interface network | Custom CIDR range to scan (e.g. `10.0.0.0/24`) | |
97 | 85 |
|
98 | | -<div align="center"> |
99 | | - <img src="/images/phantom.png" width="800px"</img> |
100 | | -</div> |
| 86 | +### Troubleshooting (Ubuntu / xcb plugin error) |
101 | 87 |
|
102 | | -2. **Scanning the Network**: |
| 88 | +``` |
| 89 | +qt.qpa.plugin: Could not load the Qt platform plugin "xcb" |
| 90 | +``` |
103 | 91 |
|
104 | | - - Click on the **"Scan"** button in the UI to initiate a network scan. |
105 | | - - The tool will display a list of all detected devices in the network, including their IP addresses, MAC addresses, hostnames, and vendors. |
| 92 | +Fix: |
106 | 93 |
|
107 | | -3. **Device Details**: |
| 94 | +```bash |
| 95 | +sudo apt install libxcb-cursor0 |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
108 | 99 |
|
109 | | - - Click on any device in the list to open a detailed window that shows more information about that particular device. |
| 100 | +## Usage |
110 | 101 |
|
111 | | -4. **Stopping the Scan**: |
| 102 | +### 1. Scan the network |
112 | 103 |
|
113 | | - - Press the **"Quit"** button to stop the ARP scan and close the application. |
| 104 | +Click **Scan** to start an ARP sweep of the local network (or a custom CIDR if `--target` was specified). Devices appear as they respond: |
| 105 | + |
| 106 | +- **White** — previously seen device, confirmed live |
| 107 | +- **Green** — new device (first time seen) |
| 108 | +- **Red** — IP address answered with a different MAC than before (possible ARP spoofing) |
| 109 | +- **Grey** — device from the database not yet confirmed live in this scan |
| 110 | + |
| 111 | +A progress bar tracks scan completion. Results can be exported to JSON or CSV with **Export Results**. |
| 112 | + |
| 113 | +### 2. Inspect a device |
| 114 | + |
| 115 | +Click any device in the list to open its detail window, which shows: |
| 116 | + |
| 117 | +- IP, MAC, hostname, vendor |
| 118 | +- First seen / last seen timestamps |
| 119 | +- Full MAC address history (useful for spoofing audits) |
| 120 | +- MITM controls |
| 121 | + |
| 122 | +### 3. MITM interception |
| 123 | + |
| 124 | +From the device detail window, click **Start MITM** to: |
| 125 | + |
| 126 | +1. ARP-spoof the target and the gateway (Phantom inserts itself in the traffic path). |
| 127 | +2. Enable IP forwarding so the target's internet access is preserved. |
| 128 | +3. Capture all non-ARP traffic to/from the target in real time. |
| 129 | + |
| 130 | +Click any captured packet to see a full hex dump and layer-by-layer field breakdown. |
| 131 | +Click **Save PCAP** to write the captured session to a `.pcap` file. |
| 132 | + |
| 133 | +> **Note:** MITM requires root/sudo. IP forwarding is restored automatically when MITM is stopped. |
| 134 | +
|
| 135 | +### 4. LLM packet analysis (Ollama) |
| 136 | + |
| 137 | +With [Ollama](https://ollama.com) running locally (`ollama serve`) and a model pulled (default: `deepseek-r1:1.5b`): |
| 138 | + |
| 139 | +1. Select a captured packet in the MITM window. |
| 140 | +2. Optionally add context in the **Context** field (e.g. `"this is a smart TV"`). |
| 141 | +3. Click **Analyse with LLM** — the analysis streams in token by token. |
| 142 | + |
| 143 | +The LLM identifies protocol/service, describes what the endpoints are doing, flags security-relevant observations, and provides a risk rating. |
| 144 | + |
| 145 | +--- |
| 146 | + |
| 147 | +## Architecture |
| 148 | + |
| 149 | +``` |
| 150 | +main.py — entry point, CLI args, QApplication bootstrap |
| 151 | +core/ |
| 152 | + arp_scanner.py — ARPScannerThread, DeviceDiscoveryDialog, DeviceDetailsWindow |
| 153 | + arp_spoofer.py — low-level ARP spoof / restore primitives |
| 154 | + mitm.py — MitmThread (spoof loop + sniffer), IP forwarding management |
| 155 | + spoof_detector.py — passive ARP sniff-based spoof detection |
| 156 | + ollama_analyst.py — OllamaThread for streaming LLM packet analysis |
| 157 | + db.py — SQLite persistence (device history, MAC audit trail) |
| 158 | + networking.py — CIDR calculation, hostname resolution helpers |
| 159 | + vendor.py — OUI/MAC vendor lookup |
| 160 | + platform.py — OS detection helper |
| 161 | +c_extension/ — native C ARP scanner for macOS |
| 162 | +ui/ — PySide6 .ui compiled files |
| 163 | +``` |
| 164 | + |
| 165 | +--- |
114 | 166 |
|
115 | 167 | ## Contribute |
116 | | -Fork the repo and send PRs if you like :) |
117 | 168 |
|
| 169 | +Fork the repo and send PRs if you like :) |
0 commit comments