Towards Automated Pentesting with Large Language Models

📅 2026-04-13
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
Traditional penetration testing relies heavily on manual efforts, suffering from low efficiency and poor scalability, while adversaries have already begun leveraging large language models (LLMs) to automatically generate malicious code, necessitating automated defensive countermeasures. This work proposes RedShell, a novel framework that introduces the first high-quality, red-team-oriented PowerShell dataset for penetration testing and fine-tunes LLMs to produce Windows exploit payloads with high syntactic correctness and semantic alignment. The approach integrates syntactic validation, semantic similarity evaluation (e.g., edit distance), and functional testing in real-world environments, enabling secure, privacy-preserving, and hardware-efficient automated attack generation. Experimental results demonstrate that over 90% of the generated payloads are syntactically valid, achieve average semantic similarity exceeding 50%, and exhibit significantly higher execution reliability compared to existing methods.

Technology Category

Natural Language Processing: Code Generation / Program Synthesis from Natural LanguageMachine Learning: Large Multimodal Models (LMMs)Computer Vision: Adversarial Attacks & Robustness

Application Category

User Modeling, Personalization and Recommendation: Attacks and countermeasures in recommendation systemsEconomics, Online Markets and Human Computation: Cost models of using LLMs in production systemsSystems and Infrastructure for Web, Mobile and WoT: Applied ML and AI for Web-based mobile applications
📝 Abstract
Large Language Models (LLMs) are redefining offensive cybersecurity by allowing the generation of harmful machine code with minimal human intervention. While attackers take advantage of dark LLMs such as XXXGPT and WolfGPT to produce malicious code, ethical hackers can follow similar approaches to automate traditional pentesting workflows. In this work, we present RedShell, a privacy-preserving, hardware-efficient framework that leverages fine-tuned LLMs to assist pentesters in generating offensive PowerShell code targeting Microsoft Windows vulnerabilities. RedShell was trained on a malicious PowerShell dataset from the literature, which we further enhanced with manually curated code samples. Experiments show that our framework achieves over 90% syntactic validity in generated samples and strong semantic alignment with reference pentesting snippets, outperforming state-of-the-art counterparts in distance metrics such as edit distance (above 50% average code similarity). Additionally, functional experiments emphasize the execution reliability of the snippets produced by RedShell in a testing scenario that mirrors real-world settings. This work sheds light on the state-of-the-art research in the field of Generative AI applied to malicious code generation and automated testing, acknowledging the potential benefits that LLMs hold within controlled environments such as pentesting.
Problem

Research questions and friction points this paper is trying to address.

Automated Pentesting
Large Language Models
Malicious Code Generation
PowerShell
Offensive Cybersecurity
Innovation

Methods, ideas, or system contributions that make the work stand out.

Large Language Models
Automated Pentesting
PowerShell Code Generation
Privacy-Preserving Framework
Malicious Code Synthesis
💼 Related Jobs
No related jobs found.
R
Ricardo Bessa
NOVA University Lisbon — FCT & NOVA LINCS, Portugal
Rui Claro
Rui Claro
INESC-ID, Instituto Superior Técnico, Universidade de Lisboa, Portugal
J
João Trindade
Layer8 - Shield Domain SA, Portugal
J
João Lourenço
NOVA University Lisbon — FCT & NOVA LINCS, Portugal