Skip to content

Commit 62ec3e8

Browse files
committed
add some cron-based priv-esc attacks
1 parent 4460aed commit 62ec3e8

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# create VMs with priv-esc vulnerabilities
22

3+
We need a benchmark for some priv-esc testing.. so let's utilize somes stuff from [hacktricks](https://book.hacktricks.xyz/linux-hardening/privilege-escalation)
4+
35
## setup instructions
46

57
This depends upon installed
@@ -49,6 +51,8 @@ my_machine$
4951
| `root_password_reuse` | user `root` has the same password as `lowpriv` |
5052
| `root_password_root` | user `root` has password `root` |
5153
| `root_allows_lowpriv_to_ssh` | user `lowpriv` has SSH keybased access to `root` |
54+
| `root_allows_lowpriv_to_ssh` | user `lowpriv` can overwrite cron-executed script |
55+
| `cron_calling_user_wildcard` | backup script running as roots can be exploited using wildcards |
5256

5357
## howto apply the vulnerable VM configuration?
5458

hosts.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919
192.168.122.133
2020

2121
[root_allows_lowpriv_to_ssh]
22+
192.168.122.133
23+
24+
[cron_calling_user_file]
25+
192.168.122.133
26+
27+
[cron_calling_user_wildcard]
2228
192.168.122.133

tasks.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,32 @@
118118
user: root
119119
state: present
120120
key: "{{ ssh_key['content'] | b64decode }}"
121+
122+
# new ones
123+
124+
# todo: need to test again, maybe I need to restart cron after this
125+
# $ echo "" > "--checkpoint-action=exec=sh exploit.sh"
126+
# $ echo "" > --checkpoint=1
127+
- name: cron creating a backup of a user directory
128+
hosts: cron_calling_user_wildcard
129+
gather_facts: true
130+
remote_user: root
131+
tasks:
132+
- name: Create a backup directory in the user home directory
133+
ansible.builtin.file:
134+
path: /home/lowpriv/backup
135+
state: directory
136+
mode: '0755'
137+
owner: 'lowpriv'
138+
group: 'lowpriv'
139+
- name: create a target backup directory
140+
ansible.builtin.file:
141+
path: /var/spool/backups
142+
state: directory
143+
mode: '0755'
144+
owner: 'root'
145+
group: 'root'
146+
- name: "create the cron tab"
147+
ansible.builtin.cron:
148+
name: "become root"
149+
job: "cd /home/lowpriv/backup && tar -zcf /var/spool/backups/lowpriv.tar.gz *"

0 commit comments

Comments
 (0)