2017-06-30 21:47:30 +02:00
|
|
|
#
|
|
|
|
# Cookbook:: metasploitable
|
|
|
|
# Recipe:: iptables
|
|
|
|
#
|
|
|
|
# Copyright:: 2017, Rapid7, All Rights Reserved.
|
|
|
|
|
|
|
|
execute "apt-get update" do
|
|
|
|
command "apt-get update"
|
|
|
|
end
|
|
|
|
|
|
|
|
bash 'setup for knockd, used for flag' do
|
2017-07-07 00:08:33 +02:00
|
|
|
code_to_execute = ""
|
|
|
|
code_to_execute << "iptables -A FORWARD 1 -p tcp -m tcp --dport 8989 -j DROP\n"
|
|
|
|
code_to_execute << "iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT\n"
|
2017-07-06 21:52:39 +02:00
|
|
|
node[:metasploitable][:ports].keys.each do |service|
|
2017-07-07 00:08:33 +02:00
|
|
|
code_to_execute << "iptables -A INPUT -p tcp --dport #{node[:metasploitable][:ports][service.to_sym]} -j ACCEPT\n"
|
2017-07-06 21:52:39 +02:00
|
|
|
end
|
2017-07-31 22:48:27 +02:00
|
|
|
code_to_execute << "iptables -A INPUT -p tcp --dport 22 -j ACCEPT\n"
|
2017-07-07 00:08:33 +02:00
|
|
|
code_to_execute << "iptables -A INPUT -j DROP\n"
|
|
|
|
code code_to_execute
|
2017-06-30 21:47:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
package 'iptables-persistent' do
|
|
|
|
action :install
|
|
|
|
end
|
|
|
|
|
|
|
|
service 'iptables-persistent' do
|
|
|
|
action [:enable, :start]
|
|
|
|
end
|
|
|
|
|