-
-
Save Splint3r7/198a3f8f19f20c28fff44993427012c3 to your computer and use it in GitHub Desktop.
Parse rake routes output to generate application URLs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Description: Rake Routes File parser | |
## Splint3r7 | Security Researcher | |
## Github: https://github.com/Splint3r7 | |
######################################### | |
import sys | |
import argparse | |
parser = argparse.ArgumentParser(description="Fetching Routes/Urls from the Rake route output") | |
parser.add_argument('-r','--rakeroutes', | |
help = "rake routes file", | |
type = str, | |
required = False) | |
args = parser.parse_args() | |
f = open (args.rakeroutes, "r") | |
def clean(strr): | |
a = strr.split("(") | |
b = a[0] | |
c = b.split(":") | |
z = c[0] | |
return z | |
def routes(): | |
routes = [] | |
for i in f: | |
i = i.strip() | |
x = i.split(" ") | |
for z in x: | |
z = z.strip() | |
if z.startswith("/"): | |
a = clean(z) | |
routes.append(a) | |
return routes | |
if __name__ == "__main__": | |
arr = routes() | |
arr_sort = list(dict.fromkeys(arr)) | |
for x in arr_sort: | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment