Skip to content

Commit

Permalink
Clean code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinhardy committed Feb 3, 2021
1 parent 49c8d01 commit 14b183b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
22 changes: 8 additions & 14 deletions SIDGuesser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def __init__(self, args, SIDFile, timeSleep=0):
self.args['SYSDBA'] = False
self.args['SYSOPER'] = False
self.timeSleep = timeSleep
self.NO_GOOD_SID_STRING_LIST = ["listener does not currently know of service requested","listener does not currently know of SID","connection to server failed"]
self.NO_GOOD_SID_STRING_LIST = ["listener does not currently know of service requested",
"listener does not currently know of SID",
"connection to server failed"]

def getValidSIDs(self):
'''
Expand All @@ -40,22 +42,15 @@ def appendValideSID (self, sid):
if sid not in self.valideSIDS:
self.valideSIDS.append(sid)

def __setUserAndPassword__(self):
'''
User and password random
'''
self.args['user'] = self.__generateRandomString__(nb=10)
self.args['password'] = self.__generateRandomString__(nb=10)


def __loadSIDsFromFile__(self):
'''
return list containing SIDS
'''
sids = []
logging.info('Load SIDS stored in the {0} file'.format(self.SIDFile))
f = open(self.SIDFile)
for l in f: sids.append(l.replace('\n','').replace('\t',''))
for l in f:
sids.append(l.replace('\n','').replace('\t',''))
f.close()
return sorted(sids)

Expand All @@ -64,9 +59,8 @@ def __testIfAGoodSID__(self):
Test if it is a good SID
'''
no_good_sid_found = False
self.__setUserAndPassword__()
self.__generateConnectionString__()
logging.debug("Try to connect with the {0} SID ({1})".format(self.args['sid'],self.args['connectionStr']))
self.__generateConnectionString__(username=self.__generateRandomString__(nb=15), password=self.__generateRandomString__(nb=5))
logging.debug("Try to connect with the {0} SID ({1})".format(self.args['sid'], self.args['connectionStr']))
status = self.connection()
if self.__needRetryConnection__(status) == True:
status = self.__retryConnect__(nbTry=4)
Expand Down Expand Up @@ -102,7 +96,7 @@ def searchKnownSIDs(self):

def bruteforceSIDs(self, size=4, charset=string.ascii_uppercase):
'''
Bruteforce_sid
Bruteforce SID
'''
self.args['print'].subtitle("Searching valid SIDs thanks to a brute-force attack on {2} chars now ({0}:{1})".format(self.args['server'], self.args['port'], size))
pbar,nb = self.getStandardBarStarted(len(charset)**size), 0
Expand Down
1 change: 1 addition & 0 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def stringToLinePadded(string, padValue=" "):

def generateRandomString (length=20):
'''
Get a Random upper case string
'''
return ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(length))

Expand Down

0 comments on commit 14b183b

Please sign in to comment.