Overview
This article examines how pairing ShellGPT — an AI-powered command-line assistant driven by the OpenAI API — with Nmap fundamentally changes the pace and precision of network reconnaissance. Traditional reconnaissance demands that the operator memorise a large vocabulary of Nmap flags, NSE script names, output-processing pipelines, and service-specific enumeration tools. ShellGPT eliminates that requirement: the operator expresses intent in plain English, and the AI returns an execution-ready command in seconds. The result is a workflow that scales from a first-time learner to an experienced penetration tester without changing a single step.This article documents progressive reconnaissance operations organised into four phases. The first phase covers setup: installing ShellGPT, configuring an OpenAI API key, and verifying end-to-end connectivity. The second phase covers active scanning: discovering live hosts, enumerating ports, fingerprinting services and operating systems, conducting stealth and aggressive scans, and running NSE-based vulnerability and protocol audits across FTP, SSH, HTTP, SMB, NFS, MSRPC, and SCTP. The third phase covers AI-driven analysis: piping saved scan output into ShellGPT for an instant attack-surface review and generating a complete enumeration command set from that analysis. The fourth phase covers technique design: asking ShellGPT to construct stealth scan configurations and explain complex flag combinations without any live target. Each section presents the natural-language prompt, the generated command, and a detailed analysis of the output, so the article serves equally as a demonstration, a reference, and a learning resource.
Table of Contents:
- Introduction
- Lab Environment
- Installing ShellGPT
- Generating and Configuring an OpenAI API Key
- Verifying ShellGPT with a Baseline Query
- Discovering Live Hosts and Saving Results
- Running a Fast Port Scan Across All Live Hosts
- Deep Service and OS Fingerprinting on a Single Target
- Enumerating MSRPC Services
- Conducting a TCP SYN (Stealth) Scan
- Scanning a Specific Set of Ports
- Scanning Multiple Targets Simultaneously
- OS Detection via TTL Analysis on Two Hosts
- Applying a Timing Template for Speed Optimisation
- Executing an Aggressive Scan
- Running an NSE Vulnerability Scan
- Enumerating HTTP Services with NSE
- Enumerating SMB Shares and OS Details
- Enumerating SSH Algorithms and Host Keys
- Detecting Web Technologies via HTTP Headers
- Running a Traceroute to Map Network Topology
- Inspecting Packets with the Packet-Trace Flag
- Saving a Service-Version Scan to Disk for Downstream Analysis
- Piping Scan Results into ShellGPT for Attack-Surface Analysis
- Generating a Complete Enumeration Command Set from Scan Output
- Designing a Stealthy SYN Scan Configuration
- Using ShellGPT to Demystify Complex Flag Combinations
- Using Shell-GPT for SSH Brute-Force Attacks
- Mitigation Strategies
- Conclusion
Introduction
Network reconnaissance is the mandatory first act of any penetration test or security assessment. Before an attacker can enumerate services, probe vulnerabilities, or plan exploitation paths, they must first map what exists on the network — which hosts are alive, which ports are open, and which software is listening on each. Nmap has been the industry-standard tool for this task for over two decades, and its depth is unmatched: it supports dozens of scan types, hundreds of NSE scripts covering every major protocol, OS fingerprinting, timing control, output formatting, and packet-level tracing. That depth is also its barrier to entry; the full Nmap reference spans thousands of options and assembling the right combination for a given task requires experience.ShellGPT removes that barrier by acting as an intelligent translator between operator intent and Nmap syntax. The operator describes what they want — “scan these hosts for live ports,” “enumerate SMB shares without credentials,” “run a vulnerability scan” — and ShellGPT produces the correct command, confirms it with an interactive Execute prompt, and runs it immediately. The same tool operates in reverse as an analyst: when fed a saved scan file, it identifies the exposed services, assesses the risk profile of each, and generates the enumeration commands needed to follow up. It also functions as an on-demand instructor, explaining any Nmap flag combination in plain language before the operator executes it.
The significance extends beyond efficiency. AI-assisted reconnaissance democratises advanced techniques: an operator who has never written an NSE invocation can produce a vulnerability scan in seconds. For defenders, the same capability is available for continuous self-assessment — the same commands that map an attacker’s target can map one’s own infrastructure on a scheduled basis. This article documents the full workflow, from initial installation through post-scan analysis, so that practitioners on both sides of the security boundary can understand, replicate, and defend against it.
Lab Environment
All scans in this article execute within a controlled VMware-based network on the 192.168.1.0/24 subnet. The attacker operates from Kali Linux 2024 at 192.168.1.17 running Nmap 7.99 and ShellGPT 1.5.1 with Python 3.13.12. The lab contains six target hosts, each representing a distinct class of system commonly encountered in real-world assessments.Не удалось прогрузить медиа
ShellGPT communicates with the OpenAI API over HTTPS on port 443; an active internet connection and a funded OpenAI account are prerequisites. All scans run as root to enable raw socket access for SYN scans, OS detection, and packet tracing. Wireshark is available for packet capture but is not used in the ShellGPT workflow documented here.
Installing ShellGPT
Before any AI-assisted scanning is possible, the attacker installs ShellGPT on Kali Linux using pipx. The pipx installer isolates the package in its own Python virtual environment, preventing dependency conflicts with the rest of the system. The command below pulls shell-gpt version 1.5.1, built on Python 3.13.12, and exposes the sgpt binary globally — the single-entry point for every AI query in this article.
Code:
pipx install shell-gpt
Не удалось прогрузить медиа
The terminal confirms a clean installation: “installed package shell-gpt 1.5.1” and registers the sgpt command as immediately available. From this point forward, every reconnaissance step begins with a plain-English prompt to sgpt rather than a manual command lookup.
Generating and Configuring an OpenAI API Key
ShellGPT routes every query through the OpenAI API, so a valid API key is a prerequisite. The attacker navigates to platform.openai.com/api-keys, clicks “+ Create new secret key,” and names the key sgpt to distinguish it from other credentials in the account. The dashboard shows the new key as Active with “All” permissions, ready to authenticate API calls from the command line.With the key in hand, the attacker exports it as an environment variable so sgpt picks it up automatically on every invocation:
Code:
export OPENAI_API_KEY="sk-proj-<redacted>"
Не удалось прогрузить медиа
Setting the key as an environment variable rather than hard-coding it in a config file keeps credentials out of shell history and reduces exposure risk — a minimal operational-security practice even in a lab environment.
Verifying ShellGPT with a Baseline Query
Before issuing any scan commands, the attacker validates the installation end-to-end with a simple conceptual question. This confirms that the API key is correctly configured, the network path to OpenAI is clear, and the sgpt binary responds to natural-language input. The command used is:
Code:
sgpt "What is Nmap?"
Не удалось прогрузить медиа
ShellGPT returns a well-structured summary: Nmap stands for Network Mapper, it is an open-source tool for host discovery, port scanning, service and version detection, OS fingerprinting, and security auditing. The response also offers to generate an Nmap cheat sheet or safe scanning examples — demonstrating that the AI is context-aware and interactive, not merely a command translator. The baseline test passes; every subsequent prompt will carry the –shell flag to request an executable command instead of an explanation.
Discovering Live Hosts and Saving Results
With ShellGPT operational, the attacker issues the first reconnaissance command: a live-host sweep of the entire 192.168.1.0/24 subnet. The –chat scan flag opens a persistent chat session named “scan,” and –shell instructs ShellGPT to return an executable command rather than a prose explanation. The natural-language prompt is:
Code:
sgpt --chat scan --shell "Scan 192.168.1.1/24 for live hosts and save IPs to network.txt"
ShellGPT synthesises the following compound command, which the attacker executes by responding E (Execute) at the interactive prompt:
Не удалось прогрузить медиа
The -sn flag performs a ping sweep without port scanning, keeping the operation fast and quiet. The -oG – flag writes grepable output to stdout, which the awk pipeline filters to extract only the IP addresses of hosts that responded with “Up.” The results land directly in network.txt. Inspecting the file with cat reveals six live hosts — 192.168.1.1, .5, .9, .10, .15, and .17 — which become the target list for every subsequent scan.
Running a Fast Port Scan Across All Live Hosts
With the host list in hand, the attacker escalates from discovery to enumeration. A single ShellGPT prompt instructs it to scan every host in network.txt and persist the results:
Code:
sgpt --chat scan --shell "Run a fast Nmap scan on targets in network.txt and save results to netscan.txt"
ShellGPT generates the following command, which the attacker executes immediately:
Не удалось прогрузить медиа
The -T4 timing template maximises speed without triggering most rate-limiting defences. The -F flag restricts the scan to the 100 most common ports, trading completeness for velocity. The -iL flag reads targets from the file, and -oN writes normal-format output to netscan.txt for later reference. The resulting output immediately surfaces the attack surface: 192.168.1.1 exposes DNS, HTTP, and HTTPS; 192.168.1.9 runs FTP, SSH, HTTP, rpcbind, NetBIOS, SMB, and NFS — a classically over-exposed Linux host; and 192.168.1.15 presents the widest profile, with FTP, SSH, Telnet, SMTP, HTTP, rpcbind, SMB, login, shell, MySQL, PostgreSQL, VNC, X11, and AJP13 — the unmistakable fingerprint of a Metasploitable target.
Deep Service and OS Fingerprinting on a Single Target
The fast scan identified 192.168.1.9 as a high-value target. The attacker drills deeper with a service-version and OS-detection scan, again delegating command construction to ShellGPT:
Code:
sgpt --chat scan --shell "Use Nmap to scan open ports, MAC address, services, and versions on 192.168.1.9"
Не удалось прогрузить медиа
The -sV flag probes each open port to extract the exact service name and version string; the -O flag activates OS fingerprinting via TCP/IP stack analysis. The output is forensically precise: FTP resolves to vsftpd 3.0.5, SSH to OpenSSH 8.9p1 on Ubuntu Linux, HTTP to Apache httpd 2.4.52, rpcbind to versions 2–4, and SMB to Samba smbd 4. The MAC address 00:0C:29:85:D1:03 confirms a VMware guest. OS detection places the kernel between Linux 4.15 and 5.19. The entire fingerprint completes in 13.25 seconds.
Enumerating MSRPC Services
The attacker targets the Microsoft RPC attack surface on 192.168.1.15 by invoking the Nmap msrpc-enum NSE script. ShellGPT accepts the intent and constructs the precise NSE invocation:
Code:
sgpt --chat scan --shell "Scan MSRPC service of 192.168.1.15 using Nmap"
Не удалось прогрузить медиа
Port 135 returns closed for MSRPC, while 139 (NetBIOS-SSN) and 445 (Microsoft-DS) are open. The NSE script reports NT_STATUS_OBJECT_NAME_NOT_FOUND — the RPC endpoint mapper is not advertising registered services, consistent with a Samba implementation on Linux rather than a native Windows RPC stack. SMB is present and accessible, but the standard Windows DCOM/RPC enumeration path is unavailable. The scan completes in 0.70 seconds.
Conducting a TCP SYN (Stealth) Scan
The attacker requests a full stealth scan against the Metasploitable target to enumerate every open TCP port without completing a three-way handshake. Because SYN scans require raw socket access, the command runs as root — a requirement ShellGPT implicitly satisfies by generating the correct flag:
Code:
sgpt --chat scan --shell "Run a TCP SYN scan on 192.168.1.15"
Не удалось прогрузить медиа
The -sS flag dispatches a SYN segment to each probed port. An open port answers with SYN/ACK; Nmap replies with RST, collapsing the half-open connection before it is logged by most application-layer monitors. The output catalogues 23 open services: FTP (21), SSH (22), Telnet (23), SMTP (25), DNS (53), HTTP (80), rpcbind (111), NetBIOS (139), SMB (445), exec (512), login (513), shell (514), rmiregistry (1099), ingreslock (1524), NFS (2049), ccproxy-ftp (2121), MySQL (3306), PostgreSQL (5432), VNC (5900), X11 (6000), IRC (6667), AJP13 (8009), and an unknown service on 8180. The MAC address 00:0C:29:1E:7E:AF confirms the VMware guest. The entire scan completes in 0.79 seconds.
Scanning a Specific Set of Ports
When the attacker needs to verify only a handful of ports, ShellGPT accepts an explicit port list and translates it directly:
Code:
sgpt --chat scan --shell "Scan ports 21,22,80,443 on 192.168.1.15"
Не удалось прогрузить медиа
The targeted scan confirms FTP (21), SSH (22), and HTTP (80) as open, while HTTPS (443) is closed. The absence of HTTPS on a host running Apache narrows the web-application attack surface to plain-text HTTP — a significant finding for subsequent credential-interception attacks. The scan resolves in 0.68 seconds.
Scanning Multiple Targets Simultaneously
ShellGPT handles multi-target scans as naturally as single-host queries:
Code:
sgpt --chat scan --shell "Scan open ports on 192.168.1.9 and 192.168.1.15"
Не удалось прогрузить медиа
Nmap scans both hosts in parallel and returns sequential reports. The report for 192.168.1.9 lists 7 open ports (FTP, SSH, HTTP, rpcbind, NetBIOS, SMB, NFS) with MAC 00:0C:29:85:D1:03. The report for 192.168.1.15 lists 23 open ports — the full Metasploitable surface — with MAC 00:0C:29:1E:7E:AF. Both hosts are confirmed up and fully enumerated within 0.83 seconds of combined scan time.
OS Detection via TTL Analysis on Two Hosts
The attacker requests OS fingerprinting across two hosts in a single prompt:
Code:
sgpt --chat scan --shell "Identify the operating systems of 192.168.1.9 and 192.168.1.11 using TTL analysis"
Не удалось прогрузить медиа
For 192.168.1.9, OS detection reports “Linux 4.15 – 5.19” as the most likely match, with secondary guesses of OpenWrt 21.02 and MikroTik RouterOS 7.2 – 7.5. For 192.168.1.11, the fingerprint is decisive: “Microsoft Windows Server 2019,” corroborated by the CPE cpe:/o:microsoft:windows_server_2019 and open ports 88 (Kerberos), 135 (MSRPC), 389 (LDAP), 445 (SMB), 464 (kpasswd), and 5985 (WS-Management) — the unmistakable signature of a Windows domain controller. The scan completes in 3.29 seconds.
Applying a Timing Template for Speed Optimisation
The attacker benchmarks scan speed using Nmap’s T4 aggressive timing template, which maximises parallelism and reduces inter-probe delays:
Code:
sgpt --chat scan --shell "Run a fast timing template scan on 192.168.1.15 using Nmap"
Не удалось прогрузить медиа
With T4 engaged, Nmap completes a full default-port scan of 192.168.1.15 — enumerating all 23 open services, including MySQL, PostgreSQL, VNC, X11, and AJP13 — in just 0.75 seconds. The T4 template is the practical default for lab environments where stealth is not a concern; in production environments, T3 or lower reduces IDS detection risk at the cost of scan duration.
Executing an Aggressive Scan
The aggressive scan combines four capabilities in a single flag — OS detection (-O), version detection (-sV), script scanning (-sC), and traceroute — yielding the most comprehensive single-pass profile Nmap can produce:
Code:
sgpt --chat scan --shell "Aggressive Scan 192.168.1.9 for open ports using Nmap"
Не удалось прогрузить медиа
The output is extensive. The FTP service (vsftpd 3.0.5) accepts anonymous logins — the ftp-anon NSE script logs in as “ftp,” traverses the pub directory, and records the session banner. SSH (OpenSSH 8.9p1) returns both ECDSA and ED25519 host key fingerprints. Apache on port 80 returns a 403 Forbidden response and its server header confirms version 2.4.52. The rpcbind script fully enumerates the RPC program table, exposing NFS, mountd, nlockmgr, and status programs across TCP and UDP. Samba smbd 4 serves both ports 139 and 445. The combined output surfaces an anonymous FTP foothold, a fully detailed SSH identity, and a complete RPC service map in one scan.
Running an NSE Vulnerability Scan
ShellGPT translates a vulnerability-scan intent directly into an NSE script invocation, removing the need-to-know individual script names:
Code:
sgpt --chat scan --shell "Run an Nmap vulnerability scan on 192.168.1.15"
Не удалось прогрузить медиа
The vuln script category runs every installed vulnerability-detection NSE script against each open port. Three critical findings emerge. First, vsftpd 2.3.4 backdoor (CVE-2011-2523) is flagged as VULNERABLE and Exploitable — the script executes id as the shell command and receives uid=0(root) gid=0(root), confirming remote root code execution without any further exploit development. Second, SSL POODLE (CVE-2014-3566) is confirmed VULNERABLE on port 25, exposing any SSL 3.0 session to CBC-padding-oracle decryption attacks. Third, an Anonymous Diffie-Hellman Key Exchange MitM Vulnerability is present on the SMTP service — the cipher suite TLS_DH_anon_WITH_RC4_128_MD5 with a 1024-bit modulus provides no authentication, allowing a man-in-the-middle to compromise session confidentiality and integrity entirely.
Enumerating HTTP Services with NSE
The attacker uses ShellGPT to invoke the http-enum NSE script, which brute-forces common web application paths against the target’s HTTP service:
Code:
sgpt --chat scan --shell "Enumerate HTTP services on 192.168.1.15 using Nmap NSE scripts"
Не удалось прогрузить медиа
The script discovers seven paths on port 80: /tikiwiki/ (Tikiwiki CMS), /test/ (test page), /phpinfo.php (PHP configuration disclosure), /phpMyAdmin/ (database administration interface), /doc/ (directory listing on Apache 2.2.8 with DAV/2 enabled), /icons/ (directory listing), and /index/ (directory listing). Each of these represents a distinct attack vector: phpinfo.php leaks the full PHP and server configuration; phpMyAdmin exposes the database tier directly; WebDAV on /doc/ may allow arbitrary file writes. The enumeration completes in 1.38 seconds and maps the entire web application surface without a single manual browser request.
Enumerating SMB Shares and OS Details
The attacker targets the SMB service on port 445 to extract share names and OS metadata without authentication:
Code:
sgpt --chat scan --shell "Enumerate SMB shares and SMB OS details on 192.168.1.15"
Не удалось прогрузить медиа
The smb-os-discovery script identifies the host as Unix running Samba 3.0.20-Debian, with the computer name metasploitable and FQDN metasploitable.localdomain. The smb-enum-shares script enumerates five shares without credentials: ADMIN$ (IPC), IPC$ (anonymous READ/WRITE), opt (disk, no anonymous access), print$ (printer drivers, no anonymous access), and tmp (disk, anonymous READ/WRITE to C:\tmp). The IPC$ and tmp shares both permit unauthenticated read/write access — IPC$ is exploitable for null-session attacks, and the writable tmp share could serve as a staging area for payload delivery.
Enumerating SSH Algorithms and Host Keys
The attacker audits the SSH service configuration to identify weak cryptographic algorithms that may be exploitable or indicate an unpatched version:
Code:
sgpt --chat scan --shell "Enumerate SSH algorithms and SSH information on 192.168.1.15"
Не удалось прогрузить медиа
The ssh-auth-methods script confirms that the server accepts both publickey and password authentication — the password method is directly susceptible to brute-force attacks. The ssh2-enum-algos script enumerates the full algorithm suite including the deprecated diffie-hellman-group1-sha1 (vulnerable to Logjam), arcfour, 3des-cbc, and CBC-mode AES variants. The ssh-hostkey script extracts a 1024-bit DSA key and a 2048-bit RSA key with their full fingerprints. The presence of these deprecated algorithms marks this SSH daemon as severely outdated and cryptographically weak.
👍71
❤️21
😁7
😮14
👏14
💯9
LIMB