Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #119 from tnich/cmd_output_fix
Browse files Browse the repository at this point in the history
Fixed command parsing
  • Loading branch information
tnich committed Apr 4, 2018
2 parents 1b4fe14 + fe0dae3 commit 7adbf1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions honssh/honeypot/honeypot-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# SUCH DAMAGE.

import subprocess
import shlex

from honssh.config import Config
from honssh.utils import validation
Expand All @@ -43,8 +44,9 @@ def get_pre_auth_details(self, conn_details):
command = '%s %s %s %s %s' % (
self.cfg.get(['honeypot-script', 'pre-auth-script']), conn_details['peer_ip'], conn_details['local_ip'],
conn_details['peer_port'], conn_details['local_port'])

sp = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
args = shlex.split(command)

sp = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = sp.communicate()
if sp.returncode == 0:
binder = result[0].split(',')
Expand All @@ -62,7 +64,8 @@ def get_post_auth_details(self, conn_details):
self.cfg.get(['honeypot-script', 'post-auth-script']), conn_details['peer_ip'], conn_details['local_ip'],
conn_details['peer_port'], conn_details['local_port'], conn_details['username'], conn_details['password'])

sp = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
args = shlex.split(command)
sp = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = sp.communicate()
if sp.returncode == 0:
binder = result[0].split(',')
Expand Down
4 changes: 3 additions & 1 deletion honssh/output/output-app_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from honssh.utils import validation

import subprocess
import shlex


class Plugin(object):
Expand Down Expand Up @@ -157,5 +158,6 @@ def validate_config(self):
return True

def runCommand(self, command):
sp = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
args = shlex.split(command)
sp = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
sp.communicate()

0 comments on commit 7adbf1b

Please sign in to comment.