-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathplaybook.yml
55 lines (49 loc) · 1.42 KB
/
playbook.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
54
55
---
- hosts: all
become: true
gather_facts: no
vars:
log4shell_options: "-p /var/log/"
pre_tasks:
- name: Check Python Version
ansible.builtin.shell: 'python3 --version'
register: python_version
failed_when: "'Python' not in python_version.stdout"
- name: Verify zstandard Python Library
ansible.builtin.shell: 'python3 -c "import zstandard"'
register: zstandard_status
failed_when: zstandard_status.rc != 0
tasks:
- name: Check server for log4j IOC
block:
- name: Create temporary directory
ansible.builtin.tempfile:
state: directory
register: tempdir
- name: Copy script to server
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ tempdir.path }}"
mode: 0700
loop:
- log4shell-detector.py
- Log4ShellDetector
- name: Run the script
ansible.builtin.shell:
cmd: "{{ tempdir.path }}/log4shell-detector.py {{ log4shell_options }}"
register: log4shell_result
async: 0
poll: 30
failed_when: "'[!]' in log4shell_result.stdout"
notify:
- Detector Output
always:
- name: Cleanup
ansible.builtin.file:
path: "{{ tempdir.path }}"
state: absent
when: tempdir.path is defined
handlers:
- name: Detector Output
debug:
msg: "{{ log4shell_result }}"