Canstralian's picture
Update app.py
5ebbe1b verified
raw
history blame
5.9 kB
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from wordlist_generator import generate_wordlist # A mock-up function for your project
from dotenv import load_dotenv
import os
import requests
import time
# Load environment variables from .env file
load_dotenv()
access_token = os.getenv("HUGGINGFACE_ACCESS_TOKEN")
# Page configuration
st.set_page_config(page_title="ReconNinja Wordlists", page_icon="💬", layout="wide")
# Header section
def display_header():
st.title("💬 ReconNinja Wordlists")
st.subheader("Tailored wordlists for efficient penetration testing")
st.markdown("""
This application generates customized wordlists for use in network reconnaissance and penetration testing.
Adjust the parameters to generate wordlists suited for your specific testing scenario.
""")
# Sidebar for user input
def get_user_inputs():
st.sidebar.header("Customize Your Wordlist")
st.sidebar.markdown("""
Adjust the following parameters to create wordlists optimized for your penetration testing tasks.
""")
wordlist_size = st.sidebar.slider("Wordlist Size", min_value=50, max_value=10000, value=1000, step=50)
min_length = st.sidebar.slider("Minimum Word Length", min_value=3, max_value=12, value=6)
max_length = st.sidebar.slider("Maximum Word Length", min_value=3, max_value=12, value=8)
include_special_chars = st.sidebar.checkbox("Include Special Characters", value=False)
include_numbers = st.sidebar.checkbox("Include Numbers", value=True)
return wordlist_size, min_length, max_length, include_special_chars, include_numbers
# Word frequency filter
def check_common_passwords(wordlist):
# Placeholder URL for common passwords (replace with a real one or use a local file)
common_passwords = requests.get("https://example.com/common_passwords.txt").text.splitlines()
filtered_list = [word for word in wordlist if word not in common_passwords]
return filtered_list
# Wordlist generation with progress indicator
def generate_wordlist_with_progress(size, min_length, max_length, special_chars, numbers):
wordlist = []
for i in range(size):
# Simulate wordlist generation (replace this with your actual word generation logic)
word = f"word{i+1}"
wordlist.append(word)
# Update the progress bar every 100 words
if i % 100 == 0:
st.progress(i / size) # This will update the progress bar
time.sleep(0.01) # Simulate delay for wordlist generation (remove in production)
return wordlist
# Wordlist generation logic
def generate_and_display_wordlist(wordlist_size, min_length, max_length, include_special_chars, include_numbers):
try:
# Generate the wordlist with progress
wordlist = generate_wordlist_with_progress(
wordlist_size,
min_length,
max_length,
include_special_chars,
include_numbers
)
# Apply word frequency filter
wordlist = check_common_passwords(wordlist)
# Display a preview of the wordlist
st.write(f"Preview of {wordlist_size} words:")
st.dataframe(pd.DataFrame(wordlist[:20], columns=["Generated Words"])) # Display first 20 words
# Provide a download link for the full wordlist
st.markdown("### Download Full Wordlist")
csv_data = pd.Series(wordlist).to_csv(index=False).encode()
st.download_button(
label="Download Wordlist as CSV",
data=csv_data,
file_name="reconninja_wordlist.csv",
mime="text/csv"
)
return wordlist
except Exception as e:
st.error(f"Error generating wordlist: {e}")
return None
# Visualizing the wordlist statistics
def display_wordlist_statistics(wordlist):
if wordlist:
st.header("Wordlist Statistics")
# Calculate and display word length distribution
word_lengths = [len(word) for word in wordlist]
word_length_df = pd.DataFrame(word_lengths, columns=["Word Length"])
fig, ax = plt.subplots(figsize=(8, 6))
sns.histplot(word_length_df["Word Length"], kde=True, bins=20, ax=ax)
ax.set_title("Word Length Distribution")
ax.set_xlabel("Word Length")
ax.set_ylabel("Frequency")
st.pyplot(fig)
# Analyze wordlist security (entropy)
def analyze_wordlist_security(wordlist):
if wordlist:
st.header("Analyze Wordlist Security")
entropy_slider = st.slider(
"Select Entropy Multiplier",
min_value=1.0,
max_value=10.0,
value=3.0,
step=0.1
)
# Simulate password entropy calculation
entropy = np.log2(len(wordlist) ** entropy_slider)
st.write(f"Estimated Entropy: {entropy:.2f} bits")
# Security analysis feedback
if entropy < 50:
st.warning("Low entropy detected! This wordlist might be vulnerable to brute-force attacks.")
else:
st.success("Good entropy! This wordlist is secure against most brute-force attempts.")
# Footer section
def display_footer():
st.markdown("---")
st.markdown(
"Made with ❤️ by Canstralian. For more information on ReconNinja, visit our [GitHub](https://github.com/Canstralian)."
)
# Main application function
def main():
display_header()
wordlist_size, min_length, max_length, include_special_chars, include_numbers = get_user_inputs()
wordlist = generate_and_display_wordlist(
wordlist_size, min_length, max_length, include_special_chars, include_numbers
)
display_wordlist_statistics(wordlist)
analyze_wordlist_security(wordlist)
display_footer()
if __name__ == "__main__":
main()