Skip to content

Instantly share code, notes, and snippets.

@nil0x42
Created September 23, 2020 14:16
Show Gist options
  • Save nil0x42/e0126ed2fe7e7197e7c15c6bb05021e6 to your computer and use it in GitHub Desktop.
Save nil0x42/e0126ed2fe7e7197e7c15c6bb05021e6 to your computer and use it in GitHub Desktop.
[OSINT] Extract twitter of all stargazers of a Github project
#!/usr/bin/env python3
# author: @nil0x42
# Usage example:
# $ export GITHUB_TOKEN="<YOUR GITHUB TOKEN>"
# $ ./get-githus-stargazers-twitter.py "rapid7/metasploit-framework"
import sys, os, requests, json
OWNER, REPO = sys.argv[1].split("/")
GH_TOKEN = os.environ.get("GITHUB_TOKEN")
graphql = """
{
repository(name: "%s", owner: "%s") {
stargazers(first: 100 %s) {
pageInfo {
hasNextPage
endCursor
}
nodes {
twitterUsername
}
}
}
}
"""
hasNextPage, after = True, ""
while hasNextPage:
r = requests.post("https://api.github.com/graphql",
json={"query": graphql % (REPO, OWNER, after)},
headers={"Authorization": "token " + GH_TOKEN}).json()
assert "errors" not in r.keys()
r=r["data"]["repository"]["stargazers"]
hasNextPage = r["pageInfo"]["hasNextPage"]
after = ', after: "%s"' % r["pageInfo"]["endCursor"]
for follower in r["nodes"]:
twitter = follower["twitterUsername"]
if twitter:
print("https://twitter.com/"+twitter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment