Skip to content

Commit 650761b

Browse files
committed
ask GPT for an explanation after each command
1 parent 4d0ddd0 commit 650761b

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

templates/explain_system.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
You currently have the following information about the system:
2+
3+
~~~
4+
${sysinfo}
5+
~~~
6+
7+
You executed the command ${cmd} and the system returned the following output:
8+
9+
~~~
10+
${cmd_output}
11+
~~~
12+
13+
Describe how you expect the system to work.

templates/gpt_query.txt renamed to templates/query_next_command.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ You already executed some commands:
99
- when you executed the command "${entry["cmd"]}" the console output was "${entry["result"]}"
1010
% endfor
1111
%endif
12-
Respond with a linux command to give to the server. The command should be used for enumeration or privilege escalation. Do not add any explanation.
12+
Respond with a linux command to give to the server. The command should be used for enumeration or privilege escalation. Do not add any explanation.
File renamed without changes.

templates/why.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

wintermute.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@
1919
print("Get initial user from virtual machine:")
2020
initial_user = conn.run("whoami")
2121

22+
sysinfo = "This is a linux-based system."
23+
2224
while True:
2325

24-
next_cmd = create_and_ask_prompt('gpt_query.txt', "next-cmd", user=initial_user, history=cmd_history.get_history())
26+
# TODO: separate between techniques (let GPT search for vulnerabiltiites) and procedures (concrete exploitation of a technique). This would make the exeuction loop a bit harder to understand and hierarchical, e.g., select a technique -> ask GPT how to exploit this technique (with a command sequence) -> execute and watch
2527

26-
# disable this for now, it's tragic because the AI won't tell me why it had chosen something
27-
# create_and_ask_prompt("why.txt", "why", user=initial_user, history=cmd_history.dump(), next_cmd=next_cmd)
28+
next_cmd = create_and_ask_prompt('query_next_command.txt', "next-cmd", user=initial_user, history=cmd_history.get_history())
2829

2930
resp = conn.run(next_cmd)
3031
cmd_history.append(next_cmd, resp)
3132

3233
# this will already by output by conn.run
3334
# logs.warning("server-output", resp)
3435

36+
# aks chatgpt to explain what it expects about the tested
37+
# system. Understanding this might help human learning
38+
system_explanation = create_and_ask_prompt('explain_system.txt', 'explain-system', sysinfo=sysinfo, cmd=next_cmd, cmd_output=resp)
39+
3540
# this asks for additional vulnerabilities identifiable in the last command output
36-
# create_and_ask_prompt('further_information.txt', 'vulns', user=initial_user, next_cmd=next_cmd, resp=resp)
41+
# create_and_ask_prompt('query_vulnerabilities.txt', 'vulns', user=initial_user, next_cmd=next_cmd, resp=resp)

0 commit comments

Comments
 (0)