Mercurial > dropbear
view test/parent_dropbear_map.py @ 1928:333688ec53d0
Handle ecdsa-sk flags, reject no-touch
For the time being Dropbear will only allow SK auth with default
parameters, user-presence needs to be set.
In future handling of authorized_keys option "no-touch-required" can be
added.
This code would also be refactored to share between ecdsa and ed25519
once I get hardware/emulation to test ed25519.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 30 Mar 2022 21:06:15 +0800 |
parents | 1c9215154d4a |
children |
line wrap: on
line source
#!/usr/bin/env python3 import os import sys import time import psutil from pathlib import Path want_name = "dropbear" # Walks up the parent process tree, prints a r-xp line of /proc/pid/maps when # it finds the wanted name def main(): try: for p in psutil.Process().parents(): print(p.pid, file=sys.stderr) print(p.name(), file=sys.stderr) print(p.cmdline(), file=sys.stderr) if want_name in p.name(): with (Path('/proc') / str(p.pid) / "maps").open() as f: for i, l in enumerate(f, 1): if ' r-xp ' in l: print(l.rstrip()) break return raise RuntimeError(f"Couldn't find parent {want_name} process") except Exception as e: print(psutil.Process().parents()) for p in psutil.Process().parents(): print(p.name()) print(e) # time.sleep(100) raise if __name__ == "__main__": main()