CallerPy - Truecaller Name Retriever [UPDATE 6/6/2014]

Started by mad_dev, October 28, 2013, 12:41:23 AM

Previous topic - Next topic

mad_dev

[UPDATE]Due to--what I assume is a JS validator--the script will work....Fear not,

CallerPy is now an online web app that supports a RESTful API.

callerpy.sysbase.org

[UPDATE] Since Truecaller moved from WP, callerpy has been down.
However, I have restarted the project.


https://github.com/Logic-gate/callerpy

THE BELOW SCRIPT WILL NOT WORK....

This tool could be classified under Social-Engineering

Callerpy is a truecaller.com name retriever.

Since my request for the API was rejected, I commenced using python parsing libraries.

Callerpy emulates the process one would encounter if using a web-browser.

The procedure

callerpy.py

:::python

.
..
...
def Run():
   current_date = datetime.datetime.now()
   print clr.YEL
   proceed = raw_input("shall I proceed? Y/N ")
   print clr.ENDC
   if proceed in ('yes', 'y', 'Y', 'YES'):
       html = open('twill_output', 'r')
       a = html.read()
       bs = BeautifulSoup(a)
       if '<p class="sr-name">' in  a:
               print 'Result Ready\n'
               for num in bs.find_all('p',{"class":"sr-name"}):
                   #print num
               p = re.split(r'<.*?>', str(num))
               for i in p:
                   print i
               hist = open('history.log', 'a')
               hist.write('On %s ----- [[%s]] \n' %(current_date, p))
               hist.close()
   elif 'http://www.truecaller.com/social_auth/?p=social_auth_index' in a:
           print clr.RED
           print 'Something went wrong'
           print clr.ENDC
           hist = open('history.log', 'a')
           hist.write('On %s ----- %s \n' %(current_date, 'No match was found'))
           hist.close()
       html.close()
   elif proceed in ('no', 'n', 'N', 'NO'):
       KeyboardInterrupt
       print 'Goodbye'

if __name__ == "__main__":
   if len(sys.argv) > 1: callerpyFunc=sys.argv[1]
   if callerpyFunc == '-hist':
       history()
   if callerpyFunc == '-ph':
       print 'Please wait...'
       auth.AUTH()
       Run()


When the script runs, it will call auth.AUTH()

auth.py

:::python

   CallerUrl = "http://www.truecaller.com/"
   # The first part of the function will get twitter's oauth_token.
   def AUTH():
       dele = open('twill_output', 'r+') # needed to insure that twill_output stays clean
       dele.truncate()
       # connect to truecaller and retrieve twitter's oauth_token hash using re.split
       print clr.MOV
       print '\nPlease wait while I get the Token\n'
       print clr.ENDC
       AuthURL = "social_auth/?p=social_auth_index"
       twitterAuthURL = "&action=login&type=twitter"
       httpIt = CallerUrl + AuthURL + twitterAuthURL
       http = httplib2.Http()
       status, response = http.request(httpIt)
       bs = BeautifulSoup(response)
       for num in bs.find_all(re.compile("a")):
           if num.has_attr('href') == True:
               if len(num['href']) > 50: #Constant links are less than 48
                   #print num.get('href') + clr.ENDC + '\n'
                   print 'Twitter token hash:\n' + clr.YEL
                   a = re.split('=', num.get('href'))
                   for token in a:
                       if len(token) > 38:
                           print token
                   print clr.ENDC
       # connect to twitter and submit the token
       print clr.MOV
       print '\nPlease wait while I get the Token\n'
       print clr.ENDC
       twitter_URL = 'https://api.twitter.com/oauth/authorize?oauth_token='
       twitter_authURL = twitter_URL + token
       print 'Twitter oauth_token link:\n' + clr.YEL
       print twitter_authURL
       print clr.ENDC
       urlRedirect.truecaller_from_twitter(url=twitter_authURL)
       return


The current mean of logging in into truecaller is by twitter.

auth.py will connect to truecaller and follow the authentication process to twitter. It will then retrieve oauth_token and send it to urlRedirect.py

urlRedirect.py

:::python

def truecaller_from_twitter(url):
   time.sleep(0.5)
   try:
       op = open('twill_output', 'w+')
       twill.set_output(op)
       #redirect_output('twill_output') # Will only write after script has finished due to missing close() in commands.py
   except:
       print 'Could not write to file'
   go(url)
   showforms() #For testing
   formclear('1')
   fv("1", "session[username_or_email]", "USERNAME") #change username/password to string for hardcoded creds
   fv("1", "session[password]", "PASSWORD")
   fv("1", "None", "1")
   print '\n'
   showforms() #For testing
   submit('6')
   save_cookies('cookie_session_twitter')
   time.sleep(1)
   number = raw_input('Please enter number: ')
   go('http://www.truecaller.com')
   showforms()
   formclear('1')
   fv('1','q', str(number))
   submit('3')
   showforms()
   info()
   show()
   op.close()


urlRedirect.py will submit your credentials to twitter and authorise truecaller. It will then save the cookie as cookie_session_twitter and submit the truecaller form.

NOTE:
save__cookies() and cookie_session_twitter are part of a previous testing version. Currently they have no use.



All of your "lookups" will be stored in history.log using the following format

:::history.log

   On 2013-05-31 03:59:51.415839 ----- [[['', 'John Doe  ', '12345678990', '', '\n', 'Planet Earth', '', '']]]


Download

http://penbang.sysbase.org/scripts/0.0.3/callerpy/
You will need to change the paths to get it working correctly.

Originally posted on http://sourceforge.net/p/penbang/discussion/general/thread/b13f3eb1/