Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
856a402
Uploaded changes in branch
Jul 16, 2024
1d1d777
Merge remote-tracking branch 'refs/remotes/origin/development' into w…
DianaStrauss Sep 3, 2024
923d6ec
fixed shortening of prompt
DianaStrauss Sep 3, 2024
234e6ef
Merge remote-tracking branch 'refs/remotes/origin/development' into w…
DianaStrauss Sep 3, 2024
629489a
Merged development into web_api_testing
DianaStrauss Sep 3, 2024
64699e3
Fixed shorten prompt bug from merge
DianaStrauss Sep 3, 2024
c141954
Updated Tree of thought so that documentation works like chain of tho…
DianaStrauss Oct 8, 2024
3dc2c4b
Implemented in-context learning for documentation
DianaStrauss Oct 15, 2024
53e5c42
refined openapi generation
DianaStrauss Oct 16, 2024
ea8795b
Updated Tree of thought so that documentation works like chain of tho…
DianaStrauss Oct 16, 2024
4409f4b
Updated Tree of thought so that documentation works like chain of tho…
DianaStrauss Oct 16, 2024
8ef5f8b
Adjusted to only record valid information of rest api
DianaStrauss Oct 23, 2024
8eb5048
optimized prompt generation
DianaStrauss Oct 24, 2024
294ca7c
Added configs for documentation and testing
DianaStrauss Oct 25, 2024
98b510f
Added way of retrieving spotify token
DianaStrauss Oct 25, 2024
975ae85
Refactored code to work with spotify benchmark
DianaStrauss Nov 11, 2024
c70a23b
Refined test cases
DianaStrauss Nov 13, 2024
1fbb37b
Added new security endpoint for testing
DianaStrauss Nov 13, 2024
6fa891d
Added new security endpoint for testing
DianaStrauss Nov 13, 2024
86f8b06
Added more testing information for documentation testing and pentesting
DianaStrauss Nov 15, 2024
cee0726
Added evaluations
DianaStrauss Nov 16, 2024
e210104
Refactored code to be more understandable
DianaStrauss Nov 18, 2024
e228cd8
Added evaluation to documentation
DianaStrauss Nov 18, 2024
3b4b4c4
Refactored code
DianaStrauss Nov 19, 2024
2908860
Restructured testing
DianaStrauss Nov 20, 2024
b1f01dc
Refactored code
DianaStrauss Nov 22, 2024
22e64ff
Refactored code so that more endpoints are found
DianaStrauss Nov 25, 2024
b103831
Refactored code to be clearer
DianaStrauss Nov 28, 2024
e4bbdfa
Added owasp config file and owas openapi sepc
DianaStrauss Dec 2, 2024
f5ef612
Fixed some small bgs
DianaStrauss Dec 4, 2024
c6d33fe
Adjusted test cases to get better analysis
DianaStrauss Dec 4, 2024
96a400d
Added setup for automatic testing
DianaStrauss Dec 5, 2024
b0162fc
refactored test cases
DianaStrauss Dec 5, 2024
3e50596
refactored test cases
DianaStrauss Dec 6, 2024
9306dc6
refactored test cases
DianaStrauss Dec 6, 2024
0f8f445
Refactored tree of thought prompt
DianaStrauss Dec 8, 2024
b62bb01
adjusted gitignore
DianaStrauss Dec 11, 2024
dd0c17e
Refactored classification of endpoints
DianaStrauss Dec 11, 2024
1af2564
Adjusted test cases for better testing
DianaStrauss Dec 12, 2024
340280e
made continuous testing easier
DianaStrauss Dec 12, 2024
04ebcfa
Adjusted prompts to be more tailored
DianaStrauss Dec 15, 2024
1ff5fa2
Refactored and adjusted code to work also for crapi benchmark
DianaStrauss Dec 20, 2024
4dca56d
Cleaned up code
DianaStrauss Jan 9, 2025
5535eb0
Refactored test cases for better vulnerability coverage
DianaStrauss Jan 30, 2025
4ea54fc
Refactored code
DianaStrauss Feb 7, 2025
bf3395b
Added test case
DianaStrauss Feb 17, 2025
1aba1b7
adjusted report
Feb 19, 2025
b4e683b
Refactored code
DianaStrauss Mar 17, 2025
285ca9e
Anonymized readme
Mar 17, 2025
90f4028
Cleaned up code from prints and unnecessary code
DianaStrauss Mar 25, 2025
f9e09b5
Merge remote-tracking branch 'origin/web-api-testing' into web-api-te…
DianaStrauss Mar 25, 2025
b0c2b8b
Merge remote-tracking branch 'origin/development' into merge_web_api_…
DianaStrauss Apr 7, 2025
01ee69e
Adjusted code to work with web_api_testing
DianaStrauss Apr 7, 2025
32b73ab
Refactored code for better readability and testing
DianaStrauss Apr 13, 2025
303baf6
added configuration handler to better test
DianaStrauss Apr 13, 2025
4276f0f
Adjusted test of prompt engineer
DianaStrauss Apr 13, 2025
40f4ff1
Adjusted code for test
DianaStrauss Apr 13, 2025
c6b7ecd
Adjusted code and tests
Apr 14, 2025
44710f3
Adjusted tests and refactored code for better readability
Apr 14, 2025
a695971
Added test cases for pentesting information and test handler + refact…
DianaStrauss Apr 17, 2025
6f05e75
Removed unnecessary prints and added documentation
DianaStrauss Apr 22, 2025
ac58b5a
Removed unnecessary comments
DianaStrauss Apr 22, 2025
02c861f
Fixed Linter issue
DianaStrauss Apr 22, 2025
3a22053
Fixed test imports for pipeline
DianaStrauss Apr 22, 2025
0d34191
Added needed dependencies to pyproject.toml
DianaStrauss Apr 22, 2025
970b72d
Added needed dependencies to pyproject.toml
DianaStrauss Apr 22, 2025
4366132
Added needed dependencies to pyproject.toml
DianaStrauss Apr 22, 2025
9d16710
Removed test case that breaks pipeline
DianaStrauss Apr 22, 2025
9b78c6c
Adjusted init for test_handler
DianaStrauss Apr 22, 2025
9ea050b
Added needed dependencies to pyproject.toml
DianaStrauss Apr 22, 2025
424c989
Merge branch 'development' into merge_web_api_testing_development
DianaStrauss Apr 22, 2025
dbfef99
Added missing dependency
DianaStrauss Apr 22, 2025
696e395
Added missing dependency
DianaStrauss Apr 22, 2025
5e3b112
Added imports in __init__
DianaStrauss Apr 22, 2025
a6653ad
Added files
DianaStrauss Apr 22, 2025
ca17dd0
Moved config files to proper locatin
DianaStrauss Apr 22, 2025
5df1e20
updated README.md with correct image
Qsan1 May 1, 2025
a0977af
Merge pull request #120 from CoralStack/development
andreashappe May 1, 2025
e1b70ab
Merge branch 'development' into merge_web_api_testing_development
DianaStrauss May 13, 2025
78b681d
fixed syntax error in .toml
DianaStrauss May 13, 2025
8ae94fb
Fix linting
DianaStrauss May 13, 2025
9c4842f
Fix linting
DianaStrauss May 13, 2025
4d5122f
Fixed wrong import
DianaStrauss May 13, 2025
600ed43
Fixed import in testing
DianaStrauss May 13, 2025
f33c154
Fixed input variables
DianaStrauss May 13, 2025
e1c8cb4
Fixed input variables
DianaStrauss May 13, 2025
be0ff19
Fixed input variables
DianaStrauss May 13, 2025
985d740
Removed helper files
DianaStrauss May 14, 2025
19afc59
Fixed typo in parsed_information.py name
DianaStrauss May 14, 2025
b5f5688
Fixed typo in parsed_information.py name
DianaStrauss May 14, 2025
f748d5f
Update src/hackingBuddyGPT/usecases/web_api_testing/documentation/par…
DianaStrauss May 14, 2025
8d8a72c
Merge pull request #114 from ipa-lab/merge_web_api_testing_development
andreashappe May 14, 2025
290b148
moved prompt generation into utils and adjusted prompt engineer and p…
DianaStrauss May 20, 2025
bb2bd3b
Added prompt file and added logging of prompt
DianaStrauss May 23, 2025
fdf3d71
Added comments to icl
DianaStrauss May 23, 2025
aecb0be
fixed tests
DianaStrauss May 23, 2025
84f6795
Merge pull request #122 from ipa-lab/adapt_prompt_engineer
andreashappe May 23, 2025
f40bbc2
complete tmux local shell integration
ShreyasMahajann Aug 8, 2025
9ee831b
Merge branch 'development' into production
ShreyasMahajann Aug 8, 2025
bc22dff
Merge pull request #127 from ShreyasMahajann/production
andreashappe Aug 27, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/development' into merge_web_api_…
…testing_development

# Conflicts:
#	.gitignore
#	README.md
#	src/hackingBuddyGPT/cli/wintermute.py
#	src/hackingBuddyGPT/usecases/base.py
#	src/hackingBuddyGPT/usecases/web/simple.py
#	src/hackingBuddyGPT/usecases/web/with_explanation.py
#	src/hackingBuddyGPT/usecases/web_api_testing/simple_openapi_documentation.py
#	src/hackingBuddyGPT/usecases/web_api_testing/simple_web_api_testing.py
#	src/hackingBuddyGPT/utils/db_storage/db_storage.py
  • Loading branch information
DianaStrauss committed Apr 7, 2025
commit b0c2b8be387f1c2a51ac47aba7521f95e07522ce
3 changes: 3 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"onCreateCommand": "./scripts/codespaces_create_and_start_containers.sh"
}
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ conn.port=2222

# exchange with the user for your target VM
conn.username='bob'
#To just use keyauth only, use '' with no space for conn.password
#Otherwise, insert the password for instance here
conn.password='secret'
#To just use username and password auth only, use '' with no space for conn.keyfilename
#Otherwise, insert the filepath for the keyfile here (for example, '/home/bob/.ssh/sshkey.rsa')
conn.keyfilename=''

# which LLM model to use (can be anything openai supports, or if you use a custom llm.api_url, anything your api provides for the model parameter
llm.model='gpt-3.5-turbo'
Expand Down
23 changes: 23 additions & 0 deletions .env.example.aws
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
llm.api_key='your-openai-key'
log_db.connection_string='log_db.sqlite3'

# exchange with the IP of your target VM
conn.host='enter the public IP of AWS Instance'
conn.hostname='DNS of AWS Instance '
conn.port=22

# user of target AWS Instance
conn.username='bob'
#To just use keyauth only, use '' with no space for conn.password
#Otherwise, insert the password for instance here
conn.password=''
#To just use username and password auth only, use '' with no space for conn.keyfilename
#Otherwise, insert the filepath for the keyfile here (for example, '/home/bob/.ssh/awskey.pem')
conn.keyfilename='/home/bob/.ssh/awskey.pem'

# which LLM model to use (can be anything openai supports, or if you use a custom llm.api_url, anything your api provides for the model parameter
llm.model='gpt-3.5-turbo'
llm.context_size=16385

# how many rounds should this thing go?
max_turns = 20
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.env
venv/
.venv/
__pycache__/
*.swp
*.log
Expand All @@ -13,6 +14,18 @@ dist/
.coverage
src/hackingBuddyGPT/usecases/web_api_testing/openapi_spec/
src/hackingBuddyGPT/usecases/web_api_testing/converted_files/
/src/hackingBuddyGPT/usecases/web_api_testing/documentation/openapi_spec/
/src/hackingBuddyGPT/usecases/web_api_testing/documentation/reports/
scripts/codespaces_ansible.cfg
scripts/codespaces_ansible_hosts.ini
scripts/codespaces_ansible_id_rsa
scripts/codespaces_ansible_id_rsa.pub
scripts/mac_ansible.cfg
scripts/mac_ansible_hosts.ini
scripts/mac_ansible_id_rsa
scripts/mac_ansible_id_rsa.pub
.aider*

src/hackingBuddyGPT/usecases/web_api_testing/documentation/openapi_spec/
src/hackingBuddyGPT/usecases/web_api_testing/documentation/reports/
src/hackingBuddyGPT/usecases/web_api_testing/retrieve_spotify_token.py
Expand Down
179 changes: 179 additions & 0 deletions CODESPACES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Use Case: GitHub Codespaces

**Backstory**

https://github.com/ipa-lab/hackingBuddyGPT/pull/85#issuecomment-2331166997

> Would it be possible to add codespace support to hackingbuddygpt in a way, that only spawns a single container (maybe with the suid/sudo use-case) and starts hackingBuddyGPT against that container? That might be the 'easiest' show-case/use-case for a new user.

**Steps**
1. Go to https://github.com/ipa-lab/hackingBuddyGPT
2. Click the "Code" button.
3. Click the "Codespaces" tab.
4. Click the "Create codespace on main" button.
5. Wait for Codespaces to start — This may take upwards of 10 minutes.

> Setting up remote connection: Building codespace...

6. After Codespaces started, you may need to restart a new Terminal via the Command Palette:

Press the key combination:

> `⇧⌘P` `Shift+Command+P` (Mac) / `Ctrl+Shift+P` (Windows/Linux)

In the Command Palette, type `>` and `Terminal: Create New Terminal` and press the return key.

7. You should see a new terminal similar to the following:

> 👋 Welcome to Codespaces! You are on our default image.
>
> `-` It includes runtimes and tools for Python, Node.js, Docker, and more. See the full list here: https://aka.ms/ghcs-default-image
>
> `-` Want to use a custom image instead? Learn more here: https://aka.ms/configure-codespace
>
> 🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1).
>
> 📝 Edit away, run your app as usual, and we'll automatically make it available for you to access.
>
> @github-username ➜ /workspaces/hackingBuddyGPT (main) $

Type the following to manually run:
```bash
./scripts/codespaces_start_hackingbuddygpt_against_a_container.sh
```
7. Eventually, you should see:

> Currently, May 2024, running hackingBuddyGPT with GPT-4-turbo against a benchmark containing 13 VMs (with maximum 20 tries per VM) cost around $5.
>
> Therefore, running hackingBuddyGPT with GPT-4-turbo against containing a container with maximum 10 tries would cost around $0.20.
>
> Enter your OpenAI API key and press the return key:

8. As requested, please enter your OpenAI API key and press the return key.

9. hackingBuddyGPT should start:

> Starting hackingBuddyGPT against a container...

10. If your OpenAI API key is *valid*, then you should see output similar to the following:

> [00:00:00] Starting turn 1 of 10
>
> Got command from LLM:
>
> …
>
> [00:01:00] Starting turn 10 of 10
>
> …
>
> Run finished
>
> maximum turn number reached

11. If your OpenAI API key is *invalid*, then you should see output similar to the following:

> [00:00:00] Starting turn 1 of 10
>
> Traceback (most recent call last):
>
> …
>
> Exception: Error from OpenAI Gateway (401

12. Alternatively, use Google Gemini instead of OpenAI

**Preqrequisites:**

```bash
python -m venv venv
```

```bash
source ./venv/bin/activate
```

```bash
pip install -e .
```

**Use gemini-openai-proxy and Gemini:**

http://localhost:8080 is gemini-openai-proxy

`gpt-4` maps to `gemini-1.5-flash-latest`

Hence use `gpt-4` below in `--llm.model=gpt-4`

Gemini free tier has a limit of 15 requests per minute, and 1500 requests per day

Hence `--max_turns 999999999` will exceed the daily limit

**Run gemini-openai-proxy**

```bash
docker run --restart=unless-stopped -it -d -p 8080:8080 --name gemini zhu327/gemini-openai-proxy:latest
```

**Manually enter your GEMINI_API_KEY value based on** https://aistudio.google.com/app/apikey

```bash
export GEMINI_API_KEY=
```

**Starting hackingBuddyGPT against a container...**

```bash
wintermute LinuxPrivesc --llm.api_key=$GEMINI_API_KEY --llm.model=gpt-4 --llm.context_size=1000000 --conn.host=192.168.122.151 --conn.username=lowpriv --conn.password=trustno1 --conn.hostname=test1 --llm.api_url=http://localhost:8080 --llm.api_backoff=60 --max_turns 999999999
```

**Google AI Studio: Gemini free tier has a limit of 15 requests per minute, and 1500 requests per day:**

https://ai.google.dev/pricing#1_5flash

> Gemini 1.5 Flash
>
> The Gemini API “free tier” is offered through the API service with lower rate limits for testing purposes. Google AI Studio usage is completely free in all available countries.
>
> Rate Limits
>
> 15 RPM (requests per minute)
>
> 1 million TPM (tokens per minute)
>
> 1,500 RPD (requests per day)
>
> Used to improve Google's products
>
> Yes

https://ai.google.dev/gemini-api/terms#data-use-unpaid

> How Google Uses Your Data
>
> When you use Unpaid Services, including, for example, Google AI Studio and the unpaid quota on Gemini API, Google uses the content you submit to the Services and any generated responses to provide, improve, and develop Google products and services and machine learning technologies, including Google's enterprise features, products, and services, consistent with our Privacy Policy https://policies.google.com/privacy
>
> To help with quality and improve our products, human reviewers may read, annotate, and process your API input and output. Google takes steps to protect your privacy as part of this process. This includes disconnecting this data from your Google Account, API key, and Cloud project before reviewers see or annotate it. **Do not submit sensitive, confidential, or personal information to the Unpaid Services.**

**README.md and Disclaimers:**

https://github.com/ipa-lab/hackingBuddyGPT/blob/main/README.md

**Please refer to [README.md](https://github.com/ipa-lab/hackingBuddyGPT/blob/main/README.md) for all disclaimers.**

Please note and accept all of them.

**References:**
* https://docs.github.com/en/codespaces
* https://docs.github.com/en/codespaces/getting-started/quickstart
* https://docs.github.com/en/codespaces/reference/using-the-vs-code-command-palette-in-codespaces
* https://openai.com/api/pricing/
* https://platform.openai.com/docs/quickstart
* https://platform.openai.com/api-keys
* https://ai.google.dev/gemini-api/docs/ai-studio-quickstart
* https://aistudio.google.com/
* https://aistudio.google.com/app/apikey
* https://ai.google.dev/
* https://ai.google.dev/gemini-api/docs/api-key
* https://github.com/zhu327/gemini-openai-proxy
* https://hub.docker.com/r/zhu327/gemini-openai-proxy
129 changes: 129 additions & 0 deletions MAC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
## Use Case: Mac, Docker Desktop and Gemini-OpenAI-Proxy

**Docker Desktop runs containers in a virtual machine on Mac.**

**Run hackingBuddyGPT on Mac as follows:**

Target a localhost container ansible-ready-ubuntu

via Docker Desktop https://docs.docker.com/desktop/setup/install/mac-install/

and Gemini-OpenAI-Proxy https://github.com/zhu327/gemini-openai-proxy

There are bugs in Docker Desktop on Mac that prevent creation of a custom Docker network 192.168.65.0/24

Therefore, localhost TCP port 49152 (or higher) dynamic port number is used for an ansible-ready-ubuntu container

http://localhost:8080 is gemini-openai-proxy

gpt-4 maps to gemini-1.5-flash-latest

Hence use gpt-4 below in --llm.model=gpt-4

Gemini free tier has a limit of 15 requests per minute, and 1500 requests per day

Hence --max_turns 999999999 will exceed the daily limit

For example:

```zsh
export GEMINI_API_KEY=

export PORT=49152

wintermute LinuxPrivesc --llm.api_key=$GEMINI_API_KEY --llm.model=gpt-4 --llm.context_size=1000000 --conn.host=localhost --conn.port $PORT --conn.username=lowpriv --conn.password=trustno1 --conn.hostname=test1 --llm.api_url=http://localhost:8080 --llm.api_backoff=60 --max_turns 999999999
```

The above example is consolidated into shell scripts with prerequisites as follows:

**Preqrequisite: Install Homebrew and Bash version 5:**

```zsh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

**Install Bash version 5 via Homebrew:**

```zsh
brew install bash
```

Bash version 4 or higher is needed for `scripts/mac_create_and_start_containers.sh`

Homebrew provides GNU Bash version 5 via license GPLv3+

Whereas Mac provides Bash version 3 via license GPLv2

**Create and start containers:**

```zsh
./scripts/mac_create_and_start_containers.sh
```

**Start hackingBuddyGPT against a container:**

```zsh
export GEMINI_API_KEY=
```

```zsh
./scripts/mac_start_hackingbuddygpt_against_a_container.sh
```

**Troubleshooting:**

**Docker Desktop: Internal Server Error**

```zsh
Server:
ERROR: request returned Internal Server Error for API route and version http://%2FUsers%2Fusername%2F.docker%2Frun%2Fdocker.sock/v1.47/info, check if the server supports the requested API version
errors pretty printing info
```

You may need to uninstall Docker Desktop https://docs.docker.com/desktop/uninstall/ and reinstall it from https://docs.docker.com/desktop/setup/install/mac-install/ and try again.

Alternatively, restart Docker Desktop and try again.

**There are known issues with Docker Desktop on Mac, such as:**

* Bug: Docker CLI Hangs for all commands
https://github.com/docker/for-mac/issues/6940

* Regression: Docker does not recover from resource saver mode
https://github.com/docker/for-mac/issues/6933

**Google AI Studio: Gemini free tier has a limit of 15 requests per minute, and 1500 requests per day:**

https://ai.google.dev/pricing#1_5flash

> Gemini 1.5 Flash
>
> The Gemini API “free tier” is offered through the API service with lower rate limits for testing purposes. Google AI Studio usage is completely free in all available countries.
>
> Rate Limits
>
> 15 RPM (requests per minute)
>
> 1 million TPM (tokens per minute)
>
> 1,500 RPD (requests per day)
>
> Used to improve Google's products
>
> Yes

https://ai.google.dev/gemini-api/terms#data-use-unpaid

> How Google Uses Your Data
>
> When you use Unpaid Services, including, for example, Google AI Studio and the unpaid quota on Gemini API, Google uses the content you submit to the Services and any generated responses to provide, improve, and develop Google products and services and machine learning technologies, including Google's enterprise features, products, and services, consistent with our Privacy Policy https://policies.google.com/privacy
>
> To help with quality and improve our products, human reviewers may read, annotate, and process your API input and output. Google takes steps to protect your privacy as part of this process. This includes disconnecting this data from your Google Account, API key, and Cloud project before reviewers see or annotate it. **Do not submit sensitive, confidential, or personal information to the Unpaid Services.**

**README.md and Disclaimers:**

https://github.com/ipa-lab/hackingBuddyGPT/blob/main/README.md

**Please refer to [README.md](https://github.com/ipa-lab/hackingBuddyGPT/blob/main/README.md) for all disclaimers.**

Please note and accept all of them.
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.