mirror of
https://github.com/clearml/dropbear
synced 2025-01-31 02:46:58 +00:00
c7b7c9a99d
This allows ASLR to re-randomize the address space for every connection, preventing some vulnerabilities from being exploitable by repeated probing. Overhead (memory and time) is yet to be confirmed. At present this is only enabled on Linux. Other BSD platforms with fexecve() would probably also work though have not been tested.
40 lines
808 B
Python
Executable File
40 lines
808 B
Python
Executable File
#!/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 the first 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:
|
|
map0 = f.readline().rstrip()
|
|
print(map0)
|
|
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()
|