Newer
Older
from flask import Flask, request, jsonify
import hashlib
import itertools
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@app.route("/bruteforce", methods=["POST"])
def bruteforce():
# Vérifier si le payload contient un hash
data = request.json
if not data or "hash" not in data:
return jsonify({
"status": "fail",
"data": None,
"errors": {
"message": "Invalid payload. Please provide a valid hash."
}
}), 400
target_hash = data["hash"]
# Logique de bruteforce
charset = "abcdefghijklmnopqrstuvwxyz0123456789"
for length in range(1, 8): # Limite la longueur des combinaisons pour les performances
for guess in itertools.product(charset, repeat=length):
guess_str = ''.join(guess)
if hashlib.md5(guess_str.encode()).hexdigest() == target_hash:
return jsonify({
"status": "success",
"data": {
"hash": target_hash,
"original": guess_str
},
"errors": None
}), 200
# Si aucune correspondance n'est trouvée
return jsonify({
"status": "fail",
"data": None,
"errors": {
"message": "No match found for the provided hash."
}
}), 404
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)