Canstralian commited on
Commit
8c1d14f
·
verified ·
1 Parent(s): a3a519d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -60
app.py CHANGED
@@ -3,11 +3,12 @@ import pandas as pd
3
  import numpy as np
4
  import matplotlib.pyplot as plt
5
  import seaborn as sns
6
- from wordlist_generator import generate_wordlist # Assuming your generate_wordlist function is imported here
7
  from dotenv import load_dotenv
8
  import os
9
 
10
- load_dotenv() # Load environment variables from .env file
 
11
  access_token = os.getenv("HUGGINGFACE_ACCESS_TOKEN")
12
 
13
  # Page configuration
@@ -41,68 +42,72 @@ include_numbers = st.sidebar.checkbox("Include Numbers", value=True)
41
  # Display wordlist generation results
42
  st.header("Generated Wordlist Preview")
43
 
44
- # Call to the actual logic for wordlist generation
45
- wordlist = generate_wordlist(
46
- size=wordlist_size,
47
- min_length=min_length,
48
- max_length=max_length,
49
- special_chars=include_special_chars,
50
- numbers=include_numbers
51
- )
52
-
53
- # Display the first 20 items in the wordlist
54
- st.write(f"Preview of {wordlist_size} words:")
55
- st.write(wordlist[:20]) # Show the first 20 words for brevity
56
-
57
- # Download link for the full wordlist
58
- st.markdown("### Download Full Wordlist")
59
- csv_data = pd.Series(wordlist).to_csv(index=False).encode()
60
- st.download_button(
61
- label="Download Wordlist as CSV",
62
- data=csv_data,
63
- file_name="reconninja_wordlist.csv",
64
- mime="text/csv"
65
- )
 
 
 
 
 
66
 
67
  # Visualize wordlist statistics (for example, word length distribution)
68
- st.header("Wordlist Statistics")
69
- word_lengths = [len(word) for word in wordlist]
70
- word_length_df = pd.DataFrame(word_lengths, columns=["Word Length"])
71
-
72
- # Create a histogram to show the distribution of word lengths
73
- fig, ax = plt.subplots(figsize=(8, 6))
74
- sns.histplot(word_length_df["Word Length"], kde=True, bins=20, ax=ax)
75
- ax.set_title("Word Length Distribution")
76
- ax.set_xlabel("Word Length")
77
- ax.set_ylabel("Frequency")
78
- st.pyplot(fig)
 
 
 
79
 
80
  # Advanced Feature - Analyzing Wordlist Security
81
- st.header("Analyze Wordlist Security")
82
-
83
- # Slider for password entropy calculation
84
- entropy_slider = st.slider(
85
- "Select Entropy Multiplier",
86
- min_value=1.0,
87
- max_value=10.0,
88
- value=3.0,
89
- step=0.1
90
- )
91
-
92
- # Simulate password entropy calculation (simple calculation for demonstration)
93
- entropy = np.log2(len(wordlist) ** entropy_slider)
94
- st.write(f"Estimated Entropy: {entropy:.2f} bits")
95
-
96
- # Showcase a mock security analysis (this would be expanded in your actual app)
97
- if entropy < 50:
98
- st.warning("Low entropy detected! This wordlist might be vulnerable to brute-force attacks.")
99
- else:
100
- st.success("Good entropy! This wordlist is secure against most brute-force attempts.")
101
-
102
- # Additional Analysis (Average Word Length)
103
- st.header("Additional Analysis: Average Word Length")
104
- avg_word_length = np.mean(word_lengths)
105
- st.write(f"Average Word Length: {avg_word_length:.2f} characters")
106
 
107
  # Footer
108
  st.markdown("---")
 
3
  import numpy as np
4
  import matplotlib.pyplot as plt
5
  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()
12
  access_token = os.getenv("HUGGINGFACE_ACCESS_TOKEN")
13
 
14
  # Page configuration
 
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
+ # Provide a download link for the full wordlist
61
+ st.markdown("### Download Full Wordlist")
62
+ csv_data = pd.Series(wordlist).to_csv(index=False).encode()
63
+ st.download_button(
64
+ label="Download Wordlist as CSV",
65
+ data=csv_data,
66
+ file_name="reconninja_wordlist.csv",
67
+ mime="text/csv"
68
+ )
69
+
70
+ except Exception as e:
71
+ st.error(f"Error generating wordlist: {e}")
72
 
73
  # Visualize wordlist statistics (for example, word length distribution)
74
+ if wordlist:
75
+ st.header("Wordlist Statistics")
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
+ # Simulate password entropy calculation (simple calculation for demonstration)
103
+ entropy = np.log2(len(wordlist) ** entropy_slider)
104
+ st.write(f"Estimated Entropy: {entropy:.2f} bits")
105
+
106
+ # Showcase a mock security analysis (this would be expanded in your actual app)
107
+ if entropy < 50:
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("---")