From ad34ef740250e6e3e791d14b6f08e6c1ab5e769f Mon Sep 17 00:00:00 2001 From: Hackubau Date: Tue, 22 Dec 2020 16:00:10 +0100 Subject: [PATCH 1/3] Create cfr-loop.sh simple shell to loop through all subfolders of a project --- cfr-loop.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cfr-loop.sh diff --git a/cfr-loop.sh b/cfr-loop.sh new file mode 100644 index 00000000..c9a8c0ee --- /dev/null +++ b/cfr-loop.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +#CFR .jar file +BINARY=$1 + +#FOLDER TO DECOMPILE +FOLDER=$2 + +#OUTPUT WHERE DECOMPILE +OUTPUT=$3 + +if [[ $# -lt 3 ]] ; then + echo 'Please provide: ' + exit 1 +fi + +for f in $FOLDER/* $FOLDER/**/* ; do + if [[ -d $f ]]; then + echo "$f is a directory" + elif [[ -f $f ]]; then + java -jar $BINARY $f --outputdir $OUTPUT + fi +done; From 3b55b367abd0995dcf58d4457c34f809a384a231 Mon Sep 17 00:00:00 2001 From: Hackubau Date: Tue, 22 Dec 2020 17:14:51 +0100 Subject: [PATCH 2/3] Update cfr-loop.sh shell updated --- cfr-loop.sh | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/cfr-loop.sh b/cfr-loop.sh index c9a8c0ee..73d9bd5d 100644 --- a/cfr-loop.sh +++ b/cfr-loop.sh @@ -1,23 +1,36 @@ #!/bin/bash +#developed by marco guassone 2020/12/22 #CFR .jar file BINARY=$1 +#EXTENSION TO ANALYZE +EXT=$2 + #FOLDER TO DECOMPILE -FOLDER=$2 +FOLDER=$3 #OUTPUT WHERE DECOMPILE -OUTPUT=$3 +OUTPUT=$4 + + +if [[ $# -lt 4 ]] ; then -if [[ $# -lt 3 ]] ; then - echo 'Please provide: ' + echo '' + echo '' + echo 'Please provide the following parameters: ' + echo ' ' + echo '' + echo '' + echo 'EXAMPLE:' + echo '' + echo '' + echo './cfr-loop.sh ./cfr-0.150.jar .class /path/to/my/project-root /tmp/a-new-or-existing-folder-as-you-want' exit 1 fi -for f in $FOLDER/* $FOLDER/**/* ; do - if [[ -d $f ]]; then - echo "$f is a directory" - elif [[ -f $f ]]; then - java -jar $BINARY $f --outputdir $OUTPUT - fi -done; +set -f +for f in $(find "$FOLDER" -name *.class) +do + java -jar $BINARY $f --outputdir $OUTPUT +done From 04effa0f66b246b55f83df25a80651e1248cb74a Mon Sep 17 00:00:00 2001 From: Hackubau Date: Wed, 23 Dec 2020 10:04:45 +0100 Subject: [PATCH 3/3] Update cfr-loop.sh fixed ext variable and added SORT option (some class are decompiled differently by others and some time it's just a matter of ordering, so, if you need a second check, you can brutally alphabetically sort the entire java file to hope your compare can check if the classes are the same) --- cfr-loop.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cfr-loop.sh b/cfr-loop.sh index 73d9bd5d..ac6c89c8 100644 --- a/cfr-loop.sh +++ b/cfr-loop.sh @@ -1,5 +1,4 @@ #!/bin/bash -#developed by marco guassone 2020/12/22 #CFR .jar file BINARY=$1 @@ -13,24 +12,34 @@ FOLDER=$3 #OUTPUT WHERE DECOMPILE OUTPUT=$4 +#SORT FILE CONTENT +SORT=$5 -if [[ $# -lt 4 ]] ; then - echo '' - echo '' +if [[ $# -lt 4 ]] ; then echo 'Please provide the following parameters: ' echo ' ' echo '' - echo '' echo 'EXAMPLE:' echo '' - echo '' echo './cfr-loop.sh ./cfr-0.150.jar .class /path/to/my/project-root /tmp/a-new-or-existing-folder-as-you-want' exit 1 fi +echo "decompiling ..." set -f -for f in $(find "$FOLDER" -name *.class) +for f in $(find "$FOLDER" -name "*$EXT") do java -jar $BINARY $f --outputdir $OUTPUT done +echo "decompiling done" + +if [[ $SORT -eq sort ]] ; then + echo "sorting ..." + set -f + for fjava in $(find "$OUTPUT" -name *.java) + do + sort $fjava --output=$fjava + done + echo "sorting done" +fi