Skip to content

Commit

Permalink
scanning error for root directory fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yunemse48 committed Sep 2, 2021
1 parent c3e30f7 commit b67df4e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions 403bypasser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", type=str, help="single URL to scan, ex: http:https://example.com")
parser.add_argument("-U", "--urllist", type=str, help="path to list of URLs, ex: urllist.txt")
parser.add_argument("-d", "--dir", type=str, help="Single directory to scan, ex: /admin")
parser.add_argument("-d", "--dir", type=str, help="Single directory to scan, ex: /admin", nargs="?", const="/")
parser.add_argument("-D", "--dirlist", type=str, help="path to list of directories, ex: dirlist.txt")

args = parser.parse_args()
Expand Down Expand Up @@ -75,7 +75,7 @@ def checkDir(self):
if not self.dir.startswith("/"):
self.dir = "/" + self.dir

if self.dir.endswith("/"):
if self.dir.endswith("/") and self.dir != "/":
self.dir = self.dir.rstrip("/")
self.dirs.append(self.dir)
elif self.dirlist:
Expand All @@ -89,8 +89,7 @@ def checkDir(self):
for x in temp:
self.dirs.append(x.strip())
else:
print("You must specify a directory name or path to list! (-d or -D)\n")
sys.exit()
self.dir = "/"


class PathRepository():
Expand Down Expand Up @@ -212,10 +211,10 @@ def manipulatePath(self):
print(target_address + " " * remaining + info)

results.append(target_address + " " * remaining + info_pure)
# time.sleep(0.05)
time.sleep(0.05)

self.writeToFile(results)
# time.sleep(1)
time.sleep(1)
self.manipulateHeaders()

def manipulateHeaders(self):
Expand All @@ -237,10 +236,10 @@ def manipulateHeaders(self):
print(f"Header= {header}")

results.append("\n" + target_address + " " * remaining + info_pure + f"\nHeader= {header}")
# time.sleep(0.05)
time.sleep(0.05)
self.writeToFile(results)

# time.sleep(1)
time.sleep(1)

results_2 = []
for header in self.dirObject.rewriteHeaders:
Expand All @@ -258,7 +257,7 @@ def manipulateHeaders(self):
print(f"Header= {header}")

results_2.append("\n" + target_address + " " * remaining + info_pure + f"\nHeader= {header}")
# time.sleep(0.05)
time.sleep(0.05)

self.writeToFile(results_2)

Expand All @@ -271,7 +270,10 @@ def __init__(self, urllist, dirlist):
def initialise(self):
for u in self.urllist:
for d in self.dirlist:
dir_objname = d.lstrip("/")
if d != "/":
dir_objname = d.lstrip("/")
else:
dir_objname = "_rootPath"
locals()[dir_objname] = PathRepository(d)
domain_name = tldextract.extract(u).domain
locals()[domain_name] = Query(u, d, locals()[dir_objname])
Expand Down

0 comments on commit b67df4e

Please sign in to comment.