@@ -75,32 +75,22 @@ def check
75
75
end
76
76
77
77
def login
78
- boundary = Rex ::Text . rand_text_alphanumeric ( 16 ) . to_s
79
-
80
- data_post = "------WebKitFormBoundary#{ boundary } \r \n "
81
- data_post << "Content-Disposition: form-data; name=\" returnto\" \r \n \r \n "
82
- data_post << "\r \n "
83
- data_post << "------WebKitFormBoundary#{ boundary } \r \n "
84
- data_post << "Content-Disposition: form-data; name=\" template\" \r \n \r \n "
85
- data_post << "\r \n "
86
- data_post << "------WebKitFormBoundary#{ boundary } \r \n "
87
- data_post << "Content-Disposition: form-data; name=\" username\" \r \n \r \n "
88
- data_post << "#{ datastore [ 'USERNAME' ] } \r \n "
89
- data_post << "------WebKitFormBoundary#{ boundary } \r \n "
90
- data_post << "Content-Disposition: form-data; name=\" password\" \r \n \r \n "
91
- data_post << "#{ datastore [ 'PASSWORD' ] } \r \n "
92
- data_post << "------WebKitFormBoundary#{ boundary } \r \n "
93
-
94
- res = send_request_cgi! ( {
78
+ data_post = Rex ::MIME ::Message . new
79
+ data_post . add_part ( '' , nil , nil , %(form-data; name="returnto") )
80
+ data_post . add_part ( '' , nil , nil , %(form-data; name="template") )
81
+ data_post . add_part ( datastore [ 'USERNAME' ] , nil , nil , %(form-data; name="username") )
82
+ data_post . add_part ( datastore [ 'PASSWORD' ] , nil , nil , %(form-data; name="password") )
83
+
84
+ res = send_request_cgi ( {
95
85
'method' => 'POST' ,
96
86
'uri' => normalize_uri ( target_uri . path , 'pivotx' , 'index.php' ) ,
97
87
'vars_get' => { 'page' => 'login' } ,
98
- 'ctype' => "multipart/form-data; boundary=----WebKitFormBoundary #{ boundary } " ,
99
- 'data' => data_post ,
88
+ 'ctype' => "multipart/form-data; boundary=#{ data_post . bound } " ,
89
+ 'data' => data_post . to_s ,
100
90
'keep_cookies' => true
101
91
} )
102
92
103
- fail_with Failure ::NoAccess , 'Login failed, probably incorrect credentials' unless res &.code == 200 && res . body . include? ( 'Dashboard' ) && ! res . body . include? ( 'Incorrect username/password' ) && res . get_cookies =~ /pivotxsession=([a-zA-Z0-9]+);/
93
+ fail_with Failure ::NoAccess , 'Login failed, probably incorrect credentials' unless ( res &.code == 200 || res &. code == 302 ) && res . get_cookies =~ /pivotxsession=([a-zA-Z0-9]+);/
104
94
105
95
@csrf_token = Regexp . last_match ( 1 )
106
96
end
0 commit comments