odexus commited on
Commit
98bc60c
·
verified ·
1 Parent(s): e29d469

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -36
app.py CHANGED
@@ -4,89 +4,75 @@ import subprocess
4
  import os
5
  import shutil
6
 
7
- # --- AUTO-COMPILER (Bypasses the .7z error) ---
 
8
  def install_hashcat():
9
- # Check if we already compiled it
10
  if not os.path.exists("hashcat-6.2.6/hashcat"):
11
- print("⚡ Downloading Hashcat Source...")
12
- # Download the .tar.gz source (Native Linux format, no .7z issues)
13
  subprocess.run("wget https://github.com/hashcat/hashcat/archive/refs/tags/v6.2.6.tar.gz", shell=True)
14
-
15
  print("⚡ Extracting...")
16
- # Use system tar command (Reliable)
17
  subprocess.run("tar -xzf v6.2.6.tar.gz", shell=True)
18
-
19
  print("⚡ Compiling...")
20
- # Run 'make' to build the binary for this specific server
21
  subprocess.run("make -C hashcat-6.2.6", shell=True)
22
-
23
- print("⚡ Hashcat Ready.")
24
-
25
- # Return the path to the newly compiled binary
26
  return "./hashcat-6.2.6/hashcat"
27
 
28
  @spaces.GPU(duration=120)
29
  def run_hashcat(hash_input, wordlist_input, allowed_symbols, attack_mode):
30
- # 1. INSTALLATION / COMPILATION
31
  try:
32
  hashcat_bin = install_hashcat()
33
  except Exception as e:
34
- return f"Installation Error: {str(e)}"
35
 
36
- # 2. Clean up
37
  subprocess.run("rm -f target.hash custom.dict", shell=True)
38
 
39
- # 3. Save Hash
40
  with open("target.hash", "w") as f:
41
  f.write(hash_input.strip())
42
-
43
- # 4. Save Wordlist
44
  with open("custom.dict", "w") as f:
45
  f.write(wordlist_input.strip())
46
 
47
- # 5. Define Custom Charset (-1)
48
  charset_arg = f"-1 {allowed_symbols}"
49
 
50
- # 6. Build Command
51
  if attack_mode == "Quick Check (NTLM)":
52
  cmd = f"{hashcat_bin} -m 1000 -a 0 target.hash custom.dict --force"
53
 
54
  elif attack_mode == "Hybrid (Words + 4 Custom Chars)":
55
- # Pattern: Word + 4 chars (e.g. Mustang99!#)
56
  cmd = f"{hashcat_bin} -m 1000 -a 6 {charset_arg} target.hash custom.dict ?1?1?1?1 --force"
57
 
58
  elif attack_mode == "Hybrid (Words + 6 Custom Chars)":
59
- # Pattern: Word + 6 chars
60
  cmd = f"{hashcat_bin} -m 1000 -a 6 {charset_arg} target.hash custom.dict ?1?1?1?1?1?1 --force"
61
 
62
  elif attack_mode == "Rules-Based Mutations":
63
- # Point to the compiled rules folder
64
  rule_path = "./hashcat-6.2.6/rules/best66.rule"
65
  cmd = f"{hashcat_bin} -m 1000 -a 0 target.hash custom.dict -r {rule_path} --force"
66
 
67
  else:
68
- return "Error: Invalid mode selected"
69
 
70
- # 7. Run
71
  try:
72
  result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=300)
73
  return result.stdout
74
  except Exception as e:
75
  return f"Error: {str(e)}"
76
 
77
- # Interface
78
  with gr.Blocks() as demo:
79
- gr.Markdown("# ⚡ DPAPI Password Recovery Tool (Source Build)")
80
- gr.Markdown("Status: *Auto-Compiler Active*")
81
 
82
  with gr.Row():
83
- txt_hash = gr.Textbox(label="1. NT Hash", placeholder="3232d48683d6ffc3e7ff9e9052c9a0f3")
84
  txt_words = gr.Textbox(label="2. Wordlist", lines=8, placeholder="Edward9945\nLove060516")
85
 
86
  with gr.Row():
87
  txt_symbols = gr.Textbox(
88
  label="3. Allowed Characters",
89
- value="!@#$&*?.",
90
  info="Only these chars will be tested"
91
  )
92
  mode_select = gr.Dropdown(
@@ -97,16 +83,12 @@ with gr.Blocks() as demo:
97
  "Rules-Based Mutations"
98
  ],
99
  label="4. Attack Mode",
100
- value="Hybrid (Words + 4 Custom Chars)"
101
  )
102
 
103
  btn_run = gr.Button("🔓 Crack Password", variant="primary")
104
  output_log = gr.Code(label="Hashcat Output", language="shell")
105
 
106
- btn_run.click(
107
- fn=run_hashcat,
108
- inputs=[txt_hash, txt_words, txt_symbols, mode_select],
109
- outputs=output_log
110
- )
111
 
112
  demo.launch()
 
4
  import os
5
  import shutil
6
 
7
+ # --- AUTO-COMPILER (THE FIX) ---
8
+ # bypasses the broken .7z library by compiling source directly
9
  def install_hashcat():
 
10
  if not os.path.exists("hashcat-6.2.6/hashcat"):
11
+ print("⚡ Downloading Source...")
 
12
  subprocess.run("wget https://github.com/hashcat/hashcat/archive/refs/tags/v6.2.6.tar.gz", shell=True)
 
13
  print("⚡ Extracting...")
 
14
  subprocess.run("tar -xzf v6.2.6.tar.gz", shell=True)
 
15
  print("⚡ Compiling...")
 
16
  subprocess.run("make -C hashcat-6.2.6", shell=True)
 
 
 
 
17
  return "./hashcat-6.2.6/hashcat"
18
 
19
  @spaces.GPU(duration=120)
20
  def run_hashcat(hash_input, wordlist_input, allowed_symbols, attack_mode):
21
+ # 1. Install
22
  try:
23
  hashcat_bin = install_hashcat()
24
  except Exception as e:
25
+ return f"Install Error: {str(e)}"
26
 
27
+ # 2. Clean
28
  subprocess.run("rm -f target.hash custom.dict", shell=True)
29
 
30
+ # 3. Save Files
31
  with open("target.hash", "w") as f:
32
  f.write(hash_input.strip())
 
 
33
  with open("custom.dict", "w") as f:
34
  f.write(wordlist_input.strip())
35
 
36
+ # 4. Define Charset
37
  charset_arg = f"-1 {allowed_symbols}"
38
 
39
+ # 5. Build Command (Your Exact Logic)
40
  if attack_mode == "Quick Check (NTLM)":
41
  cmd = f"{hashcat_bin} -m 1000 -a 0 target.hash custom.dict --force"
42
 
43
  elif attack_mode == "Hybrid (Words + 4 Custom Chars)":
 
44
  cmd = f"{hashcat_bin} -m 1000 -a 6 {charset_arg} target.hash custom.dict ?1?1?1?1 --force"
45
 
46
  elif attack_mode == "Hybrid (Words + 6 Custom Chars)":
 
47
  cmd = f"{hashcat_bin} -m 1000 -a 6 {charset_arg} target.hash custom.dict ?1?1?1?1?1?1 --force"
48
 
49
  elif attack_mode == "Rules-Based Mutations":
50
+ # Points to the compiled rules folder
51
  rule_path = "./hashcat-6.2.6/rules/best66.rule"
52
  cmd = f"{hashcat_bin} -m 1000 -a 0 target.hash custom.dict -r {rule_path} --force"
53
 
54
  else:
55
+ return "Error: Invalid mode"
56
 
57
+ # 6. Run
58
  try:
59
  result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=300)
60
  return result.stdout
61
  except Exception as e:
62
  return f"Error: {str(e)}"
63
 
64
+ # Interface (Your Exact Settings)
65
  with gr.Blocks() as demo:
66
+ gr.Markdown("# ⚡ DPAPI Password Recovery Tool")
 
67
 
68
  with gr.Row():
69
+ txt_hash = gr.Textbox(label="1. NT Hash", placeholder="Paste NTLM hash here")
70
  txt_words = gr.Textbox(label="2. Wordlist", lines=8, placeholder="Edward9945\nLove060516")
71
 
72
  with gr.Row():
73
  txt_symbols = gr.Textbox(
74
  label="3. Allowed Characters",
75
+ value="acdegilmnorstuvwxz0123456789!@#$&*?.",
76
  info="Only these chars will be tested"
77
  )
78
  mode_select = gr.Dropdown(
 
83
  "Rules-Based Mutations"
84
  ],
85
  label="4. Attack Mode",
86
+ value="Hybrid (Words + 6 Custom Chars)"
87
  )
88
 
89
  btn_run = gr.Button("🔓 Crack Password", variant="primary")
90
  output_log = gr.Code(label="Hashcat Output", language="shell")
91
 
92
+ btn_run.click(fn=run_hashcat, inputs=[txt_hash, txt_words, txt_symbols, mode_select], outputs=output_log)
 
 
 
 
93
 
94
  demo.launch()