Gemini CLI + Kali Linux in Practice: A Complete Guide to AI-Automated Penetration Testing

Kali Linux 2025.3 officially integrates Google Gemini CLI, enabling natural language-driven automated penetration testing.
Kali Linux 2025.3 adds Google Gemini CLI to its official repository, allowing security professionals to describe task objectives in natural language while AI automatically orchestrates tool chains like Nmap and Nikto to execute scans, detect vulnerabilities, and generate structured reports. Built on an AI Agent architecture with tool calling, context awareness, and intelligent error correction, it supports red team reconnaissance, blue team incident response, and more — though it cannot replace professional judgment and must only be used within legally authorized scope.
When AI Enters the Security Terminal: The Fusion of Gemini CLI and Kali Linux
In 2025, the cybersecurity field witnessed a landmark change: Kali Linux 2025.3 officially integrated Google Gemini CLI, injecting generative AI capabilities directly into the command-line terminal that penetration testers know best. Security professionals no longer need to manually type complex scanning commands one by one — they can now describe task objectives in natural language, letting AI automatically orchestrate tool chains, execute scans, analyze results, and generate reports.
Kali Linux is a Debian-based Linux distribution maintained by the Offensive Security team, formerly known as BackTrack Linux. It comes pre-installed with over 600 penetration testing and security auditing tools, including Nmap, Metasploit, Burp Suite, Wireshark, and more, making it the standard working platform for penetration testers and security researchers worldwide. Each major Kali version update typically introduces new tool integrations and kernel upgrades, and the 2025.3 release's inclusion of AI tools in the official repository marks the distribution's transformation from a traditional tool collection to an intelligent security platform.
This isn't a simple chatbot wrapper — it's a terminal AI assistant with genuine tool invocation, context awareness, and automation orchestration capabilities. Gemini CLI is a command-line interaction tool built by Google on its Gemini large language model family. The Gemini model, developed by Google DeepMind, is a multimodal AI model with text understanding, code generation, and logical reasoning capabilities. The CLI version is designed specifically for developers and technical professionals, calling model capabilities directly through the terminal. It supports a Function Calling mechanism that enables the model to invoke external tools to perform actual operations after identifying user intent, rather than merely generating text responses. This "tool calling" architecture is the key technical feature that distinguishes it from ordinary chatbots.
This article provides a complete walkthrough from environment setup to hands-on demonstrations, covering Gemini CLI's working methodology in penetration testing, its core capabilities, and the security and ethical boundaries that must be observed.
Disclaimer: This article is intended solely for educational and legitimate security research purposes. Any unauthorized scanning or attack activity is illegal.
Environment Setup: Kali Linux 2025.3 + Gemini CLI Installation and Configuration
Obtaining Kali Linux 2025.3
First, download the latest version from the official Kali website (kali.org). Two main formats are available:
- ISO image files: Suitable for direct installation on physical machines or custom virtual machines
- Pre-built virtual machine files: Supporting VMware and VirtualBox, ready to use out of the box
For quickly setting up a lab environment, the VMware pre-built virtual machine is recommended. After downloading, extract the folder, find the .vmx file, and double-click it to automatically import into VMware. It's recommended to adjust the virtual machine memory allocation to at least 4GB to ensure smooth AI tool operation.
Installing and Configuring Gemini CLI
After booting Kali Linux (default username and password are both kali), open a terminal and execute the following steps:
# Check current system version
cat /etc/os-release
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install Gemini CLI
sudo apt install gemini-cli
After installation, enter gemini-cli -h to view the help menu and learn about all available options and command syntax. When running gemini-cli for the first time, the system will prompt for Google account authentication — press 1 to select Google login, and the browser will automatically open an authentication page where you can complete email and password verification.

After successful authentication, the Gemini CLI interactive dialog interface will appear in the terminal, and you can now issue security testing tasks using natural language.
Hands-On Demo: Automated Penetration Testing with Natural Language
Comprehensive Security Scanning Driven by a Single Sentence
Gemini CLI's core capability lies in this: you only need to describe a task objective in natural language, and it automatically decomposes it into multiple technical steps and executes them one by one. Behind this capability is the implementation of an AI Agent architecture — an Agent that can perceive its environment, formulate plans, invoke tools, and iterate execution based on feedback. Its core technologies include the ReAct (Reasoning + Acting) framework, which allows the model to alternate between thinking and acting; Tool Use / Function Calling, which enables the model to invoke external command-line tools; and a memory mechanism that allows the Agent to maintain contextual coherence across multi-step tasks. In security testing scenarios, this means AI can not only generate individual commands but also dynamically adjust subsequent strategies based on the output of previous steps — for example, automatically deciding to run a web vulnerability scan after discovering port 80 is open. This chain-of-thought reasoning capability is something traditional script automation cannot achieve.
Here's a typical penetration testing prompt example:
"Scan http://testphp.vulnweb.com, find open ports, identify the HTTP server, run a Nikto scan for common vulnerabilities, check for SQL injection and XSS, and generate a JSON report saved to /tmp/example.json"
After entering this prompt, Gemini CLI will automatically plan and execute the following workflow:
- Nmap port scanning: AI generates and requests authorization to execute the Nmap command; users can press
1,2, or3to select the authorization level - Service version detection: Automatically parses scan results to identify open ports and running service versions
- Nikto web vulnerability scanning: After requesting execution permission, automatically runs the web vulnerability scan
- SQL injection and XSS detection: Performs targeted vulnerability checks against discovered web services
- Structured report generation: Consolidates all results into a JSON file

Nmap Port Scanning Technical Background
Nmap (Network Mapper) is an open-source network exploration and security auditing tool developed by Gordon Lyon, considered one of the most fundamental and important tools in the cybersecurity field. It discovers hosts on a network, open ports, running services and their versions, and can even infer operating system types by sending carefully crafted network packets to target hosts and analyzing their responses. Nmap supports multiple scanning techniques, including TCP SYN scan (half-open scan), TCP Connect scan, UDP scan, and FIN/Xmas/Null stealth scans. Its scripting engine (NSE) also allows users to write and run custom scripts for more complex detection tasks.
Nikto Web Vulnerability Scanner Explained
Nikto is an open-source web server scanner specifically designed to detect potential security issues on web servers. It can check over 6,700 potentially dangerous files and programs, detect known vulnerabilities across more than 1,250 server versions, and identify approximately 270 server configuration issues. Nikto's detection scope includes outdated server software versions, dangerous CGI scripts, default installation files, sensitive directory exposure, and missing HTTP header security configurations. While Nikto is not a stealthy scanning tool (it leaves extensive traces in target logs), its comprehensiveness makes it a standard tool during the initial phases of security assessments.
SQL Injection and XSS Vulnerability Principles
SQL injection (SQLi) and Cross-Site Scripting (XSS) are web application security vulnerabilities that have consistently ranked among the top in the OWASP Top 10. SQL injection works by attackers inserting malicious SQL statements into user input fields, exploiting insufficient input filtering in applications to directly manipulate the backend database, potentially leading to data breaches, data tampering, or complete server compromise. XSS involves attackers injecting malicious JavaScript code into web pages; when other users browse the page, the malicious script executes in the victim's browser, potentially stealing session cookies, hijacking user accounts, or redirecting to phishing pages. XSS is categorized into three types: reflected, stored, and DOM-based, with stored XSS being the most dangerous since malicious code is permanently stored on the target server.
Intelligent Error Correction and Result Interpretation
Throughout the entire process, if errors or omissions occur, Gemini CLI automatically identifies issues and attempts to fix them. For instance, when a tool is missing dependencies, it automatically generates installation commands; when command parameters are incorrect, it adjusts them and re-executes.

After scanning is complete, the terminal clearly displays all findings: open port lists (e.g., TCP 53, TCP 80), service version information (e.g., Nginx 1.19.0), vulnerability entries discovered by Nikto, and SQL injection and XSS detection results. The entire workflow from entering a single sentence to obtaining a complete report represents a very significant efficiency improvement.
Gemini CLI Core Capabilities: Red Team, Blue Team, and General Use Cases
Offensive Security (Red Team Applications)
- Reconnaissance planning: Converts targets into checklists and prioritized tasks, automatically summarizing findings
- Tool chain orchestration: Bridges gaps between tools — for example, parsing Nmap output to automatically identify web targets and run Nikto, eliminating manual copy-pasting
- Rapid PoC development: Creates proof-of-concept scripts or exploit templates for validating and reproducing security findings
- Repetitive task automation: Generates parsing scripts for scanner output, deduplicates findings, and batch-creates reports
Defensive Security (Blue Team Applications)
- Incident triage: Summarizes suspicious logs or scanner output and suggests investigation steps
- Patch prioritization: Aggregates vulnerability information and develops prioritized remediation plans
- Security hardening checks: Automatically generates checklists and scripts to validate security configurations
- Documentation and training: Generates onboarding guides, operational procedures, and standard operating procedures for security teams
General Capabilities
- Interactive terminal conversations: Converse with AI directly from the shell to get tool explanations or request code generation
- Session context retention: Maintains context throughout the terminal session, keeping follow-up questions coherent
- Multi-format report output: Supports structured formats including JSON, Markdown, and plain text
- Knowledge assistance: Explains unfamiliar tool parameters and protocols, helps interpret ambiguous output

Technical Limitations and Security Ethics Red Lines
Technical Limitations That Cannot Be Ignored
Despite Gemini CLI's impressive capabilities, every user must clearly understand the following limitations:
- Cannot replace professional judgment: AI can suggest courses of action, but it doesn't understand your specific business context and risk tolerance — human verification remains indispensable
- False positive risks exist: AI-generated summaries or commands may be inaccurate; every output must be reviewed by a human before being trusted
- Over-automation hazards: Executing AI-generated commands without review could lead to unexpected service disruptions or data loss
Legal and Ethical Bottom Lines
These are the bottom lines every security professional must remember:
- Written authorization is a prerequisite: Before testing or scanning any system you don't own, you must obtain explicit written permission
- Restrict to controlled environments: Use Gemini CLI only in controlled lab environments or against authorized targets
- Defense-first principle: Prioritize defensive and educational workflows, such as incident triage, report generation, and security configuration assistance
- Automated scanning is not above the law: No matter how convenient the tool, unauthorized automated scanning is illegal
New Thinking for Penetration Testing in the AI Era
The combination of Gemini CLI and Kali Linux represents an important direction in cybersecurity tool evolution — a paradigm shift from "memorizing command syntax" to "describing testing intent." The core value of security professionals is no longer memorizing every tool's parameters, but possessing the right security mindset, risk assessment ability, and professional interpretation of results.
AI lowers the technical barrier to penetration testing while simultaneously amplifying the risk of misuse. The more powerful the tool, the greater the user's responsibility. While embracing AI-empowered security testing, always put legality, compliance, and professional ethics first — this is the true spirit of ethical hacking.
For security professionals looking to get started with AI-assisted penetration testing, it's recommended to begin by building a local lab environment and practicing repeatedly on legitimate targets to gradually master Gemini CLI's capability boundaries and best practices. DVWA (Damn Vulnerable Web Application) is a PHP/MySQL web application intentionally designed with multiple security vulnerabilities, supporting adjustable security levels (low, medium, high, impossible), making it a classic training ground for learning web security offense and defense. VulnHub is a community platform offering numerous downloadable virtual machine targets, each simulating different real-world attack scenarios, from simple privilege escalation to complex multi-layer network penetration. Additionally, HackTheBox and TryHackMe provide online lab environments and guided learning paths. Practicing on these legitimate targets is the standard approach for security professionals to improve practical skills without breaking the law, and a safe way to validate the capability boundaries of new tools like Gemini CLI.
Related articles
TutorialsChatGPT Plus Subscription Guide: Are GPT-5.5, image-2, and Codex Worth the Upgrade?
A detailed look at ChatGPT Plus features — GPT-5.5, image-2, and Codex — with a Plus vs Pro comparison and a complete step-by-step subscription guide for users outside the US.
TutorialsHarness AI Engineering in Practice: Using Claude Code to Master Enterprise-Level E-Commerce Development
Deep dive into Harness AI Engineering: master enterprise e-commerce development with Claude Code using the Rules, Skills, Wiki, and Changes framework.
TutorialsCursor + Codex Dual-IDE Collaboration: A Practical Methodology for Open-Source Project Customization
A complete methodology for open-source project customization based on real-world experience, detailing the Cursor+Codex dual-IDE workflow, seven-stage process, MVP validation, and AI source code reading techniques.