File size: 2,559 Bytes
39e1f35 27aabbb a8e82a4 27aabbb 1adcbad fde4d6e 1adcbad a6a9510 a8e82a4 fde4d6e a6a9510 a8e82a4 39e1f35 a8e82a4 1adcbad a8e82a4 a6a9510 a8e82a4 530efe9 a8e82a4 27aabbb fa86a89 a8e82a4 2782704 a6a9510 2782704 fa86a89 27aabbb a8e82a4 1adcbad 530efe9 a8e82a4 2782704 1adcbad a8e82a4 530efe9 a8e82a4 530efe9 1adcbad 530efe9 1adcbad 2782704 1adcbad 39e1f35 a8e82a4 98cb2a9 27aabbb 1adcbad 530efe9 1adcbad 530efe9 1adcbad 39e1f35 a8e82a4 fde4d6e a8e82a4 27aabbb 98cb2a9 a8e82a4 1adcbad 98cb2a9 27aabbb 98cb2a9 39e1f35 a8e82a4 98cb2a9 27aabbb a8e82a4 27aabbb 2782704 39e1f35 1adcbad 98cb2a9 39e1f35 a8e82a4 1adcbad a8e82a4 1adcbad 98cb2a9 2782704 1adcbad 39e1f35 fa86a89 | 1 2 3 4 5 6 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | import gradio as gr
# -----------------------------
# JAVA HASHCODE
# -----------------------------
def java_hash(s):
h = 0
for c in s:
h = (31 * h + ord(c)) & 0xFFFFFFFF
# convert to signed 32-bit
if h >= 0x80000000:
h -= 0x100000000
return h
# -----------------------------
# NORMALIZATION (KEY FIX)
# -----------------------------
def normalize_java_target(value):
try:
v = int(value)
signed = v if v < 0x80000000 else v - 0x100000000
unsigned = v & 0xFFFFFFFF
return {v, signed, unsigned}
except:
return {value}
# -----------------------------
# CLEAN WORDLIST
# -----------------------------
def clean_wordlist(text):
return [
w.strip()
for w in text.splitlines()
if w.strip()
]
# -----------------------------
# CRACK ENGINE (JAVA ONLY)
# -----------------------------
def crack_java(target_hash, words):
matches = []
targets = normalize_java_target(target_hash)
for w in words:
try:
result = java_hash(w)
# compare ALL representations automatically
if result in targets:
matches.append(w)
except:
pass
return matches
# -----------------------------
# MAIN
# -----------------------------
def analyze(hash_value, wordlist_text):
if wordlist_text.strip():
wordlist = clean_wordlist(wordlist_text)
else:
wordlist = [
"admin", "password", "root", "test", "user",
"login", "guest", "1234", "12345", "qwerty",
"test23"
]
matches = crack_java(hash_value, wordlist)
detected_out = "Java String.hashCode() (detected by integer format)"
if matches:
result_out = f"Matches: {matches}"
else:
result_out = "No matches found (try larger wordlist)"
return detected_out, result_out
# -----------------------------
# UI
# -----------------------------
with gr.Blocks() as demo:
gr.Markdown("# 🔍 Java hashCode Reverser")
hash_input = gr.Textbox(label="Hash / Integer Value")
wordlist_input = gr.Textbox(
label="Wordlist (optional, one per line)",
lines=10
)
run_btn = gr.Button("Crack")
detected_out = gr.Textbox(label="Detected Algorithm")
result_out = gr.Textbox(label="Recovered Matches")
run_btn.click(
fn=analyze,
inputs=[hash_input, wordlist_input],
outputs=[detected_out, result_out]
)
if __name__ == "__main__":
demo.launch() |