Skip to content

Commit 6eceab6

Browse files
committed
Merge branch 'development' of github.com:ipa-lab/hackingBuddyGPT into log_infrastructure
2 parents 663fd82 + 71924f5 commit 6eceab6

File tree

97 files changed

+1244
-827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1244
-827
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"onCreateCommand": "./codespaces_create_and_start_containers.sh"
2+
"onCreateCommand": "./scripts/codespaces_create_and_start_containers.sh"
33
}

.gitignore

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ src/hackingBuddyGPT/usecases/web_api_testing/openapi_spec/
1616
src/hackingBuddyGPT/usecases/web_api_testing/converted_files/
1717
/src/hackingBuddyGPT/usecases/web_api_testing/documentation/openapi_spec/
1818
/src/hackingBuddyGPT/usecases/web_api_testing/documentation/reports/
19-
codespaces_ansible.cfg
20-
codespaces_ansible_hosts.ini
21-
codespaces_ansible_id_rsa
22-
codespaces_ansible_id_rsa.pub
23-
mac_ansible.cfg
24-
mac_ansible_hosts.ini
25-
mac_ansible_id_rsa
26-
mac_ansible_id_rsa.pub
19+
scripts/codespaces_ansible.cfg
20+
scripts/codespaces_ansible_hosts.ini
21+
scripts/codespaces_ansible_id_rsa
22+
scripts/codespaces_ansible_id_rsa.pub
23+
scripts/mac_ansible.cfg
24+
scripts/mac_ansible_hosts.ini
25+
scripts/mac_ansible_id_rsa
26+
scripts/mac_ansible_id_rsa.pub
27+
.aider*

MAC.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ There are bugs in Docker Desktop on Mac that prevent creation of a custom Docker
1414

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

17-
http://localhost:8080 is genmini-openai-proxy
17+
http://localhost:8080 is gemini-openai-proxy
18+
19+
gpt-4 maps to gemini-1.5-flash-latest
20+
21+
Hence use gpt-4 below in --llm.model=gpt-4
22+
23+
Gemini free tier has a limit of 15 requests per minute, and 1500 requests per day
24+
25+
Hence --max_turns 999999999 will exceed the daily limit
1826

1927
For example:
2028

@@ -23,7 +31,7 @@ export GEMINI_API_KEY=
2331

2432
export PORT=49152
2533

26-
wintermute LinuxPrivesc --llm.api_key=$GEMINI_API_KEY --llm.model=gemini-1.5-flash-latest --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
34+
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
2735
```
2836

2937
The above example is consolidated into shell scripts with prerequisites as follows:
@@ -40,7 +48,7 @@ The above example is consolidated into shell scripts with prerequisites as follo
4048
brew install bash
4149
```
4250

43-
Bash version 4 or higher is needed for `mac_create_and_start_containers.sh`
51+
Bash version 4 or higher is needed for `scripts/mac_create_and_start_containers.sh`
4452

4553
Homebrew provides GNU Bash version 5 via license GPLv3+
4654

@@ -49,7 +57,7 @@ Whereas Mac provides Bash version 3 via license GPLv2
4957
**Create and start containers:**
5058

5159
```zsh
52-
./mac_create_and_start_containers.sh
60+
./scripts/mac_create_and_start_containers.sh
5361
```
5462

5563
**Start hackingBuddyGPT against a container:**
@@ -59,7 +67,7 @@ export GEMINI_API_KEY=
5967
```
6068

6169
```zsh
62-
./mac_start_hackingbuddygpt_against_a_container.sh
70+
./scripts/mac_start_hackingbuddygpt_against_a_container.sh
6371
```
6472

6573
**Troubleshooting:**

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ In the Command Palette, type `>` and `Terminal: Create New Terminal` and press t
231231
232232
Type the following to manually run:
233233
```bash
234-
./codespaces_start_hackingbuddygpt_against_a_container.sh
234+
./scripts/codespaces_start_hackingbuddygpt_against_a_container.sh
235235
```
236236
7. Eventually, you should see:
237237

@@ -300,6 +300,12 @@ $ python src/hackingBuddyGPT/cli/wintermute.py LinuxPrivesc --llm.api_key=sk...C
300300
$ pip install '.[testing]'
301301
```
302302

303+
## Use Cases
304+
305+
Mac, Docker Desktop and Gemini-OpenAI-Proxy:
306+
307+
* See https://github.com/ipa-lab/hackingBuddyGPT/blob/main/MAC.md
308+
303309
## Publications about hackingBuddyGPT
304310

305311
Given our background in academia, we have authored papers that lay the groundwork and report on our efforts:

publish_notes.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# how to publish to pypi
2+
3+
## start with testing if the project builds and tag the version
4+
5+
```bash
6+
python -m venv venv
7+
source venv/bin/activate
8+
pip install -e .
9+
pytest
10+
git tag v0.3.0
11+
git push origin v0.3.0
12+
```
13+
14+
## build and new package
15+
16+
(according to https://packaging.python.org/en/latest/tutorials/packaging-projects/)
17+
18+
```bash
19+
pip install build twine
20+
python3 -m build
21+
vi ~/.pypirc
22+
twine check dist/*
23+
```
24+
25+
Now, for next time.. test install the package in a new vanilla environment, then..
26+
27+
```bash
28+
twine upload dist/*
29+
```
30+
31+
## repo todos
32+
33+
- rebase development upon main
34+
- bump the pyproject version number to a new `-dev`

pyproject.toml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "hackingBuddyGPT"
7-
authors = [{ name = "Andreas Happe", email = "[email protected]" }]
7+
# original author was Andreas Happe, for an up-to-date list see
8+
# https://github.com/ipa-lab/hackingBuddyGPT/graphs/contributors
9+
authors = [
10+
{ name = "HackingBuddyGPT maintainers", email = "[email protected]" }
11+
]
812
maintainers = [
9-
{ name = "Andreas Happe", email = "[email protected]" },
10-
{ name = "Juergen Cito", email = "juergen.cito@tuwiena.c.at" },
13+
{ name = "Andreas Happe", email = "[email protected]" },
14+
{ name = "Juergen Cito", email = "juergen.cito@tuwien.ac.at" }
1115
]
1216
description = "Helping Ethical Hackers use LLMs in 50 lines of code"
1317
readme = "README.md"
1418
keywords = ["hacking", "pen-testing", "LLM", "AI", "agent"]
1519
requires-python = ">=3.10"
16-
version = "0.3.1"
20+
version = "0.4.0-dev"
1721
license = { file = "LICENSE" }
1822
classifiers = [
1923
"Programming Language :: Python :: 3",
2024
"License :: OSI Approved :: MIT License",
2125
"Operating System :: OS Independent",
22-
"Development Status :: 4 - Beta",
26+
"Development Status :: 4 - Beta",
2327
]
2428
dependencies = [
2529
'fabric == 3.2.2',
@@ -61,8 +65,18 @@ pythonpath = "src"
6165
addopts = ["--import-mode=importlib"]
6266
[project.optional-dependencies]
6367
testing = ['pytest', 'pytest-mock']
68+
dev = [
69+
'ruff',
70+
]
6471

6572
[project.scripts]
6673
wintermute = "hackingBuddyGPT.cli.wintermute:main"
6774
hackingBuddyGPT = "hackingBuddyGPT.cli.wintermute:main"
6875
wintermuteViewer = "hackingBuddyGPT.cli.viewer:main"
76+
77+
[tool.ruff]
78+
line-length = 120
79+
80+
[tool.ruff.lint]
81+
select = ["E", "F", "B", "I"]
82+
ignore = ["E501", "F401", "F403"]

codespaces_create_and_start_containers.sh renamed to scripts/codespaces_create_and_start_containers.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
# Purpose: In GitHub Codespaces, automates the setup of Docker containers,
44
# preparation of Ansible inventory, and modification of tasks for testing.
5-
# Usage: ./codespaces_create_and_start_containers.sh
5+
# Usage: ./scripts/codespaces_create_and_start_containers.sh
66

77
# Enable strict error handling for better script robustness
88
set -e # Exit immediately if a command exits with a non-zero status
99
set -u # Treat unset variables as an error and exit immediately
1010
set -o pipefail # Return the exit status of the last command in a pipeline that failed
1111
set -x # Print each command before executing it (useful for debugging)
1212

13+
cd $(dirname $0)
14+
15+
bash_version=$(/bin/bash --version | head -n 1 | awk '{print $4}' | cut -d. -f1)
16+
17+
if (( bash_version < 4 )); then
18+
echo 'Error: Requires Bash version 4 or higher.'
19+
exit 1
20+
fi
21+
1322
# Step 1: Initialization
1423

1524
if [ ! -f hosts.ini ]; then

codespaces_start_hackingbuddygpt_against_a_container.sh renamed to scripts/codespaces_start_hackingbuddygpt_against_a_container.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
#!/bin/bash
22

33
# Purpose: In GitHub Codespaces, start hackingBuddyGPT against a container
4-
# Usage: ./codespaces_start_hackingbuddygpt_against_a_container.sh
4+
# Usage: ./scripts/codespaces_start_hackingbuddygpt_against_a_container.sh
55

66
# Enable strict error handling for better script robustness
77
set -e # Exit immediately if a command exits with a non-zero status
88
set -u # Treat unset variables as an error and exit immediately
99
set -o pipefail # Return the exit status of the last command in a pipeline that failed
1010
set -x # Print each command before executing it (useful for debugging)
1111

12+
cd $(dirname $0)
13+
14+
bash_version=$(/bin/bash --version | head -n 1 | awk '{print $4}' | cut -d. -f1)
15+
16+
if (( bash_version < 4 )); then
17+
echo 'Error: Requires Bash version 4 or higher.'
18+
exit 1
19+
fi
20+
1221
# Step 1: Install prerequisites
1322

1423
# setup virtual python environment
24+
cd ..
1525
python -m venv venv
1626
source ./venv/bin/activate
1727

@@ -35,3 +45,21 @@ echo "Starting hackingBuddyGPT against a container..."
3545
echo
3646

3747
wintermute LinuxPrivesc --llm.api_key=$OPENAI_API_KEY --llm.model=gpt-4-turbo --llm.context_size=8192 --conn.host=192.168.122.151 --conn.username=lowpriv --conn.password=trustno1 --conn.hostname=test1
48+
49+
# Alternatively, the following comments demonstrate using gemini-openai-proxy and Gemini
50+
51+
# http://localhost:8080 is gemini-openai-proxy
52+
53+
# gpt-4 maps to gemini-1.5-flash-latest
54+
55+
# Hence use gpt-4 below in --llm.model=gpt-4
56+
57+
# Gemini free tier has a limit of 15 requests per minute, and 1500 requests per day
58+
59+
# Hence --max_turns 999999999 will exceed the daily limit
60+
61+
# docker run --restart=unless-stopped -it -d -p 8080:8080 --name gemini zhu327/gemini-openai-proxy:latest
62+
63+
# export GEMINI_API_KEY=
64+
65+
# 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
File renamed without changes.

0 commit comments

Comments
 (0)