Spaces:
Build error
Update app.py
Browse filesChanges Explained:
Word Frequency Filter (check_common_passwords):
The function check_common_passwords filters out words that appear in a list of common passwords.
The list of common passwords is fetched from an external URL. You should replace this URL with one containing a real list of common passwords or use a local file.
Progress Indicator (generate_wordlist_with_progress):
The wordlist generation now includes a progress bar that updates as each word is generated.
The st.progress function updates the progress bar every 100 words generated. A small time.sleep(0.01) simulates a delay during wordlist generation (you can remove it once the actual generation logic is in place).
Integrated Features:
The wordlist is generated using the generate_wordlist_with_progress function, and then it’s filtered using the check_common_passwords function before being displayed and downloaded.
The UI provides a preview of the first 20 words and allows the user to download the full wordlist as a CSV file.
Final Thoughts:
Test the application to ensure both the progress indicator and word frequency filter work smoothly.
Replace the placeholder URL for the common password list with an actual source, or store the list locally.
For large wordlists, the progress bar should help users track the generation status.
@@ -6,6 +6,8 @@ import seaborn as sns
|
|
6 |
from wordlist_generator import generate_wordlist # A mock-up function for your project
|
7 |
from dotenv import load_dotenv
|
8 |
import os
|
|
|
|
|
9 |
|
10 |
# Load environment variables from .env file
|
11 |
load_dotenv()
|
@@ -37,18 +39,44 @@ def get_user_inputs():
|
|
37 |
|
38 |
return wordlist_size, min_length, max_length, include_special_chars, include_numbers
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
# Wordlist generation logic
|
41 |
def generate_and_display_wordlist(wordlist_size, min_length, max_length, include_special_chars, include_numbers):
|
42 |
try:
|
43 |
-
# Generate the wordlist
|
44 |
-
wordlist =
|
45 |
-
|
46 |
-
min_length
|
47 |
-
max_length
|
48 |
-
|
49 |
-
|
50 |
)
|
51 |
|
|
|
|
|
|
|
52 |
# Display a preview of the wordlist
|
53 |
st.write(f"Preview of {wordlist_size} words:")
|
54 |
st.dataframe(pd.DataFrame(wordlist[:20], columns=["Generated Words"])) # Display first 20 words
|
|
|
6 |
from wordlist_generator import generate_wordlist # A mock-up function for your project
|
7 |
from dotenv import load_dotenv
|
8 |
import os
|
9 |
+
import requests
|
10 |
+
import time
|
11 |
|
12 |
# Load environment variables from .env file
|
13 |
load_dotenv()
|
|
|
39 |
|
40 |
return wordlist_size, min_length, max_length, include_special_chars, include_numbers
|
41 |
|
42 |
+
# Word frequency filter
|
43 |
+
def check_common_passwords(wordlist):
|
44 |
+
# Placeholder URL for common passwords (replace with a real one or use a local file)
|
45 |
+
common_passwords = requests.get("https://example.com/common_passwords.txt").text.splitlines()
|
46 |
+
filtered_list = [word for word in wordlist if word not in common_passwords]
|
47 |
+
return filtered_list
|
48 |
+
|
49 |
+
# Wordlist generation with progress indicator
|
50 |
+
def generate_wordlist_with_progress(size, min_length, max_length, special_chars, numbers):
|
51 |
+
wordlist = []
|
52 |
+
for i in range(size):
|
53 |
+
# Simulate wordlist generation (replace this with your actual word generation logic)
|
54 |
+
word = f"word{i+1}"
|
55 |
+
wordlist.append(word)
|
56 |
+
|
57 |
+
# Update the progress bar every 100 words
|
58 |
+
if i % 100 == 0:
|
59 |
+
st.progress(i / size) # This will update the progress bar
|
60 |
+
|
61 |
+
time.sleep(0.01) # Simulate delay for wordlist generation (remove in production)
|
62 |
+
|
63 |
+
return wordlist
|
64 |
+
|
65 |
# Wordlist generation logic
|
66 |
def generate_and_display_wordlist(wordlist_size, min_length, max_length, include_special_chars, include_numbers):
|
67 |
try:
|
68 |
+
# Generate the wordlist with progress
|
69 |
+
wordlist = generate_wordlist_with_progress(
|
70 |
+
wordlist_size,
|
71 |
+
min_length,
|
72 |
+
max_length,
|
73 |
+
include_special_chars,
|
74 |
+
include_numbers
|
75 |
)
|
76 |
|
77 |
+
# Apply word frequency filter
|
78 |
+
wordlist = check_common_passwords(wordlist)
|
79 |
+
|
80 |
# Display a preview of the wordlist
|
81 |
st.write(f"Preview of {wordlist_size} words:")
|
82 |
st.dataframe(pd.DataFrame(wordlist[:20], columns=["Generated Words"])) # Display first 20 words
|