RedShell generates malicious PowerShell with <10% parse errors and moderate similarity to references
RedShell can automatically produce syntactically valid malicious PowerShell code that matches reference snippets with over 50% edit distance similarity and over 40% METEOR score
Security & privacy arXiv 13 Apr 2026 Method Prototype evidence
Published as “RedShell: A Generative AI-Based Approach to Ethical Hacking”
Why it matters
RedShell gives red-team practitioners an automated way to produce realistic malicious PowerShell payloads, potentially speeding up penetration-testing workflows.
Summary
RedShell can automatically generate malicious PowerShell code that is syntactically valid in fewer than 10% of cases and semantically similar to reference snippets, with mean Edit Distance scores above 50% and METEOR scores above 40%. The evidence comes from a dataset of 2,262 PowerShell samples and evaluation against both open-source and proprietary LLM baselines, showing comparable or better performance on standard code-generation metrics.
What they found 3
- Parse errors occur in fewer than 10% of generated samples.
“Experiments show that our tool was able to generate syntactically valid PowerShell code, with fewer than 10% of the generated samples resulting in parse errors.”
- Qwen2.5-Coder outperforms prior reference models on all similarity metrics.
“Qwen2.5-Coder outperformed the reference models across all output similarity metrics.”
- Using the extended dataset yields higher BLEU-4 and Exact Match scores than using only the reference dataset.
“the model fine-tuned with our extended dataset demonstrated more substantial improvements in BLEU-4 and Exact Match”
Caveats 5
- all the three specialized models produced snippets with significantly high warning percentages.
- The “UnexpectedToken” parse error was the most frequent occurrence to prevent the execution of the generated samples.
- only leaving uncovered the Resource Development tactic.
- the train-test split does not guarantee balanced representation across MITRE ATT&CK tactics.
- A potential threat to the validity of RedShell lies in the absence of a functional evaluation of the generated snippets.
What’s new here 4
- Introduces a curated malicious PowerShell ground-truth dataset (reference + extended) for training offensive code generators.
- Fine-tunes open-source LLMs (Qwen2.5, Qwen2.5-Coder, Llama3.1) locally, avoiding external API privacy concerns and ethical guardrails.
- Demonstrates that the fine-tuned Qwen2.5-Coder surpasses prior specialized models (CodeGPT, CodeGen, CodeT5+) and closed models (ChatGPT 3.5, DeepSeekChatV3) on multiple similarity metrics.
- Shows that expanding the dataset improves stricter metrics (BLEU-4, Exact Match) while keeping overall semantic scores stable.