Skip to content

Instantly share code, notes, and snippets.

@moetayuko
Created February 10, 2025 12:17
Show Gist options
  • Select an option

  • Save moetayuko/588498f9dd4ce4cea1b948f748500133 to your computer and use it in GitHub Desktop.

Select an option

Save moetayuko/588498f9dd4ce4cea1b948f748500133 to your computer and use it in GitHub Desktop.
import asyncio
import itertools
import pathlib
import re
import aiofiles
BLOB_LIST = """
# PASTE YOUR BLOB LIST HERE
"""
async def find_filenames(file):
async with aiofiles.open(file, "rb") as f:
contents = await f.read()
all_so = re.findall("[a-zA-Z0-9_\\-\\.]+\\.so", contents.decode("ISO-8859-1"))
return all_so
async def gather_with_concurrency(n, *coros):
semaphore = asyncio.Semaphore(n)
async def sem_coro(coro):
async with semaphore:
return await coro
return await asyncio.gather(*(sem_coro(c) for c in coros))
async def main():
known_files = [
pathlib.Path(re.split(":|;", f)[0])
for f in BLOB_LIST.splitlines()
if f and f[0] != "#"
]
known_names = set([f.name for f in known_files])
tasks = [find_filenames(f) for f in known_files]
appeared = await gather_with_concurrency(500, *tasks)
appeared = set(itertools.chain(*appeared))
unknown = appeared - known_names
print("\n".join(unknown))
if "__main__" == __name__:
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment