Skip to content

Commit

Permalink
optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
SirDank committed Sep 9, 2023
1 parent ed9466b commit d79ee77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
29 changes: 13 additions & 16 deletions dankware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,20 @@ def random_ip() -> str:
- Follows: https://github.com/robertdavidgraham/masscan/blob/master/data/exclude.conf
"""

excluded_prefixes_one = {'6':'','7':'','10':'','11':'','21':'','22':'','26':'','28':'','29':'','30':'','33':'','55':'','127':'','136':'','205':'','214':'','215':''}
excluded_prefixes_two = {'23.27':'','31.25':'','50.117':'','74.115':'','75.127':'','81.87':'','100.64':'','128.16':'','128.40':'','128.41':'','128.86':'','128.232':'','128.240':'','128.243':'','129.11':'','129.12':'','129.31':'','129.67':'','129.123':'','129.169':'','129.215':'','129.234':'','130.88':'','130.159':'','130.209':'','130.246':'','131.111':'','131.227':'','131.231':'','131.251':'','134.36':'','134.83':'','134.151':'','134.219':'','134.220':'','134.225':'','136.148':'','136.156':'','137.44':'','137.50':'','137.73':'','137.108':'','137.195':'','137.222':'','137.253':'','138.38':'','138.40':'','138.250':'','138.253':'','139.133':'','139.153':'','139.166':'','139.184':'','139.222':'','140.97':'','141.163':'','141.241':'','142.111':'','142.252':'','143.52':'','143.117':'','143.167':'','143.210':'','143.234':'','144.32':'','144.39':'','144.82':'','144.124':'','144.173':'','146.87':'','146.97':'','146.169':'','146.176':'','146.179':'','146.191':'','146.227':'','147.143':'','147.188':'','147.197':'','148.79':'','148.88':'','148.197':'','149.155':'','149.170':'','150.204':'','152.71':'','152.78':'','152.105':'','153.11':'','155.198':'','155.245':'','157.140':'','157.228':'','158.94':'','158.125':'','158.143':'','158.223':'','159.92':'','160.5':'','160.9':'','161.73':'','161.74':'','161.76':'','161.112':'','163.1':'','163.119':'','163.160':'','163.167':'','164.11':'','165.160':'','166.88':'','169.254':'','172.252':'','192.168':'','192.177':'','192.186':'','193.60':'','194.66':'','194.80':'','195.194':'','198.18':'','205.164':'','212.121':'','212.219':''}
excluded_prefixes_three = {'4.53.201':'','5.152.179':'','8.12.162':'','8.12.163':'','8.12.164':'','8.14.84':'','8.14.145':'','8.14.146':'','8.14.147':'','8.17.250':'','8.17.251':'','8.17.252':'','23.231.128':'','31.25.2':'','31.25.4':'','37.72.112':'','37.72.172':'','38.72.200':'','46.254.200':'','50.93.192':'','50.93.193':'','50.93.194':'','50.93.195':'','50.93.196':'','50.93.197':'','50.115.128':'','50.118.128':'','63.141.222':'','64.62.253':'','64.92.96':'','64.145.79':'','64.145.82':'','64.158.146':'','65.49.24':'','65.49.93':'','65.162.192':'','66.79.160':'','66.160.191':'','68.68.96':'','69.46.64':'','69.176.80':'','72.13.80':'','72.52.76':'','74.82.43':'','74.82.160':'','74.114.88':'','74.115.2':'','74.115.4':'','74.122.100':'','85.12.64':'','89.207.208':'','92.245.224':'','103.251.91':'','108.171.32':'','108.171.42':'','108.171.52':'','108.171.62':'','118.193.78':'','130.93.16':'','132.206.9':'','132.206.123':'','132.206.125':'','141.170.64':'','141.170.96':'','141.170.100':'','146.82.55.93':'','149.54.136':'','149.54.152':'','159.86.128':'','173.245.64':'','173.245.194':'','173.245.220':'','173.252.192':'','178.18.16':'','178.18.26':'','178.18.27':'','178.18.28':'','178.18.29':'','183.182.22':'','185.83.168':'','192.12.72':'','192.18.195':'','192.35.172':'','192.41.104':'','192.41.112':'','192.41.128':'','192.68.153':'','192.76.6':'','192.76.8':'','192.76.16':'','192.76.32':'','192.82.153':'','192.84.5':'','192.84.75':'','192.84.76':'','192.84.80':'','192.84.212':'','192.88.9':'','192.88.10':'','192.88.99':'','192.92.114':'','192.94.235':'','192.100.78':'','192.100.154':'','192.107.168':'','192.108.120':'','192.124.46':'','192.133.244':'','192.149.111':'','192.150.180':'','192.150.184':'','192.153.213':'','192.155.160':'','192.156.162':'','192.160.194':'','192.171.128':'','192.171.192':'','192.173.1':'','192.173.2':'','192.173.4':'','192.173.128':'','192.188.157':'','192.188.158':'','192.190.201':'','192.190.202':'','192.195.42':'','192.195.105':'','192.195.116':'','192.195.118':'','192.249.64':'','192.250.240':'','193.32.22':'','193.37.225':'','193.37.240':'','193.38.143':'','193.39.80':'','193.39.172':'','193.39.212':'','193.107.116':'','193.130.15':'','193.133.28':'','193.138.86':'','194.32.32':'','194.35.93':'','194.35.186':'','194.35.192':'','194.35.241':'','194.36.1':'','194.36.2':'','194.36.121':'','194.36.152':'','194.60.218':'','194.110.214':'','194.187.32':'','198.12.120':'','198.12.121':'','198.12.122':'','198.51.100':'','198.144.240':'','199.33.120':'','199.33.124':'','199.48.147':'','199.68.196':'','199.127.240':'','199.187.168':'','199.188.238':'','199.255.208':'','203.12.6':'','204.13.64':'','204.16.192':'','204.19.238':'','204.74.208':'','204.113.91':'','205.159.189':'','205.209.128':'','206.108.52':'','206.165.4':'','208.77.40':'','208.80.4':'','208.123.223':'','209.51.185':'','209.54.48':'','209.107.192':'','209.107.210':'','209.107.212':'','211.156.110':'','212.121.192':'','216.151.183':'','216.151.190':'','216.172.128':'','216.185.36':'','216.218.233':'','216.224.112':''}
excluded_prefixes_one = {'22', '10', '205', '30', '11', '55', '215', '29', '7', '6', '26', '214', '33', '21', '28', '127', '136'}
excluded_prefixes_two = {'161.73', '141.163', '143.52', '149.155', '139.222', '137.253', '157.228', '140.97', '146.87', '198.18', '129.169', '50.117', '146.227', '144.32', '134.83', '139.153', '160.5', '194.66', '212.219', '146.191', '129.11', '149.170', '129.67', '138.253', '134.36', '205.164', '192.177', '134.225', '139.133', '152.71', '136.148', '158.223', '137.222', '130.209', '172.252', '143.210', '164.11', '128.41', '147.143', '158.94', '192.168', '138.250', '158.125', '81.87', '134.219', '143.234', '144.82', '152.78', '128.243', '100.64', '130.246', '137.195', '152.105', '150.204', '141.241', '143.167', '139.166', '144.39', '161.74', '147.197', '163.160', '161.112', '136.156', '137.44', '143.117', '129.12', '134.220', '166.88', '134.151', '131.231', '31.25', '129.215', '153.11', '128.40', '142.111', '23.27', '75.127', '144.173', '148.79', '74.115', '192.186', '163.1', '146.176', '193.60', '129.123', '212.121', '142.252', '165.160', '146.97', '148.197', '131.251', '137.108', '163.167', '129.31', '163.119', '194.80', '130.88', '137.73', '147.188', '137.50', '130.159', '131.111', '148.88', '129.234', '131.227', '155.245', '159.92', '146.179', '169.254', '138.40', '144.124', '155.198', '139.184', '128.232', '157.140', '128.240', '158.143', '161.76', '195.194', '138.38', '128.86', '160.9', '146.169', '128.16'}
excluded_prefixes_three = {'8.17.250', '194.36.2', '199.187.168', '192.173.1', '216.151.190', '193.32.22', '72.52.76', '50.93.194', '178.18.29', '74.82.43', '192.84.75', '199.255.208', '208.80.4', '198.12.120', '192.153.213', '8.14.146', '64.158.146', '69.176.80', '192.160.194', '68.68.96', '23.231.128', '173.245.194', '192.84.212', '193.107.116', '198.12.121', '192.41.112', '8.12.162', '216.172.128', '108.171.52', '192.84.76', '173.252.192', '74.122.100', '50.93.197', '141.170.100', '192.173.128', '74.115.2', '209.107.212', '192.195.118', '178.18.28', '192.133.244', '192.68.153', '192.108.120', '194.35.186', '209.107.192', '192.173.4', '194.35.241', '204.113.91', '192.35.172', '193.37.225', '199.33.120', '108.171.32', '209.54.48', '203.12.6', '50.93.196', '50.93.195', '199.48.147', '50.115.128', '192.84.5', '192.171.128', '8.14.84', '192.88.99', '216.218.233', '194.35.192', '192.76.16', '64.145.82', '185.83.168', '74.114.88', '193.37.240', '66.79.160', '69.46.64', '193.39.172', '204.74.208', '192.92.114', '192.84.80', '132.206.125', '194.60.218', '198.144.240', '63.141.222', '192.149.111', '208.123.223', '192.156.162', '192.155.160', '193.39.80', '192.195.105', '50.118.128', '38.72.200', '146.82.55.93', '192.94.235', '132.206.9', '8.14.147', '8.17.251', '192.190.201', '132.206.123', '192.250.240', '50.93.192', '74.115.4', '141.170.96', '192.107.168', '178.18.27', '193.138.86', '198.51.100', '192.100.154', '206.108.52', '74.82.160', '192.76.8', '192.76.32', '37.72.112', '192.88.10', '194.36.121', '205.159.189', '192.18.195', '149.54.152', '103.251.91', '192.195.42', '194.110.214', '199.33.124', '204.16.192', '192.100.78', '178.18.26', '194.35.93', '37.72.172', '208.77.40', '64.92.96', '212.121.192', '192.76.6', '192.249.64', '192.124.46', '211.156.110', '159.86.128', '192.173.2', '192.171.192', '85.12.64', '89.207.208', '199.188.238', '108.171.62', '64.62.253', '31.25.4', '72.13.80', '118.193.78', '8.12.164', '65.162.192', '65.49.24', '130.93.16', '205.209.128', '141.170.64', '50.93.193', '192.150.180', '192.190.202', '5.152.179', '192.150.184', '173.245.64', '209.107.210', '206.165.4', '192.41.128', '65.49.93', '183.182.22', '193.133.28', '199.68.196', '198.12.122', '192.88.9', '209.51.185', '192.12.72', '193.38.143', '149.54.136', '216.151.183', '216.224.112', '192.188.157', '194.36.152', '192.188.158', '31.25.2', '8.17.252', '108.171.42', '192.41.104', '199.127.240', '64.145.79', '193.39.212', '216.185.36', '194.187.32', '8.12.163', '178.18.16', '204.19.238', '173.245.220', '8.14.145', '92.245.224', '192.82.153', '4.53.201', '194.32.32', '192.195.116', '46.254.200', '194.36.1', '66.160.191', '204.13.64', '193.130.15'}

while True:

first_octet = random.randint(1, 223)
if f"{first_octet}" in excluded_prefixes_one.keys(): continue
if f"{first_octet}" in excluded_prefixes_one: continue

second_octet = random.randint(0, 255)
if f"{first_octet}.{second_octet}" in excluded_prefixes_two.keys(): continue
if f"{first_octet}.{second_octet}" in excluded_prefixes_two: continue

third_octet = random.randint(0, 255)
if f"{first_octet}.{second_octet}.{third_octet}" in excluded_prefixes_three.keys(): continue
if f"{first_octet}.{second_octet}.{third_octet}" in excluded_prefixes_three: continue

fourth_octet = random.randint(0, 255)

Expand Down Expand Up @@ -389,16 +389,16 @@ def clr(text: str, preset: int = 1, colour_one: str = white, colour_two: str = r
"""

symbols = ['[', ']', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '|', '\\', ';', ':', "'", '"', ',', '.', '<', '>', '/', '?', '`', '~']
symbols = ('[', ']', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '|', '\\', ';', ':', "'", '"', ',', '.', '<', '>', '/', '?', '`', '~')

words_green = ['true', 'True', 'TRUE', 'online', 'Online', 'ONLINE', 'successfully', 'Successfully', 'SUCCESSFULLY', 'successful', 'Successful', 'SUCCESSFUL', 'success', 'Success', 'SUCCESS']
words_red = ['falsely', 'Falsely', 'FALSELY', 'false', 'False', 'FALSE', 'offline', 'Offline', 'OFFLINE', 'failures', 'Failures', 'FAILURES', 'failure', 'Failure', 'FAILURE', 'failed', 'Failed', 'FAILED', 'fail', 'Fail', 'FAIL']
words_green = ('true', 'True', 'TRUE', 'online', 'Online', 'ONLINE', 'successfully', 'Successfully', 'SUCCESSFULLY', 'successful', 'Successful', 'SUCCESSFUL', 'success', 'Success', 'SUCCESS')
words_red = ('falsely', 'Falsely', 'FALSELY', 'false', 'False', 'FALSE', 'offline', 'Offline', 'OFFLINE', 'failures', 'Failures', 'FAILURES', 'failure', 'Failure', 'FAILURE', 'failed', 'Failed', 'FAILED', 'fail', 'Fail', 'FAIL')

colours_to_replace = [Fore.BLACK, Fore.BLUE, Fore.CYAN, Fore.GREEN, Fore.MAGENTA, Fore.RED, Fore.WHITE, Fore.YELLOW, Style.BRIGHT, Style.RESET_ALL]
colours_alt = ["BBLACKK", "BBLUEE", "CCYANN", "GGREENN", "MMAGENTAA", "RREDD", "WWHITEE", "YYELLOWW", "BBRIGHTT", "RRESETT"]

bad_colours = ['BLACK', 'WHITE', 'LIGHTBLACK_EX', 'LIGHTWHITE_EX', 'RESET']
styles = [Style.BRIGHT, Style.DIM, Style.NORMAL]
bad_colours = ('BLACK', 'WHITE', 'LIGHTBLACK_EX', 'LIGHTWHITE_EX', 'RESET')
#styles = (Style.BRIGHT, Style.DIM, Style.NORMAL)

if colours == []:
codes = vars(Fore)
Expand Down Expand Up @@ -435,7 +435,7 @@ def clr(text: str, preset: int = 1, colour_one: str = white, colour_two: str = r

# random | TRUE, FALSE will not be coloured!

elif preset in [3, 4]:
elif preset in (3, 4):

text = [_ for _ in text]

Expand Down Expand Up @@ -833,10 +833,9 @@ def err(exc_info, mode = "default") -> str:

ex_type, ex_value, ex_traceback = exc_info
trace_back = extract_tb(ex_traceback)
stack_trace = []

if mode == "default":

stack_trace = []

for trace in trace_back:
filename = trace[0]
Expand All @@ -850,8 +849,6 @@ def err(exc_info, mode = "default") -> str:
report += "\n > Error Stack Trace: \n{}".format('\n'.join(stack_trace))

elif mode == "mini":

stack_trace = []

for trace in trace_back:
filename = trace[0]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

license = "MIT",
name = "dankware",
version = "3.4.3",
version = "3.4.4",
author = "SirDank",

author_email = "[email protected]",
Expand Down

0 comments on commit d79ee77

Please sign in to comment.