mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-07-06 11:27:52 +02:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from backend.models.scan import Scan
|
||||
from backend.models.target import Target
|
||||
from backend.models.prompt import Prompt
|
||||
from backend.models.endpoint import Endpoint
|
||||
from backend.models.vulnerability import Vulnerability, VulnerabilityTest
|
||||
from backend.models.report import Report
|
||||
|
||||
__all__ = [
|
||||
"Scan",
|
||||
"Target",
|
||||
"Prompt",
|
||||
"Endpoint",
|
||||
"Vulnerability",
|
||||
"VulnerabilityTest",
|
||||
"Report"
|
||||
]
|
||||
@@ -0,0 +1,61 @@
|
||||
"""
|
||||
NeuroSploit v3 - Endpoint Model
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from sqlalchemy import String, Integer, DateTime, Text, JSON, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from backend.db.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class Endpoint(Base):
|
||||
"""Discovered endpoint model"""
|
||||
__tablename__ = "endpoints"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
scan_id: Mapped[str] = mapped_column(String(36), ForeignKey("scans.id", ondelete="CASCADE"))
|
||||
target_id: Mapped[Optional[str]] = mapped_column(String(36), ForeignKey("targets.id", ondelete="SET NULL"), nullable=True)
|
||||
|
||||
# Endpoint details
|
||||
url: Mapped[str] = mapped_column(Text)
|
||||
method: Mapped[str] = mapped_column(String(10), default="GET")
|
||||
path: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Parameters
|
||||
parameters: Mapped[List] = mapped_column(JSON, default=list) # [{name, type, value}]
|
||||
headers: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
|
||||
# Response info
|
||||
response_status: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
||||
content_type: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
content_length: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
||||
|
||||
# Detection
|
||||
technologies: Mapped[List] = mapped_column(JSON, default=list)
|
||||
interesting: Mapped[bool] = mapped_column(default=False) # Marked as interesting for testing
|
||||
|
||||
# Timestamps
|
||||
discovered_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Relationships
|
||||
scan: Mapped["Scan"] = relationship("Scan", back_populates="endpoints")
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"scan_id": self.scan_id,
|
||||
"target_id": self.target_id,
|
||||
"url": self.url,
|
||||
"method": self.method,
|
||||
"path": self.path,
|
||||
"parameters": self.parameters,
|
||||
"headers": self.headers,
|
||||
"response_status": self.response_status,
|
||||
"content_type": self.content_type,
|
||||
"content_length": self.content_length,
|
||||
"technologies": self.technologies,
|
||||
"interesting": self.interesting,
|
||||
"discovered_at": self.discovered_at.isoformat() if self.discovered_at else None
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
"""
|
||||
NeuroSploit v3 - Prompt Model
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from sqlalchemy import String, Boolean, DateTime, Text, JSON
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from backend.db.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class Prompt(Base):
|
||||
"""Prompt model for storing custom and preset prompts"""
|
||||
__tablename__ = "prompts"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
name: Mapped[str] = mapped_column(String(255))
|
||||
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
content: Mapped[str] = mapped_column(Text)
|
||||
|
||||
# Categorization
|
||||
is_preset: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
category: Mapped[Optional[str]] = mapped_column(String(100), nullable=True) # pentest, bug_bounty, api, etc.
|
||||
|
||||
# Parsed vulnerabilities (extracted by AI)
|
||||
parsed_vulnerabilities: Mapped[List] = mapped_column(JSON, default=list)
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"description": self.description,
|
||||
"content": self.content,
|
||||
"is_preset": self.is_preset,
|
||||
"category": self.category,
|
||||
"parsed_vulnerabilities": self.parsed_vulnerabilities,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None,
|
||||
"updated_at": self.updated_at.isoformat() if self.updated_at else None
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
NeuroSploit v3 - Report Model
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from sqlalchemy import String, DateTime, Text, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from backend.db.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class Report(Base):
|
||||
"""Report model"""
|
||||
__tablename__ = "reports"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
scan_id: Mapped[str] = mapped_column(String(36), ForeignKey("scans.id", ondelete="CASCADE"))
|
||||
|
||||
# Report details
|
||||
title: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
format: Mapped[str] = mapped_column(String(20), default="html") # html, pdf, json
|
||||
file_path: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Content
|
||||
executive_summary: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Timestamps
|
||||
generated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Relationship
|
||||
scan: Mapped["Scan"] = relationship("Scan", back_populates="reports")
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"scan_id": self.scan_id,
|
||||
"title": self.title,
|
||||
"format": self.format,
|
||||
"file_path": self.file_path,
|
||||
"executive_summary": self.executive_summary,
|
||||
"generated_at": self.generated_at.isoformat() if self.generated_at else None
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
"""
|
||||
NeuroSploit v3 - Scan Model
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from sqlalchemy import String, Integer, Boolean, DateTime, Text, JSON
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from backend.db.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class Scan(Base):
|
||||
"""Scan model representing a penetration test scan"""
|
||||
__tablename__ = "scans"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
name: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
status: Mapped[str] = mapped_column(String(50), default="pending") # pending, running, completed, failed, stopped
|
||||
scan_type: Mapped[str] = mapped_column(String(50), default="full") # quick, full, custom
|
||||
recon_enabled: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
|
||||
# Progress tracking
|
||||
progress: Mapped[int] = mapped_column(Integer, default=0)
|
||||
current_phase: Mapped[Optional[str]] = mapped_column(String(50), nullable=True) # recon, testing, reporting
|
||||
|
||||
# Configuration
|
||||
config: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
|
||||
# Custom prompt (if any)
|
||||
custom_prompt: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
prompt_id: Mapped[Optional[str]] = mapped_column(String(36), nullable=True)
|
||||
|
||||
# Authentication for testing (IMPORTANT: Use responsibly with authorization)
|
||||
auth_type: Mapped[Optional[str]] = mapped_column(String(50), nullable=True) # none, cookie, header, basic, bearer
|
||||
auth_credentials: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True) # Stores auth data securely
|
||||
custom_headers: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True) # Additional HTTP headers
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
started_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
completed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
# Error handling
|
||||
error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Statistics (updated during scan)
|
||||
total_endpoints: Mapped[int] = mapped_column(Integer, default=0)
|
||||
total_vulnerabilities: Mapped[int] = mapped_column(Integer, default=0)
|
||||
critical_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
high_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
medium_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
low_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
info_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
# Relationships
|
||||
targets: Mapped[List["Target"]] = relationship("Target", back_populates="scan", cascade="all, delete-orphan")
|
||||
endpoints: Mapped[List["Endpoint"]] = relationship("Endpoint", back_populates="scan", cascade="all, delete-orphan")
|
||||
vulnerabilities: Mapped[List["Vulnerability"]] = relationship("Vulnerability", back_populates="scan", cascade="all, delete-orphan")
|
||||
reports: Mapped[List["Report"]] = relationship("Report", back_populates="scan", cascade="all, delete-orphan")
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"status": self.status,
|
||||
"scan_type": self.scan_type,
|
||||
"recon_enabled": self.recon_enabled,
|
||||
"progress": self.progress,
|
||||
"current_phase": self.current_phase,
|
||||
"config": self.config,
|
||||
"custom_prompt": self.custom_prompt,
|
||||
"prompt_id": self.prompt_id,
|
||||
"auth_type": self.auth_type,
|
||||
"auth_credentials": self.auth_credentials, # Careful: may contain sensitive data
|
||||
"custom_headers": self.custom_headers,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None,
|
||||
"started_at": self.started_at.isoformat() if self.started_at else None,
|
||||
"completed_at": self.completed_at.isoformat() if self.completed_at else None,
|
||||
"error_message": self.error_message,
|
||||
"total_endpoints": self.total_endpoints,
|
||||
"total_vulnerabilities": self.total_vulnerabilities,
|
||||
"critical_count": self.critical_count,
|
||||
"high_count": self.high_count,
|
||||
"medium_count": self.medium_count,
|
||||
"low_count": self.low_count,
|
||||
"info_count": self.info_count
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
NeuroSploit v3 - Target Model
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from sqlalchemy import String, Integer, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from backend.db.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class Target(Base):
|
||||
"""Target URL model"""
|
||||
__tablename__ = "targets"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
scan_id: Mapped[str] = mapped_column(String(36), ForeignKey("scans.id", ondelete="CASCADE"))
|
||||
|
||||
# URL details
|
||||
url: Mapped[str] = mapped_column(String(2048))
|
||||
hostname: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
port: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
||||
protocol: Mapped[Optional[str]] = mapped_column(String(10), nullable=True)
|
||||
path: Mapped[Optional[str]] = mapped_column(String(2048), nullable=True)
|
||||
|
||||
# Status
|
||||
status: Mapped[str] = mapped_column(String(50), default="pending") # pending, scanning, completed, failed
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Relationship
|
||||
scan: Mapped["Scan"] = relationship("Scan", back_populates="targets")
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"scan_id": self.scan_id,
|
||||
"url": self.url,
|
||||
"hostname": self.hostname,
|
||||
"port": self.port,
|
||||
"protocol": self.protocol,
|
||||
"path": self.path,
|
||||
"status": self.status,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
"""
|
||||
NeuroSploit v3 - Vulnerability Models
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from sqlalchemy import String, Integer, Float, Boolean, DateTime, Text, JSON, ForeignKey
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from backend.db.database import Base
|
||||
import uuid
|
||||
|
||||
|
||||
class VulnerabilityTest(Base):
|
||||
"""Individual vulnerability test record"""
|
||||
__tablename__ = "vulnerability_tests"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
scan_id: Mapped[str] = mapped_column(String(36), ForeignKey("scans.id", ondelete="CASCADE"))
|
||||
endpoint_id: Mapped[Optional[str]] = mapped_column(String(36), ForeignKey("endpoints.id", ondelete="SET NULL"), nullable=True)
|
||||
|
||||
# Test details
|
||||
vulnerability_type: Mapped[str] = mapped_column(String(100)) # xss_reflected, sqli_union, etc.
|
||||
payload: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Request/Response
|
||||
request_data: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
response_data: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
|
||||
# Result
|
||||
is_vulnerable: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
confidence: Mapped[Optional[float]] = mapped_column(Float, nullable=True) # 0.0 to 1.0
|
||||
evidence: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Timestamps
|
||||
tested_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"scan_id": self.scan_id,
|
||||
"endpoint_id": self.endpoint_id,
|
||||
"vulnerability_type": self.vulnerability_type,
|
||||
"payload": self.payload,
|
||||
"request_data": self.request_data,
|
||||
"response_data": self.response_data,
|
||||
"is_vulnerable": self.is_vulnerable,
|
||||
"confidence": self.confidence,
|
||||
"evidence": self.evidence,
|
||||
"tested_at": self.tested_at.isoformat() if self.tested_at else None
|
||||
}
|
||||
|
||||
|
||||
class Vulnerability(Base):
|
||||
"""Confirmed vulnerability model"""
|
||||
__tablename__ = "vulnerabilities"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
scan_id: Mapped[str] = mapped_column(String(36), ForeignKey("scans.id", ondelete="CASCADE"))
|
||||
test_id: Mapped[Optional[str]] = mapped_column(String(36), ForeignKey("vulnerability_tests.id", ondelete="SET NULL"), nullable=True)
|
||||
|
||||
# Vulnerability details
|
||||
title: Mapped[str] = mapped_column(String(500))
|
||||
vulnerability_type: Mapped[str] = mapped_column(String(100))
|
||||
severity: Mapped[str] = mapped_column(String(20)) # critical, high, medium, low, info
|
||||
|
||||
# Scoring
|
||||
cvss_score: Mapped[Optional[float]] = mapped_column(Float, nullable=True)
|
||||
cvss_vector: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
cwe_id: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
||||
|
||||
# Details
|
||||
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
affected_endpoint: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Proof of Concept
|
||||
poc_request: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
poc_response: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
poc_payload: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
poc_parameter: Mapped[Optional[str]] = mapped_column(String(500), nullable=True) # Vulnerable parameter
|
||||
poc_evidence: Mapped[Optional[str]] = mapped_column(Text, nullable=True) # Evidence of vulnerability
|
||||
|
||||
# Remediation
|
||||
impact: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
remediation: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
references: Mapped[List] = mapped_column(JSON, default=list)
|
||||
|
||||
# AI Analysis
|
||||
ai_analysis: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Relationships
|
||||
scan: Mapped["Scan"] = relationship("Scan", back_populates="vulnerabilities")
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
"id": self.id,
|
||||
"scan_id": self.scan_id,
|
||||
"test_id": self.test_id,
|
||||
"title": self.title,
|
||||
"vulnerability_type": self.vulnerability_type,
|
||||
"severity": self.severity,
|
||||
"cvss_score": self.cvss_score,
|
||||
"cvss_vector": self.cvss_vector,
|
||||
"cwe_id": self.cwe_id,
|
||||
"description": self.description,
|
||||
"affected_endpoint": self.affected_endpoint,
|
||||
"poc_request": self.poc_request,
|
||||
"poc_response": self.poc_response,
|
||||
"poc_payload": self.poc_payload,
|
||||
"poc_parameter": self.poc_parameter,
|
||||
"poc_evidence": self.poc_evidence,
|
||||
"impact": self.impact,
|
||||
"remediation": self.remediation,
|
||||
"references": self.references,
|
||||
"ai_analysis": self.ai_analysis,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
Reference in New Issue
Block a user