Skip to content

Commit 8369855

Browse files
committed
pushing for help
1 parent c190cc7 commit 8369855

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/metasploit/framework/varnish/client.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ module Framework
77
module Varnish
88
module Client
99

10-
auth_required_regex = /107 \d+\s\s\s\s\s\s\n(\w+)\n\nAuthentication 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\nAuthentication required\./ # 107 auth
11+
@AUTH_SUCCESS_REGEX = /200 \d+/ # 200 ok
1212

1313
def login(pass)
1414
# based on https://www.varnish-cache.org/trac/wiki/CLI
1515
begin
16-
auth = require_auth?.to_s
17-
if not auth == 'false'
16+
auth = require_auth?
17+
if not !!auth
1818
#raise RuntimeError, $1 + "\n" + pass.strip + "\n" + $1 + "\n" + "auth " + Digest::SHA256.hexdigest("#{$1}\n#{pass.strip}\n#{$1}\n")
1919
response = Digest::SHA256.hexdigest("#{$1}\n#{pass.strip}\n#{$1}\n")
2020
sock.put("auth #{response}\n")
2121
res = sock.get_once(-1,3)
2222
raise RuntimeError, res
23-
if res && res =~ @auth_success_regex
23+
if res && res =~ @AUTH_SUCCESS_REGEX
2424
return true
2525
else
2626
return false
@@ -41,11 +41,10 @@ def require_auth?
4141
# function returns false if no auth is required, else
4242
sock.put("auth #{Rex::Text.rand_text_alphanumeric(3)}\n") # Cause a login fail to get the challenge
4343
res = sock.get_once(-1,3) # grab challenge
44-
if res && res =~ @auth_required_regex
44+
if res && res =~ @AUTH_REQUIRED_REGEX
4545
return $1
46-
else
47-
return false
4846
end
47+
return false
4948
end
5049

5150
end

0 commit comments

Comments
 (0)