diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 34807bf..15f233c --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Short Form | Long Form | Description -b | --burp | Toggle to use when inputting a Burp 'Save selected' file containing multiple JS files -c | --cookies | Add cookies to the request -h | --help | show the help message and exit +-js | --javascript | Download all javascript files ### Examples diff --git a/linkfinder.py b/linkfinder.py index 6675322..f82f8c4 100755 --- a/linkfinder.py +++ b/linkfinder.py @@ -8,7 +8,7 @@ os.environ["BROWSER"] = "open" # Import libraries -import re, sys, glob, html, argparse, jsbeautifier, webbrowser, subprocess, base64, ssl, xml.etree.ElementTree +import re, sys, glob, html, argparse, jsbeautifier, webbrowser, subprocess, base64, ssl, xml.etree.ElementTree, requests from gzip import GzipFile from string import Template @@ -25,6 +25,57 @@ except ImportError: from urllib2 import Request, urlopen +class javascript: + def __init__(self, url, endpoints): + self.url = url + self.endpoints = endpoints + + def clean_parameters(self, file): + if "?" in file: + return file.split("?")[0] + else: + return file + + def is_javascript_file(self, file): + try: + ext = file.rsplit('.', 1)[1].lower() + if ext == "js": + return True + else: + return False + except: + return False + + def verify_slash(self, file): + if file[0] == "/": + return file + else: + return '/'+file + + def save_file(self, file): + if self.is_full_url(file): + r = requests.get(file) + with open("javascript_files/"+self.get_file_path(file), 'w') as f: + f.write(jsbeautifier.beautify(r.text)) + else: + r = requests.get(self.url+self.verify_slash(file)) + with open("javascript_files/"+self.get_file_path(file), 'w') as f: + f.write(jsbeautifier.beautify(r.text)) + + def is_full_url(self, file): + if 'http' in file: + return True + else: + return False + def get_file_path(self, url): + return url.split("/")[-1] + + def main(self): + for endpoint in self.endpoints: + path = self.clean_parameters(html.escape(endpoint["link"]).encode('ascii', 'ignore').decode('utf8')) + if self.is_javascript_file(path): + self.save_file(path) + # Regex used regex_str = r""" @@ -313,8 +364,17 @@ def check_url(url): parser.add_argument("-t", "--timeout", help="How many seconds to wait for the server to send data before giving up (default: " + str(default_timeout) + " seconds)", default=default_timeout, type=int, metavar="") + parser.add_argument("-js", "--javascript", + help="It will download all JavaScript files and unminify them", + action="store_true") args = parser.parse_args() + if args.javascript: + try: + os.mkdir("javascript_files") + except: + pass + if args.input[-1:] == "/": args.input = args.input[:-1] @@ -374,7 +434,9 @@ def check_url(url): except Exception as e: print("Invalid input defined or SSL error for: " + endpoint) continue - + javascript = javascript(args.input, endpoints) + if args.javascript: + javascript.main() if args.output == 'cli': cli_output(endpoints) else: @@ -401,3 +463,5 @@ def check_url(url): if args.output != 'cli': html_save(output) + + diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 diff --git a/template.html b/template.html old mode 100644 new mode 100755 diff --git a/test_parser.py b/test_parser.py old mode 100644 new mode 100755