-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasses_CVE-2021-4034.yml
58 lines (43 loc) · 1.42 KB
/
asses_CVE-2021-4034.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- name: Check vulerability for privilege escalation CVE-2021-4043
gather_facts: yes
hosts: operational
#become: yes
tasks:
- name: Check user
shell: whoami
register: executingUser
failed_when: executingUser.rc > 0 or 'root' in executingUser.stdout
changed_when: False
- name: Copy malicious binary
copy:
src: cve-2021-4034-exploit
dest: ~/
owner: "{{ executingUser.stdout }}"
group: "{{ executingUser.stdout }}"
mode: '700'
- debug:
msg: "User before escalation {{ executingUser.stdout }}"
- name: Try privilege escalation
shell: |
~/cve-2021-4034-exploit 2>&1
whoami
register: whoamiAfter
- debug:
msg: "Return of escalation: {{ whoamiAfter.stdout_lines }}"
- debug:
msg: "whoamiAfter: {{ whoamiAfter.stdout_lines }}"
- name: Remove malicious binary and temporary files of exploit
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items:
- ~/cve-2021-4034-exploit
- ~/lol/
- ~/GCONV_PATH=./
- ~/payload.so
- ~/payload.c
- name: Check result of privilege escalation
assert:
that: "'root' not in {{ whoamiAfter.stdout_lines }}"
fail_msg: "Privilege escalation worked: I'm root."
success_msg: "System is safe. I'm user {{ executingUser.stdout }}."