Skip to content

Commit

Permalink
removed shell subprocess call and except pass
Browse files Browse the repository at this point in the history
  • Loading branch information
c0m4r committed Jan 6, 2024
1 parent b2055fa commit 17b368f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions loki.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from bisect import bisect_left
from collections import Counter
from subprocess import Popen, PIPE
from subprocess import Popen, PIPE, run

# yara-python module
import yara
Expand Down Expand Up @@ -848,8 +848,9 @@ def scan_processes_linux(self):
# Process Masquerading Detection -----------------------------------

if re.search(r"\[", cmd):
maps = Popen("cat /proc/" + str(pid) + "/maps", shell=True, stdout=PIPE)
if maps.stdout.read():
maps = "/proc/%s/maps" % str(pid)
maps = run(["cat", maps], encoding="utf-8", stdout=PIPE)
if maps.stdout.strip():
logger.log(
"WARNING",
"ProcessScan",
Expand Down Expand Up @@ -1617,11 +1618,8 @@ def save_pidfile():


def remove_pidfile():
if args.d:
try:
os.remove(args.pidfile)
except Exception:
pass
if args.d and os.path.exists(args.pidfile):
os.remove(args.pidfile)


# CTRL+C Handler --------------------------------------------------------------
Expand Down

0 comments on commit 17b368f

Please sign in to comment.