Text Generation
Transformers
English
AI
NLP
Cybersecurity
Ethical Hacking
Pentesting
Inference Endpoints
Canstralian commited on
Commit
b8dba5e
·
verified ·
1 Parent(s): eb13b46

Create pentest_ai_streamlit.py

Browse files
Files changed (1) hide show
  1. pentest_ai_streamlit.py +49 -0
pentest_ai_streamlit.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Load the model and tokenizer from Hugging Face
5
+ MODEL_NAME = "Canstralian/pentest_ai"
6
+
7
+ @st.cache_resource
8
+ def load_model():
9
+ # Load the tokenizer and model
10
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
11
+ model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
12
+ return pipeline("text-generation", model=model, tokenizer=tokenizer)
13
+
14
+ # Load the pentest_ai model
15
+ pentest_ai = load_model()
16
+
17
+ # Streamlit interface setup
18
+ st.title("Pentest AI Assistant")
19
+ st.write("This tool allows you to ask penetration testing and cybersecurity-related queries, and it will generate AI-powered suggestions or commands.")
20
+
21
+ # Text input for user's question
22
+ user_input = st.text_area("Enter your question or command:")
23
+
24
+ # Button to trigger generation
25
+ if st.button("Generate Response"):
26
+ if user_input.strip() == "":
27
+ st.error("Please enter a valid input.")
28
+ else:
29
+ # Generate response using the model
30
+ with st.spinner("Generating response..."):
31
+ response = pentest_ai(user_input, max_length=150, num_return_sequences=1)[0]['generated_text']
32
+
33
+ # Display the model's response
34
+ st.subheader("AI Response:")
35
+ st.write(response)
36
+
37
+ # Add an example button to help users see a sample
38
+ if st.button("Show Example"):
39
+ example_query = "How do I scan a network for open ports?"
40
+ with st.spinner("Generating response for example query..."):
41
+ example_response = pentest_ai(example_query, max_length=150, num_return_sequences=1)[0]['generated_text']
42
+
43
+ st.subheader("Example Query:")
44
+ st.write(example_query)
45
+ st.subheader("AI Response:")
46
+ st.write(example_response)
47
+
48
+ # Instructions for the user
49
+ st.info("Note: This AI model provides general advice. Always ensure you're testing on systems you have permission to, and follow legal and ethical guidelines.")