Last active
March 17, 2022 00:37
-
-
Save nil0x42/df824d885d884f0b5c5c0da2be475076 to your computer and use it in GitHub Desktop.
[OSINT] Get twitter of all your github followers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
#author: @nil0x42 | |
# Usage: | |
# $ export GITHUB_TOKEN="<YOUR GITHUB TOKEN>" | |
# $ ./get-github-followers-twitter.py <GITHUB USER> | |
import sys, os, requests, json | |
LOGIN = sys.argv[1] | |
GH_TOKEN = os.environ.get("GITHUB_TOKEN") | |
graphql = """ | |
{ | |
user(login: "%s") { | |
followers(first:100 %s) { | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
nodes { | |
twitterUsername | |
} | |
} | |
} | |
} | |
""" | |
hasNextPage, after = True, "" | |
while hasNextPage: | |
r = requests.post("https://api.github.com/graphql", | |
json={"query": graphql % (LOGIN, after)}, | |
headers={"Authorization": "token " + GH_TOKEN}).json() | |
assert "errors" not in r.keys() | |
r=r["data"]["user"]["followers"] | |
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