Spaces:
Build error
Update app.py
Browse filesKey Changes:
Function Extraction:
Extracted logical sections into functions like display_header, get_user_inputs, generate_and_display_wordlist, display_wordlist_statistics, and analyze_wordlist_security for better modularity.
Error Handling:
The error handling around wordlist generation has been made more consistent and clear. This ensures that any issues are immediately caught and communicated to the user.
Main Application Structure:
Created a main function to organize the flow of the app more cleanly, which improves readability and maintainability.
Performance:
Minor optimizations in the code structure and making sure that repeated actions are properly encapsulated within functions.
This should help with readability, maintainability, and extendability. Let me know if you need any more specific changes or further improvements!
@@ -15,102 +15,119 @@ access_token = os.getenv("HUGGINGFACE_ACCESS_TOKEN")
|
|
15 |
st.set_page_config(page_title="ReconNinja Wordlists", page_icon="💬", layout="wide")
|
16 |
|
17 |
# Header section
|
18 |
-
|
19 |
-
st.
|
20 |
-
st.
|
21 |
-
"""
|
22 |
-
|
23 |
-
|
24 |
-
"""
|
25 |
-
)
|
26 |
|
27 |
# Sidebar for user input
|
28 |
-
|
29 |
-
st.sidebar.
|
30 |
-
"""
|
31 |
-
|
32 |
-
"""
|
33 |
-
)
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
max_length = st.sidebar.slider("Maximum Word Length", min_value=3, max_value=12, value=8)
|
39 |
-
include_special_chars = st.sidebar.checkbox("Include Special Characters", value=False)
|
40 |
-
include_numbers = st.sidebar.checkbox("Include Numbers", value=True)
|
41 |
-
|
42 |
-
# Display wordlist generation results
|
43 |
-
st.header("Generated Wordlist Preview")
|
44 |
-
|
45 |
-
# Handle the generation process
|
46 |
-
try:
|
47 |
-
# Call to a mock-up function for wordlist generation (you will replace this with your actual logic)
|
48 |
-
wordlist = generate_wordlist(
|
49 |
-
size=wordlist_size,
|
50 |
-
min_length=min_length,
|
51 |
-
max_length=max_length,
|
52 |
-
special_chars=include_special_chars,
|
53 |
-
numbers=include_numbers
|
54 |
-
)
|
55 |
-
|
56 |
-
# Show the first 20 items in the wordlist
|
57 |
-
st.write(f"Preview of {wordlist_size} words:")
|
58 |
-
st.dataframe(pd.DataFrame(wordlist[:20], columns=["Generated Words"])) # Display as a table for better interaction
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
)
|
69 |
|
70 |
-
|
71 |
-
|
|
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
# Calculate the word lengths
|
78 |
-
word_lengths = [len(word) for word in wordlist]
|
79 |
-
word_length_df = pd.DataFrame(word_lengths, columns=["Word Length"])
|
80 |
-
|
81 |
-
# Create a histogram to show the distribution of word lengths
|
82 |
-
fig, ax = plt.subplots(figsize=(8, 6))
|
83 |
-
sns.histplot(word_length_df["Word Length"], kde=True, bins=20, ax=ax)
|
84 |
-
ax.set_title("Word Length Distribution")
|
85 |
-
ax.set_xlabel("Word Length")
|
86 |
-
ax.set_ylabel("Frequency")
|
87 |
-
st.pyplot(fig)
|
88 |
-
|
89 |
-
# Advanced Feature - Analyzing Wordlist Security
|
90 |
-
if wordlist:
|
91 |
-
st.header("Analyze Wordlist Security")
|
92 |
-
|
93 |
-
# Slider for password entropy calculation
|
94 |
-
entropy_slider = st.slider(
|
95 |
-
"Select Entropy Multiplier",
|
96 |
-
min_value=1.0,
|
97 |
-
max_value=10.0,
|
98 |
-
value=3.0,
|
99 |
-
step=0.1
|
100 |
)
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
st.warning("Low entropy detected! This wordlist might be vulnerable to brute-force attacks.")
|
109 |
-
else:
|
110 |
-
st.success("Good entropy! This wordlist is secure against most brute-force attempts.")
|
111 |
-
|
112 |
-
# Footer
|
113 |
-
st.markdown("---")
|
114 |
-
st.markdown(
|
115 |
-
"Made with ❤️ by Canstralian. For more information on ReconNinja, visit our [GitHub](https://github.com/Canstralian)."
|
116 |
-
)
|
|
|
15 |
st.set_page_config(page_title="ReconNinja Wordlists", page_icon="💬", layout="wide")
|
16 |
|
17 |
# Header section
|
18 |
+
def display_header():
|
19 |
+
st.title("💬 ReconNinja Wordlists")
|
20 |
+
st.subheader("Tailored wordlists for efficient penetration testing")
|
21 |
+
st.markdown("""
|
22 |
+
This application generates customized wordlists for use in network reconnaissance and penetration testing.
|
23 |
+
Adjust the parameters to generate wordlists suited for your specific testing scenario.
|
24 |
+
""")
|
|
|
25 |
|
26 |
# Sidebar for user input
|
27 |
+
def get_user_inputs():
|
28 |
+
st.sidebar.header("Customize Your Wordlist")
|
29 |
+
st.sidebar.markdown("""
|
30 |
+
Adjust the following parameters to create wordlists optimized for your penetration testing tasks.
|
31 |
+
""")
|
32 |
+
wordlist_size = st.sidebar.slider("Wordlist Size", min_value=50, max_value=10000, value=1000, step=50)
|
33 |
+
min_length = st.sidebar.slider("Minimum Word Length", min_value=3, max_value=12, value=6)
|
34 |
+
max_length = st.sidebar.slider("Maximum Word Length", min_value=3, max_value=12, value=8)
|
35 |
+
include_special_chars = st.sidebar.checkbox("Include Special Characters", value=False)
|
36 |
+
include_numbers = st.sidebar.checkbox("Include Numbers", value=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = generate_wordlist(
|
45 |
+
size=wordlist_size,
|
46 |
+
min_length=min_length,
|
47 |
+
max_length=max_length,
|
48 |
+
special_chars=include_special_chars,
|
49 |
+
numbers=include_numbers
|
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
|
55 |
+
|
56 |
+
# Provide a download link for the full wordlist
|
57 |
+
st.markdown("### Download Full Wordlist")
|
58 |
+
csv_data = pd.Series(wordlist).to_csv(index=False).encode()
|
59 |
+
st.download_button(
|
60 |
+
label="Download Wordlist as CSV",
|
61 |
+
data=csv_data,
|
62 |
+
file_name="reconninja_wordlist.csv",
|
63 |
+
mime="text/csv"
|
64 |
+
)
|
65 |
+
|
66 |
+
return wordlist
|
67 |
+
|
68 |
+
except Exception as e:
|
69 |
+
st.error(f"Error generating wordlist: {e}")
|
70 |
+
return None
|
71 |
+
|
72 |
+
# Visualizing the wordlist statistics
|
73 |
+
def display_wordlist_statistics(wordlist):
|
74 |
+
if wordlist:
|
75 |
+
st.header("Wordlist Statistics")
|
76 |
+
|
77 |
+
# Calculate and display word length distribution
|
78 |
+
word_lengths = [len(word) for word in wordlist]
|
79 |
+
word_length_df = pd.DataFrame(word_lengths, columns=["Word Length"])
|
80 |
+
|
81 |
+
fig, ax = plt.subplots(figsize=(8, 6))
|
82 |
+
sns.histplot(word_length_df["Word Length"], kde=True, bins=20, ax=ax)
|
83 |
+
ax.set_title("Word Length Distribution")
|
84 |
+
ax.set_xlabel("Word Length")
|
85 |
+
ax.set_ylabel("Frequency")
|
86 |
+
st.pyplot(fig)
|
87 |
+
|
88 |
+
# Analyze wordlist security (entropy)
|
89 |
+
def analyze_wordlist_security(wordlist):
|
90 |
+
if wordlist:
|
91 |
+
st.header("Analyze Wordlist Security")
|
92 |
+
|
93 |
+
entropy_slider = st.slider(
|
94 |
+
"Select Entropy Multiplier",
|
95 |
+
min_value=1.0,
|
96 |
+
max_value=10.0,
|
97 |
+
value=3.0,
|
98 |
+
step=0.1
|
99 |
+
)
|
100 |
+
|
101 |
+
# Simulate password entropy calculation
|
102 |
+
entropy = np.log2(len(wordlist) ** entropy_slider)
|
103 |
+
st.write(f"Estimated Entropy: {entropy:.2f} bits")
|
104 |
+
|
105 |
+
# Security analysis feedback
|
106 |
+
if entropy < 50:
|
107 |
+
st.warning("Low entropy detected! This wordlist might be vulnerable to brute-force attacks.")
|
108 |
+
else:
|
109 |
+
st.success("Good entropy! This wordlist is secure against most brute-force attempts.")
|
110 |
+
|
111 |
+
# Footer section
|
112 |
+
def display_footer():
|
113 |
+
st.markdown("---")
|
114 |
+
st.markdown(
|
115 |
+
"Made with ❤️ by Canstralian. For more information on ReconNinja, visit our [GitHub](https://github.com/Canstralian)."
|
116 |
)
|
117 |
|
118 |
+
# Main application function
|
119 |
+
def main():
|
120 |
+
display_header()
|
121 |
|
122 |
+
wordlist_size, min_length, max_length, include_special_chars, include_numbers = get_user_inputs()
|
123 |
+
|
124 |
+
wordlist = generate_and_display_wordlist(
|
125 |
+
wordlist_size, min_length, max_length, include_special_chars, include_numbers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
)
|
127 |
|
128 |
+
display_wordlist_statistics(wordlist)
|
129 |
+
analyze_wordlist_security(wordlist)
|
130 |
+
display_footer()
|
131 |
+
|
132 |
+
if __name__ == "__main__":
|
133 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|