Mercurial > dropbear
annotate test/parent_dropbear_map.py @ 1916:3f4cdf839a1a
Make SHA1 optional, implement SHA256 fingerprints
SHA256 is always compiled and only enable SHA1 when needed. Fingerprints
are always SHA256: base64 format, md5 and sha1 are removed. dbrandom now
uses sha256 its hash function.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 30 Mar 2022 11:44:04 +0800 |
parents | 1c9215154d4a |
children |
rev | line source |
---|---|
1861 | 1 #!/usr/bin/env python3 |
2 | |
3 import os | |
4 import sys | |
5 import time | |
6 import psutil | |
7 | |
8 from pathlib import Path | |
9 | |
10 | |
11 want_name = "dropbear" | |
1874
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
12 # Walks up the parent process tree, prints a r-xp line of /proc/pid/maps when |
1861 | 13 # it finds the wanted name |
14 | |
15 def main(): | |
16 | |
17 try: | |
18 for p in psutil.Process().parents(): | |
19 print(p.pid, file=sys.stderr) | |
20 print(p.name(), file=sys.stderr) | |
21 print(p.cmdline(), file=sys.stderr) | |
22 | |
23 if want_name in p.name(): | |
24 with (Path('/proc') / str(p.pid) / "maps").open() as f: | |
1874
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
25 for i, l in enumerate(f, 1): |
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
26 if ' r-xp ' in l: |
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
27 print(l.rstrip()) |
1c9215154d4a
Handle /proc/.../maps being reordered
Matt Johnston <matt@ucc.asn.au>
parents:
1861
diff
changeset
|
28 break |
1861 | 29 return |
30 | |
31 raise RuntimeError(f"Couldn't find parent {want_name} process") | |
32 except Exception as e: | |
33 print(psutil.Process().parents()) | |
34 for p in psutil.Process().parents(): | |
35 print(p.name()) | |
36 print(e) | |
37 # time.sleep(100) | |
38 raise | |
39 | |
40 if __name__ == "__main__": | |
41 main() |