MCPcopy Index your code
hub / github.com/OWASP/Python-Honeypot / download_file

Function download_file

api/server.py:576–613  ·  view source on GitHub ↗

Download PCAP files --- parameters: - in: query name: md5 schema: type: string required: true description: value of the PCAP file to download example: 282e14c5b89ff2af63f4146fbd0a6c68 responses: '200':

()

Source from the content-addressed store, hash-verified

574
575@app.route("/api/pcap/download", methods=["GET"])
576def download_file():
577 """
578 Download PCAP files
579 ---
580 parameters:
581 - in: query
582 name: md5
583 schema:
584 type: string
585 required: true
586 description: value of the PCAP file to download
587 example: 282e14c5b89ff2af63f4146fbd0a6c68
588 responses:
589 '200':
590 description: Ok
591 '404':
592 description: Not Found
593 examples:
594 application/json: { "msg": "file/path not found!","status": "error"}
595 """
596 try:
597 md5_value = get_value_from_request("md5")
598 abort(404) if not md5_value else md5_value
599
600 fs = elasticsearch_events.search(
601 index='ohp_file_archive',
602 body=filter_by_fields(md5_value, ['md5'])
603 )['hits']['hits'][0]['_source']
604 return send_file(
605 io.BytesIO(binascii.a2b_base64(fs['content'])),
606 attachment_filename=fs['filename'],
607 as_attachment=True,
608 mimetype='application/cap'
609 ), 200
610
611 except Exception as e:
612 print(e)
613 return abort(404)
614
615
616@app.route("/api/core/list/modules", methods=["GET"])

Callers

nothing calls this directly

Calls 2

filter_by_fieldsFunction · 0.90
get_value_from_requestFunction · 0.85

Tested by

no test coverage detected