当前位置: 首页>>代码示例>>Python>>正文


Python cmd.Cmd方法代码示例

本文整理汇总了Python中cmd.Cmd方法的典型用法代码示例。如果您正苦于以下问题:Python cmd.Cmd方法的具体用法?Python cmd.Cmd怎么用?Python cmd.Cmd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmd的用法示例。


在下文中一共展示了cmd.Cmd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pseudo_raw_input

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def pseudo_raw_input(self, prompt):
        """copied from cmd cmdloop; like raw_input, but accounts for changed stdin, stdout"""

        if self.use_rawinput:
            try:
                line = raw_input(prompt)
            except EOFError:
                if self.continue_on_eof:
                    line = '#'
                    # Fixme: sys.stdin
                else:
                    line = 'EOF'
        else:
            self.stdout.write(prompt)
            self.stdout.flush()
            line = self.stdin.readline()
            if not len(line):
                line = 'EOF'
            else:
                if line[-1] == '\n': # this was always true in Cmd
                    line = line[:-1]
        return line 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:24,代码来源:cmd2plus.py

示例2: test_input_reset_at_EOF

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def test_input_reset_at_EOF(self):
        input = StringIO.StringIO("print test\nprint test2")
        output = StringIO.StringIO()
        cmd = self.simplecmd2(stdin=input, stdout=output)
        cmd.use_rawinput = False
        cmd.cmdloop()
        self.assertMultiLineEqual(output.getvalue(),
            ("(Cmd) test\n"
             "(Cmd) test2\n"
             "(Cmd) *** Unknown syntax: EOF\n"))
        input = StringIO.StringIO("print \n\n")
        output = StringIO.StringIO()
        cmd.stdin = input
        cmd.stdout = output
        cmd.cmdloop()
        self.assertMultiLineEqual(output.getvalue(),
            ("(Cmd) \n"
             "(Cmd) \n"
             "(Cmd) *** Unknown syntax: EOF\n")) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_cmd.py

示例3: __init__

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def __init__(self, share, win32Process, smbConnection):
        cmd.Cmd.__init__(self)
        self.__share = share
        self.__output = '\\' + OUTPUT_FILENAME
        self.__outputBuffer = ''
        self.__shell = 'cmd.exe /Q /c '
        self.__win32Process = win32Process
        self.__transferClient = smbConnection
        self.__pwd = 'C:\\'
        self.__noOutput = False
        self.intro = '[!] Launching semi-interactive shell - Careful what you execute'

        # We don't wanna deal with timeouts from now on.
        if self.__transferClient is not None:
            self.__transferClient.setTimeout(100000)
            self.do_cd('\\')
        else:
            self.__noOutput = True 
开发者ID:x0day,项目名称:MultiProxies,代码行数:20,代码来源:wmi_exec.py

示例4: __init__

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def __init__(self, share, rpc, mode):
        cmd.Cmd.__init__(self)
        self.__share = share
        self.__mode = mode
        self.__output = '\\Windows\\Temp\\' + OUTPUT_FILENAME
        self.__batchFile = '%TEMP%\\' + BATCH_FILENAME
        self.__outputBuffer = ''
        self.__command = ''
        self.__shell = '%COMSPEC% /Q /c '
        self.__serviceName = 'BTOBTO'.encode('utf-16le')
        self.intro = '[!] Launching semi-interactive shell - Careful what you execute'

        dce = dcerpc.DCERPC_v5(rpc)


        try:
            dce.connect()
        except Exception, e:
            pass 
开发者ID:x0day,项目名称:MultiProxies,代码行数:21,代码来源:smb_exec.py

示例5: __init__

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def __init__(self, color=False, caching=False, reset=False):
        if color:
            colorama.init()
            cmd.Cmd.__init__(self, stdout=colorama.initialise.wrapped_stdout)
        else:
            cmd.Cmd.__init__(self)

        if platform.system() == "Windows":
            self.use_rawinput = False

        self.color = color
        self.caching = caching
        self.reset = reset

        self.fe = None
        self.repl = None
        self.tokenizer = Tokenizer()

        self.__intro()
        self.__set_prompt_path() 
开发者ID:wendlers,项目名称:mpfshell,代码行数:22,代码来源:mpfshell.py

示例6: pseudo_raw_input

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def pseudo_raw_input(self, prompt):
        """copied from cmd's cmdloop; like raw_input, but accounts for changed stdin, stdout"""

        if self.use_rawinput:
            try:
                line = raw_input(prompt)
            except EOFError:
                line = 'EOF'
        else:
            self.stdout.write(prompt)
            self.stdout.flush()
            line = self.stdin.readline()
            if not len(line):
                line = 'EOF'
            else:
                if line[-1] == '\n': # this was always true in Cmd
                    line = line[:-1]
        return line 
开发者ID:n0tr00t,项目名称:Beehive,代码行数:20,代码来源:cmd2.py

示例7: __init__

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def __init__(self, config_path):
        cmd.Cmd.__init__(self)

        self.config_path = config_path

        try:
            self.config = configparser.ConfigParser()
            self.config.read(self.config_path)
        except Exception as e:
            print("[-] Error reading cme.conf: {}".format(e))
            sys.exit(1)

        self.workspace_dir = os.path.expanduser('~/.cme/workspaces')
        self.conn = None
        self.p_loader = protocol_loader()
        self.protocols = self.p_loader.get_protocols()

        self.workspace = self.config.get('CME', 'workspace')
        self.do_workspace(self.workspace)

        self.db = self.config.get('CME', 'last_used_db')
        if self.db:
            self.do_proto(self.db) 
开发者ID:byt3bl33d3r,项目名称:CrackMapExec,代码行数:25,代码来源:cmedb.py

示例8: run_transcript_tests

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def run_transcript_tests(self, callargs: List[str]) -> None:
        """Runs transcript tests for provided file(s).

        This is called when either -t is provided on the command line or the transcript_files argument is provided
        during construction of the cmd2.Cmd instance.

        :param callargs: list of transcript test file names
        """
        import unittest
        from .transcript import Cmd2TestCase

        class TestMyAppCase(Cmd2TestCase):
            cmdapp = self

        self.__class__.testfiles = callargs
        sys.argv = [sys.argv[0]]  # the --test argument upsets unittest.main()
        testcase = TestMyAppCase()
        runner = unittest.TextTestRunner()
        runner.run(testcase) 
开发者ID:TuuuNya,项目名称:WebPocket,代码行数:21,代码来源:cmd2.py

示例9: __init__

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def __init__(self, share, win32Process, smbConnection):
        cmd.Cmd.__init__(self)
        self.__share = share
        self.__output = '\\' + OUTPUT_FILENAME
        self.__outputBuffer = str('')
        self.__shell = 'cmd.exe /Q /c '
        self.__win32Process = win32Process
        self.__transferClient = smbConnection
        self.__pwd = str('C:\\')
        self.__noOutput = False
        self.intro = '[!] Launching semi-interactive shell - Careful what you execute\n[!] Press help for extra shell commands'

        # We don't wanna deal with timeouts from now on.
        if self.__transferClient is not None:
            self.__transferClient.setTimeout(1000000)
            self.do_cd('\\')
        else:
            self.__noOutput = True 
开发者ID:aas-n,项目名称:spraykatz,代码行数:20,代码来源:wmiexec_delete.py

示例10: do_columns

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def do_columns(self, option, intro=None):
			try:
				if option == "users":
					print "[-] Displaying the columns in the User Table"
					tb = dp.read_sql('select *from UserTB', conn)
					print tb.columns.values.tolist()
				elif option == "groups":
					print "[-] Displaying the columns in the Group Table"
					tb = dp.read_sql('select *from GroupTB', conn)
					print tb.columns.values.tolist()
				elif option == "computers":
					print "[-] Displaying the columns in the Computer Table"
					tb = dp.read_sql('select *from ComputerTB', conn)
					print tb.columns.values.tolist()
				else:
					print "Not one of the tables."
			except pandas.io.sql.DatabaseError:
				print colors.RD + "[-] " + colors.NRM + "Error: Empty database."
			return cmd.Cmd.cmdloop(self, intro) 
开发者ID:Tylous,项目名称:Vibe,代码行数:21,代码来源:vibe.py

示例11: do_share_hunter

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def do_share_hunter(self, option, intro=None):
			try:
				self.cmd_sub_arg_parse(option)
				if not netaddr:
					print colors.RD + "[-] " + colors.NRM + "No target provided. Please try again"
					return
				else:
					targets = IP(netaddr)
				if not user and not password and not domain:
					print colors.RD + "[-] " + colors.NRM + "Missing user information (i.e Domain, Username, Password). Please try again"
				else:
					pass

				sh = Share_Hunting(domain, user, password, jitter)
				print targets
				sh.share_hunter(targets)
			except IndexError:
				print colors.RD + "[-] " + colors.NRM + "Invalid Option"
				print colors.BLU + "[*] " + colors.NRM + "Scans target(s) enumerating the shares on the target(s) and the level of access the specified user, using  -u/--user. Can take a list or range of hosts, using -t/--target. Example  share_hunter --user admin -t 192.168.1./24 -j 3."
			except KeyboardInterrupt:
				return
			return cmd.Cmd.cmdloop(self, intro) 
开发者ID:Tylous,项目名称:Vibe,代码行数:24,代码来源:vibe.py

示例12: do_help

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def do_help(self, intro=None):
			print "Commands"
			print "========"
			print "clear                Clears the screen"
			print "help                 Displays this help menu"
			print "list                 Lists either all Users, Computers, or Groups. Use the -f option to pipe the contents to a file"
			print "session              Scans target(s) to see who has/is currently logged in. Can take a list or range of hosts, using -t/--target and specify a user using -d/--domain, -u/--user, -p/--password and --jitter/-j to add a delay. Requires: read/write privileges on either Admin$ or C$ share"
			print "net                  Perform a query to view all information pertaining to a specific user, group, or computer (Similar to the Windows net user, net group commands). example: \'net group Domain Admins\'"
			print "columns              Displays the column names in each of the three major tables (users, groups and computers"
			print "query                Executes a query on the contents of tables"
			print "search               Searches for a key word(s) through every field of every table for any matches, displaying row"
			print "share_hunter         Scans target(s) enumerating the shares on the target(s) and the level of access the specified user, using -d/--domain, -u/--user, -p/--password. Can take a list or range of hosts, using -t/--target and --jitter/-j to add a delay"
			print "show                 Shows the contents of Users, Computers, Credentials, Groups, Password policy, Store, Credentials, Files Servers and Access tables"
			print "store                Displays the contents of a specific table. Example: \'show [table name] (access, creds, computers, file servers, pwdpolicy, users)"
			print "export               Export the contents of the database to a path in one of the following formats: CSV, HTML. (using with -f or --filetype)"
			print "exit                 Exit Vibe"
			return cmd.Cmd.cmdloop(self, intro) 
开发者ID:Tylous,项目名称:Vibe,代码行数:19,代码来源:vibe.py

示例13: __init__

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def __init__(self,settings,ssh_session=None, dcon=dict):
        cmd.Cmd.__init__(self)
        self.prompt = color.setcolor('b1tifi:: ', color='Blue')
        self.settings   = settings
        self.db         = dcon['db_cursor']
        self.con        = dcon['db_con']
        self.sshConnect = ssh_session
        self.search_all_agents() 
开发者ID:mh4x0f,项目名称:b1tifi,代码行数:10,代码来源:console.py

示例14: do_help

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def do_help(self, arg):
        if arg:
            funcname = self.func_named(arg)
            if funcname:
                fn = getattr(self, funcname)
                try:
                    fn.optionParser.print_help(file=self.stdout)
                except AttributeError:
                    cmd.Cmd.do_help(self, funcname[3:])
        else:
            cmd.Cmd.do_help(self, arg) 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:13,代码来源:cmd2plus.py

示例15: __init__

# 需要导入模块: import cmd [as 别名]
# 或者: from cmd import Cmd [as 别名]
def __init__(self, *args, **kwargs):
        self.continue_on_eof = False
        if 'continue_on_eof' in kwargs:
            self.continue_on_eof = kwargs['continue_on_eof']
            del kwargs['continue_on_eof']
        cmd.Cmd.__init__(self, *args, **kwargs)
        self.initial_stdout = sys.stdout
        self.history = History()
        self.pystate = {}
        self.shortcuts = sorted(self.shortcuts.items(), reverse=True)
        self.keywords = self.reserved_words + [fname[3:] for fname in dir(self)
                                               if fname.startswith('do_')]
        self._init_parser() 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:15,代码来源:cmd2plus.py


注:本文中的cmd.Cmd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。