File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
lib/metasploit/framework/varnish Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -7,20 +7,20 @@ module Framework
7
7
module Varnish
8
8
module Client
9
9
10
- auth_required_regex = /107 \d +\s \s \s \s \s \s \n (\w +)\n \n Authentication required./ # 107 auth
11
- auth_success_regex = /200 \d +/ # 200 ok
10
+ @AUTH_REQUIRED_REGEX = /107 \d +\s \s \s \s \s \s \n (\w +)\n \n Authentication required\ . / # 107 auth
11
+ @AUTH_SUCCESS_REGEX = /200 \d +/ # 200 ok
12
12
13
13
def login ( pass )
14
14
# based on https://www.varnish-cache.org/trac/wiki/CLI
15
15
begin
16
- auth = require_auth? . to_s
17
- if not auth == 'false'
16
+ auth = require_auth?
17
+ if not !! auth
18
18
#raise RuntimeError, $1 + "\n" + pass.strip + "\n" + $1 + "\n" + "auth " + Digest::SHA256.hexdigest("#{$1}\n#{pass.strip}\n#{$1}\n")
19
19
response = Digest ::SHA256 . hexdigest ( "#{ $1} \n #{ pass . strip } \n #{ $1} \n " )
20
20
sock . put ( "auth #{ response } \n " )
21
21
res = sock . get_once ( -1 , 3 )
22
22
raise RuntimeError , res
23
- if res && res =~ @auth_success_regex
23
+ if res && res =~ @AUTH_SUCCESS_REGEX
24
24
return true
25
25
else
26
26
return false
@@ -41,11 +41,10 @@ def require_auth?
41
41
# function returns false if no auth is required, else
42
42
sock . put ( "auth #{ Rex ::Text . rand_text_alphanumeric ( 3 ) } \n " ) # Cause a login fail to get the challenge
43
43
res = sock . get_once ( -1 , 3 ) # grab challenge
44
- if res && res =~ @auth_required_regex
44
+ if res && res =~ @AUTH_REQUIRED_REGEX
45
45
return $1
46
- else
47
- return false
48
46
end
47
+ return false
49
48
end
50
49
51
50
end
You can’t perform that action at this time.
0 commit comments