Skip to content

Commit

Permalink
Fix process termination, update default arguments (#94)
Browse files Browse the repository at this point in the history
* Add --open flag for Nmap

* Remove unused imports from decorators

* Close unused processes after queue.join
  • Loading branch information
manmolecular authored Apr 3, 2020
1 parent 868b506 commit ae1f2b1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion grinder/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def vulners_scan(

# Check for top-ports if defined
arguments = (
f"-Pn -sV --script=.{vulners_path} --host-timeout {str(host_timeout)}s"
f"-Pn -sV --open --script=.{vulners_path} --host-timeout {str(host_timeout)}s"
)
if top_ports:
arguments = f"{arguments} --top-ports {str(top_ports)}"
Expand Down
2 changes: 1 addition & 1 deletion grinder/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
from functools import wraps
from os import path, makedirs, system
from os import system
from time import time, strftime, gmtime


Expand Down
4 changes: 2 additions & 2 deletions grinder/defaultvalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class DefaultNmapScanValues:
TOP_PORTS = None
SUDO = False
HOST_TIMEOUT = 30
ARGUMENTS = "-Pn -T4 -A"
ARGUMENTS = "-Pn -T4 -A --open"
WORKERS = 10


Expand All @@ -124,7 +124,7 @@ class DefaultProcessManagerValues:
"""
PORTS = None
SUDO = False
ARGUMENTS = "-Pn -A"
ARGUMENTS = "-Pn -A --open"
WORKERS = 10


Expand Down
4 changes: 2 additions & 2 deletions grinder/nmapprocessmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class NmapProcessingDefaultManagerValues:

POLLING_RATE = 0.5
EMPTY_QUEUE_POLLING_RATE = 1.0
PROCESS_TIMEOUT = 300


class NmapProcessing(Process):
Expand Down Expand Up @@ -166,7 +165,8 @@ def organize_processes(self) -> None:
queue.put((None, None))
queue.join()
for process in processes:
process.join(timeout=NmapProcessingDefaultManagerValues.PROCESS_TIMEOUT)
if process.is_alive():
process.terminate()

def start(self) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions grinder/pyscriptexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class PyProcessingValues:

POLLING_RATE = 0.5
EMPTY_QUEUE_POLLING_RATE = 1.0
PROCESS_TIMEOUT = 300


class PyProcessing(Process):
Expand Down Expand Up @@ -238,7 +237,8 @@ def organize_processes(self) -> None:
queue.put((None, None, None))
queue.join()
for process in processes:
process.join(timeout=PyProcessingValues.PROCESS_TIMEOUT)
if process.is_alive():
process.terminate()

def start(self) -> None:
"""
Expand Down

0 comments on commit ae1f2b1

Please sign in to comment.