Advertisement
Doddy

[Perl] DH Image Locate 0.3

Oct 13th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.46 KB | None | 0 0
  1. #!usr/bin/perl
  2. # DH Image Locate 0.3
  3. #(C) Doddy Hackman 2016
  4.  
  5. use Image::ExifTool;
  6. use Getopt::Long;
  7. use Color::Output;
  8. Color::Output::Init;
  9.  
  10. GetOptions(
  11.     "dump_all=s"   => \$dump_all,
  12.     "dump_gps_tags=s"  => \$dump_gps_tags,
  13.     "locate=s"   => \$locate
  14. );
  15.  
  16. head();
  17.  
  18. if ($dump_all) {
  19.  
  20.     if ( -f $dump_all ) {
  21.         printear_titulo("[+] Finding information in : ");
  22.         print $dump_all. "\n\n";
  23.         dump_all($dump_all);
  24.     }
  25.     else {
  26.         printear("[-] File not found\n");
  27.     }
  28.  
  29. }
  30. elsif ($dump_gps_tags) {
  31.  
  32.     if ( -f $dump_gps_tags ) {
  33.         printear_titulo("[+] Finding GPS tags in : ");
  34.         print $dump_gps_tags. "\n\n";
  35.         dump_gps_tags_and_locate($dump_gps_tags,"0");
  36.     }
  37.     else {
  38.         printear("[-] File not found\n");
  39.     }
  40. }
  41. elsif ($locate) {
  42.  
  43.     if ( -f $locate ) {
  44.         printear_titulo("[+] Scanning photo : ");
  45.         print $locate. "\n\n";
  46.         dump_gps_tags_and_locate($locate,"1");
  47.     }
  48.     else {
  49.         printear("[-] File not found\n");
  50.     }
  51.  
  52. } else {
  53.     sintax();
  54. }
  55.  
  56. copyright();
  57.  
  58. # Functions
  59.  
  60. sub dump_all {
  61.  
  62.     my $imagen_target = $_[0];
  63.  
  64.     my $datos_imagen       = new Image::ExifTool;
  65.     my $informacion_imagen = $datos_imagen->ImageInfo($imagen_target);
  66.  
  67.     for my $abriendo_imagen ( $datos_imagen->GetFoundTags("Group0") ) {
  68.         my $valor = $informacion_imagen->{$abriendo_imagen};
  69.         printear("[+] $abriendo_imagen : ");
  70.         print $valor. "\n";
  71.     }
  72.  
  73. }
  74.  
  75. sub dump_gps_tags_and_locate {
  76.    
  77.     my $imagen_target = shift;
  78.     my $locate = shift;
  79.  
  80.     my $datos_imagen       = new Image::ExifTool;
  81.     my $informacion_imagen = $datos_imagen->ImageInfo($imagen_target);
  82.  
  83.     my $latitud = $informacion_imagen->{GPSLatitude};
  84.     my $longitud = $informacion_imagen->{GPSLongitude};
  85.     my $altitud = $informacion_imagen->{GPSAltitude};
  86.     my $fecha = $informacion_imagen->{GPSDateTime};
  87.     my $posicion_real = $informacion_imagen->{GPSPosition};
  88.    
  89.     my $finder_ready = 0;
  90.    
  91.    
  92.     if($latitud ne "") {
  93.         printear("[+] Latitude : ");
  94.         print $latitud. "\n";
  95.     } else {
  96.         printear("[-] Latitude : ");
  97.         print "Not Found". "\n";   
  98.     }
  99.    
  100.     if($longitud ne "") {
  101.         printear("[+] Longitude : ");
  102.         print $longitud. "\n";
  103.     } else {
  104.         printear("[-] Longitude : ");
  105.         print "Not Found". "\n";
  106.     }
  107.    
  108.     if($latitud ne "") {
  109.         printear("[+] Altitude : ");
  110.         print $altitud. "\n";
  111.     } else {
  112.         printear("[-] Altitude : ");
  113.         print "Not Found". "\n";
  114.     }
  115.    
  116.     if($fecha ne "") {
  117.         printear("[+] DateTime : ");
  118.         print $fecha. "\n";
  119.     } else {
  120.         printear("[-] DateTime : ");
  121.         print "Not Found". "\n";
  122.     }
  123.    
  124.     if($posicion_real ne "") {
  125.         printear("[+] Position : ");
  126.         print $posicion_real. "\n";
  127.         $finder_ready = 1;
  128.     } else {
  129.         printear("[-] Position : ");
  130.         print "Not Found". "\n";
  131.         $finder_ready = 0;
  132.     }
  133.    
  134.     if($locate eq "1") {
  135.         if($finder_ready eq "1") {
  136.             my $gps_split = $posicion_real;
  137.             $gps_split =~ s/deg//g;
  138.             $gps_split =~ s/'//g;
  139.             $gps_split =~ s/"//g;
  140.             $gps_split =~ s/W//g;
  141.             $gps_split =~ s/N,/-/g;
  142.             $gps_split =~ s/  / /g;
  143.                        
  144.             my $url = "https://www.google.com.ar/maps/search/".$gps_split."/";
  145.            
  146.             printear_titulo("\n[!] Position Located\n\n");
  147.             printear("[+] GPS : ");
  148.             print $gps_split."\n";
  149.            
  150.             printear("\n[?] Open in browser [y,n] : ");
  151.             chomp(my $rta = <STDIN>);
  152.             if($rta=~/y/ig) {
  153.                 printear_titulo("\n[+] Enjoy the program !\n");
  154.                 system("start firefox \"" . $url."\"");
  155.             } else {
  156.                 printear("\n[+] GoogleMaps : ");
  157.                 print $url. "\n";
  158.             }
  159.            
  160.         } else {
  161.             printear_titulo("\n[-] Position GPS not available");
  162.         }
  163.     }
  164.    
  165. }
  166.  
  167. # More Functions
  168.  
  169. sub printear {
  170.     cprint( "\x036" . $_[0] . "\x030" );
  171. }
  172.  
  173. sub printear_logo {
  174.     cprint( "\x037" . $_[0] . "\x030" );
  175. }
  176.  
  177. sub printear_titulo {
  178.     cprint( "\x0310" . $_[0] . "\x030" );
  179. }
  180.  
  181. sub sintax {
  182.  
  183.     printear("[+] Sintax : ");
  184.     print "perl $0 <option> <value>\n";
  185.     printear("\n[+] Options : \n\n");
  186.     print "-dump_all <image> : Get all information of a image\n";
  187.     print "-dump_gps <image> : Get all tags GPS of a image\n";
  188.     print "-locate <image> : Locate Image in GoogleMaps\n";
  189.     printear("\n[+] Example : ");
  190.     print "perl dh_image_locate.pl -dump_all test.jpg\n";
  191.     copyright();
  192. }
  193.  
  194. sub head {
  195.     printear_logo("\n-- == DH Image Locate 0.3 == --\n\n\n");
  196. }
  197.  
  198. sub copyright {
  199.     printear_logo("\n\n-- == (C) Doddy Hackman 2016 == --\n\n");
  200.     exit(1);
  201. }
  202.  
  203. #The End ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement