blob: 6f997b8bf17f5a020de39c10706fd3c587f6c5bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from pathlib import Path
import sys
from test_dropbear import *
def test_reexec(request, dropbear):
"""
Tests that two consecutive connections have different address layouts.
This indicates that re-exec makes ASLR work
"""
cmd = (Path(request.node.fspath).parent / "parent_dropbear_map.py").resolve()
r = dbclient(request, cmd, capture_output=True, text=True)
map1 = r.stdout.rstrip()
print(r.stderr, file=sys.stderr)
r.check_returncode()
r = dbclient(request, cmd, capture_output=True, text=True)
map2 = r.stdout.rstrip()
print(r.stderr, file=sys.stderr)
r.check_returncode()
print(map1)
print(map2)
# expect something like
# "563174d59000-563174d5d000 r--p 00000000 00:29 4242372 /home/matt/src/dropbear/build/dropbear"
assert map1.endswith('/dropbear')
assert ' r--p ' in map1
a1 = map1.split()[0]
a2 = map2.split()[0]
print(a1)
print(a2)
# relocation addresses should differ
assert a1 != a2
|