Skip to content

Commit 546e24a

Browse files
author
jvazquez-r7
committed
Merge branch 'external_ip_discovery' of https://github.com/sempervictus/metasploit-framework into sempervictus-external_ip_discovery
2 parents 2f95d08 + 25f3f93 commit 546e24a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
9+
require 'msf/core'
10+
11+
12+
class Metasploit3 < Msf::Auxiliary
13+
14+
# Exploit mixins should be called first
15+
include Msf::Exploit::Remote::HttpClient
16+
include Msf::Auxiliary::Report
17+
18+
def initialize
19+
super(
20+
'Name' => 'External IP',
21+
'Description' => 'This module checks for the public source IP address of the current route to the RHOST',
22+
'Author' => ['RageLtMan'],
23+
'License' => MSF_LICENSE,
24+
'References' =>
25+
[
26+
[ 'URL', 'http://ifconfig.me/ip' ],
27+
]
28+
)
29+
30+
register_options(
31+
[
32+
OptEnum.new('RHOST', [true, 'The ifconfig.me server to use','49.212.202.172',['49.212.202.172','133.242.129.236']]),
33+
OptString.new('VHOST', [true, "The VHOST to use", 'ifconfig.me' ]),
34+
OptBool.new('REPORT_HOST', [false, 'Add the found IP to the database', false])
35+
], self.class)
36+
end
37+
38+
def run
39+
begin
40+
connect
41+
res = send_request_raw({'uri' => '/ip', 'method' => 'GET' })
42+
our_addr = res.body.strip
43+
if Rex::Socket.is_ipv4?(our_addr) or Rex::Socket.is_ipv6?(our_addr)
44+
print_good("Source ip to #{ip} is #{our_addr}")
45+
report_host(our_addr) if datastore['REPORT_HOST']
46+
end
47+
48+
end
49+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
50+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e
51+
raise e
52+
end
53+
end
54+

0 commit comments

Comments
 (0)