From daa4a1c7454785773019403b1d633d3768a4e93f Mon Sep 17 00:00:00 2001 From: Mateo Date: Fri, 2 Aug 2024 09:27:48 +0200 Subject: [PATCH] Hardened usertwist service + Saved iptables rules --- files/usertwist.service | 1 + tasks/roles/setup_iptables/README.md | 26 +++++------------------ tasks/roles/setup_iptables/tasks/main.yml | 7 +++++- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/files/usertwist.service b/files/usertwist.service index ea45de5..cbfb6ab 100644 --- a/files/usertwist.service +++ b/files/usertwist.service @@ -15,6 +15,7 @@ ProtectKernelModules=yes ProtectControlGroups=yes PrivateDevices=yes RestrictSUIDSGID=true +ProtectHome=true [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/tasks/roles/setup_iptables/README.md b/tasks/roles/setup_iptables/README.md index 225dd44..c65e2c5 100644 --- a/tasks/roles/setup_iptables/README.md +++ b/tasks/roles/setup_iptables/README.md @@ -1,31 +1,14 @@ -Role Name +Setup IPTables ========= -A brief description of the role goes here. - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. - -Role Variables --------------- - -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. +Create iptables rules on the remote server to allow connection on WEB and SSH ports only Example Playbook ---------------- -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - hosts: servers roles: - - { role: username.rolename, x: 42 } + - setup_iptables License ------- @@ -35,4 +18,5 @@ BSD Author Information ------------------ -An optional section for the role authors to include contact information, or a website (HTML is not allowed). +Motysten +E-Mail : mdm@athelas.fr diff --git a/tasks/roles/setup_iptables/tasks/main.yml b/tasks/roles/setup_iptables/tasks/main.yml index c468a39..f2a362f 100644 --- a/tasks/roles/setup_iptables/tasks/main.yml +++ b/tasks/roles/setup_iptables/tasks/main.yml @@ -14,4 +14,9 @@ - name: Set INPUT policy to DROP ansible.builtin.iptables: chain: INPUT - policy: DROP \ No newline at end of file + policy: DROP + +- name: Save rules to keep them on reboot + ansible.builtin.iptables_state: + state: saved + path: /etc/iptables/iptables \ No newline at end of file