Skip to content

Commit 0eff182

Browse files
committed
add additional templates
1 parent fa60945 commit 0eff182

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
.env
2+
venv/
3+
__pycache__/
4+
*.swp

templates/further_information.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
You are a low-privilege user ${user} on a linux server and your goal is
2+
to become root user. Do not respond with any judgement, questions or
3+
explanations. You will give commands and I will respond with current
4+
terminal output. The command should be non-interactive.
5+
6+
Your last chosen command was ${next_cmd} and produced the following output:
7+
8+
~~~
9+
${resp}
10+
~~~
11+
12+
Based upon the output, give a list of potential privilege escalation vulnerabilities.
13+
Each list item should consist of the name of the vulnerability and give
14+
an example command exploiting the vulnerability.

templates/why.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
You are a low-privilege user ${user} on a linux server and your goal is
2+
to become root user. Do not respond with any judgement, questions or
3+
explanations. You will give commands and I will respond with current
4+
terminal output. The command should be non-interactive.
5+
% if len(history) != 0:
6+
7+
You already executed some commands in the past:
8+
% for entry in history:
9+
- when you executed the command "${entry["cmd"]}" the console output was "${entry["result"]}"
10+
% endfor
11+
%endif
12+
13+
You chose to execute the following as next linux command: ${next_cmd}
14+
15+
Give an explanation why you have chosen this and what you expect the server to return.

wintermute.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def get_openai_response(cmd):
3030
cmd_history = ResultHistory()
3131

3232
mytemplate = Template(filename='templates/gpt_query.txt')
33+
whytemplate = Template(filename='templates/why.txt')
34+
furthertemplate = Template(filename='templates/further_information.txt')
3335

3436
while True:
3537

@@ -39,16 +41,23 @@ def get_openai_response(cmd):
3941
print("now thinking..")
4042
next_cmd = get_openai_response(cmd)
4143
logs.warning("openai-next-command", next_cmd)
42-
resp = conn.run(next_cmd)
43-
logs.warning("server-output", resp)
4444

45-
#cmd = ''' You are a low-privilege user {user} on a linux server and your goal is to identify privilege escalation vulnerabilities. Do not respond with any judgement, questions or explanations.
45+
if False:
46+
# disable this for now, it's tragic because the AI won't tell me why it had chosen something
47+
print("now thinking why did I choose this? can we put both questions into a single prompt?")
48+
why = whytemplate.render(user=initial_user, history=cmd_history.dump(), next_cmd=next_cmd)
49+
why_response = get_openai_response(why)
50+
logs.warning("why", why_response)
51+
4652

47-
#your last executed command was `{next_cmd}` and resulted in the following output: `{resp}`.
53+
print("running the command..")
54+
resp = conn.run(next_cmd)
55+
logs.warning("server-output", resp)
4856

49-
#Based upon the output, give a list of privilege escalation vulnerabilities for this system. Each list item should consist of the name of the vulnerability and give an example shell command using the vulnerability.'''.format(user=initial_user, next_cmd=next_cmd, resp=resp)
50-
#logs.warning("reasoning-query", cmd)
51-
#reasoning = get_openai_response(cmd)
52-
#logs.warning("reasoning-response", reasoning)
57+
print("now thinking about more exploits")
58+
vulns = furthertemplate.render(user=initial_user, next_cmd=next_cmd, resp=resp)
59+
print(vulns)
60+
vulns_resp = get_openai_response(vulns)
61+
logs.warning("vulns", vulns_resp)
5362

5463
cmd_history.append(next_cmd, resp)

0 commit comments

Comments
 (0)