KrishnaKarle/Vulnerability-CVE-Scanner

GitHub: KrishnaKarle/Vulnerability-CVE-Scanner

基于Python的轻量级CVE漏洞扫描器,通过端口探测和服务Banner抓取结合NVD数据库查询已知漏洞。

Stars: 0 | Forks: 0

# 漏洞-CVE-扫描器 import socket import requests # 常用扫描端口 COMMON_PORTS = { 21: "FTP", 22: "SSH", 23: "TELNET", 25: "SMTP", 53: "DNS", 80: "HTTP", 110: "POP3", 139: "NETBIOS", 143: "IMAP", 443: "HTTPS", 3306: "MySQL", 8080: "HTTP-ALT" } # -------- Banner 抓取 -------- def get_banner(ip, port): try: s = socket.socket() s.settimeout(2) s.connect((ip, port)) ``` # HTTP services require request if port == 80 or port == 8080: s.send(b"GET / HTTP/1.1\r\nHost: test\r\n\r\n") banner = s.recv(1024).decode(errors="ignore").strip() s.close() return banner except: return None ``` # -------- 端口扫描器 -------- def scan_ports(ip): open_ports = [] ``` print("\nScanning target:", ip) print("--------------------------------") for port in COMMON_PORTS: try: s = socket.socket() s.settimeout(1) result = s.connect_ex((ip, port)) if result == 0: service = COMMON_PORTS[port] banner = get_banner(ip, port) print(f"[OPEN] Port {port} ({service})") if banner: print("Banner:", banner) open_ports.append((port, service, banner)) s.close() except: pass return open_ports ``` # -------- CVE 查询 -------- def search_cve(keyword): ``` print("\nSearching CVEs for:", keyword) url = f"https://services.nvd.nist.gov/rest/json/cves/2.0?keywordSearch={keyword}&resultsPerPage=3" try: r = requests.get(url) data = r.json() if "vulnerabilities" in data: for vuln in data["vulnerabilities"]: cve = vuln["cve"]["id"] description = vuln["cve"]["descriptions"][0]["value"] print("\nCVE:", cve) print("Description:", description[:200], "...") else: print("No CVE found") except: print("Error fetching CVE data") ``` # -------- 报告生成器 -------- def generate_report(ip, results): ``` print("\n\n======= SCAN REPORT =======") print("Target:", ip) print("---------------------------") for port, service, banner in results: print(f"\nPort: {port}") print("Service:", service) if banner: print("Banner:", banner) keyword = banner.split()[0] search_cve(keyword) ``` # -------- 主程序 -------- def main(): ``` target = input("Enter target IP or domain: ") try: ip = socket.gethostbyname(target) except: print("Invalid target") return results = scan_ports(ip) generate_report(ip, results) ``` if __name__ == "__main__": main()
标签:Banner Grabbing, C2日志可视化, DNS枚举, NVD数据库, Python安全开发, 加密, 套接字编程, 子域名枚举, 安全合规, 实时处理, 密码管理, 对称加密, 指纹识别, 插件系统, 数据统计, 无线安全, 服务器安全, 漏洞扫描器, 端口扫描, 系统安全, 网络代理, 网络安全工具, 自动化审计, 逆向工具