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