Canstralian commited on
Commit
2237390
·
verified ·
1 Parent(s): 5ebbe1b

Update app.py

Browse files

Key Changes:
Navigation:

Added a sidebar with a radio button to switch between different sections: "Wordlist Generator", "Statistics", and "Security Analysis".
Improved Visualizations:

Word Length Distribution Bar Chart: Displays the frequency of word lengths in the wordlist.
Word Cloud: A visual representation of the most frequent words in the wordlist.
Dynamic Updates:

The wordlist is generated when the user accesses the "Wordlist Generator" section. Other sections (Statistics, Security Analysis) will display content based on the current wordlist.
Next Steps:
You can add more features to the visualizations, like customizing the word cloud further or adding additional metrics (e.g., entropy per word length).
Further refine the UI/UX by enhancing the layout and allowing for more complex inputs (e.g., selecting specific character sets for special characters).

Files changed (1) hide show
  1. app.py +42 -45
app.py CHANGED
@@ -6,8 +6,7 @@ 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
- import requests
10
- import time
11
 
12
  # Load environment variables from .env file
13
  load_dotenv()
@@ -16,6 +15,13 @@ access_token = os.getenv("HUGGINGFACE_ACCESS_TOKEN")
16
  # Page configuration
17
  st.set_page_config(page_title="ReconNinja Wordlists", page_icon="💬", layout="wide")
18
 
 
 
 
 
 
 
 
19
  # Header section
20
  def display_header():
21
  st.title("💬 ReconNinja Wordlists")
@@ -39,44 +45,18 @@ def get_user_inputs():
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
@@ -106,13 +86,20 @@ def display_wordlist_statistics(wordlist):
106
  word_lengths = [len(word) for word in wordlist]
107
  word_length_df = pd.DataFrame(word_lengths, columns=["Word Length"])
108
 
 
 
109
  fig, ax = plt.subplots(figsize=(8, 6))
110
- sns.histplot(word_length_df["Word Length"], kde=True, bins=20, ax=ax)
111
- ax.set_title("Word Length Distribution")
112
  ax.set_xlabel("Word Length")
113
  ax.set_ylabel("Frequency")
114
  st.pyplot(fig)
115
 
 
 
 
 
 
116
  # Analyze wordlist security (entropy)
117
  def analyze_wordlist_security(wordlist):
118
  if wordlist:
@@ -145,17 +132,27 @@ def display_footer():
145
 
146
  # Main application function
147
  def main():
 
 
148
  display_header()
149
 
150
- wordlist_size, min_length, max_length, include_special_chars, include_numbers = get_user_inputs()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
- wordlist = generate_and_display_wordlist(
153
- wordlist_size, min_length, max_length, include_special_chars, include_numbers
154
- )
155
-
156
- display_wordlist_statistics(wordlist)
157
- analyze_wordlist_security(wordlist)
158
  display_footer()
159
 
160
  if __name__ == "__main__":
161
- main()
 
6
  from wordlist_generator import generate_wordlist # A mock-up function for your project
7
  from dotenv import load_dotenv
8
  import os
9
+ from wordcloud import WordCloud
 
10
 
11
  # Load environment variables from .env file
12
  load_dotenv()
 
15
  # Page configuration
16
  st.set_page_config(page_title="ReconNinja Wordlists", page_icon="💬", layout="wide")
17
 
18
+ # Sidebar for navigation
19
+ def display_sidebar():
20
+ st.sidebar.title("Navigation")
21
+ options = ["Wordlist Generator", "Statistics", "Security Analysis"]
22
+ choice = st.sidebar.radio("Go to", options)
23
+ return choice
24
+
25
  # Header section
26
  def display_header():
27
  st.title("💬 ReconNinja Wordlists")
 
45
 
46
  return wordlist_size, min_length, max_length, include_special_chars, include_numbers
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  # Wordlist generation logic
49
  def generate_and_display_wordlist(wordlist_size, min_length, max_length, include_special_chars, include_numbers):
50
  try:
51
+ # Generate the wordlist
52
+ wordlist = generate_wordlist(
53
+ size=wordlist_size,
54
+ min_length=min_length,
55
+ max_length=max_length,
56
+ special_chars=include_special_chars,
57
+ numbers=include_numbers
58
  )
59
 
 
 
 
60
  # Display a preview of the wordlist
61
  st.write(f"Preview of {wordlist_size} words:")
62
  st.dataframe(pd.DataFrame(wordlist[:20], columns=["Generated Words"])) # Display first 20 words
 
86
  word_lengths = [len(word) for word in wordlist]
87
  word_length_df = pd.DataFrame(word_lengths, columns=["Word Length"])
88
 
89
+ # Bar Chart for Word Length Distribution
90
+ st.subheader("Word Length Distribution")
91
  fig, ax = plt.subplots(figsize=(8, 6))
92
+ sns.countplot(x=word_length_df["Word Length"], ax=ax, palette="viridis")
93
+ ax.set_title("Frequency of Word Lengths")
94
  ax.set_xlabel("Word Length")
95
  ax.set_ylabel("Frequency")
96
  st.pyplot(fig)
97
 
98
+ # Word Cloud of Words
99
+ st.subheader("Word Cloud")
100
+ wordcloud = WordCloud(width=800, height=400, background_color="white").generate(" ".join(wordlist))
101
+ st.image(wordcloud.to_array(), use_column_width=True)
102
+
103
  # Analyze wordlist security (entropy)
104
  def analyze_wordlist_security(wordlist):
105
  if wordlist:
 
132
 
133
  # Main application function
134
  def main():
135
+ choice = display_sidebar()
136
+
137
  display_header()
138
 
139
+ if choice == "Wordlist Generator":
140
+ wordlist_size, min_length, max_length, include_special_chars, include_numbers = get_user_inputs()
141
+ wordlist = generate_and_display_wordlist(
142
+ wordlist_size, min_length, max_length, include_special_chars, include_numbers
143
+ )
144
+ elif choice == "Statistics":
145
+ if 'wordlist' not in locals():
146
+ st.warning("Please generate a wordlist first!")
147
+ else:
148
+ display_wordlist_statistics(wordlist)
149
+ elif choice == "Security Analysis":
150
+ if 'wordlist' not in locals():
151
+ st.warning("Please generate a wordlist first!")
152
+ else:
153
+ analyze_wordlist_security(wordlist)
154
 
 
 
 
 
 
 
155
  display_footer()
156
 
157
  if __name__ == "__main__":
158
+ main()