本文整理汇总了Python中impacket.LOG.debug方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.debug方法的具体用法?Python LOG.debug怎么用?Python LOG.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类impacket.LOG
的用法示例。
在下文中一共展示了LOG.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getBootKey
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def getBootKey(self):
bootKey = ''
ans = rrp.hOpenLocalMachine(self.__rrp)
self.__regHandle = ans['phKey']
for key in ['JD','Skew1','GBG','Data']:
LOG.debug('Retrieving class info for %s'% key)
ans = rrp.hBaseRegOpenKey(self.__rrp, self.__regHandle, 'SYSTEM\\CurrentControlSet\\Control\\Lsa\\%s' % key)
keyHandle = ans['phkResult']
ans = rrp.hBaseRegQueryInfoKey(self.__rrp,keyHandle)
bootKey = bootKey + ans['lpClassOut'][:-1]
rrp.hBaseRegCloseKey(self.__rrp, keyHandle)
transforms = [ 8, 5, 4, 2, 11, 9, 13, 3, 0, 6, 1, 12, 14, 10, 15, 7 ]
bootKey = unhexlify(bootKey)
for i in xrange(len(bootKey)):
self.__bootKey += bootKey[transforms[i]]
LOG.info('Target system bootKey: 0x%s' % hexlify(self.__bootKey))
return self.__bootKey
示例2: checkNoLMHashPolicy
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def checkNoLMHashPolicy(self):
LOG.debug('Checking NoLMHash Policy')
ans = rrp.hOpenLocalMachine(self.__rrp)
self.__regHandle = ans['phKey']
ans = rrp.hBaseRegOpenKey(self.__rrp, self.__regHandle, 'SYSTEM\\CurrentControlSet\\Control\\Lsa')
keyHandle = ans['phkResult']
try:
dataType, noLMHash = rrp.hBaseRegQueryValue(self.__rrp, keyHandle, 'NoLmHash')
except:
noLMHash = 0
if noLMHash != 1:
LOG.debug('LMHashes are being stored')
return False
LOG.debug('LMHashes are NOT being stored')
return True
示例3: getHBootKey
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def getHBootKey(self):
LOG.debug('Calculating HashedBootKey from SAM')
QWERTY = "!@#$%^&*()qwertyUIOPAzxcvbnmQQQQQQQQQQQQ)(*@&%\0"
DIGITS = "0123456789012345678901234567890123456789\0"
F = self.getValue(ntpath.join('SAM\Domains\Account','F'))[1]
domainData = DOMAIN_ACCOUNT_F(F)
rc4Key = self.MD5(domainData['Key0']['Salt'] + QWERTY + self.__bootKey + DIGITS)
rc4 = ARC4.new(rc4Key)
self.__hashedBootKey = rc4.encrypt(domainData['Key0']['Key']+domainData['Key0']['CheckSum'])
# Verify key with checksum
checkSum = self.MD5( self.__hashedBootKey[:16] + DIGITS + self.__hashedBootKey[:16] + QWERTY)
if checkSum != self.__hashedBootKey[16:]:
raise Exception('hashedBootKey CheckSum failed, Syskey startup password probably in use! :(')
示例4: mountDB
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def mountDB(self):
LOG.debug("Mounting DB...")
if self.__isRemote is True:
self.__DB = self.__fileName
self.__DB.open()
else:
self.__DB = open(self.__fileName,"rb")
mainHeader = self.getPage(-1)
self.__DBHeader = ESENT_DB_HEADER(mainHeader)
self.__pageSize = self.__DBHeader['PageSize']
self.__DB.seek(0,2)
self.__totalPages = (self.__DB.tell() / self.__pageSize) -2
LOG.debug("Database Version:0x%x, Revision:0x%x"% (self.__DBHeader['Version'], self.__DBHeader['FileFormatRevision']))
LOG.debug("Page Size: %d" % self.__pageSize)
LOG.debug("Total Pages in file: %d" % self.__totalPages)
self.parseCatalog(CATALOG_PAGE_NUMBER)
示例5: getBootKey
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def getBootKey(self):
# Local Version whenever we are given the files directly
bootKey = ''
tmpKey = ''
winreg = winregistry.Registry(self.__systemHive, False)
# We gotta find out the Current Control Set
currentControlSet = winreg.getValue('\\Select\\Current')[1]
currentControlSet = "ControlSet%03d" % currentControlSet
for key in ['JD', 'Skew1', 'GBG', 'Data']:
LOG.debug('Retrieving class info for %s' % key)
ans = winreg.getClass('\\%s\\Control\\Lsa\\%s' % (currentControlSet, key))
digit = ans[:16].decode('utf-16le')
tmpKey = tmpKey + digit
transforms = [8, 5, 4, 2, 11, 9, 13, 3, 0, 6, 1, 12, 14, 10, 15, 7]
tmpKey = unhexlify(tmpKey)
for i in xrange(len(tmpKey)):
bootKey += tmpKey[transforms[i]]
LOG.info('Target system bootKey: 0x%s' % hexlify(bootKey))
return bootKey
示例6: getCredential
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def getCredential(self, server, anySPN=True):
for c in self.credentials:
if c['server'].prettyPrint().upper() == server.upper():
LOG.debug('Returning cached credential for %s' % c['server'].prettyPrint().upper())
return c
LOG.debug('SPN %s not found in cache' % server.upper())
if anySPN is True:
LOG.debug('AnySPN is True, looking for another suitable SPN')
for c in self.credentials:
# Let's search for any TGT/TGS that matches the server w/o the SPN's service type, returns
# the first one
if c['server'].prettyPrint().find('/') >=0:
if c['server'].prettyPrint().upper().split('/')[1] == server.upper().split('/')[1]:
LOG.debug('Returning cached credential for %s' % c['server'].prettyPrint().upper())
return c
return None
示例7: __init__
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def __init__(self,request, client_address, server):
self.server = server
self.protocol_version = 'HTTP/1.1'
self.challengeMessage = None
self.target = None
self.client = None
self.machineAccount = None
self.machineHashes = None
self.domainIp = None
self.authUser = None
self.wpad = 'function FindProxyForURL(url, host){if ((host == "localhost") || shExpMatch(host, "localhost.*") ||' \
'(host == "127.0.0.1")) return "DIRECT"; if (dnsDomainIs(host, "%s")) return "DIRECT"; ' \
'return "PROXY %s:80; DIRECT";} '
if self.server.config.mode != 'REDIRECT':
if self.server.config.target is None:
# Reflection mode, defaults to SMB at the target, for now
self.server.config.target = TargetsProcessor(singleTarget='SMB://%s:445/' % client_address[0])
self.target = self.server.config.target.getTarget(self.server.config.randomtargets)
LOG.info("HTTPD: Received connection from %s, attacking target %s://%s" % (client_address[0] ,self.target.scheme, self.target.netloc))
try:
http.server.SimpleHTTPRequestHandler.__init__(self,request, client_address, server)
except Exception as e:
LOG.debug("Exception:", exc_info=True)
LOG.error(str(e))
示例8: generateImpacketCert
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def generateImpacketCert(certname='/tmp/impacket.crt'):
# Create a private key
pkey = crypto.PKey()
pkey.generate_key(crypto.TYPE_RSA, 2048)
# Create the certificate
cert = crypto.X509()
cert.gmtime_adj_notBefore(0)
# Valid for 5 years
cert.gmtime_adj_notAfter(60*60*24*365*5)
subj = cert.get_subject()
subj.CN = 'impacket'
cert.set_pubkey(pkey)
cert.sign(pkey, "sha256")
# We write both from the same file
with open(certname, 'w') as certfile:
certfile.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey).decode('utf-8'))
certfile.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode('utf-8'))
LOG.debug('Wrote certificate to %s' % certname)
# Class to wrap the client socket in SSL when serving as a SOCKS server
示例9: transferResponse
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def transferResponse(self):
data = self.relaySocket.recv(self.packetSize)
headerSize = data.find(EOL+EOL)
headers = self.getHeaders(data)
try:
bodySize = int(headers['content-length'])
readSize = len(data)
# Make sure we send the entire response, but don't keep it in memory
self.socksSocket.send(data)
while readSize < bodySize + headerSize + 4:
data = self.relaySocket.recv(self.packetSize)
readSize += len(data)
self.socksSocket.send(data)
except KeyError:
try:
if headers['transfer-encoding'] == 'chunked':
# Chunked transfer-encoding, bah
LOG.debug('Server sent chunked encoding - transferring')
self.transferChunked(data, headers)
else:
# No body in the response, send as-is
self.socksSocket.send(data)
except KeyError:
# No body in the response, send as-is
self.socksSocket.send(data)
示例10: transferChunked
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def transferChunked(self, data, headers):
headerSize = data.find(EOL+EOL)
self.socksSocket.send(data[:headerSize + 4])
body = data[headerSize + 4:]
# Size of the chunk
datasize = int(body[:body.find(EOL)], 16)
while datasize > 0:
# Size of the total body
bodySize = body.find(EOL) + 2 + datasize + 2
readSize = len(body)
# Make sure we send the entire response, but don't keep it in memory
self.socksSocket.send(body)
while readSize < bodySize:
maxReadSize = bodySize - readSize
body = self.relaySocket.recv(min(self.packetSize, maxReadSize))
readSize += len(body)
self.socksSocket.send(body)
body = self.relaySocket.recv(self.packetSize)
datasize = int(body[:body.find(EOL)], 16)
LOG.debug('Last chunk received - exiting chunked transfer')
self.socksSocket.send(body)
示例11: tunnelConnection
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def tunnelConnection(self):
keyword = ''
tag = ''
while True:
try:
data = self.socksSocket.recv(self.packetSize)
except Exception, e:
# Socks socket (client) closed connection or something else. Not fatal for killing the existing relay
print keyword, tag
LOG.debug('IMAP: sockSocket recv(): %s' % (str(e)))
break
# If this returns with an empty string, it means the socket was closed
if data == '':
break
# Set the new keyword, unless it is false, then break out of the function
result = self.processTunnelData(keyword, tag, data)
if result is False:
break
# If its not false, it's a tuple with the keyword and tag
keyword, tag = result
示例12: keepAliveTimer
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def keepAliveTimer(server):
LOG.debug('KeepAlive Timer reached. Updating connections')
for target in server.activeRelays.keys():
for port in server.activeRelays[target].keys():
# Now cycle through the users
for user in server.activeRelays[target][port].keys():
if user != 'data' and user != 'scheme':
# Let's call the keepAlive method for the handler to keep the connection alive
if server.activeRelays[target][port][user]['inUse'] is False:
LOG.debug('Calling keepAlive() for %s@%s:%s' % (user, target, port))
try:
server.activeRelays[target][port][user]['protocolClient'].keepAlive()
except Exception, e:
LOG.debug('SOCKS: %s' % str(e))
if str(e).find('Broken pipe') >= 0 or str(e).find('reset by peer') >=0 or \
str(e).find('Invalid argument') >= 0 or str(e).find('Server not connected') >=0:
# Connection died, taking out of the active list
del (server.activeRelays[target][port][user])
if len(server.activeRelays[target][port].keys()) == 1:
del (server.activeRelays[target][port])
LOG.debug('Removing active relay for %s@%s:%s' % (user, target, port))
else:
LOG.debug('Skipping %s@%s:%s since it\'s being used at the moment' % (user, target, port))
示例13: DRSCrackNames
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def DRSCrackNames(self, formatOffered=drsuapi.DS_NAME_FORMAT.DS_DISPLAY_NAME,
formatDesired=drsuapi.DS_NAME_FORMAT.DS_FQDN_1779_NAME, name=''):
if self.__drsr is None:
self.__connectDrds()
LOG.debug('Calling DRSCrackNames for %s ' % name)
resp = drsuapi.hDRSCrackNames(self.__drsr, self.__hDrs, 0, formatOffered, formatDesired, (name,))
return resp
示例14: __checkServiceStatus
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def __checkServiceStatus(self):
# Open SC Manager
ans = scmr.hROpenSCManagerW(self.__scmr)
self.__scManagerHandle = ans['lpScHandle']
# Now let's open the service
ans = scmr.hROpenServiceW(self.__scmr, self.__scManagerHandle, self.__serviceName)
self.__serviceHandle = ans['lpServiceHandle']
# Let's check its status
ans = scmr.hRQueryServiceStatus(self.__scmr, self.__serviceHandle)
if ans['lpServiceStatus']['dwCurrentState'] == scmr.SERVICE_STOPPED:
LOG.info('Service %s is in stopped state'% self.__serviceName)
self.__shouldStop = True
self.__started = False
elif ans['lpServiceStatus']['dwCurrentState'] == scmr.SERVICE_RUNNING:
LOG.debug('Service %s is already running'% self.__serviceName)
self.__shouldStop = False
self.__started = True
else:
raise Exception('Unknown service state 0x%x - Aborting' % ans['CurrentState'])
# Let's check its configuration if service is stopped, maybe it's disabled :s
if self.__started is False:
ans = scmr.hRQueryServiceConfigW(self.__scmr,self.__serviceHandle)
if ans['lpServiceConfig']['dwStartType'] == 0x4:
LOG.info('Service %s is disabled, enabling it'% self.__serviceName)
self.__disabled = True
scmr.hRChangeServiceConfigW(self.__scmr, self.__serviceHandle, dwStartType = 0x3)
LOG.info('Starting service %s' % self.__serviceName)
scmr.hRStartServiceW(self.__scmr,self.__serviceHandle)
time.sleep(1)
示例15: saveSECURITY
# 需要导入模块: from impacket import LOG [as 别名]
# 或者: from impacket.LOG import debug [as 别名]
def saveSECURITY(self):
LOG.debug('Saving remote SECURITY database')
return self.__retrieveHive('SECURITY')