Created
June 13, 2026 12:42
-
-
Save hikhvar/6367b842a4ce514870e7c3db035abd98 to your computer and use it in GitHub Desktop.
Python Script fetching the affected AUR packages from the atomic lock attack and compare with installed packages. Check if they have been updated after 8th of June.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Fetch a package list and report which entries were installed/updated on this | |
| machine after a cutoff date, along with the latest action date for each. | |
| Source list: a HedgeDoc note containing one package name per line. | |
| Install history: /var/log/pacman.log ([ALPM] installed/upgraded lines). | |
| """ | |
| import re | |
| import sys | |
| import urllib.request | |
| from datetime import datetime, timezone | |
| PACKAGE_LIST_URL = "https://md.archlinux.org/s/SxbqukK6IA/download" | |
| PACMAN_LOG = "/var/log/pacman.log" | |
| CUTOFF = datetime(2026, 6, 8, tzinfo=timezone.utc) | |
| LOG_LINE = re.compile( | |
| r"^\[(?P<ts>[^\]]+)\] \[ALPM\] (?:installed|upgraded) (?P<pkg>\S+)" | |
| ) | |
| def fetch_package_list(url): | |
| with urllib.request.urlopen(url, timeout=30) as response: | |
| text = response.read().decode("utf-8") | |
| return {line.strip() for line in text.splitlines() if line.strip()} | |
| def latest_actions_after_cutoff(log_path, cutoff): | |
| latest = {} | |
| with open(log_path, encoding="utf-8", errors="replace") as log: | |
| for line in log: | |
| match = LOG_LINE.match(line) | |
| if not match: | |
| continue | |
| timestamp = datetime.fromisoformat(match.group("ts")).astimezone(timezone.utc) | |
| if timestamp < cutoff: | |
| continue | |
| pkg = match.group("pkg") | |
| if pkg not in latest or timestamp > latest[pkg]: | |
| latest[pkg] = timestamp | |
| return latest | |
| def main(): | |
| wanted = fetch_package_list(PACKAGE_LIST_URL) | |
| actions = latest_actions_after_cutoff(PACMAN_LOG, CUTOFF) | |
| matches = sorted( | |
| ((pkg, ts) for pkg, ts in actions.items() if pkg in wanted), | |
| key=lambda item: item[1], | |
| ) | |
| print(f"Source list: {len(wanted)} packages") | |
| print(f"Cutoff: installed/updated after {CUTOFF.date().isoformat()}") | |
| print(f"Matches found: {len(matches)}\n") | |
| if not matches: | |
| print("No packages from the list were installed/updated after the cutoff.") | |
| return | |
| width = max(len(pkg) for pkg, _ in matches) | |
| for pkg, ts in matches: | |
| print(f"{pkg:<{width}} {ts.astimezone().isoformat()}") | |
| if __name__ == "__main__": | |
| sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment