-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathdumpapk
executable file
·64 lines (53 loc) · 1.25 KB
/
dumpapk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl
#
# dump Android apk file, decompile, cleanup, rename as java
#
# -samy kamkar
use y;;;
use strict;
#my %p = map { uc($_) => env_path($_) } qw(jad d2j-dex2jar.sh unzip perl find egrep);
my $UNZIP = env_path("unzip");
my $JADX = env_path("jadx");
my $D2J = env_path("d2j-dex2jar.sh");
my $PERL = env_path("perl");
my $FIND = env_path("find");
my $EGREP = env_path("egrep");
$ENV{_JADX_PATH} = $JADX;
die "usage: $0 <apk>\n" unless @ARGV == 1;
my $apk = shift;
my $jardir = "jar";
my $jr = << 'EOF';
find . | perl -lne '$x||=`pwd`;chomp$x; if(-d $_){chdir($_); system "$ENV{_JADX_PATH}", <*.class>; chdir($x); }'
EOF
$jr =~ s/\$ENV\{(.*?)\}/$ENV{$1}/g;
my $cl = << 'EOF';
perl -ni -e 'print unless /^\/\/\s*(Decompiled by Jad|Jad home)/' `find . | egrep jad$`
EOF
# jad to jar
my $jad2jar = << 'EOF';
find . | perl -lne'$o=$_;if(s/\.jad$/.java/){print"$o -> $_";rename($o,$_)}'
EOF
runv($UNZIP, $apk);
my @jars;
foreach (<*.dex>)
{
runv($D2J, "-f", $_);
s/\.dex$/-dex2jar.jar/;
push @jars, $_;
}
for my $jar (@jars)
{
($jardir = $jar) =~ s/\.jar//;
mkdir($jardir);
cd($jardir);
runv($UNZIP, "../$jar");
runv($jr);
# if .jad files
if (grep { /jad$/ } `find .`)
{
runv($cl);
runv($jad2jar);
}
cd("..");
}
cd("..");