Skip to content

Commit a0422fe

Browse files
committed
Make failing username dynamic
1 parent e33da00 commit a0422fe

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

modules/auxiliary/server/capture/postgresql.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,21 @@ def on_client_data(c)
8989
:active => true
9090
)
9191
print_status("PostgreSQL LOGIN #{@state[c][:name]} #{@state[c][:username]} / #{@state[c][:password]} / #{@state[c][:database]}")
92-
# send failure message, currently the failing username is always "postgres"
93-
# TODO: make failing username dynamic!
92+
# send failure message
9493
sdata = [
95-
0x45, 0x00, 0x00, 0x00, 0x61, 0x53, 0x46, 0x41,
96-
0x54, 0x41, 0x4c, 0x00, 0x43, 0x32, 0x38, 0x50,
97-
0x30, 0x31, 0x00, 0x4d, 0x70, 0x61, 0x73, 0x73,
98-
0x77, 0x6f, 0x72, 0x64, 0x20, 0x61, 0x75, 0x74,
99-
0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74,
100-
0x69, 0x6f, 0x6e, 0x20, 0x66, 0x61, 0x69, 0x6c,
101-
0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x75,
102-
0x73, 0x65, 0x72, 0x20, 0x22, 0x70, 0x6f, 0x73,
103-
0x74, 0x67, 0x72, 0x65, 0x73, 0x22, 0x00, 0x46,
104-
0x61, 0x75, 0x74, 0x68, 0x2e, 0x63, 0x00, 0x4c,
105-
0x33, 0x30, 0x32, 0x00, 0x52, 0x61, 0x75, 0x74,
106-
0x68, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64,
107-
0x00, 0x00].pack("C" * 98)
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)
108107
c.put sdata
109108
c.close
110109
end

0 commit comments

Comments
 (0)