From 19093c13e91ee39b2b5625381916ba4af5112357 Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Fri, 21 Oct 2016 23:17:18 +0300 Subject: [PATCH] Do not use redirected stdout for shares --- pupy/modules/shares.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/pupy/modules/shares.py b/pupy/modules/shares.py index 3d34bb57..dd5f86db 100644 --- a/pupy/modules/shares.py +++ b/pupy/modules/shares.py @@ -1,6 +1,5 @@ # -*- coding: UTF8 -*- from pupylib.PupyModule import * -from pupylib.utils.rpyc_utils import redirected_stdo from netaddr import * __class_name__="Shares" @@ -8,7 +7,7 @@ __class_name__="Shares" @config(category="admin") class Shares(PupyModule): """ List local and remote shared folder and permission """ - + def init_argparse(self): example = 'Examples:\n' example += '>> run shares local\n' @@ -17,10 +16,10 @@ class Shares(PupyModule): self.arg_parser = PupyArgumentParser(prog="shares", description=self.__doc__, epilog=example) subparsers = self.arg_parser.add_subparsers(title='Enumerate shared folders') - + local = subparsers.add_parser('local', help='Retrieve local shared folders') local.set_defaults(local="list_shared_folders") - + remote = subparsers.add_parser('remote', help='Retrieve remote shared folders and permission') remote.add_argument("-u", metavar="USERNAME", dest='user', default='', help="Username, if omitted null session assumed") remote.add_argument("-p", metavar="PASSWORD", dest='passwd', default='', help="Password") @@ -31,8 +30,8 @@ class Shares(PupyModule): def run(self, args): - - # Retrieve local shared folders + + # Retrieve local shared folders try: if args.local: if self.client.is_windows(): @@ -42,33 +41,33 @@ class Shares(PupyModule): self.client.load_package("winerror") self.client.load_package("wmi") self.client.load_package("pupwinutils.drives") - - with redirected_stdo(self.client.conn): - self.client.conn.modules['pupwinutils.drives'].shared_folders() + + print self.client.conn.modules['pupwinutils.drives'].shared_folders() else: self.warning('this module works only for windows. Try using: run shares remote -t 127.0.0.1') - return + return except: pass - + # Retrieve remote shared folders if not args.target: self.error("target (-t) parameter must be specify") - return + return if "/" in args.target: hosts = IPNetwork(args.target) else: hosts = list() hosts.append(args.target) - + print hosts self.client.load_package("impacket") self.client.load_package("calendar") self.client.load_package("pupyutils.share_enum") - with redirected_stdo(self.client.conn): - for host in hosts: - self.info("Connecting to the remote host: %s" % host) - self.client.conn.modules["pupyutils.share_enum"].connect(host, args.port, args.user, args.passwd, args.hash, args.domain) \ No newline at end of file + for host in hosts: + self.info("Connecting to the remote host: %s" % host) + print self.client.conn.modules["pupyutils.share_enum"].connect( + host, args.port, args.user, args.passwd, args.hash, args.domain + )