├── .gitignore ├── README.md ├── endpointdiff.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | LinkFinder 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # endpointdiff 2 | endpointdiff is a simple wrapper script around LinkFinder (https://github.com/GerbenJavado/LinkFinder) to quickly identify whether endpoints have changed based on diffs of JS files. 3 | 4 | ## Installation 5 | endpointdiff supports Python3. It depends on LinkFinder, so it will also need the dependencies LinkFinder has. 6 | 7 | ``` 8 | # After cloning this repository, clone `LinkFinder` within: 9 | git clone https://github.com/GerbenJavado/LinkFinder.git 10 | 11 | # Install the dependencies 12 | pip3 install -r requirements.txt 13 | ``` 14 | 15 | The structure should look like: 16 | 17 | ``` 18 | ├── endpointdiff 19 | │ ├── LinkFinder/ 20 | ``` 21 | 22 | ## Usage 23 | 24 | Short Form | Long Form | Description 25 | ------------- | ------------- |------------- 26 | -n | --new | Input a new: URL, file or folder. For folders a wildcard can be used (e.g. '/*.js'). 27 | -o | --old | Input an old: URL, file or folder. For folders a wildcard can be used (e.g. '/*.js'). 28 | -r | --regex | RegEx for filtering purposes against found endpoints (e.g. ^/api/) 29 | -s | --save | File location to save the diff output to. 30 | -c | --cookies | Add cookies to the request 31 | -h | --help | show the help message and exit 32 | 33 | Most if not all of the `LinkFinder` functionality should be able to be leveraged. Some examples on usage are: 34 | 35 | If you want to determine the diff in endpoints for 2 JS URLs: 36 | 37 | `python3 endpointdiff.py -o https://site.com/oldjs -n https://site.com/newjs` 38 | 39 | If you want to determine the diff in endpoints for a saved local version, and then save the output: 40 | 41 | `python3 endpointdiff.py -o old/js/file.js -n https://site.com/newjs -s path/to/save.txt` 42 | 43 | If you want to analyze entire folders against each other: 44 | 45 | `python3 endpointdiff.py -o old/*.js -n new/*.js` -------------------------------------------------------------------------------- /endpointdiff.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import subprocess 3 | 4 | class bcolors: 5 | GREEN = '\033[92m' 6 | RED = '\033[91m' 7 | END = '\033[0m' 8 | 9 | def get_endpoints(url, cookies, regex): 10 | endpoints = subprocess.Popen(['python3', 'LinkFinder/linkfinder.py', '-i', url, '-o', 'cli', '-c', cookies, '-r', regex], stdout=subprocess.PIPE) 11 | return [endpoint for endpoint in endpoints.stdout.read().decode('utf-8').split('\n') if endpoint] 12 | 13 | 14 | def get_diff(old_endpoints, new_endpoints): 15 | removed = [endpoint for endpoint in old_endpoints if endpoint not in new_endpoints] 16 | added = [endpoint for endpoint in new_endpoints if endpoint not in old_endpoints] 17 | 18 | return removed, added 19 | 20 | 21 | if __name__ == "__main__": 22 | # Parse command line 23 | parser = argparse.ArgumentParser() 24 | parser.add_argument("-n", "--new", 25 | help="Input a new: URL, file or folder. \ 26 | For folders a wildcard can be used (e.g. '/*.js').", 27 | required=True, action="store") 28 | parser.add_argument("-o", "--old", 29 | help="Input an old: URL, file or folder. \ 30 | For folders a wildcard can be used (e.g. '/*.js').", 31 | required=True, action="store") 32 | parser.add_argument("-r", "--regex", 33 | help="RegEx for filtering purposes \ 34 | against found endpoint (e.g. ^/api/)", 35 | action="store", default="") 36 | parser.add_argument("-c", "--cookies", 37 | help="Add cookies for authenticated JS files", 38 | action="store", default="") 39 | parser.add_argument("-s", "--save", 40 | help="File location to save the diff output to", 41 | action="store") 42 | args = parser.parse_args() 43 | old_endpoints = get_endpoints(args.old, args.cookies, args.regex) 44 | new_endpoints = get_endpoints(args.new, args.cookies, args.regex) 45 | removed, added = get_diff(old_endpoints, new_endpoints) 46 | 47 | for endpoint in added: 48 | print(f'{bcolors.GREEN} + {endpoint} {bcolors.END}') 49 | 50 | for endpoint in removed: 51 | print(f'{bcolors.RED} - {endpoint} {bcolors.END}') 52 | 53 | if args.save: 54 | with open(args.save, 'w') as f: 55 | for endpoint in added: 56 | f.write(f'+ {endpoint}\n') 57 | for endpoint in removed: 58 | f.write(f'- {endpoint}\n') 59 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | jsbeautifier 2 | --------------------------------------------------------------------------------