Initial commit

This commit is contained in:
Casper V. Kristensen 2023-03-17 02:18:22 +01:00
parent f045b943fb
commit 44b050e0aa
4 changed files with 59 additions and 1 deletions

View file

@ -1,3 +1,6 @@
# cteave
Recklessly open all new websites in the browser.
Recklessly open all new websites on the internet. That's the idea, anyway. For now, we just open any website that
obtains an HTTPS certificate, lol.
![screenshot](screenshot.png)

52
main.py Normal file
View file

@ -0,0 +1,52 @@
import asyncio
import webbrowser
import certstream
import httpx
from termcolor import colored
client = httpx.AsyncClient()
semaphore = asyncio.Semaphore(10)
async def handler(message: dict, context: dict) -> None:
if message["message_type"] != "certificate_update":
return
domains = message["data"]["leaf_cert"]["all_domains"]
try:
domain = next(d for d in domains if "*" not in d)
except StopIteration:
return
url = f"https://{domain}"
try:
async with semaphore:
r = await client.head(url, timeout=1)
except httpx.HTTPError:
print(colored("???", on_color="on_dark_grey"), domain)
return
if r.status_code != 200:
print(colored(str(r.status_code), on_color="on_yellow"), domain)
return
print(colored(str(r.status_code), on_color="on_cyan"), domain)
webbrowser.open_new_tab(url)
async def main() -> None:
loop = asyncio.get_running_loop()
def callback(message: dict, context: dict) -> None:
asyncio.run_coroutine_threadsafe(handler(message, context), loop=loop)
await asyncio.to_thread(
certstream.listen_for_events,
message_callback=callback,
url="wss://certstream.calidog.io/",
)
asyncio.run(main())

3
requirements.txt Normal file
View file

@ -0,0 +1,3 @@
certstream~=1.12
httpx~=0.23
colorama~=0.4

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB