Update public source
This commit is contained in:
@@ -17,7 +17,6 @@ from cracklab.server.services.method_definition import (
|
|||||||
validate_method_definition,
|
validate_method_definition,
|
||||||
)
|
)
|
||||||
from cracklab.server.services.search_context import (
|
from cracklab.server.services.search_context import (
|
||||||
SearchContextError,
|
|
||||||
SearchContextService,
|
SearchContextService,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -181,28 +181,53 @@ def jobs_page():
|
|||||||
"limited",
|
"limited",
|
||||||
)
|
)
|
||||||
|
|
||||||
if issue_mode == "all":
|
if issue_mode == "search":
|
||||||
limit = None
|
|
||||||
else:
|
|
||||||
limit_raw = request.form.get(
|
|
||||||
"limit",
|
|
||||||
"100",
|
|
||||||
).strip()
|
|
||||||
|
|
||||||
try:
|
if not search_context_token:
|
||||||
limit = int(limit_raw)
|
|
||||||
except ValueError as exc:
|
|
||||||
raise JobIssuanceError(
|
raise JobIssuanceError(
|
||||||
"Количество handshakes должно быть целым числом."
|
"Search context is missing. Return to Search "
|
||||||
) from exc
|
"and export the results again."
|
||||||
|
)
|
||||||
|
|
||||||
issued_job = issuance_service.issue_job(
|
issued_job = (
|
||||||
method_id=selected_method_id,
|
issuance_service.issue_job_from_search_context(
|
||||||
method_version=selected_version,
|
token=search_context_token,
|
||||||
limit=limit,
|
method_id=selected_method_id,
|
||||||
)
|
method_version=selected_version,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
if issue_mode == "all":
|
||||||
|
limit = None
|
||||||
|
else:
|
||||||
|
limit_raw = request.form.get(
|
||||||
|
"limit",
|
||||||
|
"100",
|
||||||
|
).strip()
|
||||||
|
|
||||||
|
try:
|
||||||
|
limit = int(limit_raw)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise JobIssuanceError(
|
||||||
|
"Количество handshakes должно быть целым числом."
|
||||||
|
) from exc
|
||||||
|
|
||||||
|
issued_job = issuance_service.issue_job(
|
||||||
|
method_id=selected_method_id,
|
||||||
|
method_version=selected_version,
|
||||||
|
limit=limit,
|
||||||
|
)
|
||||||
|
|
||||||
if issued_job is None:
|
if issued_job is None:
|
||||||
|
|
||||||
|
if issue_mode == "search":
|
||||||
|
raise JobIssuanceError(
|
||||||
|
"No handshakes from Search results are available "
|
||||||
|
"for the selected method and version."
|
||||||
|
)
|
||||||
|
|
||||||
raise JobIssuanceError(
|
raise JobIssuanceError(
|
||||||
"Нет handshakes, доступных для нового job."
|
"Нет handshakes, доступных для нового job."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -105,6 +105,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="jobs-issue-column">
|
<div class="jobs-issue-column">
|
||||||
|
<h3>Standard issuance</h3>
|
||||||
|
<p class="page-description">
|
||||||
|
Выдача доступных рукопожатий из всей базы CrackLab.
|
||||||
|
</p>
|
||||||
<form method="post" class="jobs-form">
|
<form method="post" class="jobs-form">
|
||||||
<input
|
<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
@@ -189,7 +193,7 @@
|
|||||||
{{ search_statistics["matched_count"] }}
|
{{ search_statistics["matched_count"] }}
|
||||||
</div>
|
</div>
|
||||||
<div class="stat-title">
|
<div class="stat-title">
|
||||||
Found by Search
|
Handshakes found by Search
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -202,6 +206,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="jobs-stat-item">
|
||||||
|
<div class="stat-value">
|
||||||
|
{{ search_statistics["matched_count"] - search_statistics["available_count"] }}
|
||||||
|
</div>
|
||||||
|
<div class="stat-title">
|
||||||
|
Skipped
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="jobs-stat-item">
|
<div class="jobs-stat-item">
|
||||||
<div class="stat-value">
|
<div class="stat-value">
|
||||||
{{ search_statistics["found_count"] }}
|
{{ search_statistics["found_count"] }}
|
||||||
@@ -239,6 +252,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<form method="post" class="jobs-form">
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="method_id"
|
||||||
|
value="{{ selected_method_id }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="method_version"
|
||||||
|
value="{{ selected_version or '' }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="search_context_token"
|
||||||
|
value="{{ search_context_token }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
name="issue_mode"
|
||||||
|
value="search"
|
||||||
|
class="methods-button jobs-action-button"
|
||||||
|
{% if not search_statistics or search_statistics["available_count"] <= 0 %}disabled{% endif %}
|
||||||
|
>
|
||||||
|
Form Job from Search
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
+64
-20
@@ -40,11 +40,16 @@ from reports.dashboard import (
|
|||||||
generate_dashboard,
|
generate_dashboard,
|
||||||
)
|
)
|
||||||
from cracklab.server.web import cracklab_bp
|
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 (
|
from reports.search import (
|
||||||
build_hash_export,
|
|
||||||
build_search_data,
|
build_search_data,
|
||||||
|
load_handshakes,
|
||||||
normalize_criteria,
|
normalize_criteria,
|
||||||
render_search_page,
|
render_search_page,
|
||||||
|
search_access_points,
|
||||||
)
|
)
|
||||||
from reports.hashcat import (
|
from reports.hashcat import (
|
||||||
build_all_hash_export,
|
build_all_hash_export,
|
||||||
@@ -1888,11 +1893,14 @@ def reports_search_data():
|
|||||||
close_database(conn)
|
close_database(conn)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/reports/search/export")
|
@app.route(
|
||||||
def reports_search_export():
|
"/reports/search/cracklab",
|
||||||
|
methods=["POST"],
|
||||||
|
)
|
||||||
|
def reports_search_cracklab():
|
||||||
|
|
||||||
criteria = normalize_criteria(
|
criteria = normalize_criteria(
|
||||||
vendor=request.args.get(
|
vendor=request.form.get(
|
||||||
"vendor",
|
"vendor",
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
@@ -1907,34 +1915,67 @@ def reports_search_export():
|
|||||||
}
|
}
|
||||||
), 400
|
), 400
|
||||||
|
|
||||||
conn = connect_database()
|
reports_conn = connect_database()
|
||||||
|
cracklab_conn = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
content = build_hash_export(
|
access_points = search_access_points(
|
||||||
conn,
|
reports_conn,
|
||||||
criteria
|
criteria
|
||||||
)
|
)
|
||||||
|
|
||||||
filename = build_export_filename(
|
handshakes = load_handshakes(
|
||||||
"search",
|
reports_conn,
|
||||||
request.args.get(
|
criteria
|
||||||
"vendor",
|
|
||||||
""
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return Response(
|
handshake_ids = [
|
||||||
content,
|
int(handshake["id"])
|
||||||
mimetype="text/plain",
|
for items in handshakes.values()
|
||||||
headers={
|
for handshake in items
|
||||||
"Content-Disposition":
|
]
|
||||||
f'attachment; filename="{filename}"'
|
|
||||||
|
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:
|
except Exception as error:
|
||||||
|
|
||||||
|
logger.exception(
|
||||||
|
"Failed to create CrackLab search context."
|
||||||
|
)
|
||||||
|
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
"error": str(error)
|
"error": str(error)
|
||||||
@@ -1943,7 +1984,10 @@ def reports_search_export():
|
|||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
||||||
close_database(conn)
|
close_database(reports_conn)
|
||||||
|
|
||||||
|
if cracklab_conn is not None:
|
||||||
|
cracklab_conn.close()
|
||||||
|
|
||||||
|
|
||||||
@app.route("/reports/static/<path:filename>")
|
@app.route("/reports/static/<path:filename>")
|
||||||
|
|||||||
+47
-8
@@ -1018,6 +1018,11 @@ def build_search_data(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
handshake_count = sum(
|
||||||
|
len(items)
|
||||||
|
for items in handshakes.values()
|
||||||
|
)
|
||||||
|
|
||||||
matching_vendors = (
|
matching_vendors = (
|
||||||
get_matching_vendors(
|
get_matching_vendors(
|
||||||
conn,
|
conn,
|
||||||
@@ -1037,6 +1042,7 @@ def build_search_data(
|
|||||||
password_access_points,
|
password_access_points,
|
||||||
"handshake_access_points":
|
"handshake_access_points":
|
||||||
handshake_access_points,
|
handshake_access_points,
|
||||||
|
"handshake_count": handshake_count,
|
||||||
"hash_count": len(hashes),
|
"hash_count": len(hashes),
|
||||||
"matching_vendors":
|
"matching_vendors":
|
||||||
matching_vendors,
|
matching_vendors,
|
||||||
@@ -1231,7 +1237,7 @@ def render_search_page(
|
|||||||
class="button"
|
class="button"
|
||||||
disabled
|
disabled
|
||||||
>
|
>
|
||||||
Export hashes
|
Экспорт в CrackLab
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -1828,18 +1834,51 @@ def render_search_page(
|
|||||||
|
|
||||||
exportButton.addEventListener(
|
exportButton.addEventListener(
|
||||||
"click",
|
"click",
|
||||||
() => {
|
async () => {
|
||||||
|
|
||||||
if (!searchParams) {
|
if (!searchParams) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url =
|
exportButton.disabled = true;
|
||||||
"/reports/search/export?"
|
|
||||||
+
|
|
||||||
searchParams.toString();
|
|
||||||
|
|
||||||
window.location.href = url;
|
try {
|
||||||
|
|
||||||
|
const response = await fetch(
|
||||||
|
"/reports/search/cracklab",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type":
|
||||||
|
"application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
body: searchParams.toString()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(
|
||||||
|
data.error || "CrackLab export failed."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.redirect_url) {
|
||||||
|
throw new Error(
|
||||||
|
"CrackLab did not return a destination URL."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.href = data.redirect_url;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
setStatus(error.message);
|
||||||
|
|
||||||
|
exportButton.disabled = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -2041,7 +2080,7 @@ def render_search_page(
|
|||||||
}
|
}
|
||||||
|
|
||||||
exportButton.disabled =
|
exportButton.disabled =
|
||||||
data.hash_count === 0;
|
data.handshake_count === 0;
|
||||||
|
|
||||||
createMap(
|
createMap(
|
||||||
data.geojson
|
data.geojson
|
||||||
|
|||||||
Reference in New Issue
Block a user