0

我制作了一个简单的 Windows 批处理文件来解码 JAR 和 APK,它可以正常工作:

@ECHO off
 SETLOCAL ENABLEDELAYEDEXPANSION
 SET listejar=:core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:framework2.jar:android.policy.jar:services.jar:apache-xml.jar:filterfw.jar:java.awt.jar:svc.jar:am.jar:android.test.runner.jar:bmgr.jar:bu.jar:com.android.future.usb.accessory.jar:com.android.location.provider.jar:com.google.android.maps.jar:com.google.android.media.effects.jar:com.google.widevine.software.drm.jar:com.samsung.device.jar:com.yamaha.android.media.jar:twframework.jar:send_bug.jar:GlobalConfig.jar:ime.jar:input.jar:javax.obex.jar:libvtmanagerjar.jar:minimode.jar:monkey.jar:pm.jar:seccamera.jar:secframework.jar:sechardware.jar:secmediarecorder.jar:sec_feature.jar
 SET baksmali=c:\DO\baksmali.jar
 SET smali=c:\do\smali.jar
 SET BTP1=c:\do
 SET BTP2=c:\do\framework

FOR %%F IN ("*.odex") DO (
        @echo.
        @echo.
        @echo.
        ECHO Decompiling %%F
        java -Xmx1024m -jar %baksmali% -a 15 -d %btp1% -d %btp2% -c %listejar% -x "%%F" -o "%%~nF"
        ECHO Compiling %%~nF classses.dex
        md "%%~dpnF"_o
        java -Xmx1024m -jar %smali% -a 15 %%~nF -o "%%~dpnF"_o\classes.dex
        RD /s/q "%%~dpnF"

        C:\DO\7z.exe u "%%~dpnF".jar %%~dpnF"_o\classes.dex >NUL
        RD /s/q %%~dpnF"_o
        DEL %%~dpnxF
        ECHO %%~nF is Deodexed
    )
cd..

CD app
FOR %%F IN ("*.odex") DO (
        @echo:
        @echo:
        @echo:
        ECHO Decompiling %%F
        java -Xmx1024m -jar %baksmali% -a 15 -d %btp1% -d %btp2% -c %listejar% -x "%%F" -o "%%~nF"
        ECHO Compiling %%~nF classses.dex
        md "%%~dpnF"_o
        java -Xmx1024m -jar %smali% -a 15 %%~nF -o "%%~dpnF"_o\classes.dex
        RD /s/q "%%~dpnF"
        C:\DO\7z.exe u "%%~dpnF".apk %%~dpnF"_o\classes.dex >NUL
        RD /s/q %%~dpnF"_o
        DEL %%~dpnxF
        ECHO %%~nF is Deodexed
    )
echo ALL DONE press any key to exit
pause >NUL
exit

但后来我试着让它变得更好一点,我不知道我做错了什么。它现在立即退出。对此事的帮助将不胜感激。

这是我在修订版中尝试做的事情:

@ECHO off
 SETLOCAL ENABLEDELAYEDEXPANSION
 SET listejar=:core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:framework2.jar:android.policy.jar:services.jar:apache-xml.jar:filterfw.jar:java.awt.jar:svc.jar:am.jar:android.test.runner.jar:bmgr.jar:bu.jar:com.android.future.usb.accessory.jar:com.android.location.provider.jar:com.google.android.maps.jar:com.google.android.media.effects.jar:com.google.widevine.software.drm.jar:com.samsung.device.jar:com.yamaha.android.media.jar:twframework.jar:send_bug.jar:GlobalConfig.jar:ime.jar:input.jar:javax.obex.jar:libvtmanagerjar.jar:minimode.jar:monkey.jar:pm.jar:seccamera.jar:secframework.jar:sechardware.jar:secmediarecorder.jar:sec_feature.jar
 SET baksmali=c:\DO\baksmali.jar
 SET smali=c:\do\smali.jar
 SET BTP1=c:\do
 SET BTP2=c:\do\framework

CD framework
 IF EXIST *.odex ( GOTO STARTFW ) ELSE ( ECHO Odex Not Found && GOTO FINISHEDFW )

 :STARTFW
 FOR %%F IN ("*.odex") DO (
 @echo.
 @echo.
 @echo.
 ECHO Decompiling %%~nxF
 java -Xmx1024m -jar %baksmali% -a 15 -d %btp1% -d %btp2% -c %listejar% -x "%%F" -o "%%~nF"
 ECHO Compiling %%~nF classses.dex
 MD "%%~dpnF"_o
 java -Xmx1024m -jar %smali% -a 15 %%~nF -o "%%~dpnF"_o\classes.dex
 RD /s/q "%%~dpnF"
 IF EXIST "%%~dpnF"_o\classes.dex (GOTO CONTINIUEFW) ELSE (GOTO CHECKFW)

 :CHECKFFW
 IF NOT EXIST C:\DO\Framework\ERORR ( MD C:\Framework\Error )
 MOVE /Y "%%~dpnF".* C:\Framework\Error
 ECHO Error With %%~nxF & %%~nF.jar
 ECHO Moved To Error Folder
 GOTO SKIPFW

 :CONTINIUEFW
 ECHO Injecting classes.dex to "%%~nF".jar
 C:\DO\7z.exe u "%%~dpnF".jar %%~dpnF"_o\classes.dex >NUL
 RD /s/q %%~dpnF"_o
 DEL %%~dpnxF
 ECHO %%~nF.jar is Deodexed
 IF EXIST *.odex ( 
  GOTO STARTFW
  ) ELSE ( 
  ECHO Odex Not Found
  GOTO FINISHEDFW
  )

 :SKIPFW
 )

:FINISHEDFW
CD..
CD app

 IF EXIST *.odex ( 
  GOTO STARTAPP 
  ) ELSE ( 
   ECHO Odex Not Found
   GOTO FINISHEDAPP
 )
:STARTAPP
 FOR %%F IN ("*.odex") DO (
 @echo.
 @echo.
 @echo.
 ECHO Decompiling %%~nxF
 java -Xmx1024m -jar %baksmali% -a 15 -d %btp1% -d %btp2% -c %listejar% -x "%%F" -o "%%~nF"
 ECHO Compiling %%~nF classses.dex
 MD "%%~dpnF"_o
 java -Xmx1024m -jar %smali% -a 15 %%~nF -o "%%~dpnF"_o\classes.dex
 RD /s/q "%%~dpnF"
 IF EXIST "%%~dpnF"_o\classes.dex ( GOTO CONTINIUEAPP ) ELSE ( GOTO CHECKAPP )

 :CHECKFAPP
 IF NOT EXIST C:\DO\app\ERORR ( MD C:\app\Error )
 MOVE /Y "%%~dpnF".* C:\app\Error
 ECHO Error With %%~nxF & %%~nF.apk
 ECHO Moved To Error Folder
 GOTO SKIPAPP

 :CONTINIUEAPP
 ECHO Injecting classes.dex to "%%~nF".apk
 C:\DO\7z.exe u "%%~dpnF".apk %%~dpnF"_o\classes.dex >NUL
 RD /s/q %%~dpnF"_o
 DEL %%~dpnxF
 ECHO %%~nF.apk is Deodexed
 IF EXIST *.odex ( 
  GOTO STARTAPP
  ) ELSE ( 
  ECHO Odex Not Found
  GOTO FINISHEDAPP
 )

 :SKIPAPP

 )

echo ALL DONE press any key to exit
pause >NUL
exit 
4

1 回答 1

1

我还没有跟踪您的代码以了解您收到语法错误的原因。但我看到了一个严重的问题 - 您试图在循环中使用 GOTO 并分支到同一循环中的标签。这根本不会按照您希望的方式工作。使用 GOTO 的那一刻,循环就被打破了。GOTO 发现标签 OK,但脚本不再知道有关循环的任何信息。除非您真的很聪明并且想要混淆您的代码,否则您的结果肯定会与您的预期不同。

通常,您永远不应该 GOTO 带括号的代码块中的标签。FOR 循环和 IF 语句都是如此。对于 IF/ELSE 块中的类似问题,请参阅(Windows 批处理)Goto inside if 块的行为非常奇怪

于 2012-07-07T21:08:24.950 回答