Update public source
This commit is contained in:
+64
-20
@@ -40,11 +40,16 @@ from reports.dashboard import (
|
||||
generate_dashboard,
|
||||
)
|
||||
from cracklab.server.web import cracklab_bp
|
||||
from cracklab.server.db.connection import (
|
||||
connect_database as connect_cracklab_database,
|
||||
)
|
||||
from cracklab.server.services.search_context import SearchContextService
|
||||
from reports.search import (
|
||||
build_hash_export,
|
||||
build_search_data,
|
||||
load_handshakes,
|
||||
normalize_criteria,
|
||||
render_search_page,
|
||||
search_access_points,
|
||||
)
|
||||
from reports.hashcat import (
|
||||
build_all_hash_export,
|
||||
@@ -1888,11 +1893,14 @@ def reports_search_data():
|
||||
close_database(conn)
|
||||
|
||||
|
||||
@app.route("/reports/search/export")
|
||||
def reports_search_export():
|
||||
@app.route(
|
||||
"/reports/search/cracklab",
|
||||
methods=["POST"],
|
||||
)
|
||||
def reports_search_cracklab():
|
||||
|
||||
criteria = normalize_criteria(
|
||||
vendor=request.args.get(
|
||||
vendor=request.form.get(
|
||||
"vendor",
|
||||
""
|
||||
)
|
||||
@@ -1907,34 +1915,67 @@ def reports_search_export():
|
||||
}
|
||||
), 400
|
||||
|
||||
conn = connect_database()
|
||||
reports_conn = connect_database()
|
||||
cracklab_conn = None
|
||||
|
||||
try:
|
||||
|
||||
content = build_hash_export(
|
||||
conn,
|
||||
access_points = search_access_points(
|
||||
reports_conn,
|
||||
criteria
|
||||
)
|
||||
|
||||
filename = build_export_filename(
|
||||
"search",
|
||||
request.args.get(
|
||||
"vendor",
|
||||
""
|
||||
)
|
||||
handshakes = load_handshakes(
|
||||
reports_conn,
|
||||
criteria
|
||||
)
|
||||
|
||||
return Response(
|
||||
content,
|
||||
mimetype="text/plain",
|
||||
headers={
|
||||
"Content-Disposition":
|
||||
f'attachment; filename="{filename}"'
|
||||
handshake_ids = [
|
||||
int(handshake["id"])
|
||||
for items in handshakes.values()
|
||||
for handshake in items
|
||||
]
|
||||
|
||||
if not handshake_ids:
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"error":
|
||||
"Search results contain no handshakes or PMKID records."
|
||||
}
|
||||
), 400
|
||||
|
||||
cracklab_conn = connect_cracklab_database()
|
||||
|
||||
context = SearchContextService(
|
||||
cracklab_conn
|
||||
).create_context(
|
||||
criteria=criteria,
|
||||
handshake_ids=handshake_ids,
|
||||
matched_access_point_count=len(access_points),
|
||||
)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"redirect_url": url_for(
|
||||
"cracklab.jobs_page",
|
||||
search_context_token=context["token"],
|
||||
),
|
||||
"matched_access_point_count":
|
||||
context["matched_access_point_count"],
|
||||
"handshake_count":
|
||||
context["handshake_count"],
|
||||
"expires_at":
|
||||
context["expires_at"],
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as error:
|
||||
|
||||
logger.exception(
|
||||
"Failed to create CrackLab search context."
|
||||
)
|
||||
|
||||
return jsonify(
|
||||
{
|
||||
"error": str(error)
|
||||
@@ -1943,7 +1984,10 @@ def reports_search_export():
|
||||
|
||||
finally:
|
||||
|
||||
close_database(conn)
|
||||
close_database(reports_conn)
|
||||
|
||||
if cracklab_conn is not None:
|
||||
cracklab_conn.close()
|
||||
|
||||
|
||||
@app.route("/reports/static/<path:filename>")
|
||||
|
||||
Reference in New Issue
Block a user