Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: anmolksachan/ThreatTracer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: threattracer_v2
Choose a base ref
...
head repository: anmolksachan/ThreatTracer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Sep 11, 2023

  1. Update threattracer.py

    anmolksachan authored Sep 11, 2023
    Copy the full SHA
    d9d1269 View commit details
  2. Update requirements.txt

    anmolksachan authored Sep 11, 2023
    Copy the full SHA
    68f2e3e View commit details
  3. Update README.md

    anmolksachan authored Sep 11, 2023
    Copy the full SHA
    5f79859 View commit details
  4. Update requirements.txt

    anmolksachan authored Sep 11, 2023
    Copy the full SHA
    1b10f87 View commit details

Commits on Sep 13, 2023

  1. Update README.md

    anmolksachan authored Sep 13, 2023
    Copy the full SHA
    68ee961 View commit details
  2. Update README.md

    Public Exploit POC
    anmolksachan authored Sep 13, 2023
    Copy the full SHA
    0e7fc21 View commit details
  3. Update README.md

    anmolksachan authored Sep 13, 2023
    Copy the full SHA
    e2c8ed5 View commit details
  4. Update README.md

    anmolksachan authored Sep 13, 2023
    Copy the full SHA
    2117d1c View commit details
  5. Update README.md

    anmolksachan authored Sep 13, 2023
    Copy the full SHA
    c702ee7 View commit details

Commits on Sep 14, 2023

  1. Update threattracer.py

    The new release of the code optimizes the previous version by incorporating asynchronous HTTP requests using the aiohttp library.
    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    d3a7b14 View commit details
  2. Update requirements.txt

    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    569871b View commit details
  3. Update README.md

    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    ae027aa View commit details
  4. Update threattracer.py

    Update to avoid crashing.
    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    09c0deb View commit details
  5. Update README.md

    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    77a5c15 View commit details
  6. Update README.md

    Updated ThreatTracer_Exploit_Identifier_POC.mp4
    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    fc43ded View commit details
  7. Update threattracer.py

    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    cda4575 View commit details
  8. Update threattracer.py

    Banner Update.
    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    5790f2c View commit details
  9. Update README.md

    POC with audio.
    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    42ac414 View commit details
  10. Update README.md

    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    59e3512 View commit details
  11. Update README.md

    POC Vimeo
    anmolksachan authored Sep 14, 2023
    Copy the full SHA
    d55de73 View commit details

Commits on Sep 15, 2023

  1. Update threattracer.py

    Github Public Exploit Lookup Support added.
    anmolksachan authored Sep 15, 2023
    Copy the full SHA
    8b68b54 View commit details
  2. Update README.md

    Update GitHub reverse exploit/ POC lookup.
    anmolksachan authored Sep 15, 2023
    Copy the full SHA
    c03b3c9 View commit details
  3. Update threattracer.py

    Banner update
    anmolksachan authored Sep 15, 2023
    Copy the full SHA
    2a52ba7 View commit details

Commits on Sep 18, 2023

  1. Update threattracer.py

    Searched for exploits at packetstorm
    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    40bccb2 View commit details
  2. Update threattracer.py

    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    6bd6d74 View commit details
  3. Update README.md

    packetstormsecurity feature added.
    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    e5ba215 View commit details
  4. Update README.md

    Sometimes the vulnerability doesn't have CVE associated yet and it is possible that a public exploit is available.
    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    8ef0864 View commit details
  5. Update threattracer.py

    CPEs indepenndent result for packetstorm.
    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    7ba2a99 View commit details
  6. Update README.md

    POC Update for packetstorm.
    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    24615d4 View commit details
  7. Update threattracer.py

    Fetch all possible exploit data.
    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    384fe98 View commit details
  8. Update README.md

    Fetch all possible exploit/ 0-Days out there
    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    207ff0a View commit details
  9. Update threattracer.py

    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    556c674 View commit details
  10. Update README.md

    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    1394e1d View commit details
  11. Update README.md

    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    d266337 View commit details
  12. Update README.md

    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    019eccc View commit details
  13. Update threattracer.py

    anmolksachan authored Sep 18, 2023
    Copy the full SHA
    6329646 View commit details

Commits on Feb 9, 2024

  1. Update threattracer.py

    Major changes due to sunset of NIST 1.0 API
    meppohak5 authored Feb 9, 2024
    Copy the full SHA
    7309c6b View commit details
  2. Merge pull request #3 from meppohak5/patch-2

    Update threattracer.py for NIST 1.0 API
    anmolksachan authored Feb 9, 2024
    Copy the full SHA
    54e6d33 View commit details
  3. Copy the full SHA
    950317b View commit details
  4. Update README.md

    Update banner.
    anmolksachan authored Feb 9, 2024
    Copy the full SHA
    125e520 View commit details

Commits on Sep 2, 2024

  1. Update threattracer.py

    updated the script, the script was not running due to some errors.
    anmolksachan authored Sep 2, 2024
    Copy the full SHA
    280edf2 View commit details

Commits on Sep 11, 2024

  1. Update requirements.txt

    anmolksachan authored Sep 11, 2024
    Copy the full SHA
    d4e3975 View commit details

Commits on Sep 20, 2024

  1. Update threattracer.py

    Fixed few runtime bugs that were causing the tool to crash.
    anmolksachan authored Sep 20, 2024
    Copy the full SHA
    787064b View commit details
  2. Update threattracer.py

    Hack The Planet!
    anmolksachan authored Sep 20, 2024
    Copy the full SHA
    accd80c View commit details

Commits on May 2, 2025

  1. Copy the full SHA
    84b6c71 View commit details
  2. Merge pull request #6 from anmolksachan/anmolksachan-patch-1

    Version 3.0 Updates
    
    Added NVD API key support for authenticated requests
    New CLI options: --cpe, --cve, --poc, --more for granular control
    Integrated CVE PoC lookup from GitHub
    Enhanced Marc Full Disclosure exploit search
    Configurable API key storage (~/.cve_finder.cfg)
    Improved retry logic with rate-limit handling
    Direct CVE/CPE lookup modes added
    Modularized code structure for maintainability
    Colored output formatting for readability
    Added exploit status checks via PyExploitDb
    Better error handling and user feedback
    anmolksachan authored May 2, 2025
    Copy the full SHA
    6f617f6 View commit details
  3. Update requirements.txt

    version 3
    anmolksachan authored May 2, 2025
    Copy the full SHA
    9a278ee View commit details
  4. Merge pull request #7 from anmolksachan/anmolksachan-patch-2

    Update requirements.txt
    anmolksachan authored May 2, 2025
    Copy the full SHA
    62e151e View commit details
  5. Update README.md

    Updated readme based on version 3.
    anmolksachan authored May 2, 2025
    Copy the full SHA
    3266484 View commit details
  6. Copy the full SHA
    6c9ea49 View commit details
Showing with 377 additions and 173 deletions.
  1. +139 −64 README.md
  2. +4 −1 requirements.txt
  3. +234 −108 threattracer.py
203 changes: 139 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,147 @@
# ThreatTracer - CVE Checker Script

![image](https://github.com/anmolksachan/ThreatTracer/assets/60771253/9f6eb058-e393-4731-ac4b-0ea5a2964b74)


This script fetches CVE details for a given component and version by identifying relevant CPEs.

## Usage

1. Make sure you have Python3 installed on your system.
2. Install required libraries using `pip3 install -r requirements.txt`.
3. Run the script using `python3 threattracer.py`.

## Script Description

This script uses the National Vulnerability Database (NVD) API to fetch Common Vulnerabilities and Exposures (CVE) details for a specified component and version.

## Features
1. CVE Finder Script: This script is designed to identify Common Vulnerabilities and Exposures (CVEs) based on the name and version of a component.
2. User-friendly Interaction: The script interacts with users to input the name and version of a software component, making it easy to search for CVEs.
3. Web Scraping: The script utilizes web scraping techniques to fetch Common Platform Enumeration (CPE) information from NIST's National Vulnerability Database (NVD).
4. Colorful Output: Output messages are color-coded using the termcolor library to enhance readability and provide a visually appealing experience.
5. CPE Search: The script searches for all matching CPEs for the specified component and version, displaying the URLs used for CPE retrieval.
6. CVE Querying: It then queries the NVD API using the CPE information to fetch CVE details for each CPE found.
7. Detailed Information: The script displays detailed information about each CVE, including the CVE ID, description, weaknesses, and link to the NVD page.
8. Robust Error Handling: The script handles cases where CPEs are not found, providing appropriate error messages to users.
9. Easy-to-Use: The user interface is designed to be straightforward, allowing users to quickly search for CVEs associated with a specific software version.
10. CPEs Enumeration: When multiple CPEs are found, the script lists all the discovered CPEs before proceeding to query CVE details for each one.
11. Reusability: The modular structure of the script makes it reusable and easy to integrate into other projects or scripts.
12. Interactive Prompt: The script employs an interactive prompt to guide users through the process of entering the software component and version.
13. Automated Querying: The script automates the process of querying and fetching CVE details, saving users time and effort.
14. API Integration: It leverages the NVD API to retrieve and present accurate CVE information for the specified software version.
15. Store results in text: Store the results in a nice formatted way.

### Prerequisites

- Python (3.6+ recommended)
- `requests` library (`pip install requests`)
- `termcolor` library (`pip install termcolor`)

### Execution

1. Run the script.
2. Enter the component (e.g., `jquery`).
3. Enter the version (e.g., `1.0.0`).

The script will display relevant CVE information, if available.
# ThreatTracer - CVE Checker, [Public Exploit Enumerater](https://github.com/anmolksachan/ThreatTracer/blob/main/README.md#public-exploit) and [ZeroDay](https://github.com/anmolksachan/ThreatTracer/assets/60771253/65328a63-a0dd-4902-b7f9-0346564480dc) finder against any product and much more

<!--![ThreatTracer Banner version 2 1 OLD ](https://github.com/anmolksachan/ThreatTracer/assets/60771253/77092c9f-f3f2-401d-8b16-d4a21a945249)-->
<!--![ThreatTracer Banner version 2 1 ](https://github.com/anmolksachan/ThreatTracer/assets/60771253/58f8e429-700d-4067-a007-518ee00a7ef7)-->
<!--<img alt="Screenshot 2024-02-09 at 7 05 14 PM" src="https://github.com/anmolksachan/ThreatTracer/assets/60771253/1be90c9e-ac0a-4038-b0f5-7aa4e5cde29f">-->
![image](https://github.com/user-attachments/assets/b5745616-d052-4c79-b0b3-774377f41ab0)

> Find CVEs, public exploits, and 0-Day vulnerabilities for any software component.
## Key Features ✨
- 🔍 **Multi-mode Search**: Lookup by:
- Component & Version (`-c apache -v 2.4`)
- Direct CPE (`--cpe cpe:2.3:a:apache:http_server:2.4`)
- Specific CVE (`--cve CVE-2021-44228`)
- 🚀 **NVD API Integration** with API key support for faster queries
- 📦 **Trickest PoC Database** integration for GitHub exploit lookup
- 📬 **Marc Full Disclosure** exploit search integration
- 🛡️ **Exploit-DB** lookup is removed with static code for faster results.
-**Rate limiting** with automatic retry system
- 🔐 **API Key Management** with persistent storage
- 📊 **Detailed Output** with color-coded results

## Installation 🛠️
```bash
git clone https://github.com/anmolksachan/ThreatTracer.git
```
```bash
cd ThreatTracer
```
```bash
pip3 install -r requirements.txt
```
```bash
python3 threattracer.py -h
```

## Configure ⚙️
```bash
$ sudo python3 threattracer.py --apiStore <API KEY> -c 'Peel Shopping' -v '9.3.0'
API key stored in /root/.cve_finder.cfg
```
Request API Key here: https://nvd.nist.gov/developers/request-an-api-key

## Usage 🚀
```bash
python3 threattracer.py --help
```
# Basic usage 🩼

```bash
python3 threattracer.py -c "Apache" -v "2.4.56"
```
# Advanced options ⚡
```bash
python3 threattracer.py -c 'Peel Shopping' -v '9.3.0' --poc --more
```
```bash
python3 threattracer.py --cpe "cpe:2.3:a:peel:peel_shopping:9.4.0"
```
```bash
python3 threattracer.py --cve CVE-2021-27190
```

## Examples 📌

Component search with PoC lookup
```bash
python3 threattracer.py -c 'PEEL SHOPPING' -v "9.4.0" --poc
```
Direct CVE analysis
```bash
python3 threattracer.py --cve CVE-2021-27190
```
Store API key for repeated use
```bash
python3 threattracer.py --apiStore YOUR_API_KEY_HERE
```

## Sample Run 📟/ Output Preview 🖥️
- Help
![image](https://github.com/user-attachments/assets/ab47f588-9388-4268-b531-73e92a0a4fc1)

- Configure NIST API Key to avoid getting rate limited [Recommended]
![image](https://github.com/user-attachments/assets/714ddb75-b6d3-4f40-b18f-9106946e489b)

- Lookup for component and version
![image](https://github.com/user-attachments/assets/69b3d89e-26db-4a2b-8a68-e319341200f0)

- Lookup for component and version with --more to get detailed description of each CVE and --poc to lookup for POCs/ Exploits.
![image](https://github.com/user-attachments/assets/e767f004-d5a4-495d-b68c-ca27c62d1ebe)

- Direct CVE lookup
![image](https://github.com/user-attachments/assets/d0276a2e-e7d0-4b99-9f7a-b8456c5729c6)

- Direct CPE lookup
![image](https://github.com/user-attachments/assets/c6504bd5-d574-4b54-a4e4-d839cecff75d)

- Not interested in configuring API, directly use from the threattracer
![image](https://github.com/user-attachments/assets/20cedf8a-3592-4c38-a10a-7df5b154bbfd)

- Force threattracer to not use NIST API even if its configured in environment
![image](https://github.com/user-attachments/assets/e05eea1a-8eb0-46eb-b56a-19692b6e657c)

- Updated exploitDB module with detailed output and faster execution
![image](https://github.com/user-attachments/assets/ed09433d-b850-4e8b-9fcb-b297087aebaf)

## Features Breakdown 💡

1. CVE Detection via NVD API
2. Exploit Verification through:
- Static mode via ExploitDB
- GitHub PoC database
- Marc Full Disclosure

3. Zero-Day Hunting capabilities
4. Rate Limit Handling with automatic retries
5. Persistent API Key storage

## Requirements 📋
```bash
pip3 install -r requirements.txt
```
## Contributors 🤝
Mayur Patil [@meppohak5](https://github.com/meppohak5) <br>
Deepak Dhasmana [@0xCaretaker](https://github.com/0xCaretaker) <br>
Contribute to be mentioned here.

## Script Example
![image](https://github.com/anmolksachan/ThreatTracer/assets/60771253/a6d744f6-0473-45e4-a16a-399412ec8f12)
## Read More 📝
Version 1: [Enhancing Penetration Testing with CVE Checker Script — ThreatTracer](https://anmolksachan.medium.com/enhancing-penetration-testing-with-cve-checker-script-threattracer-p-484487747a77)<br>
Version 3: [ThreatTracer 3.0: Redefining Vulnerability Intelligence for Modern Defenders](https://anmolksachan.medium.com/threattracer-3-0-redefining-vulnerability-intelligence-for-modern-defenders-7661ffc11873)

![image](https://github.com/anmolksachan/ThreatTracer/assets/60771253/128be6ce-7204-49b6-adaf-d7ec1f342a25)
## Note 🔗
Feel free to enhance, modify, or contribute to this script to suit your needs and explore more security-related projects!

## Sample Run
<!--![Studio_Project_V2](https://github.com/anmolksachan/ThreatTracer/assets/60771253/a8938aa2-06cc-4fbf-a640-c10d77219185)-->
![demo](https://github.com/anmolksachan/ThreatTracer/assets/60771253/7c1e8a3c-77d9-4686-a7a7-e7e696e2237f)
## Support ❤️

### Contact
⭐ Star this repository<br>
📣 Follow [@FR13ND0x7F](https://twitter.com/fr13nd0x7f)<br>
🤝 Contribute through pull requests

Shoot my DM : [@FR13ND0x7F](https://twitter.com/fr13nd0x7f)
## Disclaimer ⚠️

### Special Thanks
[@FR13ND0x7F](https://twitter.com/fr13nd0x7f)
[@0xCaretaker](https://github.com/0xCaretaker)
[@meppohak5](https://github.com/meppohak5)
Contribute to be mentioned here.
This tool is for educational and ethical security testing purposes only. Use only on systems you own or have explicit permission to test.

### Note
Feel free to enhance, modify, or contribute to this script to suit your needs and explore more security-related projects!
## License 📜

## __Want to support my work?__
Give me a Star in the repository or follow me [@FR13ND0x7F](https://twitter.com/fr13nd0x7f) , thats enough for me :P
[MIT License](https://github.com/anmolksachan/ThreatTracer?tab=MIT-1-ov-file#readme) - Copyright (c) 2024 Anmol Sachan
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
aiohttp
requests==2.26.0
termcolor
requests
beautifulsoup4
colorama
342 changes: 234 additions & 108 deletions threattracer.py
Original file line number Diff line number Diff line change
@@ -1,126 +1,252 @@
import sys
import os
import requests
import re
import time
import json
import csv
from io import StringIO
from termcolor import colored
from datetime import datetime
from bs4 import BeautifulSoup
import argparse

art = """
# Configuration
CONFIG_FILE = os.path.expanduser("~/.cve_finder.cfg")

# ASCII Art Banner
art = r"""
_______ _ _ _______
|__ __| | | |__ __|
| | | |__ _ __ ___ __ _| |_ | |_ __ __ _ ___ ___ _ __
| | | '_ \| '__/ _ \/ _` | __|| | '__/ _` |/ __/ _ \ '__|
| | | '_ \| '__/ _ \/ _` | __|| | '__/ _` |/__ / _ \ '__|
| | | | | | | | __/ (_| | |_ | | | | (_| | (_| __/ |
|_| |_| |_|_| \___|\__,_|\__||_|_| \__,_|\___\___|_|
A Script to identify CVE using CPE by name & version
|_| |_| |_|_| \___|\__,_|\__||_|_| \__,_|\___\___|_| Version 3.0
A Script to identify CVE and public exploits using CPE/CVE by name & version
-+ Hunt for 0Days and unpublished exploits +-
Credit: @FR13ND0x7F @0xCaretaker @meppohak5
"""

print(colored(art, "cyan"))

def find_cpes(component, version):
base_url = "https://nvd.nist.gov/products/cpe/search/results"
params = {
"namingFormat": "2.3",
"keyword": f"{component} {version}"
}

response = requests.get(base_url, params=params)
print(f"URL Used: {response.url}") # Print the URL used to find CPE
content = response.text

cpe_matches = re.findall(r'cpe:(.*?)<', content)
return cpe_matches
def load_api_key():
if os.path.exists(CONFIG_FILE):
with open(CONFIG_FILE, 'r') as f:
return f.read().strip()
return None

def save_api_key(api_key):
with open(CONFIG_FILE, 'w') as f:
f.write(api_key)
print(colored(f"API key stored in {CONFIG_FILE}", "green"))

def parse_args():
parser = argparse.ArgumentParser(
description="ThreatTracer: CVE and Exploit Finder Script",
epilog="Examples:\n"
" python3 threattracer.py -c 'PEEL SHOPPING' -v 9.4.0\n"
" python3 threattracer.py --cpe 'cpe:2.3:a:peel:peel_shopping:9.4.0:*:*:*:*:*:*:*'\n"
" python3 threattracer.py --cve CVE-2021-44228",
formatter_class=argparse.RawTextHelpFormatter
)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("-c", "--component", help="Component name (e.g., Apache) with version(-v/--version)")
group.add_argument("--cpe", help="Direct CPE lookup")
group.add_argument("--cve", help="Direct CVE lookup")
parser.add_argument("-v", "--version", help="Component version (required with -c)")
parser.add_argument("--api", help="NVD API key for authenticated requests")
parser.add_argument("--apiStore", help="Store NVD API key for future use")
parser.add_argument("--noapi", action="store_true", help="Force non-API mode")
parser.add_argument("--poc", action="store_true", help="Show available PoCs")
parser.add_argument("--more", action="store_true", help="Show detailed descriptions")

args = parser.parse_args()

if args.cpe or args.cve:
args.poc = True
args.more = True

if args.component and not args.version:
parser.error("-c/--component requires -v/--version")

if args.cve:
cve_pattern = re.compile(r'^CVE-\d{4}-\d{4,}$')
if not cve_pattern.match(args.cve.upper()):
parser.error("Invalid CVE format. Expected format: CVE-YYYY-NNNNN")

return args

args = parse_args()

if args.apiStore:
save_api_key(args.apiStore)
sys.exit(0)

STORED_API_KEY = load_api_key()
USE_API = bool(args.api or STORED_API_KEY) and not args.noapi
API_KEY = args.api if args.api else STORED_API_KEY

def synk_db(cve_id):
res = requests.get(f"https://security.snyk.io/vuln/?search={cve_id}")
a_tag_pattern = r'data-snyk-test="vuln table title".*>([^"]+)<!----><!---->'
a_tag_matches = re.findall(a_tag_pattern, res.text)

if a_tag_matches:
snyk_short_name = a_tag_matches[0].lstrip().rstrip()
return snyk_short_name

def fetch_cve_details(cpe_strings):
base_url = "https://services.nvd.nist.gov/rest/json/cves/1.0"
results = []
print(colored(art, "cyan"))

for cpe_string in cpe_strings:
cve_query_string = ":".join(cpe_string.split(":")[1:5]) # Extract relevant CPE part (vendor, product, version, update)
url = f"{base_url}?cpeMatchString=cpe:/{cve_query_string}"
# Cache for Exploit-DB CSV
exploit_db_cache = None

def get_exploit_db():
global exploit_db_cache
if exploit_db_cache is not None:
return exploit_db_cache

url = "https://gitlab.com/exploit-database/exploitdb/-/raw/main/files_exploits.csv?ref_type=heads"
try:
response = requests.get(url)
data = response.json()

if "result" in data:
cves = data["result"]["CVE_Items"]
for cve_item in cves:
cve_id = cve_item["cve"]["CVE_data_meta"]["ID"]
snyk_short_name = synk_db(cve_id)

description = cve_item["cve"]["description"]["description_data"][0]["value"]
link = f"https://nvd.nist.gov/vuln/detail/{cve_id}"

weaknesses = []
if "problemtype" in cve_item["cve"]:
for problem_type in cve_item["cve"]["problemtype"]["problemtype_data"]:
for description in problem_type["description"]:
weaknesses.append(description["value"])
response.raise_for_status()
csv_content = StringIO(response.text)
reader = csv.DictReader(csv_content)
exploit_db_cache = {row['id']: row for row in reader}
return exploit_db_cache
except Exception as e:
print(colored(f"⚠️ Failed to fetch Exploit-DB: {e}", "red"))
return {}

def search_exploitdb(cve_id):
exploits = []
cve_id = cve_id.lower()
exploit_db = get_exploit_db()

for exp_id, data in exploit_db.items():
if cve_id in data.get('codes', '').lower():
exploits.append({
'id': exp_id,
'description': data['description'],
'link': f"https://www.exploit-db.com/exploits/{exp_id}"
})
return exploits

def make_api_request(url, params=None):
headers = {"User-Agent": "Mozilla/5.0"}
if USE_API and API_KEY:
headers["apiKey"] = API_KEY
for attempt in range(3):
try:
response = requests.get(url, params=params, headers=headers)
if response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', 6))
print(colored(f"⚠️ Rate limit exceeded. Retrying in {retry_after}s...", "yellow"))
time.sleep(retry_after)
continue
response.raise_for_status()
return response.json()
except requests.RequestException as e:
print(colored(f"⚠️ Request failed: {e}", "red"))
time.sleep(2 ** attempt)
return None

if "description_data" in cve_item["cve"]["description"]:
description_text = cve_item["cve"]["description"]["description_data"][0]["value"]
else:
description_text = "Description not available."

cve_details = {
"CVE ID": cve_id,
"Short Name": snyk_short_name,
"Description": description_text,
"Weaknesses": ", ".join(weaknesses),
"Link": link
}

results.append(cve_details)

return results

if __name__ == "__main__":
print(colored("CPE Finder Script", "green", attrs=["bold"]))
print("This script searches for the CPEs of a component and version.\n")

component = input(colored("Enter the component (e.g., jquery): ", "cyan"))
version = input(colored("Enter the version (e.g., 1.0.0): ", "cyan"))

cpe_strings = find_cpes(component, version)
if cpe_strings:
print(colored("CPEs Found:", "green"))
for cpe_string in cpe_strings:
print(colored(f" {cpe_string}", "green"))

export_option = input(colored("\nDo you want to export results to a text document? (yes/no): ", "yellow"))
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
filename = f"{component}_{version}_{timestamp}.txt"
def find_cpes(component, version):
url = "https://services.nvd.nist.gov/rest/json/cpes/2.0"
keyword = f"{component} {version}"
print(colored(f"\n🔍 Searching for: {keyword}", "cyan"))
data = make_api_request(url, {"keywordSearch": keyword})
if not data:
return []
return [item['cpe']['cpeName'] for item in data.get('products', [])]

def fetch_trickest_info(cve_id):
if not args.poc:
return []
year = cve_id.split('-')[1]
url = f"https://raw.githubusercontent.com/trickest/cve/refs/heads/main/{year}/{cve_id}.md"
try:
response = requests.get(url)
if response.status_code != 200:
return []
return list(set(re.findall(r'https://github\.com/[^\s)]+', response.text)))[:5]
except:
return []

def fetch_cve_details_by_cve(cve_id):
url = "https://services.nvd.nist.gov/rest/json/cves/2.0"
data = make_api_request(url, {"cveId": cve_id})
if not data:
return []
vulnerabilities = []
for item in data.get('vulnerabilities', []):
cve = item['cve']
cve_id = cve['id']
exploits = search_exploitdb(cve_id)
trickest_links = fetch_trickest_info(cve_id)
vulnerabilities.append({
"CVE ID": cve_id,
"Description": cve.get('descriptions', [{}])[0].get('value', 'N/A'),
"Weaknesses": ', '.join([d['value'] for w in cve.get('weaknesses', []) for d in w.get('description', [])]),
"Link": f"https://nvd.nist.gov/vuln/detail/{cve_id}",
"Exploits": exploits,
"GitHub PoCs": trickest_links
})
return vulnerabilities

def fetch_cve_details_by_cpe(cpe_string):
url = "https://services.nvd.nist.gov/rest/json/cves/2.0"
data = make_api_request(url, {"cpeName": cpe_string})
if not data:
return []
vulnerabilities = []
for item in data.get('vulnerabilities', []):
cve = item['cve']
cve_id = cve['id']
exploits = search_exploitdb(cve_id)
trickest_links = fetch_trickest_info(cve_id)
vulnerabilities.append({
"CVE ID": cve_id,
"Description": cve.get('descriptions', [{}])[0].get('value', 'N/A'),
"Weaknesses": ', '.join([d['value'] for w in cve.get('weaknesses', []) for d in w.get('description', [])]),
"Link": f"https://nvd.nist.gov/vuln/detail/{cve_id}",
"Exploits": exploits,
"GitHub PoCs": trickest_links
})
return vulnerabilities

def print_cve_info(details):
for d in details:
print(colored(f"\nCVE ID: {d['CVE ID']}", "white"))
print(colored(f"Description: {d['Description']}", "yellow"))
print(colored(f"Weaknesses: {d['Weaknesses']}", "red"))
print(colored(f"Link: {d['Link']}", "blue"))

if export_option.lower() == "yes":
results = fetch_cve_details(cpe_strings)
with open(filename, "w") as f:
for result in results:
f.write(f"CVE ID: {result['CVE ID']}\n")
if result["Short Name"]:
f.write(f"Short Name: {result['Short Name']}\n")
f.write(f"Description: {result['Description']}\n")
if result["Weaknesses"]:
f.write(f"Weaknesses: {result['Weaknesses']}\n")
f.write(f"Link: {result['Link']}\n\n")
print(colored(f"Results exported to '{filename}'", "green"))
if d['Exploits']:
print(colored("\nExploit-DB Entries:", "magenta"))
for exp in d['Exploits']:
print(f" ID: {exp['id']}")
print(f" Description: {exp['description']}")
print(f" Link: {exp['link']}")

results = fetch_cve_details(cpe_strings)
for result in results:
print(colored("\nCVE Details", "cyan", attrs=["underline"]))
print(colored(f"CVE ID: {result['CVE ID']}", "red"))
if result["Short Name"]:
print(colored(f"Short Name: {result['Short Name']}", "green"))
print(colored(f"Description: {result['Description']}", "yellow"))
if result["Weaknesses"]:
print(colored(f"Weaknesses: {result['Weaknesses']}", "magenta"))
print(colored(f"Link: {result['Link']}\n", "blue"))
else:
print(colored("CPEs not found for the provided component and version.", "red"))
if d['GitHub PoCs']:
print(colored("\nGitHub PoCs:", "cyan"))
for link in d['GitHub PoCs']:
print(f" {link}")

def main():
if args.cve:
print(colored(f"\n🔍 Checking CVE: {args.cve.upper()}", "green"))
details = fetch_cve_details_by_cve(args.cve.upper())
print_cve_info(details)
return

if args.cpe:
print(colored(f"\n🔍 Checking CPE: {args.cpe}", "green"))
details = fetch_cve_details_by_cpe(args.cpe)
print_cve_info(details)
return

cpes = find_cpes(args.component, args.version)
if not cpes:
print(colored("❌ No CPEs found.", "red"))
return

print(colored("\nCPEs Found:", "green"))
for c in cpes:
print(f" - {c}")

for c in cpes:
print(colored(f"\n🔍 Checking CVEs for: {c}", "green"))
details = fetch_cve_details_by_cpe(c)
print_cve_info(details)

if __name__ == "__main__":
main()