27 lines
905 B
Python
27 lines
905 B
Python
import re
|
|
|
|
import requests
|
|
|
|
INTERESTING = re.compile(
|
|
r'(^|/)(\.?env|config|settings|secret|credential|token|key|api|'
|
|
r'auth|\.bash|\.zsh|profile|keys?)', re.I)
|
|
|
|
tok = open(r"C:/Users/User/Desktop/keyhunter/gh_tokens.txt").readline().strip()
|
|
H = {"Authorization": f"Bearer {tok}", "User-Agent": "keyfarm"}
|
|
|
|
interesting, total = 0, 0
|
|
samples = []
|
|
for page in (1, 2, 3):
|
|
r = requests.get("https://api.github.com/gists/public",
|
|
params={"per_page": 100, "page": page}, headers=H, timeout=20)
|
|
for g in r.json():
|
|
total += 1
|
|
files = g.get("files") or {}
|
|
fname = " ".join(files.keys())
|
|
if INTERESTING.search(fname):
|
|
interesting += 1
|
|
if len(samples) < 10:
|
|
samples.append(fname[:80])
|
|
print(f"total={total} interesting={interesting} ({interesting*100//max(total,1)}%)")
|
|
for s in samples:
|
|
print(" -", s) |