Skip to content

Instantly share code, notes, and snippets.

@haccer
Last active July 23, 2020 22:36
Show Gist options
  • Save haccer/d4852a36853918f9532bcb67507bde2d to your computer and use it in GitHub Desktop.
Save haccer/d4852a36853918f9532bcb67507bde2d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# Google Groups v1
# python3 ggroup.py domains.txt
import requests
import re
import sys
with open(sys.argv[1]) as f:
sites = f.read().splitlines()
msg = ""
for site in sites:
r = requests.get("https://groups.google.com/a/"+site+"/d/")
if r.status_code == 500:
msg = "500 Error: Google Groups not found"
elif "Redirecting to" in r.text:
try:
rr = requests.get("https://accounts.google.com/AccountChooser?continue=https://groups.google.com/a/"+site+"/d/&hl=en&service=groups2&hd="+site)
if rr.status_code == 200 and "https://accounts.google.com/Service" in rr.url:
msg = "- redirect to Google"
else:
msg = "- redirect to {}".format(rr.url)
except requests.exceptions.RequestException as e:
host = re.findall(r"host='(.*?)', port", str(e))[0]
uri = re.findall(r'url: (.*?) \(Caused', str(e))[0]
msg = "- redirect to INTERNAL HOST: {}{}".format(host, uri)
elif r.status_code == 404:
msg = "- 404"
else:
msg = "- Open!"
print(site, msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment