Skip to content

Commit

Permalink
Fix the warning added to Python 3.8: SyntaxWarning: "is" with a liter…
Browse files Browse the repository at this point in the history
…al. Did you mean "=="?
  • Loading branch information
slasyz committed Nov 28, 2019
1 parent 8f5ae81 commit 0a7ba18
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/GetADUsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def run(self):
password = password + '@' + address.rpartition('@')[0]
address = address.rpartition('@')[2]

if domain is '':
if domain == '':
logging.critical('Domain should be specified!')
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion examples/GetNPUsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def request_multiple_TGTs(self, usernames):
password = password + '@' + address.rpartition('@')[0]
address = address.rpartition('@')[2]

if domain is '':
if domain == '':
logging.critical('Domain should be specified!')
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion examples/GetUserSPNs.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def run(self):
password = password + '@' + address.rpartition('@')[0]
address = address.rpartition('@')[2]

if userDomain is '':
if userDomain == '':
logging.critical('userDomain should be specified!')
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion examples/addcomputer.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def run(self):
'')

try:
if domain is None or domain is '':
if domain is None or domain == '':
logging.critical('Domain should be specified!')
sys.exit(1)

Expand Down
6 changes: 3 additions & 3 deletions examples/goldenPac.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ def exploit(self):
# Windows XP). So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if self.__lmhash is '' and self.__nthash is '':
if self.__lmhash == '' and self.__nthash == '':
from impacket.ntlm import compute_lmhash, compute_nthash
self.__lmhash = compute_lmhash(self.__password)
self.__nthash = compute_nthash(self.__password)
Expand Down Expand Up @@ -991,7 +991,7 @@ def exploit(self):
# Windows XP). So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if self.__lmhash is '' and self.__nthash is '':
if self.__lmhash == '' and self.__nthash == '':
from impacket.ntlm import compute_lmhash, compute_nthash
self.__lmhash = compute_lmhash(self.__password)
self.__nthash = compute_nthash(self.__password)
Expand Down Expand Up @@ -1116,7 +1116,7 @@ def exploit(self):
password = password + '@' + address.rpartition('@')[0]
address = address.rpartition('@')[2]

if domain is '':
if domain == '':
logging.critical('Domain should be specified!')
sys.exit(1)

Expand Down
4 changes: 2 additions & 2 deletions examples/ntfs-read.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def read(self,offset,length):
if offset % self.ClusterSize:
# Read the whole VCN
bufTemp = self.readVCN(vcnToStart, 1)
if bufTemp is b'':
if bufTemp == b'':
# Something went wrong
return None
buf = bufTemp[offset % self.ClusterSize:]
Expand All @@ -513,7 +513,7 @@ def read(self,offset,length):
if curLength // self.ClusterSize:
# Yep.. so let's read full clusters
bufTemp = self.readVCN(vcnToStart, curLength // self.ClusterSize)
if bufTemp is b'':
if bufTemp == b'':
# Something went wrong
return None
if len(bufTemp) > curLength:
Expand Down
6 changes: 3 additions & 3 deletions examples/raiseChild.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ def raiseUp(self, childName, childCreds, parentName):
# Windows XP). So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if childCreds['lmhash'] is '' and childCreds['nthash'] is '':
if childCreds['lmhash'] == '' and childCreds['nthash'] == '':
from impacket.ntlm import compute_lmhash, compute_nthash
childCreds['lmhash'] = compute_lmhash(childCreds['password'])
childCreds['nthash'] = compute_nthash(childCreds['password'])
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def raiseUp(self, childName, childCreds, parentName):
# Windows XP). So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if childCreds['lmhash'] is '' and childCreds['nthash'] is '':
if childCreds['lmhash'] == '' and childCreds['nthash'] == '':
from impacket.ntlm import compute_lmhash, compute_nthash
childCreds['lmhash'] = compute_lmhash(childCreds['password'])
childCreds['nthash'] = compute_nthash(childCreds['password'])
Expand Down Expand Up @@ -1271,7 +1271,7 @@ def exploit(self):
else:
logging.getLogger().setLevel(logging.INFO)

if domain is '':
if domain == '':
logging.critical('Domain should be specified!')
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion impacket/dcerpc/v5/dcom/wmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,7 @@ def marshalMe(self):
if itemValue is None:
ndTable |= 3 << (2*i)
else:
if itemValue is '':
if itemValue == '':
ndTable |= 1 << (2*i)
valueTable += pack('<L', 0)
else:
Expand Down
4 changes: 2 additions & 2 deletions impacket/dcerpc/v5/ndr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ def getData(self, soFar = 0):
data += b'\xbd'*pad
soFar += pad

if self.structure is ():
if self.structure == ():
return data

for fieldName, fieldTypeOrClass in self.structure:
Expand Down Expand Up @@ -1420,7 +1420,7 @@ def fromString(self, data, soFar = 0 ):
data = data[pad:]
soFar += pad

if self.structure is ():
if self.structure == ():
return soFar-soFar0

for fieldName, fieldTypeOrClass in self.structure:
Expand Down
8 changes: 4 additions & 4 deletions impacket/krb5/kerberosv5.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def getKerberosTGT(clientName, password, domain, lmhash, nthash, aesKey='', kdcH
r = sendReceive(message, domain, kdcHost)
except KerberosError as e:
if e.getErrorCode() == constants.ErrorCodes.KDC_ERR_ETYPE_NOSUPP.value:
if supportedCiphers[0] in (constants.EncryptionTypes.aes128_cts_hmac_sha1_96.value, constants.EncryptionTypes.aes256_cts_hmac_sha1_96.value) and aesKey is '':
if supportedCiphers[0] in (constants.EncryptionTypes.aes128_cts_hmac_sha1_96.value, constants.EncryptionTypes.aes256_cts_hmac_sha1_96.value) and aesKey == '':
supportedCiphers = (int(constants.EncryptionTypes.rc4_hmac.value),)
seq_set_iter(reqBody, 'etype', supportedCiphers)
message = encoder.encode(asReq)
Expand Down Expand Up @@ -299,7 +299,7 @@ def getKerberosTGT(clientName, password, domain, lmhash, nthash, aesKey='', kdcH
tgt = sendReceive(encoder.encode(asReq), domain, kdcHost)
except Exception as e:
if str(e).find('KDC_ERR_ETYPE_NOSUPP') >= 0:
if lmhash is b'' and nthash is b'' and (aesKey is b'' or aesKey is None):
if lmhash == b'' and nthash == b'' and (aesKey == b'' or aesKey is None):
from impacket.ntlm import compute_lmhash, compute_nthash
lmhash = compute_lmhash(password)
nthash = compute_nthash(password)
Expand Down Expand Up @@ -576,7 +576,7 @@ def getKerberosType1(username, password, domain, lmhash, nthash, aesKey='', TGT
# So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if lmhash is b'' and nthash is b'' and (aesKey is b'' or aesKey is None) and TGT is None and TGS is None:
if lmhash == b'' and nthash == b'' and (aesKey == b'' or aesKey is None) and TGT is None and TGS is None:
from impacket.ntlm import compute_lmhash, compute_nthash
LOG.debug('Got KDC_ERR_ETYPE_NOSUPP, fallback to RC4')
lmhash = compute_lmhash(password)
Expand Down Expand Up @@ -604,7 +604,7 @@ def getKerberosType1(username, password, domain, lmhash, nthash, aesKey='', TGT
# So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if lmhash is b'' and nthash is b'' and (aesKey is b'' or aesKey is None) and TGT is None and TGS is None:
if lmhash == b'' and nthash == b'' and (aesKey == b'' or aesKey is None) and TGT is None and TGS is None:
from impacket.ntlm import compute_lmhash, compute_nthash
LOG.debug('Got KDC_ERR_ETYPE_NOSUPP, fallback to RC4')
lmhash = compute_lmhash(password)
Expand Down
2 changes: 1 addition & 1 deletion impacket/smbconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def kerberosLogin(self, user, password, domain='', lmhash='', nthash='', aesKey=
# So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if lmhash is '' and nthash is '' and (aesKey is '' or aesKey is None) and TGT is None and TGS is None:
if lmhash == '' and nthash == '' and (aesKey == '' or aesKey is None) and TGT is None and TGS is None:
lmhash = compute_lmhash(password)
nthash = compute_nthash(password)
else:
Expand Down
4 changes: 2 additions & 2 deletions impacket/tds.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ def kerberosLogin(self, database, username, password='', domain='', hashes=None,
# So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if lmhash is '' and nthash is '' and (aesKey is '' or aesKey is None) and TGT is None and TGS is None:
if lmhash == '' and nthash == '' and (aesKey == '' or aesKey is None) and TGT is None and TGS is None:
from impacket.ntlm import compute_lmhash, compute_nthash
LOG.debug('Got KDC_ERR_ETYPE_NOSUPP, fallback to RC4')
lmhash = compute_lmhash(password)
Expand Down Expand Up @@ -810,7 +810,7 @@ def kerberosLogin(self, database, username, password='', domain='', hashes=None,
# So, if that's the case we'll force using RC4 by converting
# the password to lm/nt hashes and hope for the best. If that's already
# done, byebye.
if lmhash is '' and nthash is '' and (aesKey is '' or aesKey is None) and TGT is None and TGS is None:
if lmhash == '' and nthash == '' and (aesKey == '' or aesKey is None) and TGT is None and TGS is None:
from impacket.ntlm import compute_lmhash, compute_nthash
LOG.debug('Got KDC_ERR_ETYPE_NOSUPP, fallback to RC4')
lmhash = compute_lmhash(password)
Expand Down
6 changes: 3 additions & 3 deletions tests/SMB_RPC/test_drsuapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def test_DRSGetNCChanges(self):
# thisObject.dump()
# print thisObject['Entinf']['pName']['StringName']
# thisObject = nextObject
# if nextObject is '':
# if nextObject == '':
# done = True
# request['pmsgIn']['V8']['uuidInvocIdSrc'] = resp['pmsgOut']['V6']['uuidInvocIdSrc']
# request['pmsgIn']['V8']['usnvecFrom'] = resp['pmsgOut']['V6']['usnvecTo']
Expand All @@ -345,7 +345,7 @@ def getMoreData(self, dce, request, resp):
#print '\n'
#print thisObject['Entinf']['pName']['StringName']
# thisObject = nextObject
# if nextObject is '':
# if nextObject == '':
# done = True

request['pmsgIn']['V10']['uuidInvocIdSrc'] = resp['pmsgOut']['V6']
Expand Down Expand Up @@ -446,7 +446,7 @@ def test_DRSGetNCChanges2(self):
# #print '\n'
# #print thisObject['Entinf']['pName']['StringName']
# thisObject = nextObject
# if nextObject is '':
# if nextObject == '':
# done = True
#
# print "B"*80
Expand Down

0 comments on commit 0a7ba18

Please sign in to comment.