當前位置: 首頁>>代碼示例>>Python>>正文


Python tsch.hSchRpcGetLastRunInfo方法代碼示例

本文整理匯總了Python中impacket.dcerpc.v5.tsch.hSchRpcGetLastRunInfo方法的典型用法代碼示例。如果您正苦於以下問題:Python tsch.hSchRpcGetLastRunInfo方法的具體用法?Python tsch.hSchRpcGetLastRunInfo怎麽用?Python tsch.hSchRpcGetLastRunInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在impacket.dcerpc.v5.tsch的用法示例。


在下文中一共展示了tsch.hSchRpcGetLastRunInfo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute

# 需要導入模塊: from impacket.dcerpc.v5 import tsch [as 別名]
# 或者: from impacket.dcerpc.v5.tsch import hSchRpcGetLastRunInfo [as 別名]
def execute(self, commands):
        dce = self._rpctransport.get_dce_rpc()

        dce.set_credentials(*self._rpctransport.get_credentials())
        if self._conn.kerberos:
            dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE)
        dce.connect()
        dce.bind(tsch.MSRPC_UUID_TSCHS)
        xml = self.gen_xml(commands)
        tmpName = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
        self._log.debug("Register random task {}".format(tmpName))
        tsch.hSchRpcRegisterTask(dce, '\\%s' % tmpName, xml, tsch.TASK_CREATE, NULL, tsch.TASK_LOGON_NONE)
        tsch.hSchRpcRun(dce, '\\%s' % tmpName)
        done = False
        while not done:
            resp = tsch.hSchRpcGetLastRunInfo(dce, '\\%s' % tmpName)
            if resp['pLastRuntime']['wYear'] != 0:
                done = True
            else:
                time.sleep(2)

        time.sleep(3)
        tsch.hSchRpcDelete(dce, '\\%s' % tmpName)
        dce.disconnect() 
開發者ID:Hackndo,項目名稱:lsassy,代碼行數:26,代碼來源:taskexe.py

示例2: test_hSchRpcGetLastRunInfo

# 需要導入模塊: from impacket.dcerpc.v5 import tsch [as 別名]
# 或者: from impacket.dcerpc.v5.tsch import hSchRpcGetLastRunInfo [as 別名]
def test_hSchRpcGetLastRunInfo(self):
        dce, rpctransport = self.connect(self.stringBindingAtSvc, tsch.MSRPC_UUID_TSCHS)
        try:
            resp = tsch.hSchRpcGetLastRunInfo(dce, '\\Microsoft\\Windows\\Defrag\\ScheduledDefrag')
            resp.dump()
        except Exception, e:
            if str(e).find('SCHED_S_TASK_HAS_NOT_RUN') <= 0:
                raise
            pass 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:11,代碼來源:test_tsch.py

示例3: test_hSchRpcGetLastRunInfo

# 需要導入模塊: from impacket.dcerpc.v5 import tsch [as 別名]
# 或者: from impacket.dcerpc.v5.tsch import hSchRpcGetLastRunInfo [as 別名]
def test_hSchRpcGetLastRunInfo(self):
        dce, rpctransport = self.connect(self.stringBindingAtSvc, tsch.MSRPC_UUID_TSCHS)
        try:
            resp = tsch.hSchRpcGetLastRunInfo(dce, '\\Microsoft\\Windows\\Defrag\\ScheduledDefrag')
            resp.dump()
        except Exception as e:
            if str(e).find('SCHED_S_TASK_HAS_NOT_RUN') <= 0:
                raise
            pass 
開發者ID:Coalfire-Research,項目名稱:Slackor,代碼行數:11,代碼來源:test_tsch.py

示例4: doStuff

# 需要導入模塊: from impacket.dcerpc.v5 import tsch [as 別名]
# 或者: from impacket.dcerpc.v5.tsch import hSchRpcGetLastRunInfo [as 別名]
def doStuff(self, command):
        dce = self.__rpctransport.get_dce_rpc()
        dce.set_credentials(*self.__rpctransport.get_credentials())
        dce.connect()
        #dce.set_auth_level(ntlm.NTLM_AUTH_PKT_PRIVACY)
        dce.bind(tsch.MSRPC_UUID_TSCHS)
        tmpName = gen_random_string(8)
        tmpFileName = tmpName + '.tmp'

        xml = self.gen_xml(command)
        taskCreated = False
        self.logger.debug('Creating task \\{}'.format(tmpName))
        tsch.hSchRpcRegisterTask(dce, '\\{}'.format(tmpName), xml, tsch.TASK_CREATE, NULL, tsch.TASK_LOGON_NONE)
        taskCreated = True

        self.logger.debug('Running task \\{}'.format(tmpName))
        tsch.hSchRpcRun(dce, '\\{}'.format(tmpName))

        done = False
        while not done:
            self.logger.debug('Calling SchRpcGetLastRunInfo for \\{}'.format(tmpName))
            resp = tsch.hSchRpcGetLastRunInfo(dce, '\\{}'.format(tmpName))
            if resp['pLastRuntime']['wYear'] != 0:
                done = True
            else:
                sleep(2)

        self.logger.debug('Deleting task \\{}'.format(tmpName))
        tsch.hSchRpcDelete(dce, '\\{}'.format(tmpName))
        taskCreated = False

        if taskCreated is True:
            tsch.hSchRpcDelete(dce, '\\{}'.format(tmpName))

            # Get output
        if self.noOutput:
            self.__outputBuffer = "Command executed with no output"
        elif self.fileless_output:
            self.get_output_fileless()
        else:
            self.get_output()
        dce.disconnect() 
開發者ID:m8r0wn,項目名稱:ActiveReign,代碼行數:44,代碼來源:atexec.py


注:本文中的impacket.dcerpc.v5.tsch.hSchRpcGetLastRunInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。