5
5
from shutil import which
6
6
from typing import Union , Dict , Iterable , List
7
7
8
+ from paramiko import util
8
9
import pwnlib .args
9
10
import pwnlib .filesystem
10
11
import pwnlib .gdb
@@ -30,8 +31,6 @@ class Pwngd(ABC):
30
31
HOME_DIR = os .path .expanduser ('~/.local/share/vagd/' )
31
32
SYSROOT = LOCAL_DIR + 'sysroot/'
32
33
LOCKFILE = LOCAL_DIR + 'vagd.lock'
33
- SYSROOT_LIB = SYSROOT + 'lib/'
34
- SYSROOT_LIB_DEBUG = SYSROOT + 'lib/debug'
35
34
KEYFILE = HOME_DIR + 'keyfile'
36
35
PUBKEYFILE = KEYFILE + '.pub'
37
36
DEFAULT_PORT = 2222
@@ -98,15 +97,15 @@ def _lock(self, typ: str):
98
97
with open (Pwngd .LOCKFILE , 'w' ) as lfile :
99
98
lfile .write (typ )
100
99
101
- def _mount_lib (self , remote_lib : str = '/usr/lib ' ) -> None :
100
+ def _mount_root (self , remote_lib : str = '/' ) -> None :
102
101
"""
103
102
mount the lib directory of remote
104
103
"""
105
- if not ( os .path .exists (Pwngd .SYSROOT ) and os . path . exists ( Pwngd . SYSROOT_LIB ) ):
106
- os .makedirs (Pwngd .SYSROOT_LIB )
107
- if not os .path .ismount (Pwngd .SYSROOT_LIB ):
104
+ if not os .path .exists (Pwngd .SYSROOT ):
105
+ os .makedirs (Pwngd .SYSROOT )
106
+ if not os .path .ismount (Pwngd .SYSROOT ):
108
107
helper .info ('mounting libs in sysroot' )
109
- self ._mount (remote_lib , Pwngd .SYSROOT_LIB )
108
+ self ._mount (remote_lib , Pwngd .SYSROOT )
110
109
111
110
def system (self , cmd : str ) -> pwnlib .tubes .ssh .ssh_channel :
112
111
"""
@@ -129,7 +128,7 @@ def _install_packages(self, packages: Iterable):
129
128
"""
130
129
self .system ("sudo apt update" ).recvall ()
131
130
packages_str = " " .join (packages )
132
- self .system (f"sudo NEEDRESTART_MODE=a apt install -y { packages_str } " ).recvall ()
131
+ self .system (f"sudo DEBIAN_FRONTEND=noninteractive apt install -y { packages_str } " ).recvall ()
133
132
134
133
def put (self , file : str , remote : str = None ):
135
134
"""
@@ -230,7 +229,7 @@ def __init__(self,
230
229
231
230
if self ._fast :
232
231
if self ._experimental :
233
- self ._mount_lib ()
232
+ self ._mount_root ()
234
233
else :
235
234
helper .error ('requires experimental features, activate with ex=True' )
236
235
@@ -309,12 +308,8 @@ def debug(self,
309
308
310
309
if self ._fast :
311
310
gdb_args += ["-ex" , f"set sysroot { pathlib .Path ().resolve ()} /{ Pwngd .SYSROOT } " ]
312
- gdbscript = f"set debug-file-directory { Pwngd .SYSROOT_LIB_DEBUG } \n " + gdbscript
313
311
elif sysroot :
314
312
gdb_args += ["-ex" , f"set sysroot { sysroot } " ]
315
- gdbscript = f"set debug-file-directory ./{ sysroot } /lib/debug\n " + gdbscript
316
- else :
317
- gdbscript = "set debug-file-directory /lib/debug\n " + gdbscript
318
313
319
314
gdb_args += ["-ex" , f"file -readnow { self ._path } " ]
320
315
0 commit comments