Skip to content

Instantly share code, notes, and snippets.

@judotens
Last active September 10, 2020 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judotens/7697755 to your computer and use it in GitHub Desktop.
Save judotens/7697755 to your computer and use it in GitHub Desktop.
Twitter Bulk Tokens Generator for PIN-based auth Twitter app
# this tools will help you to generate a twitter tokens for bulk twitter accounts using PIN-based authorization twitter app.
# eg: Twitter for Iphone
# todo: save your bulk twitter accounts to pasukan.txt, line separated each account.
# format: username:password
# - Revealing Twitter for iPhone consumer key & secret - Ref: http://seriot.ch/abusing_twitter_api.php#3
import os
dirname, filename = os.path.split(os.path.abspath(__file__))
import tweepy
import urllib2
import urllib
from cookielib import CookieJar
def sB(isi, s, e):
return isi[isi.find(s)+len(s):isi.find(e)]
def getPIN(url, username, password):
cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
isi = opener.open(url).read()
authenticity_token = sB(isi, 'authenticity_token" type="hidden" value="', '" /></div>')
oauth_token = sB(isi, '<input id="oauth_token" name="oauth_token" type="hidden" value="', '" /> ')
formdata = { "authenticity_token" : authenticity_token, "remember" : "1", "allow" : "Izinkan aplikasi", "oauth_token": oauth_token, "session[username_or_email]" : username, "session[password]": password }
data_encoded = urllib.urlencode(formdata)
response = opener.open("https://api.twitter.com/oauth/authorize", data_encoded)
content = response.read()
pin = sB(content, '<code>', '</code>')
if pin == "" or len(pin) > 10: return None
return pin
if __name__ == "__main__":
targets = open(dirname + "/pasukan.txt")
consumer_key = YOUR_CONSUMER_KEY_HERE
consumer_secret = YOUR_CONSUMER_SECRET_HERE
for target in targets:
pecah = target.split(":")
username = pecah[0].strip()
password = pecah[1].strip()
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
url = auth.get_authorization_url()
pin = getPIN(url,username,password)
if pin == None: continue
token = auth.get_access_token(verifier=pin)
cetak = {'access_token': token.key, 'access_secret': token.secret, 'username': username, 'password':password}
print cetak
#print "%s:%s\t%s\t%s" % (str(username), str(password), str(token.key), str(token.secret))
bot_twitter_1:password
bot_twitter_2:password
bot_twitter_3:password
bot_twitter_4:password
bot_twitter_5:password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment