Lib Name Extraction from APKs

This topic contains 0 replies, has 1 voice, and was last updated by  vivekg79 6 years, 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #31377

    vivekg79
    Member

    #!/usr/bin/perl -w 

    use strict;

    use File::Basename;

    use File::Find; 

    use warnings;  

    use IO::Uncompress::Unzip qw($UnzipError);

    use Archive::Zip qw( :ERROR_CODES :CONSTANTS );

    use Cwd;

    my $dir = cwd();

    opendir(my $dir1, “$dir”);

    open (MYFILE, “>$dir/output.txt”);

    my @filenames = sort readdir($dir1);

    closedir($dir1);
    foreach my $planet (@filenames)

     { 

      my(undef, undef, $ftype) = fileparse($planet,qr”..*”);
        if($ftype =~ m/.apk/)

        {
    my $zip = Archive::Zip->new();
    my $zipfilename = $zip->read($planet);

    $zip->extractTree();

    find(&wanted, $dir);
        }
    }

    # this function travers all the subfolders to find the shared libraries with extension “.so”

    sub wanted

    {

    my $filename = $File::Find::name;
    $filename = substr($filename,rindex($filename,”lib/”),length($filename));
    my(undef, undef, my $fileso) = fileparse(“$filename”,qr”..*”);
    if($fileso =~ m/.so/)

    {

    print MYFILE “$filename rn”;

    }

    }

     


    Readme



    To run in Linux environment

    1) Install perl in your linux environment 

    2) place all the .apk files and the perl script in the same folder(/home/usr/perlscript)

    3) run the perl script from the terminal((/home/usr/perlscript $perl perl.pl)

    4) a text file “output.txt” is created in the same directory.

     

    NOTE: if there is  error “Can't locate Archive/Zip.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .)”

     

    please download “pool/main/liba/libarchive-zip-perl/libarchive-zip-perl_1.30-2_all.deb” and install from http://www.examplenow.com/pack…..erl/repeat the steps 3 and 4.

     

    To run in Windows environment

    1) Install Perll in you windows OS from “http://www.perl.org/get.html”

    2) place all the .apk files and perl script in the same folder.

    3) run the perl script from the command prompt 

    4) a text file “output.txt” is created in the same directory.

Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.