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()