Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6.50 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #Firegpg Replacement/work around for Ubuntu GPG bug
  3. #by nullbyt3
  4. #Script Requirements: Nano/Pico text editor and obviously GnuGPG
  5. use strict;
  6. use warnings;
  7.  
  8.    system("clear");
  9.    print "-----------------------------------------------------------\n";
  10.    print "\t\t**Welcome to the GnuGPG **\n\t[*]File encrypter/decrypter/Key finder/Text Editor[*]\n";
  11.    print "\n-------------------[*]by nullbyt3[*]-----------------------";
  12. my @options= ("1)Encrypt a file?", "2)Decrypt a file?", "3)List ALL Keys?","4)Grep for particular key?","5)Import a Key?","6)Export Public key to file?",
  13.                "7)Delete a Key?", "7)GPG Text editor?(create a file then Encrypt/Decrypt it)"
  14.                                    );
  15.  
  16.  
  17.  
  18. foreach  my $options(@options){
  19.                        print "\n$options\n";
  20.              
  21. }
  22.      print "Your choice: ";
  23.       chomp (my $resp =<STDIN>);
  24.  
  25.  if ($resp eq "1"){
  26.              print "File to encrypt?:";
  27.              chomp (my $file = <STDIN>);          
  28.              print "Key to use:";
  29.              chomp (my $key = <STDIN>);
  30.  
  31.            my $command = "gpg --recipient $key --armor --encrypt $file";    
  32.            system("$command");
  33.            print "File successfully encrypted!\n";
  34.          
  35.              
  36.  
  37.  
  38.  
  39.                                }if($resp eq "2"){
  40.                                      print "File to be decrypted: ";        
  41.                                      chomp (my $file=<STDIN>);
  42.                                      print "Output File: ";
  43.                                      chomp (my $out =<STDIN>);
  44.        
  45.                                      my $command = "gpg --output $out --decrypt $file";      
  46.                                      system ("$command");                            
  47.                                      print "[+]File decrypted successfully![+]\n";
  48.                                      exit;
  49.                                  
  50.                                                                                  
  51.  
  52.                                                
  53.                                                               }if($resp eq "3"){
  54.                                                                      my $command = "gpg --list-keys | more";
  55.                                                                      system("$command");
  56.                                                                      exit;
  57.  
  58.    
  59.                  
  60.                                                                                              }if($resp eq "4"){
  61.                                                                                                      print "Key to grep for?:";
  62.                                                                                                      chomp (my $find =<STDIN>);
  63.                                                                                                      my $command = "gpg --list-keys | grep $find";
  64.                                                                                                      system("$command");
  65.                                                                                                      exit;  
  66.    
  67.  
  68.  
  69.                                                             }if($resp eq "5"){
  70.                                                                  print "Name of Key file?:";
  71.                                                                  chomp (my $key =<STDIN>);    
  72.                                                                  my $command = "gpg --import $key";
  73.                                                                  system("$command");
  74.                                                                  print "[+]Key successfully imported![+]\n";
  75.                                                                  exit;
  76.                                                                  
  77.                         }if($resp eq "6"){
  78.                                print "Key to display?:";
  79.                                chomp (my $key=<STDIN>);
  80.                                my $command = "gpg --armor --export $key -o key.asc";
  81.                                system("$command");
  82.            
  83.                                if(1){
  84.                            
  85.                             print "\n[+]Key successfully exported[+]\n"  
  86.                              }else{ die;}
  87.                               exit;
  88.     }if($resp eq "7"){
  89.              print "Key to Delete from keyring?:";
  90.              chomp(my $key_to_delete = <STDIN>);
  91.              my $key_command = "gpg --delete-keys $key_to_delete";          
  92.              system("$key_command");
  93.              print "[+]Key Deleted[+]\n";
  94.              exit;
  95. #Line 86   Pico Text editor
  96.  
  97.         }if($resp eq "8"){
  98.             print "File to create(gpg or txt?):";
  99.             chomp(my $file = <STDIN>);
  100.  
  101.              if( $file eq "txt"){
  102.                  print "Name of text file?(No extensions! ie myfile):";      
  103.              chomp(my $txt = <STDIN>);
  104.                  my $command = "pico $txt.txt";
  105.                  system("$command");
  106.                  print "[+]File Created![+]\n";
  107.  
  108.                  print "Would you like to encrypt the new file?:(Y or N):";
  109.                  chomp(my $ans = <STDIN>);
  110.                 if(($ans eq "y") or ($ans eq "Y")){
  111.                   print "Which key would you like to use?:";
  112.                 chomp(my $key = <STDIN>);
  113.                  my $enccmd = "gpg --recipient $key --armor --encrypt $txt.txt";
  114.                  system("$enccmd");
  115.                  print "[+]File created and Encrypted![+]\n";
  116.                  exit;
  117.               }
  118. #line 108
  119.         }    
  120.             if($file eq "gpg"){
  121.                print "Name for the gpg file(No extensions! ie myfile):";
  122.                chomp(my $gpg=<STDIN>);
  123.                my $command1 = "pico $gpg.txt.gpg";
  124.                system("$command1");
  125.                print "[+]File Created![+]\n";
  126.                print "Would you like to decrypt the new file?(Y or N):";            
  127.               chomp (my $ans1 = <STDIN>);
  128.               if(($ans1 eq "y") or ($ans1 eq "Y")){
  129.               print "outfile to use?:";
  130.               chomp(my $out =<STDIN>);
  131.               my $deccmd = "gpg --output $out --decrypt $gpg.txt.gpg";
  132.               system("$deccmd");
  133.               print "[+]file Decrypted![+]\n";
  134.               exit;
  135.               }
  136.                
  137.  
  138. }
  139.             }else{
  140.  
  141.            print "[-]Error[-] Check the options and try again\n\n";
  142.  
  143.  
  144.  
  145.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement