-
Notifications
You must be signed in to change notification settings - Fork 13
/
PyGoatBot.py
64 lines (56 loc) · 2.74 KB
/
PyGoatBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.logic import BestMatch
# Dataset generated by ChatGPT
training_data = [
'What is OWASP PyGoat?',
'OWASP PyGoat is an intentionally vulnerable web application used for learning web security testing.',
'Why should I learn web security testing?',
'Learning web security testing can help you understand how to identify and prevent web application attacks.',
'What types of vulnerabilities can PyGoat help me learn about?',
'PyGoat can help you learn about various types of web application vulnerabilities, including injection attacks, cross-site scripting (XSS), and broken authentication and session management.',
'How can I use PyGoat to learn web security testing?',
'PyGoat includes a series of lessons and challenges designed to teach you about web security testing techniques and common vulnerabilities.',
'Is PyGoat suitable for beginners?',
'Yes, PyGoat is designed to be accessible to beginners and experienced professionals alike.',
'Where can I download PyGoat?',
'You can download PyGoat from the official GitHub repository at https://github.com/OWASP/PyGoat',
'Are there any resources available to help me get started with PyGoat?',
'Yes, the PyGoat documentation includes a Getting Started guide and a list of additional resources to help you learn about web security testing.',
'Can I contribute to PyGoat?',
'Yes, PyGoat is an open-source project and welcomes contributions from anyone interested in improving the application.',
]
chatbot = ChatBot(
"PyGoatBot",
storage_adapter="chatterbot.storage.SQLStorageAdapter",
database_uri="sqlite:///database.sqlite3",
logic_adapters=[
{
"import_path": "chatterbot.logic.BestMatch",
"default_response": "I'm sorry, I'm not sure",
"maximum_similarity_threshold": 0.80,
}
],
)
trainer = ListTrainer(chatbot)
trainer.train(training_data)
print("Welcome to PyGoatBot! Type 'q' or 'exit' to quit.")
while True:
try:
user_input = input("You: ")
if user_input.lower() == "exit" or user_input.lower() == "q":
break
print("Available questions:")
for i, question in enumerate(training_data[::2], start=1):
print(f"{i}. {question}")
while True:
try:
question_index = int(input("Enter a number to select a question: "))
break
except ValueError:
print("Please enter a valid number.")
question = training_data[(question_index - 1) * 2]
response = chatbot.get_response(question)
print(f"PyGoatBot: {response}")
except (KeyboardInterrupt, EOFError):
break