Skip to content

Commit

Permalink
spy: make kill_procid more portable
Browse files Browse the repository at this point in the history
  • Loading branch information
silv3rr committed Aug 2, 2024
1 parent 21c7d98 commit 4722e07
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions spy.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,15 @@ def kill_procid(u_name, users):
""" kill user using procid """
for user in users:
if user.name == u_name:
if os.popen(f"ps --no-headers -o comm -p {user.get('procid')}").read().strip() == 'glftpd':
try:
procid = user.get('procid')
os.kill(int(procid), 15)
return dict(status="Success", procid=procid)
except OSError as err:
return dict(status="NotRoot", procid=procid, error=err)
#if os.popen(f"ps --no-headers -o comm -p {user.get('procid')}").read().strip() == 'glftpd':
with open(os.path.join('/proc', str(user.get('procid')), 'comm'), 'rb') as fp:
if fp.read().split(b'\x00')[0].decode().strip() == 'glftpd':
try:
procid = user.get('procid')
os.kill(int(procid), 15)
return dict(status="Success", procid=procid)
except OSError as err:
return dict(status="NotRoot", procid=procid, error=err)
return dict(status="NotFound")


Expand Down

0 comments on commit 4722e07

Please sign in to comment.