def smbcmdlist(): parse_list_file(conf.smbcmdlist) targets_tuple = () for target in targets: if len(target.getValidCredentials()) == 0: continue else: first_credentials = target.getValidCredentials()[0] logger.info('Executing SMB commands on %s with user %s' % (target.getIdentity(), first_credentials.getUser())) shell = InteractiveShell(target, first_credentials, conf.name) if len(commands) > 0: logger.info('Executing SMB commands from provided file') for command in commands: print 'SMB command \'%s\' output:' % command try: shell.onecmd(command) except SessionError, e: #traceback.print_exc() logger.error('SMB error: %s' % (e.getErrorString(), )) except NetBIOSTimeout, e: logger.error('SMB connection timed out') except keimpxError, e: logger.error(e) except KeyboardInterrupt, _: print logger.info('User aborted') shell.do_exit('')
def smb_cmd_list(targets): commands = parse_list_file(conf.smbcmdlist) targets_tuple = () for target in targets: if len(target.get_valid_credentials()) == 0: continue else: admin_credentials = get_admin_credentials(target) if admin_credentials is False: admin_credentials = target.get_valid_credentials()[0] logger.warn( 'No admin user identified for target %s, some commands will not work' % target.get_identity()) logger.info('Executing SMB commands on %s with user %s' % (target.get_identity(), admin_credentials.getUser())) shell = InteractiveShell(target, admin_credentials, conf.name) if len(commands) > 0: logger.info('Executing SMB commands from provided file') for command in commands: print('SMB command \'%s\' output:' % command) try: shell.onecmd(command) except SessionError as e: # traceback.print_exc() logger.error('SMB error: %s' % (e.getErrorString(), )) except NetBIOSTimeout as e: logger.error('SMB connection timed out') except keimpxError as e: logger.error(e) except KeyboardInterrupt as _: print() logger.info('User aborted') shell.do_exit('') except Exception as e: # traceback.print_exc() logger.error(str(e)) print('----------8<----------')
def smbcmdlist(): parse_list_file(conf.smbcmdlist) targets_tuple = () for target in targets: if len(target.getValidCredentials()) == 0: continue else: admin_credentials = get_admin_credentials(target) if admin_credentials is False: admin_credentials = target.getValidCredentials()[0] logger.warn("No admin user identified for target %s, some commands will not work" % target.getIdentity()) logger.info("Executing SMB commands on %s with user %s" % (target.getIdentity(), admin_credentials.getUser())) shell = InteractiveShell(target, admin_credentials, conf.name) if len(commands) > 0: logger.info("Executing SMB commands from provided file") for command in commands: print "SMB command '%s' output:" % command try: shell.onecmd(command) except SessionError, e: # traceback.print_exc() logger.error("SMB error: %s" % (e.getErrorString(),)) except NetBIOSTimeout, e: logger.error("SMB connection timed out") except keimpxError, e: logger.error(e) except KeyboardInterrupt, _: print logger.info("User aborted") shell.do_exit("")