|
9 | 9 |
|
10 | 10 | HackingBuddyGPT helps security researchers use LLMs to discover new attack vectors and save the world (or earn bug bounties) in 50 lines of code or less. In the long run, we hope to make the world a safer place by empowering security professionals to get more hacking done by using AI. The more testing they can do, the safer all of us will get. |
11 | 11 |
|
| 12 | +**🆕 New Feature**: hackingBuddyGPT now supports both SSH connections to remote targets and local shell execution for easier testing and development! |
| 13 | + |
| 14 | +**⚠️ WARNING**: This software will execute commands on live environments. When using local shell mode, commands will be executed on your local system, which could potentially lead to data loss, system modification, or security vulnerabilities. Always use appropriate precautions and consider using isolated environments or virtual machines for testing. |
| 15 | + |
| 16 | + |
12 | 17 | We aim to become **THE go-to framework for security researchers** and pen-testers interested in using LLMs or LLM-based autonomous agents for security testing. To aid their experiments, we also offer re-usable [linux priv-esc benchmarks](https://github.com/ipa-lab/benchmark-privesc-linux) and publish all our findings as open-access reports. |
13 | 18 |
|
14 | 19 | If you want to use hackingBuddyGPT and need help selecting the best LLM for your tasks, [we have a paper comparing multiple LLMs](https://arxiv.org/abs/2310.11409). |
@@ -65,21 +70,22 @@ Our initial forays were focused upon evaluating the efficiency of LLMs for [linu |
65 | 70 | privilege escalation attacks](https://arxiv.org/abs/2310.11409) and we are currently breaching out into evaluation |
66 | 71 | the use of LLMs for web penetration-testing and web api testing. |
67 | 72 |
|
68 | | -| Name | Description | Screenshot | |
69 | | -|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
70 | | -| [minimal](https://docs.hackingbuddy.ai/docs/dev-guide/dev-quickstart) | A minimal 50 LoC Linux Priv-Esc example. This is the usecase from [Build your own Agent/Usecase](#build-your-own-agentusecase) |  | |
71 | | -| [linux-privesc](https://docs.hackingbuddy.ai/docs/usecases/linux-priv-esc) | Given an SSH-connection for a low-privilege user, task the LLM to become the root user. This would be a typical Linux privilege escalation attack. We published two academic papers about this: [paper #1](https://arxiv.org/abs/2308.00121) and [paper #2](https://arxiv.org/abs/2310.11409) |  | |
72 | | -| [web-pentest (WIP)](https://docs.hackingbuddy.ai/docs/usecases/web) | Directly hack a webpage. Currently in heavy development and pre-alpha stage. |  | |
73 | | -| [web-api-pentest (WIP)](https://docs.hackingbuddy.ai/docs/usecases/web-api) | Directly test a REST API. Currently in heavy development and pre-alpha stage. (Documentation and testing of REST API.) | Documentation: Testing: | |
| 73 | +| Name | Description | Screenshot | |
| 74 | +|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 75 | +| [minimal](https://docs.hackingbuddy.ai/docs/dev-guide/dev-quickstart) | A minimal 50 LoC Linux Priv-Esc example. This is the usecase from [Build your own Agent/Usecase](#build-your-own-agentusecase) |  | |
| 76 | +| [linux-privesc](https://docs.hackingbuddy.ai/docs/usecases/linux-priv-esc) | Given a connection (SSH or local shell) for a low-privilege user, task the LLM to become the root user. This would be a typical Linux privilege escalation attack. We published two academic papers about this: [paper #1](https://arxiv.org/abs/2308.00121) and [paper #2](https://arxiv.org/abs/2310.11409) |  | |
| 77 | +| [web-pentest (WIP)](https://docs.hackingbuddy.ai/docs/usecases/web) | Directly hack a webpage. Currently in heavy development and pre-alpha stage. |  | |
| 78 | +| [web-api-pentest (WIP)](https://docs.hackingbuddy.ai/docs/usecases/web-api) | Directly test a REST API. Currently in heavy development and pre-alpha stage. (Documentation and testing of REST API.) | Documentation: Testing: | |
74 | 79 | | [extended linux-privesc](https://docs.hackingbuddy.ai/docs/usecases/extended-linux-privesc) | This usecases extends linux-privesc with additional features such as retrieval augmented generation (RAG) or chain-of-thought (CoT) |   | |
| 80 | + |
75 | 81 | ## Build your own Agent/Usecase |
76 | 82 |
|
77 | 83 | So you want to create your own LLM hacking agent? We've got you covered and taken care of the tedious groundwork. |
78 | 84 |
|
79 | 85 | Create a new usecase and implement `perform_round` containing all system/LLM interactions. We provide multiple helper and base classes so that a new experiment can be implemented in a few dozen lines of code. Tedious tasks, such as |
80 | 86 | connecting to the LLM, logging, etc. are taken care of by our framework. Check our [developer quickstart quide](https://docs.hackingbuddy.ai/docs/dev-guide/dev-quickstart) for more information. |
81 | 87 |
|
82 | | -The following would create a new (minimal) linux privilege-escalation agent. Through using our infrastructure, this already uses configurable LLM-connections (e.g., for testing OpenAI or locally run LLMs), logs trace data to a local sqlite database for each run, implements a round limit (after which the agent will stop if root has not been achieved until then) and can connect to a linux target over SSH for fully-autonomous command execution (as well as password guessing). |
| 88 | +The following would create a new (minimal) linux privilege-escalation agent. Through using our infrastructure, this already uses configurable LLM-connections (e.g., for testing OpenAI or locally run LLMs), logs trace data to a local sqlite database for each run, implements a round limit (after which the agent will stop if root has not been achieved until then) and can connect to a target system either locally or over SSH for fully-autonomous command execution (as well as password guessing). |
83 | 89 |
|
84 | 90 | ~~~ python |
85 | 91 | template_dir = pathlib.Path(__file__).parent |
@@ -155,7 +161,9 @@ We try to keep our python dependencies as light as possible. This should allow f |
155 | 161 |
|
156 | 162 | 1. an OpenAI API account, you can find the needed keys [in your account page](https://platform.openai.com/account/api-keys) |
157 | 163 | - please note that executing this script will call OpenAI and thus charges will occur to your account. Please keep track of those. |
158 | | -2. a potential target that is accessible over SSH. You can either use a deliberately vulnerable machine such as [Lin.Security.1](https://www.vulnhub.com/entry/) or a security benchmark such as our [linux priv-esc benchmark](https://github.com/ipa-lab/benchmark-privesc-linux). |
| 164 | +2. a target environment to test against. You have two options: |
| 165 | + - **Local Shell**: Use your local system (useful for testing and development) |
| 166 | + - **SSH Target**: A remote machine accessible over SSH. You can use a deliberately vulnerable machine such as [Lin.Security.1](https://www.vulnhub.com/entry/) or a security benchmark such as our [linux priv-esc benchmark](https://github.com/ipa-lab/benchmark-privesc-linux). |
159 | 167 |
|
160 | 168 | To get everything up and running, clone the repo, download requirements, setup API keys and credentials, and start `wintermute.py`: |
161 | 169 |
|
@@ -229,11 +237,45 @@ usage: src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc [--help] [--config con |
229 | 237 | --conn.port='2222' (default from .env file, alternatives: 22 from builtin) |
230 | 238 | ``` |
231 | 239 |
|
232 | | -### Provide a Target Machine over SSH |
| 240 | +### Connection Options: Local Shell vs SSH |
| 241 | +
|
| 242 | +hackingBuddyGPT now supports two connection modes: |
| 243 | +
|
| 244 | +#### Local Shell Mode |
| 245 | +Use your local system for testing and development. This is useful for quick experimentation without needing a separate target machine. |
| 246 | +
|
| 247 | +**Setup Steps:** |
| 248 | +1. First, create a new tmux session with a specific name: |
| 249 | + ```bash |
| 250 | + $ tmux new-session -s <session_name> |
| 251 | + ``` |
| 252 | + |
| 253 | +2. Once you have the tmux shell running, use hackingBuddyGPT to interact with it: |
| 254 | + ```bash |
| 255 | + # Local shell with tmux session |
| 256 | + $ python src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc --conn=local_shell --conn.tmux_session=<session_name> |
| 257 | + ``` |
| 258 | +
|
| 259 | +**Example:** |
| 260 | +```bash |
| 261 | +# Step 1: Create tmux session named "hacking_session" |
| 262 | +$ tmux new-session -s hacking_session |
| 263 | + |
| 264 | +# Step 2: In another terminal, run hackingBuddyGPT |
| 265 | +$ python src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc --conn=local_shell --conn.tmux_session=hacking_session |
| 266 | +``` |
| 267 | +
|
| 268 | +#### SSH Mode |
| 269 | +Connect to a remote target machine over SSH. This is the traditional mode for testing against vulnerable VMs. |
| 270 | +
|
| 271 | +```bash |
| 272 | +# SSH connection (note the updated format with --conn=ssh) |
| 273 | +$ python src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc --conn=ssh --conn.host=192.168.122.151 --conn.username=lowpriv --conn.password=trustno1 |
| 274 | +``` |
233 | 275 |
|
234 | | -The next important part is having a machine that we can run our agent against. In our case, the target machine will be situated at `192.168.122.151`. |
| 276 | +When using SSH mode, the target machine should be situated at your specified IP address (e.g., `192.168.122.151` in the example above). |
235 | 277 |
|
236 | | -We are using vulnerable Linux systems running in Virtual Machines for this. Never run this against real systems. |
| 278 | +We are using vulnerable Linux systems running in Virtual Machines for SSH testing. Never run this against real production systems. |
237 | 279 |
|
238 | 280 | > 💡 **We also provide vulnerable machines!** |
239 | 281 | > |
@@ -277,9 +319,13 @@ Finally we can run hackingBuddyGPT against our provided test VM. Enjoy! |
277 | 319 | With that out of the way, let's look at an example hackingBuddyGPT run. Each run is structured in rounds. At the start of each round, hackingBuddyGPT asks a LLM for the next command to execute (e.g., `whoami`) for the first round. It then executes that command on the virtual machine, prints its output and starts a new round (in which it also includes the output of prior rounds) until it reaches step number 10 or becomes root: |
278 | 320 |
|
279 | 321 | ```bash |
280 | | -# start wintermute, i.e., attack the configured virtual machine |
281 | | -$ python src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc --llm.api_key=sk...ChangeMeToYourOpenAiApiKey --llm.model=gpt-4-turbo --llm.context_size=8192 --conn.host=192.168.122.151 --conn.username=lowpriv --conn.password=trustno1 --conn.hostname=test1 |
| 322 | +# Example 1: Using local shell with tmux session |
| 323 | +# First create the tmux session: tmux new-session -s hacking_session |
| 324 | +# Then run hackingBuddyGPT: |
| 325 | +$ python src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc --llm.api_key=sk...ChangeMeToYourOpenAiApiKey --llm.model=gpt-4-turbo --llm.context_size=8192 --conn=local_shell --conn.tmux_session=hacking_session |
282 | 326 |
|
| 327 | +# Example 2: Using SSH connection (updated format) |
| 328 | +$ python src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc --llm.api_key=sk...ChangeMeToYourOpenAiApiKey --llm.model=gpt-4-turbo --llm.context_size=8192 --conn=ssh --conn.host=192.168.122.151 --conn.username=lowpriv --conn.password=trustno1 --conn.hostname=test1 |
283 | 329 |
|
284 | 330 | # install dependencies for testing if you want to run the tests |
285 | 331 | $ pip install '.[testing]' |
|
0 commit comments