← Lab /Security & privacy

LLM framework generates >90% syntactically valid PowerShell pentest code

RedShell can produce offensive PowerShell snippets with over 90% syntactic validity and high semantic similarity to reference attacks

Security & privacy arXiv 13 Apr 2026 Method Prototype evidence

Published as “Towards Automated Pentesting with Large Language Models”

Why it matters

RedShell demonstrates that lightweight, locally fine-tuned LLMs can reliably generate offensive PowerShell code, enabling more automated and privacy-preserving pentesting workflows.

Summary

RedShell can generate malicious PowerShell code that is syntactically valid in over 90% of cases and shows more than 50% average code similarity to reference snippets, while achieving 100% correctness in functional tests against a realistic pentesting scenario. The framework is built with a privacy-preserving, hardware-efficient fine-tuning approach that runs on a single GPU and does not require large-scale pre-training. Evidence is based on comparisons to several open-source and proprietary baselines, but the models still emit safety-related warnings in more than a quarter of outputs and the underlying dataset has limited size and coverage.

What they found 2

  1. Syntactic validity exceeds 90% of generated samples.

    “with 90% of the generated samples successfully parsed without errors.”

  2. Functional evaluation shows 100% correctness of generated payloads.

    “achieve 100% correctness in produced samples”

Caveats 5

  • All models triggered more than 25% warning occurrences regarding safety violations of PowerShell, indicating unsafe code generation.
  • Size Limitation. The dataset provides a limited number and diversity of code samples, which may limit the efficacy of the fine-tuning process.
  • Module Coverage. Relevant offensive PowerShell modules were not covered by the dataset, including Nishang [35], PowerUpSQL [42], and MicroBurst [41].
  • MITRE ATT&CK Coverage. The Resource Development tactic was not covered by the dataset.
  • the train-test split of the dataset does not guarantee balanced representation across MITRE ATT&CK tactics.

What’s new here 4

  • Fine-tunes existing LLMs on a curated malicious PowerShell dataset without large-scale pre-training, using only a single GPU.
  • Provides a privacy-preserving, locally run framework (RedShell) rather than relying on cloud APIs.
  • Extends the original PowerShell dataset by more than 100%, covering all MITRE ATT&CK tactics and additional modules.
  • Evaluates functional reliability of generated payloads in a controlled, realistic pentesting environment.