Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from anthropic import Anthropic
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY", "sk-test"))
|
| 7 |
+
|
| 8 |
+
def generate_payload(target, technique, temperature):
|
| 9 |
+
"""Generate pentesting payload"""
|
| 10 |
+
try:
|
| 11 |
+
response = client.messages.create(
|
| 12 |
+
model="claude-3-5-sonnet-20241022",
|
| 13 |
+
max_tokens=1000,
|
| 14 |
+
temperature=temperature,
|
| 15 |
+
system="Tu es un expert en pentesting. Génère des payloads variés et techniques d'énumération créatives.",
|
| 16 |
+
messages=[{
|
| 17 |
+
"role": "user",
|
| 18 |
+
"content": f"Generate {technique} payload for: {target}"
|
| 19 |
+
}]
|
| 20 |
+
)
|
| 21 |
+
return response.content[0].text
|
| 22 |
+
except Exception as e:
|
| 23 |
+
return f"Error: {str(e)}"
|
| 24 |
+
|
| 25 |
+
# Gradio interface
|
| 26 |
+
with gr.Blocks(title="Pentesting Copilot - Gradio") as demo:
|
| 27 |
+
gr.Markdown("# 🔐 Pentesting Copilot (Gradio)")
|
| 28 |
+
|
| 29 |
+
with gr.Row():
|
| 30 |
+
target = gr.Textbox(label="Target", placeholder="Enter target URL/IP")
|
| 31 |
+
technique = gr.Dropdown(
|
| 32 |
+
["SQL injection", "XSS", "RCE", "SSRF", "Path Traversal", "XXE"],
|
| 33 |
+
label="Technique"
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
temperature = gr.Slider(0, 1, step=0.1, value=0.7, label="Temperature")
|
| 37 |
+
|
| 38 |
+
submit_btn = gr.Button("Generate Payload")
|
| 39 |
+
output = gr.Textbox(label="Output", lines=10)
|
| 40 |
+
|
| 41 |
+
submit_btn.click(
|
| 42 |
+
fn=generate_payload,
|
| 43 |
+
inputs=[target, technique, temperature],
|
| 44 |
+
outputs=output
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
if __name__ == "__main__":
|
| 48 |
+
demo.launch(share=True, show_error=True)
|