Using Claude Code as a Tool for Penetration Testing

Agent Claude

© Lead Image © Kirillm, 123RF.com

© Lead Image © Kirillm, 123RF.com

Article from Issue 313/2026
Author(s):

Attackers are using AI to carry out their attacks. Why not put AI to work on the defense? We tried out Claude Code as a tool for pen testing.

I recently found the time to sit down with Claude Code [1] from Anthropic to get a better understanding of why friends and colleagues were so enthusiastic about AI-assisted coding. Claude Code is an agentic coding tool that, according to the vendor, "runs in a terminal/IDE, understands the full codebase and can act autonomously toward a goal." In other words, we have already moved far from just chatting to AI; instead we have given it agency to act on our behalf.

Working in cybersecurity, much of my focus has been on defending against attacks for clients, but over the last few years I have significantly improved my offensive security knowledge. And, sitting down with Claude Code, the first thing I thought of was chaining multiple security tools together to see what was possible.

In this article, I will demonstrate how to get started with Claude Code and apply it to an example of ethical hacking. The following approach will build a platform for Claude so it can send its agents off to pentest any target that I point it at, simply by typing the run command. In other words, I will set up pentest infrastructure using Claude to help with the Python coding, plus the integration of the tools involved. My involvement, as part of the assisted coding work, will be to make sure Claude Code is configured in a way that means I get the most reliable and repeatable results. I think this is a clever route to take because I get the benefits of running multiple agents via Claude to perform simultaneous pentests, and the configuration is fluid enough that I can easily make changes via Claude's CLI using chatbot-like instructions.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Download Article PDF now with Express Checkout
Price $2.95
(incl. VAT)

Buy Linux Magazine

Related content

  • Claude Code Best Practices

    We'll show you some best practices for introducing Claude Code (or another LLM-based coding assistant) while maintaining knowledge and control of the code.

  • Claude Code Workflow

    AI is here to stay, and understanding how it works under the hood can mean the difference between frustration and genuinely useful results. This article covers LLM fundamentals, effective prompting, and a structured agentic workflow that puts you in control.

  • Nmap Scripting

    Nmap is rolling out a new scripting engine to automatically investigate vulnerabilities that turn up in a security scan. We’ll show you how to protect your network with Nmap and NSE.

  • Attacking Webcams

    If you still aren't convinced of the need for vigilance, find out how easy it is for an attacker to get control of a laptop camera.

  • Is Linus Torvalds Vibe Coding?

    The creator of Linux has added AI into his process for Linux kernel development, and it's more than just for debugging.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News