kali-based WIP
hacking edition work in progress
frdel committed
Mar 2, 2025 at 20:42 UTC
13f6b0e1e05d815c9c09ca8e32ebe16a802ce9df
11 files changed
+89
-39
docker/run/DockerfileKali
new
+33
@@ -0,0 +1,33 @@
1
+# Use the latest slim version of Kali Linux
2
+FROM kalilinux/kali-rolling
3
+
4
+# Check if the argument is provided, else throw an error
5
+ARG BRANCH
6
+RUN if [ -z "$BRANCH" ]; then echo "ERROR: BRANCH is not set!" >&2; exit 1; fi
7
+ENV BRANCH=$BRANCH
8
+
9
+# Copy contents of the project to /a0
10
+COPY ./fs/ /
11
+
12
+# pre installation steps
13
+RUN bash /ins/pre_install.sh $BRANCH
14
+RUN bash /ins/pre_install_kali.sh $BRANCH
15
+
16
+# install additional software
17
+RUN bash /ins/install_additional.sh $BRANCH
18
+
19
+# install A0
20
+RUN bash /ins/install_A0.sh $BRANCH
21
+
22
+# cleanup repo and install A0 without caching, this speeds up builds
23
+ARG CACHE_DATE=none
24
+RUN echo "cache buster $CACHE_DATE" && bash /ins/install_A02.sh $BRANCH
25
+
26
+# post installation steps
27
+RUN bash /ins/post_install.sh $BRANCH
28
+
29
+# Expose ports
30
+EXPOSE 22 80
31
+
32
+# initialize runtime
33
+CMD ["/bin/bash", "-c", "/bin/bash /exe/initialize.sh $BRANCH"]
\ No newline at end of file
docker/run/build.txt
+3
@@ -4,6 +4,9 @@ docker build -t agent-zero-run:local --build-arg BRANCH=development --build-arg
4
# local image without cache
5
docker build -t agent-zero-run:local --build-arg BRANCH=development --no-cache .
6
7
+# local image from Kali
8
+docker build -f ./DockerfileKali -t agent-zero-run:hacking --build-arg BRANCH=main --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S) .
9
+
10
# dockerhub push:
11
12
docker login
docker/run/fs/ins/install_additional.sh
+3
@@ -1,4 +1,7 @@
1
#!/bin/bash
2
3
+# install playwright
4
+bash /ins/install_playwright.sh "$@"
5
+
6
# searxng
7
bash /ins/install_searxng.sh "$@"
\ No newline at end of file
docker/run/fs/ins/install_playwright.sh
+9
-1
@@ -7,4 +7,12 @@
7
pip install playwright
8
9
# install chromium with dependencies
10
-playwright install --with-deps chromium-headless-shell
10
+# for kali-based
11
+if [ "$@" = "hacking" ]; then
12
+ apt-get install -y fonts-unifont libnss3 libnspr4
13
+ playwright install chromium-headless-shell
14
+else
15
+ # for debian based
16
+ playwright install --with-deps chromium-headless-shell
17
+fi
18
+
docker/run/fs/ins/install_searxng.sh
+1
-1
@@ -2,7 +2,7 @@
2
3
# Install necessary packages
4
apt-get install -y \
5
- python3-dev python3-babel python3-venv \
5
+ python3.12-dev python3-babel python3.12-venv \
6
uwsgi uwsgi-plugin-python3 \
7
git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev
8
docker/run/fs/ins/post_install.sh
-3
@@ -1,8 +1,5 @@
1
#!/bin/bash
2
3
-# install playwright
4
-bash /ins/install_playwright.sh "$@"
5
-
3
# Cleanup package list
4
rm -rf /var/lib/apt/lists/*
5
apt-get clean
\ No newline at end of file
docker/run/fs/ins/pre_install.sh
+17
-5
@@ -2,9 +2,8 @@
2
3
# Update and install necessary packages
4
apt-get update && apt-get install -y \
5
- python3 \
6
- python3-pip \
7
- python3-venv \
5
+ python3.12 \
6
+ python3.12-venv \
7
nodejs \
8
npm \
9
openssh-server \
@@ -14,5 +13,18 @@ apt-get update && apt-get install -y \
13
git \
14
ffmpeg
15
17
-# prepare SSH daemon
18
-bash /ins/setup_ssh.sh "$@"
\ No newline at end of file
16
+# Configure system alternatives so that /usr/bin/python3 points to Python 3.12
17
+sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
18
+sudo update-alternatives --set python3 /usr/bin/python3.12
19
+
20
+# Update pip3 symlink: if pip3.12 exists, point pip3 to it;
21
+# otherwise, install pip using Python 3.12's ensurepip.
22
+if [ -f /usr/bin/pip3.12 ]; then
23
+ sudo ln -sf /usr/bin/pip3.12 /usr/bin/pip3
24
+else
25
+ python3 -m ensurepip --upgrade
26
+ python3 -m pip install --upgrade pip
27
+fi
28
+
29
+# Prepare SSH daemon
30
+bash /ins/setup_ssh.sh "$@"
docker/run/fs/ins/pre_install_kali.sh
new
+6
@@ -0,0 +1,6 @@
1
+#!/bin/bash
2
+
3
+# ubuntu based dependencies for playwright
4
+# moved to install_playwright.sh
5
+# apt-get update && apt-get install -y fonts-unifont fonts-ubuntu
6
+
docker/run/fs/ins/setup_ssh.sh
+1
-1
@@ -1,6 +1,6 @@
1
#!/bin/bash
2
3
# Set up SSH
4
-mkdir /var/run/sshd && \
4
+mkdir -p /var/run/sshd && \
5
# echo 'root:toor' | chpasswd && \
6
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
\ No newline at end of file
python/helpers/dirty_json.py
+15
-27
@@ -103,9 +103,14 @@ class DirtyJson:
103
return None
104
105
def _match(self, text: str) -> bool:
106
- cnt = len(text)
107
- if self._peek(cnt).lower() == text.lower():
108
- self._advance(cnt)
106
+ # first char should match current char
107
+ if not self.current_char or self.current_char.lower() != text[0].lower():
108
+ return False
109
+
110
+ # peek remaining chars
111
+ remaining = len(text) - 1
112
+ if self._peek(remaining).lower() == text[1:].lower():
113
+ self._advance(len(text))
114
return True
115
return False
116
@@ -187,6 +192,13 @@ class DirtyJson:
192
self._skip_whitespace()
193
if self.current_char == ',':
194
self._advance()
195
+ # handle trailing commas, end of array
196
+ self._skip_whitespace()
197
+ if self.current_char is None or self.current_char == ']':
198
+ if self.current_char == ']':
199
+ self._advance()
200
+ self.stack.pop()
201
+ return
202
elif self.current_char != ']':
203
self.stack.pop()
204
return
@@ -245,30 +257,6 @@ class DirtyJson:
257
except ValueError:
258
return float(number_str)
259
248
- def _parse_true(self):
249
- self._advance()
250
- for char in 'rue':
251
- if self.current_char != char:
252
- return None
253
- self._advance()
254
- return True
255
-
256
- def _parse_false(self):
257
- self._advance()
258
- for char in 'alse':
259
- if self.current_char != char:
260
- return None
261
- self._advance()
262
- return False
263
-
264
- def _parse_null(self):
265
- self._advance()
266
- for char in 'ull':
267
- if self.current_char != char:
268
- return None
269
- self._advance()
270
- return None
271
-
260
def _parse_unquoted_string(self):
261
result = ""
262
while self.current_char is not None and self.current_char not in [':', ',', '}', ']']:
python/helpers/history.py
+1
-1
@@ -126,7 +126,7 @@ class Topic(Record):
126
msg_max_size = (
127
set["chat_model_ctx_length"]
128
* set["chat_model_ctx_history"]
129
- * HISTORY_TOPIC_RATIO
129
+ * CURRENT_TOPIC_RATIO
130
* LARGE_MESSAGE_TO_TOPIC_RATIO
131
)
132
large_msgs = []