<s> from Maltego import * <EOL> import logging <EOL> import requests <EOL> import json <EOL> import stawk_db <EOL> import re <EOL> logging . basicConfig ( level = logging . DEBUG , filename = '<STR_LIT>' , format = '<STR_LIT>' , datefmt = '<STR_LIT>' ) <EOL> sys . stderr = sys . stdout <EOL> def main ( ) : <EOL> print "<STR_LIT>" ; <EOL> MaltegoXML_in = sys . stdin . read ( ) <EOL> if MaltegoXML_in < > '<STR_LIT>' : <EOL> m = MaltegoMsg ( MaltegoXML_in ) <EOL> cursor = stawk_db . dbconnect ( ) <EOL> TRX = MaltegoTransform ( ) <EOL> try : <EOL> logging . debug ( "<STR_LIT>" ) <EOL> for item in m . TransformSettings . keys ( ) : <EOL> logging . debug ( "<STR_LIT>" + item + "<STR_LIT>" + m . TransformSettings [ item ] ) <EOL> radius = "<STR_LIT:5>" <EOL> lat = m . AdditionalFields [ '<STR_LIT>' ] <EOL> lng = m . AdditionalFields [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in m . AdditionalFields : <EOL> radius = m . AdditionalFields <EOL> logging . debug ( "<STR_LIT>" % ( lat , lng , radius ) ) <EOL> r = requests . get ( "<STR_LIT>" % ( lat , lng , radius ) ) <EOL> tw = json . loads ( r . text ) <EOL> logging . debug ( "<STR_LIT>" % len ( tw [ '<STR_LIT>' ] ) ) <EOL> for tweep in tw [ '<STR_LIT>' ] : <EOL> name = tweep [ '<STR_LIT>' ] . encode ( '<STR_LIT:utf8>' , '<STR_LIT>' ) <EOL> username = tweep [ '<STR_LIT>' ] . encode ( '<STR_LIT:utf8>' , '<STR_LIT>' ) <EOL> uid = tweep [ '<STR_LIT>' ] . encode ( '<STR_LIT:utf8>' , '<STR_LIT>' ) <EOL> recent_tweet = tweep [ '<STR_LIT:text>' ] . encode ( '<STR_LIT:utf8>' , '<STR_LIT>' ) <EOL> img = tweep [ '<STR_LIT>' ] . encode ( '<STR_LIT:utf8>' , '<STR_LIT>' ) <EOL> profile_page = "<STR_LIT>" % username <EOL> largephoto = re . sub ( '<STR_LIT>' , '<STR_LIT>' , img ) <EOL> NewEnt = TRX . addEntity ( "<STR_LIT>" , name ) <EOL> NewEnt . addAdditionalFields ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:strict>" , uid ) <EOL> NewEnt . addAdditionalFields ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:strict>" , profile_page ) <EOL> NewEnt . addAdditionalFields ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:strict>" , username ) <EOL> NewEnt . addAdditionalFields ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:strict>" , name ) <EOL> NewEnt . addAdditionalFields ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , largephoto ) <EOL> NewEnt . addAdditionalFields ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , recent_tweet ) <EOL> NewEnt . setIconURL ( img ) <EOL> except Exception , e : <EOL> logging . debug ( "<STR_LIT>" ) <EOL> logging . debug ( e ) <EOL> TRX . returnOutput ( ) <EOL> main ( ) </s>
