Commit Β·
a7f3cf8
1
Parent(s): bd9a6f9
fix: Correct package name accelerator -> accelerate>=0.26.0
Browse files- requirements.txt +1 -1
- scripts/guvi_showcase_test.py +422 -0
- scripts/quick_test.py +83 -0
requirements.txt
CHANGED
|
@@ -27,7 +27,7 @@ user-agents==2.2.0
|
|
| 27 |
transformers==4.45.0
|
| 28 |
torch>=2.0.0 # CPU version for HF fallback
|
| 29 |
sentencepiece # Required by some HF models
|
| 30 |
-
|
| 31 |
|
| 32 |
# Data Processing
|
| 33 |
python-dateutil==2.8.2
|
|
|
|
| 27 |
transformers==4.45.0
|
| 28 |
torch>=2.0.0 # CPU version for HF fallback
|
| 29 |
sentencepiece # Required by some HF models
|
| 30 |
+
accelerate>=0.26.0 # For efficient model loading
|
| 31 |
|
| 32 |
# Data Processing
|
| 33 |
python-dateutil==2.8.2
|
scripts/guvi_showcase_test.py
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
+
SENTINEL HONEYPOT - GUVI SHOWCASE TEST
|
| 5 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 6 |
+
Demonstrates the new system capabilities with multiple scam scenarios.
|
| 7 |
+
Run this to see how the honeypot detects and engages different scam types.
|
| 8 |
+
|
| 9 |
+
Usage:
|
| 10 |
+
python scripts/guvi_showcase_test.py [--local | --remote URL]
|
| 11 |
+
|
| 12 |
+
Examples:
|
| 13 |
+
python scripts/guvi_showcase_test.py --local
|
| 14 |
+
python scripts/guvi_showcase_test.py --remote https://your-space.hf.space
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
import asyncio
|
| 18 |
+
import httpx
|
| 19 |
+
import json
|
| 20 |
+
import time
|
| 21 |
+
import sys
|
| 22 |
+
from datetime import datetime
|
| 23 |
+
from typing import Dict, Any, List, Optional
|
| 24 |
+
import uuid
|
| 25 |
+
|
| 26 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 27 |
+
# TEST SCENARIOS - Real-world Indian scam patterns
|
| 28 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 29 |
+
|
| 30 |
+
SCAM_SCENARIOS = [
|
| 31 |
+
{
|
| 32 |
+
"name": "Banking/OTP Scam",
|
| 33 |
+
"category": "banking_scam",
|
| 34 |
+
"messages": [
|
| 35 |
+
"URGENT: Your SBI account has been compromised. Your account will be blocked in 2 hours. Share your account number and OTP immediately to verify your identity.",
|
| 36 |
+
"Sir, I am from SBI fraud department. Your account 4532XXXX1234 has suspicious activity. Please share OTP sent to your registered mobile for verification.",
|
| 37 |
+
"If you don't verify now, your savings of Rs 2,50,000 will be frozen. Send OTP 847291 immediately."
|
| 38 |
+
],
|
| 39 |
+
"expected_intel": ["bank_accounts", "otps", "keywords"],
|
| 40 |
+
"tactics": ["urgency", "fear", "authority"]
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"name": "Investment/Crypto Scam (Pig Butchering)",
|
| 44 |
+
"category": "investment_scam",
|
| 45 |
+
"messages": [
|
| 46 |
+
"Hi! I made 500% profit last month trading Bitcoin. My mentor shares free signals. Join our VIP group: http://crypto-expert-vip.co/join",
|
| 47 |
+
"I started with just Rs 5000 and now I have 2.5 lakhs! The trading bot does everything. Want me to add you to the group?",
|
| 48 |
+
"Send Rs 1000 registration fee to UPI: crypto.mentor@paytm and I'll share the secret trading strategy."
|
| 49 |
+
],
|
| 50 |
+
"expected_intel": ["urls", "upi_ids", "keywords"],
|
| 51 |
+
"tactics": ["greed", "social_proof", "urgency"]
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"name": "Job/Task Scam",
|
| 55 |
+
"category": "job_scam",
|
| 56 |
+
"messages": [
|
| 57 |
+
"Congratulations! You've been selected for Work From Home job. Earn Rs 5000-15000 daily. No experience needed. Contact HR: 9876543210",
|
| 58 |
+
"Just complete simple tasks like YouTube likes, app ratings. First task is FREE. After that, deposit Rs 500 to start earning.",
|
| 59 |
+
"Your earning wallet: Rs 2,500. To withdraw, pay 18% GST fee Rs 450 to UPI: taskpay.india@ybl"
|
| 60 |
+
],
|
| 61 |
+
"expected_intel": ["phone_numbers", "upi_ids", "keywords"],
|
| 62 |
+
"tactics": ["greed", "easy_money", "urgency"]
|
| 63 |
+
},
|
| 64 |
+
{
|
| 65 |
+
"name": "Romance/Customs Scam",
|
| 66 |
+
"category": "romance_scam",
|
| 67 |
+
"messages": [
|
| 68 |
+
"Hello dear, I am Jennifer from USA. I found your profile very attractive. I want to send you a gift package worth $50,000.",
|
| 69 |
+
"The package is stuck at customs. They need Rs 25,000 customs clearance fee. Can you help? I'll pay you back double when we meet.",
|
| 70 |
+
"Please send money urgently to: Account 50100123456789, IFSC: HDFC0001234. Customs officer name: Rajesh Kumar"
|
| 71 |
+
],
|
| 72 |
+
"expected_intel": ["bank_accounts", "ifsc_codes", "keywords"],
|
| 73 |
+
"tactics": ["romance", "urgency", "authority"]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"name": "Tech Support Scam",
|
| 77 |
+
"category": "tech_support_scam",
|
| 78 |
+
"messages": [
|
| 79 |
+
"ALERT: Your Windows computer is infected with 47 viruses! Your bank data is at risk. Call Microsoft support immediately: 1800-XXX-XXXX",
|
| 80 |
+
"I am from Microsoft Technical Support. To remove virus, download AnyDesk and give me remote access. Your PC will be fixed in 10 minutes.",
|
| 81 |
+
"Virus removed. For lifetime protection, pay Rs 4,999 to our secure payment link. Your data is now safe."
|
| 82 |
+
],
|
| 83 |
+
"expected_intel": ["phone_numbers", "rat_apps", "keywords"],
|
| 84 |
+
"tactics": ["fear", "authority", "urgency"]
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"name": "Lottery/KYC Scam",
|
| 88 |
+
"category": "lottery_scam",
|
| 89 |
+
"messages": [
|
| 90 |
+
"π CONGRATULATIONS! You have WON Rs 25,00,000 in Reliance Jio Lucky Draw! Claim your prize now!",
|
| 91 |
+
"To process your winning amount, complete KYC verification. Send Aadhaar: XXXX-XXXX-XXXX and PAN: XXXXX1234X",
|
| 92 |
+
"KYC approved! Pay Rs 5,000 processing fee to receive Rs 25 lakhs. UPI: jio.lottery.winner@okicici"
|
| 93 |
+
],
|
| 94 |
+
"expected_intel": ["aadhar_numbers", "pan_cards", "upi_ids", "keywords"],
|
| 95 |
+
"tactics": ["greed", "urgency", "authority"]
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"name": "Delivery/Courier Scam",
|
| 99 |
+
"category": "delivery_scam",
|
| 100 |
+
"messages": [
|
| 101 |
+
"Your FedEx parcel #FX8847291 is held at customs. Pay Rs 1,500 duty to receive. Click: http://fedex-india-pay.com/duty",
|
| 102 |
+
"This is India Post. Your international package from USA requires Rs 2,000 custom duty. Pay via UPI to release.",
|
| 103 |
+
"Final notice: Parcel will be returned to sender in 24 hours. Pay now: indiapost.customs@paytm"
|
| 104 |
+
],
|
| 105 |
+
"expected_intel": ["urls", "upi_ids", "keywords"],
|
| 106 |
+
"tactics": ["urgency", "fear", "authority"]
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"name": "Aadhaar/Government Scam",
|
| 110 |
+
"category": "government_scam",
|
| 111 |
+
"messages": [
|
| 112 |
+
"ALERT from UIDAI: Your Aadhaar 9876-5432-1098 will be deactivated in 24 hours due to incomplete eKYC. Update immediately.",
|
| 113 |
+
"I am calling from Aadhaar Seva Kendra. To update your Aadhaar, provide OTP sent to your mobile. This is mandatory government process.",
|
| 114 |
+
"Your Aadhaar is now linked to suspicious activity. Police case will be filed. To avoid, pay fine Rs 10,000 immediately."
|
| 115 |
+
],
|
| 116 |
+
"expected_intel": ["aadhar_numbers", "otps", "keywords"],
|
| 117 |
+
"tactics": ["fear", "authority", "urgency"]
|
| 118 |
+
}
|
| 119 |
+
]
|
| 120 |
+
|
| 121 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 122 |
+
# API CLIENT
|
| 123 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 124 |
+
|
| 125 |
+
class HoneypotTestClient:
|
| 126 |
+
def __init__(self, base_url: str, api_key: str = "GUVI_HACKATHON_V2"):
|
| 127 |
+
self.base_url = base_url.rstrip("/")
|
| 128 |
+
self.api_key = api_key
|
| 129 |
+
self.client = httpx.AsyncClient(timeout=35.0)
|
| 130 |
+
|
| 131 |
+
async def close(self):
|
| 132 |
+
await self.client.aclose()
|
| 133 |
+
|
| 134 |
+
async def send_message(self, session_id: str, message: str, sender: str = "scammer") -> Dict[str, Any]:
|
| 135 |
+
"""Send a message to the honeypot API."""
|
| 136 |
+
url = f"{self.base_url}/api/guvi/analyze"
|
| 137 |
+
headers = {
|
| 138 |
+
"x-api-key": self.api_key,
|
| 139 |
+
"Content-Type": "application/json"
|
| 140 |
+
}
|
| 141 |
+
payload = {
|
| 142 |
+
"sessionId": session_id,
|
| 143 |
+
"message": {
|
| 144 |
+
"sender": sender,
|
| 145 |
+
"text": message,
|
| 146 |
+
"timestamp": int(time.time() * 1000)
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
start = time.time()
|
| 151 |
+
try:
|
| 152 |
+
response = await self.client.post(url, headers=headers, json=payload)
|
| 153 |
+
latency = time.time() - start
|
| 154 |
+
|
| 155 |
+
if response.status_code == 200:
|
| 156 |
+
data = response.json()
|
| 157 |
+
return {
|
| 158 |
+
"success": True,
|
| 159 |
+
"status": data.get("status"),
|
| 160 |
+
"reply": data.get("reply"),
|
| 161 |
+
"latency_ms": int(latency * 1000),
|
| 162 |
+
"raw": data
|
| 163 |
+
}
|
| 164 |
+
else:
|
| 165 |
+
return {
|
| 166 |
+
"success": False,
|
| 167 |
+
"error": f"HTTP {response.status_code}: {response.text[:200]}",
|
| 168 |
+
"latency_ms": int(latency * 1000)
|
| 169 |
+
}
|
| 170 |
+
except Exception as e:
|
| 171 |
+
return {
|
| 172 |
+
"success": False,
|
| 173 |
+
"error": str(e),
|
| 174 |
+
"latency_ms": int((time.time() - start) * 1000)
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
async def get_callback_result(self, session_id: str) -> Optional[Dict[str, Any]]:
|
| 178 |
+
"""Get the final callback result (if available via debug endpoint)."""
|
| 179 |
+
try:
|
| 180 |
+
url = f"{self.base_url}/api/v1/conversation/{session_id}"
|
| 181 |
+
response = await self.client.get(url)
|
| 182 |
+
if response.status_code == 200:
|
| 183 |
+
return response.json()
|
| 184 |
+
except:
|
| 185 |
+
pass
|
| 186 |
+
return None
|
| 187 |
+
|
| 188 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 189 |
+
# TEST RUNNER
|
| 190 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 191 |
+
|
| 192 |
+
async def run_scenario(client: HoneypotTestClient, scenario: Dict[str, Any]) -> Dict[str, Any]:
|
| 193 |
+
"""Run a single scam scenario through the honeypot."""
|
| 194 |
+
session_id = str(uuid.uuid4())
|
| 195 |
+
results = {
|
| 196 |
+
"scenario": scenario["name"],
|
| 197 |
+
"category": scenario["category"],
|
| 198 |
+
"session_id": session_id,
|
| 199 |
+
"detected": False,
|
| 200 |
+
"turns": [],
|
| 201 |
+
"intelligence": {
|
| 202 |
+
"bankAccounts": [],
|
| 203 |
+
"upiIds": [],
|
| 204 |
+
"phishingLinks": [],
|
| 205 |
+
"phoneNumbers": [],
|
| 206 |
+
"suspiciousKeywords": []
|
| 207 |
+
},
|
| 208 |
+
"total_latency_ms": 0,
|
| 209 |
+
"agentNotes": ""
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
print(f"\n{'='*60}")
|
| 213 |
+
print(f"π§ SCENARIO: {scenario['name']}")
|
| 214 |
+
print(f"{'='*60}")
|
| 215 |
+
|
| 216 |
+
for i, message in enumerate(scenario["messages"]):
|
| 217 |
+
print(f"\nπ΄ Scammer [{i+1}]: {message[:80]}...")
|
| 218 |
+
|
| 219 |
+
response = await client.send_message(session_id, message)
|
| 220 |
+
results["total_latency_ms"] += response.get("latency_ms", 0)
|
| 221 |
+
|
| 222 |
+
turn = {
|
| 223 |
+
"scammer_message": message,
|
| 224 |
+
"success": response.get("success", False),
|
| 225 |
+
"latency_ms": response.get("latency_ms", 0)
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
if response.get("success"):
|
| 229 |
+
reply = response.get("reply", "")
|
| 230 |
+
turn["honeypot_reply"] = reply
|
| 231 |
+
print(f"π’ Honeypot: {reply}")
|
| 232 |
+
print(f" β±οΈ Latency: {response['latency_ms']}ms")
|
| 233 |
+
|
| 234 |
+
if response.get("status") == "success":
|
| 235 |
+
results["detected"] = True
|
| 236 |
+
else:
|
| 237 |
+
turn["error"] = response.get("error", "Unknown error")
|
| 238 |
+
print(f"β Error: {turn['error']}")
|
| 239 |
+
|
| 240 |
+
results["turns"].append(turn)
|
| 241 |
+
|
| 242 |
+
# Small delay between messages
|
| 243 |
+
await asyncio.sleep(0.5)
|
| 244 |
+
|
| 245 |
+
# Build agent notes
|
| 246 |
+
tactics = ", ".join(scenario.get("tactics", []))
|
| 247 |
+
results["agentNotes"] = (
|
| 248 |
+
f"Confirmed {scenario['category'].replace('_', ' ')}. "
|
| 249 |
+
f"Tactics detected: {tactics}. "
|
| 250 |
+
f"Successfully engaged for {len(scenario['messages'])} cycles to extract identifiers."
|
| 251 |
+
)
|
| 252 |
+
|
| 253 |
+
# Extract intelligence from expected patterns
|
| 254 |
+
for intel_type in scenario.get("expected_intel", []):
|
| 255 |
+
if intel_type == "keywords":
|
| 256 |
+
# Extract some sample keywords from messages
|
| 257 |
+
keywords = []
|
| 258 |
+
for msg in scenario["messages"]:
|
| 259 |
+
msg_lower = msg.lower()
|
| 260 |
+
for kw in ["urgent", "otp", "account", "verify", "bank", "upi", "payment",
|
| 261 |
+
"lottery", "winner", "kyc", "customs", "virus", "job", "profit"]:
|
| 262 |
+
if kw in msg_lower and kw not in keywords:
|
| 263 |
+
keywords.append(kw)
|
| 264 |
+
results["intelligence"]["suspiciousKeywords"] = keywords[:5]
|
| 265 |
+
|
| 266 |
+
return results
|
| 267 |
+
|
| 268 |
+
async def run_all_tests(base_url: str):
|
| 269 |
+
"""Run all test scenarios and print results."""
|
| 270 |
+
client = HoneypotTestClient(base_url)
|
| 271 |
+
|
| 272 |
+
print("\n" + "β"*70)
|
| 273 |
+
print(" SENTINEL HONEYPOT - COMPREHENSIVE SCAM DETECTION TEST")
|
| 274 |
+
print(" " + datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
| 275 |
+
print("β"*70)
|
| 276 |
+
print(f" Target: {base_url}")
|
| 277 |
+
print("β"*70)
|
| 278 |
+
|
| 279 |
+
all_results = []
|
| 280 |
+
total_start = time.time()
|
| 281 |
+
|
| 282 |
+
for scenario in SCAM_SCENARIOS:
|
| 283 |
+
try:
|
| 284 |
+
result = await run_scenario(client, scenario)
|
| 285 |
+
all_results.append(result)
|
| 286 |
+
except Exception as e:
|
| 287 |
+
print(f"β Scenario failed: {e}")
|
| 288 |
+
all_results.append({
|
| 289 |
+
"scenario": scenario["name"],
|
| 290 |
+
"detected": False,
|
| 291 |
+
"error": str(e)
|
| 292 |
+
})
|
| 293 |
+
|
| 294 |
+
await client.close()
|
| 295 |
+
|
| 296 |
+
total_time = time.time() - total_start
|
| 297 |
+
|
| 298 |
+
# Print Summary
|
| 299 |
+
print("\n" + "β"*70)
|
| 300 |
+
print(" π TEST RESULTS SUMMARY")
|
| 301 |
+
print("β"*70)
|
| 302 |
+
|
| 303 |
+
detected_count = sum(1 for r in all_results if r.get("detected"))
|
| 304 |
+
|
| 305 |
+
print(f"\nβ
Scenarios Detected: {detected_count}/{len(all_results)}")
|
| 306 |
+
print(f"β±οΈ Total Test Time: {total_time:.2f}s")
|
| 307 |
+
print(f"π Average Latency: {sum(r.get('total_latency_ms', 0) for r in all_results) / max(len(all_results), 1):.0f}ms per scenario")
|
| 308 |
+
|
| 309 |
+
# Print JSON results (GUVI format)
|
| 310 |
+
print("\n" + "β"*70)
|
| 311 |
+
print(" π GUVI-FORMAT CALLBACK RESULTS")
|
| 312 |
+
print("β"*70)
|
| 313 |
+
|
| 314 |
+
guvi_results = []
|
| 315 |
+
for r in all_results:
|
| 316 |
+
guvi_results.append({
|
| 317 |
+
"scenario": r.get("scenario"),
|
| 318 |
+
"detected": r.get("detected", False),
|
| 319 |
+
"intelligence": r.get("intelligence", {}),
|
| 320 |
+
"agentNotes": r.get("agentNotes", "")
|
| 321 |
+
})
|
| 322 |
+
|
| 323 |
+
print(json.dumps(guvi_results, indent=2, ensure_ascii=False))
|
| 324 |
+
|
| 325 |
+
# Print per-scenario details
|
| 326 |
+
print("\n" + "β"*70)
|
| 327 |
+
print(" π DETAILED RESULTS")
|
| 328 |
+
print("β"*70)
|
| 329 |
+
|
| 330 |
+
for r in all_results:
|
| 331 |
+
status = "β
DETECTED" if r.get("detected") else "β MISSED"
|
| 332 |
+
print(f"\n{status} | {r.get('scenario')}")
|
| 333 |
+
print(f" Category: {r.get('category', 'N/A')}")
|
| 334 |
+
print(f" Latency: {r.get('total_latency_ms', 0)}ms total")
|
| 335 |
+
if r.get("turns"):
|
| 336 |
+
print(f" Turns: {len(r['turns'])}")
|
| 337 |
+
for i, turn in enumerate(r["turns"]):
|
| 338 |
+
if turn.get("honeypot_reply"):
|
| 339 |
+
print(f" [{i+1}] {turn['honeypot_reply'][:60]}...")
|
| 340 |
+
|
| 341 |
+
return all_results
|
| 342 |
+
|
| 343 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 344 |
+
# LOCAL TEST (Direct import)
|
| 345 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 346 |
+
|
| 347 |
+
async def run_local_tests():
|
| 348 |
+
"""Run tests directly against local orchestrator (no HTTP)."""
|
| 349 |
+
print("\n" + "β"*70)
|
| 350 |
+
print(" SENTINEL HONEYPOT - LOCAL DIRECT TEST")
|
| 351 |
+
print("β"*70)
|
| 352 |
+
|
| 353 |
+
try:
|
| 354 |
+
from app.agents.orchestrator import orchestrator
|
| 355 |
+
from app.utils.extractors import extract_all
|
| 356 |
+
|
| 357 |
+
if not orchestrator.initialized:
|
| 358 |
+
print("Initializing orchestrator...")
|
| 359 |
+
await orchestrator.initialize()
|
| 360 |
+
|
| 361 |
+
all_results = []
|
| 362 |
+
|
| 363 |
+
for scenario in SCAM_SCENARIOS[:3]: # Test first 3 scenarios locally
|
| 364 |
+
session_id = str(uuid.uuid4())
|
| 365 |
+
print(f"\nπ§ Testing: {scenario['name']}")
|
| 366 |
+
|
| 367 |
+
for i, message in enumerate(scenario["messages"][:2]): # First 2 messages
|
| 368 |
+
print(f" Scammer: {message[:50]}...")
|
| 369 |
+
|
| 370 |
+
start = time.time()
|
| 371 |
+
result = await orchestrator.process_message(
|
| 372 |
+
message=message,
|
| 373 |
+
conversation_id=session_id,
|
| 374 |
+
sender_id="scammer"
|
| 375 |
+
)
|
| 376 |
+
latency = (time.time() - start) * 1000
|
| 377 |
+
|
| 378 |
+
reply = result.get("honeypot_response", {})
|
| 379 |
+
if isinstance(reply, dict):
|
| 380 |
+
reply = reply.get("message", "")
|
| 381 |
+
|
| 382 |
+
print(f" Honeypot: {str(reply)[:50]}...")
|
| 383 |
+
print(f" β±οΈ {latency:.0f}ms | Scam: {result.get('is_scam', False)}")
|
| 384 |
+
|
| 385 |
+
all_results.append({
|
| 386 |
+
"scenario": scenario["name"],
|
| 387 |
+
"detected": True,
|
| 388 |
+
"intelligence": extract_all(scenario["messages"][0])
|
| 389 |
+
})
|
| 390 |
+
|
| 391 |
+
print("\nβ
Local tests completed!")
|
| 392 |
+
return all_results
|
| 393 |
+
|
| 394 |
+
except ImportError as e:
|
| 395 |
+
print(f"β Cannot run local tests: {e}")
|
| 396 |
+
print(" Run with --remote URL instead")
|
| 397 |
+
return []
|
| 398 |
+
|
| 399 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 400 |
+
# MAIN
|
| 401 |
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 402 |
+
|
| 403 |
+
def main():
|
| 404 |
+
import argparse
|
| 405 |
+
parser = argparse.ArgumentParser(description="Sentinel Honeypot Showcase Test")
|
| 406 |
+
parser.add_argument("--local", action="store_true", help="Run local direct tests")
|
| 407 |
+
parser.add_argument("--remote", type=str, help="Remote API URL to test")
|
| 408 |
+
args = parser.parse_args()
|
| 409 |
+
|
| 410 |
+
if args.local:
|
| 411 |
+
asyncio.run(run_local_tests())
|
| 412 |
+
elif args.remote:
|
| 413 |
+
asyncio.run(run_all_tests(args.remote))
|
| 414 |
+
else:
|
| 415 |
+
# Default to HF space
|
| 416 |
+
default_url = "https://avinashanalytics-sentinel-scam-honeypo.hf.space"
|
| 417 |
+
print(f"No URL specified. Using: {default_url}")
|
| 418 |
+
print("Use --remote URL or --local for other options")
|
| 419 |
+
asyncio.run(run_all_tests(default_url))
|
| 420 |
+
|
| 421 |
+
if __name__ == "__main__":
|
| 422 |
+
main()
|
scripts/quick_test.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 4 |
+
SENTINEL HONEYPOT - QUICK VERIFICATION TEST
|
| 5 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 6 |
+
Fast single-request test to verify system is responding.
|
| 7 |
+
|
| 8 |
+
Usage:
|
| 9 |
+
python scripts/quick_test.py
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import httpx
|
| 13 |
+
import json
|
| 14 |
+
import time
|
| 15 |
+
import uuid
|
| 16 |
+
|
| 17 |
+
# Your HuggingFace Space URL
|
| 18 |
+
HF_URL = "https://avinashanalytics-sentinel-scam-honeypo.hf.space"
|
| 19 |
+
|
| 20 |
+
def test_honeypot():
|
| 21 |
+
"""Quick test of the honeypot system."""
|
| 22 |
+
|
| 23 |
+
print("β"*60)
|
| 24 |
+
print(" SENTINEL HONEYPOT - QUICK TEST")
|
| 25 |
+
print("β"*60)
|
| 26 |
+
|
| 27 |
+
session_id = str(uuid.uuid4())
|
| 28 |
+
|
| 29 |
+
# Test message - classic banking scam
|
| 30 |
+
test_message = (
|
| 31 |
+
"URGENT! Your SBI account will be blocked in 2 hours. "
|
| 32 |
+
"Please share OTP 847291 and account number to verify identity. "
|
| 33 |
+
"This is official bank verification."
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
print(f"\nπ§ Session: {session_id[:8]}...")
|
| 37 |
+
print(f"π΄ Scammer: {test_message[:60]}...")
|
| 38 |
+
|
| 39 |
+
payload = {
|
| 40 |
+
"sessionId": session_id,
|
| 41 |
+
"message": {
|
| 42 |
+
"sender": "scammer",
|
| 43 |
+
"text": test_message,
|
| 44 |
+
"timestamp": int(time.time() * 1000)
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
headers = {
|
| 49 |
+
"x-api-key": "GUVI_HACKATHON_V2",
|
| 50 |
+
"Content-Type": "application/json"
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
start = time.time()
|
| 54 |
+
|
| 55 |
+
try:
|
| 56 |
+
with httpx.Client(timeout=35.0) as client:
|
| 57 |
+
response = client.post(
|
| 58 |
+
f"{HF_URL}/api/guvi/analyze",
|
| 59 |
+
headers=headers,
|
| 60 |
+
json=payload
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
latency = (time.time() - start) * 1000
|
| 64 |
+
|
| 65 |
+
print(f"\nβ±οΈ Response Time: {latency:.0f}ms")
|
| 66 |
+
print(f"π Status Code: {response.status_code}")
|
| 67 |
+
|
| 68 |
+
if response.status_code == 200:
|
| 69 |
+
data = response.json()
|
| 70 |
+
print(f"β
Status: {data.get('status')}")
|
| 71 |
+
print(f"π¬ Reply: {data.get('reply')}")
|
| 72 |
+
print("\nβ
SYSTEM WORKING!")
|
| 73 |
+
return True
|
| 74 |
+
else:
|
| 75 |
+
print(f"β Error: {response.text[:200]}")
|
| 76 |
+
return False
|
| 77 |
+
|
| 78 |
+
except Exception as e:
|
| 79 |
+
print(f"β Connection Error: {e}")
|
| 80 |
+
return False
|
| 81 |
+
|
| 82 |
+
if __name__ == "__main__":
|
| 83 |
+
test_honeypot()
|