• Publicidad

DH Twitter Locator 0.6

¿Estás desarrollando un proyecto, o piensas hacerlo? Pon aquí tu propuesta, lo más seguro es que alguien esté interesado en ayudarte.

DH Twitter Locator 0.6

Notapor BigBear » 2016-11-11 13:27 @602

Un script en Perl para escanear los tuits de cualquier usuario, basado en la idea original de "tinfoleak by Vicente Aguilera Diaz".

Funciones:

[+] Extrae información del perfil
[+] Escanea los tuits en busca de apps y locations
[+] Permite cargar las localizaciones en Google Maps
[+] Guarda todo en registros

El código:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. # !usr/bin/perl
  2. # DH Twitter Locator 0.6
  3. # (C) Doddy Hackman 2016
  4. # Credits :
  5. # Based in idea original of: tinfoleak by Vicente Aguilera Diaz
  6.  
  7. use LWP::UserAgent;
  8. use IO::Socket::SSL;
  9. use HTTP::Request::Common;
  10. use JSON;
  11. use Data::Dumper;
  12. use MIME::Base64;
  13. use Date::Parse;
  14. use DateTime;
  15. use Getopt::Long;
  16. use Color::Output;
  17. Color::Output::Init;
  18.  
  19. my $consumer_key = "IQKbtAYlXLripLGPWd0HUA";
  20. my $consumer_secret = "GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU";
  21.  
  22. my $bearer_token = "$consumer_key:$consumer_secret";
  23. my $bearer_token_64 = encode_base64($bearer_token);
  24.  
  25. my $nave = LWP::UserAgent->new(ssl_opts => {verify_hostname => 0,SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE});
  26. $nave->agent(
  27. "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"
  28. );
  29. $nave->timeout(5);
  30.  
  31. GetOptions(
  32.         "profile"   => \$profile,
  33.         "apps"   => \$apps,
  34.     "locations"  => \$locations,
  35.     "username=s"   => \$username,
  36.     "count=i"   => \$count,
  37.     "savefile=s"  => \$savefile,
  38. );
  39.  
  40. head();
  41.  
  42. if ($profile) {
  43.         if($profile && $username) {
  44.                 search_profile($username);
  45.         } else {
  46.                 sintax();
  47.         }      
  48. }
  49. if ($apps) {
  50.         if($apps && $username && $count) {
  51.                 search_apps($username,$count);
  52.         } else {
  53.                 sintax();
  54.         }
  55. }
  56. if ($locations) {
  57.         if($locations && $username && $count) {
  58.                 search_locations($username,$count);
  59.         } else {
  60.                 sintax();
  61.         }
  62. }
  63. if(!$profile and !$apps and !$locations) {
  64.         sintax();
  65. } else {
  66.         if($savefile) {
  67.                 printear_logo("\n[+] Logs $savefile saved\n");
  68.         }
  69. }
  70.  
  71. copyright();
  72.  
  73. # Functions
  74.  
  75. sub search_profile {
  76.         my ($username) = @_;
  77.        
  78.         printear_titulo("\n[+] Loading Profile in Username : ");
  79.         print $username." ...\n\n";
  80.        
  81.         #my $code = toma("http://localhost/twitter/getuser.php");
  82.         my $code = get_code("https://api.twitter.com/1.1/users/show.json?screen_name=".$username);
  83.  
  84.         my $resultado = JSON->new->decode($code);
  85.  
  86.         my $screen_name = $resultado->{"screen_name"};
  87.         if($screen_name eq "") {
  88.                 $screen_name = "Not Found";
  89.         }
  90.         my $name = $resultado->{"name"};
  91.         if($name eq "") {
  92.                 $name = "Not Found";
  93.         }
  94.         my $id = $resultado->{"id_str"};
  95.         if($id eq "") {
  96.                 $id = "Not Found";
  97.         }
  98.         my $created = parse_date($resultado->{"created_at"});
  99.         if($created eq "") {
  100.                 $created = "Not Found";
  101.         }
  102.         my $followers = $resultado->{"followers_count"};
  103.         if($followers eq "") {
  104.                 $followers = "Not Found";
  105.         }
  106.         my $tweets_count = $resultado->{"statuses_count"};
  107.         if($tweets_count eq "") {
  108.                 $tweets_count = "Not Found";
  109.         }
  110.         my $location = $resultado->{"location"};
  111.         if($location eq "") {
  112.                 $location = "Not Found";
  113.         }
  114.         my $description = $resultado->{"description"};
  115.         if($description eq "") {
  116.                 $description = "Not Found";
  117.         }
  118.         my $url = $resultado->{"url"};
  119.         if($url eq "") {
  120.                 $url = "Not Found";
  121.         }
  122.         my $profile_image = $resultado->{"profile_image_url"};
  123.         if($profile_image eq "") {
  124.                 $profile_image = "Not Found";
  125.         }
  126.        
  127.         printear("Screen Name : ");
  128.         print $screen_name."\n";
  129.         printear("Username : ");
  130.         print $name."\n";
  131.         printear("ID : ");
  132.         print $id."\n";
  133.         printear("Created at : ");
  134.         print $created."\n";
  135.         printear("Followers : ");
  136.         print $followers."\n";
  137.         printear("Tweets count : ");
  138.         print $tweets_count."\n";
  139.         printear("Location : ");
  140.         print $location."\n";
  141.         printear("Description : ");
  142.         print $description."\n";
  143.         printear("URL : ");
  144.         print $url."\n";
  145.         printear("Profile Image : ");
  146.         print $profile_image."\n";
  147.        
  148.         printear_titulo("\n[+] Profile Loaded\n");
  149.        
  150.         if($savefile) {
  151.                 savefile($savefile,"\n[+] Loading Profile in Username : $username\n");
  152.                 savefile($savefile,"Screen Name : $screen_name");
  153.                 savefile($savefile,"Username : $name");
  154.                 savefile($savefile,"ID : $id");
  155.                 savefile($savefile,"Created at : $created");
  156.                 savefile($savefile,"Followers : $followers");
  157.                 savefile($savefile,"Tweets count : $tweets_count");
  158.                 savefile($savefile,"Location : $location");
  159.                 savefile($savefile,"Description : $description");
  160.                 savefile($savefile,"URL : $url");
  161.                 savefile($savefile,"Profile Image : $profile_image");
  162.                 savefile($savefile,"\n[+] Profile Loaded");
  163.         }
  164.  
  165. }
  166.  
  167. sub search_apps {
  168.         my($username,$count) = @_;
  169.        
  170.         printear_titulo("\n[+] Searching Apps in Username : ");
  171.         print $username." ...\n\n";
  172.  
  173.         my $code = get_code("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$username."&include_rts=True&count=".$count);
  174.        
  175.         my $resultado = JSON->new->decode($code);
  176.        
  177.         my @resultado = @$resultado;
  178.        
  179.         my $i = 0;
  180.  
  181.         if(int(@resultado) eq "0") {
  182.                 printear_rojo("[-] Tweets not found\n");
  183.         } else {
  184.                 printear("[+] Tweets found : ");
  185.                 print int(@resultado)."\n\n\n";
  186.                 printear("  Tweet\t\t Date\t\t   Apps\n");
  187.                 print "  -----------------------------------------------------\n\n";
  188.                
  189.                 if($savefile) {
  190.                         savefile($savefile,"\n[+] Searching Apps in Username : $username\n");
  191.                         savefile($savefile,"[+] Tweets found : ".int(@resultado)."\n");
  192.                         savefile($savefile,"  Tweet\t\t Date\t\t   Apps\n");
  193.                         savefile($savefile,"  -----------------------------------------------------\n");
  194.                 }
  195.  
  196.                 for my $result(@resultado) {
  197.                         $i++;
  198.                         my $source_split = $result->{"source"};
  199.                         if($source_split=~/>(.*)<\/a>/) {
  200.                                 my $source = $1;
  201.                                 my $datetime = parse_date($result->{"created_at"});
  202.                                 if($source ne "") {
  203.                                         printf("   %-5s %-22s %-15s\n", $i,$datetime,$source);
  204.                                         if($savefile) {
  205.                                                 savefile($savefile,"   $i\t$datetime\t$source");
  206.                                         }
  207.                                 }
  208.                         }
  209.                 }
  210.                
  211.                 printear_titulo("\n\n[+] Apps Loaded\n");
  212.                
  213.                 if($savefile) {
  214.                         savefile($savefile,"\n[+] Apps Loaded\n");
  215.                 }
  216.         }
  217.        
  218. }
  219.  
  220. sub search_locations {
  221.         my($username,$count) = @_;
  222.        
  223.         printear_titulo("\n[+] Searching Locations in Username : ");
  224.         print $username." ...\n\n";
  225.  
  226.         my $code = get_code("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$username."&include_rts=True&count=".$count);
  227.        
  228.         my $resultado = JSON->new->decode($code);
  229.        
  230.         my @resultado = @$resultado;
  231.        
  232.         my $i = 0;
  233.  
  234.         if(int(@resultado) eq "0") {
  235.                 printear_rojo("[-] Tweets not found\n");
  236.         } else {
  237.                 printear("[+] Tweets found : ");
  238.                 print int(@resultado)."\n\n\n";
  239.  
  240.                 printear("  Tweet\t\t Date\t\t     Locations\n");
  241.                 print "  -----------------------------------------------------\n\n";
  242.                
  243.                 if($savefile) {
  244.                         savefile($savefile,"\n[+] Searching Locations in Username : $username\n");
  245.                         savefile($savefile,"[+] Tweets found : ".int(@resultado)."\n");
  246.                         savefile($savefile,"  Tweet\t\t Date\t\t   Locations\n");
  247.                         savefile($savefile,"  -----------------------------------------------------\n");
  248.                 }
  249.  
  250.                 for my $result(@resultado) {
  251.                         $i++;
  252.                         my $place = $result->{"place"}{"country"};
  253.                         my $coordinates1 = $result->{"geo"}{"coordinates"}[0];
  254.                         my $coordinates2 = $result->{"geo"}{"coordinates"}[1];
  255.                         my $datetime = parse_date($result->{"created_at"});
  256.                         if($place ne "") {
  257.                                 my $data = "";
  258.                                 if($coordinates1 ne "" && $coordinates2 ne "") {
  259.                                         $data = $place." [".$coordinates1.",".$coordinates2."]";
  260.                                 } else {
  261.                                         $data = $place;
  262.                                 }
  263.                                 printf("   %-5s %-22s %-15s\n", $i,$datetime,$data);
  264.                                 if($savefile) {
  265.                                         savefile($savefile,"   $i\t$datetime\t$data");
  266.                                 }
  267.                         }
  268.                 }
  269.                 printear_titulo("\n\n[+] Locations Loaded\n");
  270.                 if($savefile) {
  271.                         savefile($savefile,"\n[+] Locations Loaded\n");
  272.                 }
  273.         }
  274.        
  275. }
  276.  
  277. # More Functions
  278.  
  279. sub get_token {
  280.         my $code = $nave->request(POST(
  281.                 "https://api.twitter.com/oauth2/token",
  282.                 "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8",
  283.                 "Authorization" => "Basic $bearer_token_64",
  284.                 Content => { "grant_type" => "client_credentials" }
  285.         ))->content;
  286.         my $resultado = JSON->new->decode($code);
  287.         my $token = $resultado->{"access_token"};
  288.         return $token;
  289. }
  290.  
  291. sub get_code {
  292.         my $url = shift;
  293.         my $code = $nave->request(GET($url,"Authorization" => "Bearer " . get_token()))->content;
  294.         return $code;
  295. }
  296.  
  297. sub parse_date {
  298.     my $date = shift;        
  299.     $time = str2time($date);    
  300.     my $datetime = DateTime->from_epoch(epoch => $time);
  301.     return $datetime->mdy("/")." ".$datetime->hms;
  302. }
  303.  
  304. sub toma {
  305.     return $nave->get( $_[0] )->content;
  306. }
  307.  
  308. sub savefile {
  309.         my ($filename,$text) = @_;
  310.         open( SAVE, ">>" . $filename );
  311.         print SAVE $text . "\n";
  312.         close SAVE;
  313. }
  314.  
  315. sub printear {
  316.     cprint( "\x036" . $_[0] . "\x030" );
  317. }
  318.  
  319. sub printear_logo {
  320.     cprint( "\x037" . $_[0] . "\x030" );
  321. }
  322.  
  323. sub printear_titulo {
  324.     cprint( "\x0310" . $_[0] . "\x030" );
  325. }
  326.  
  327. sub printear_rojo {
  328.     cprint( "\x034" . $_[0] . "\x030" );
  329. }
  330.  
  331. sub printear_azul {
  332.     cprint( "\x033" . $_[0] . "\x030" );
  333. }
  334.  
  335. sub sintax {
  336.     printear("\n[+] Sintax : ");
  337.     print "perl $0 <option> <value>\n";
  338.     printear("\n[+] Options : \n\n");
  339.     print "-profile : Show profile information\n";
  340.     print "-apps : List apps in tweets\n";
  341.     print "-locations : List locations in tweets\n";
  342.     print "-username <username> : Set username to find\n";
  343.         print "-count <count> : Set count to find\n";
  344.         print "-savefile <filename> : Save results\n";
  345.     printear("\n[+] Example : ");
  346.     print "perl dh_twitter_locator.pl -profile -apps -locations -username test -count 800 -savefile results.txt\n";
  347.     copyright();
  348. }
  349.  
  350. sub head {
  351.     printear_logo("\n-- == DH Twitter Locator 0.6 == --\n\n");
  352. }
  353.  
  354. sub copyright {
  355.     printear_logo("\n\n-- == (C) Doddy Hackman 2016 == --\n\n");
  356.     exit(1);
  357. }
  358.  
  359. #The End ?
  360.  
Coloreado en 0.009 segundos, usando GeSHi 1.0.8.4


Un video con ejemplos de uso:



Si quieren bajar el programa lo pueden hacer acá:

SourceForge.
Github.

Eso sería todo.
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Volver a Proyectos

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado

cron