worawit / blutter

Flutter Mobile Application Reverse Engineering Tool
MIT License
929 stars 147 forks source link

fixed unhandled class id kRecordCid and kLibraryPrefixCid #21

Closed yzctzl closed 10 months ago

yzctzl commented 10 months ago

unhandled class id kRecordCid and kLibraryPrefixCid will report error as shown in #19 and #20 . Very close to the ToCString()/ToString() functions of these classes, I made a patch.

yzctzl commented 10 months ago

It may be inconvenient to handle nearly a hundred classes (all cids < kNumPredefinedCids). I don't know if this is appropriate, but it may avoid error like #20 , and only those classes that can extract more information need special treatment. Thanks!

// in VarValue.h
struct VarSubInstance : public VarValue {
    explicit VarSubInstance(dart::Object& obj) : VarValue(obj.GetClassId(), true), obj(obj) {}
    virtual ValueType TypeId() { return obj.GetClassId(); }
    virtual std::string ToString() { return obj.ToCString(); }

    dart::Object& obj;
};

// in CodeAnalylizer_arm64.cpp getPoolObject function's switch body
        default: {
            if (obj.GetClassId() < dart::kNumPredefinedCids) {
                return new VarSubInstance(obj);
            }
        }
ai474427793 commented 10 months ago

I tried to run the last step of the command But the program threw a problem, as shown below root@debian:/home/lwd/blutter2/blutter# python3 blutter.py '/home/lwd/下载/1/arm64-v8a' out_dir --rebuild Dart version: 2.19.6, Snapshot: adb4292f3ec25074ca70abcd2d5c7251, Target: android arm64 -- Configuring done -- Generating done -- Build files have been written to: /home/lwd/blutter2/blutter/build/blutter_dartvm2.19.6_android_arm64 [1/22] Building CXX object CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx.gch FAILED: CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx.gch /usr/bin/c++ -DDART_COMPRESSED_POINTERS -DDART_PRECOMPILED_RUNTIME -DDART_TARGET_OS_ANDROID -DDART_TARGET_OS_WINDOWS_UWP -DEXCLUDE_CFE_AND_KERNEL_PLATFORM -DFRIDA_TEMPLATE_DIR=\"/home/lwd/blutter2/blutter/scripts\" -DHAS_TYPE_REF -DNDEBUG -DPRODUCT -DTARGET_ARCH_ARM64 -DU_USING_ICU_NAMESPACE=0 -D_HAS_EXCEPTIONS=0 -I/usr/include/capstone -isystem /home/lwd/blutter2/blutter/packages/include/dartvm2.19.6 -O3 -DNDEBUG -O3 -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -fno-omit-frame-pointer -std=c++20 -Winvalid-pch -x c++-header -include /home/lwd/blutter2/blutter/build/blutter_dartvm2.19.6_android_arm64/CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx -MD -MT CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx.gch -MF CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx.gch.d -o CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx.gch -c /home/lwd/blutter2/blutter/build/blutter_dartvm2.19.6_android_arm64/CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx.cxx In file included from /home/lwd/blutter2/blutter/build/blutter_dartvm2.19.6_android_arm64/CMakeFiles/blutter_dartvm2.19.6_android_arm64.dir/cmake_pch.hxx:5, from <command-line>: /home/lwd/blutter2/blutter/blutter/src/pch.h:12:10: fatal error: format: 没有那个文件或目录 12 | #include <format> | ^~~~~~~~ compilation terminated. ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/lwd/blutter2/blutter/blutter.py", line 138, in <module> main(args.indir, args.outdir, args.rebuild, args.vs_sln) File "/home/lwd/blutter2/blutter/blutter.py", line 120, in main cmake_blutter(blutter_name, dartlib_name, macros) File "/home/lwd/blutter2/blutter/blutter.py", line 76, in cmake_blutter subprocess.run([NINJA_CMD], cwd=builddir, check=True) File "/usr/lib/python3.11/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ninja']' returned non-zero exit status 1. root@debian:/home/lwd/blutter2/blutter#

I also tried the same operation on Windows, but there was still an error during the final build, as shown in the error code below `(lwd) D:\fridahook\blutter>python blutter.py C:\Users\Administrator\Desktop\arm64-v8a C:\Users\Administrator\Desktop\out Dart version: 2.19.6, Snapshot: adb4292f3ec25074ca70abcd2d5c7251, Target: android arm64 CMake Error at I:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:67 (message): The C compiler

"I:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: 'D:/fridahook/blutter/build/dartvm2.19.6_android_arm64/CMakeFiles/CMakeScratch/TryCompile-jtpr3a'

Run Build Command(s): I:/PROGRA~2/MICROS~1/2022/COMMUN~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe -v cmTC_2ac9d
[1/2] I:\PROGRA~2\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1438~1.331\bin\Hostx64\x64\cl.exe  /nologo   /DWIN32 /D_WINDOWS  /Zi /Ob0 /Od /RTC1 -MDd /showIncludes /FoCMakeFiles\cmTC_2ac9d.dir\testCCompiler.c.obj /FdCMakeFiles\cmTC_2ac9d.dir\ /FS -c D:\fridahook\blutter\build\dartvm2.19.6_android_arm64\CMakeFiles\CMakeScratch\TryCompile-jtpr3a\testCCompiler.c
[2/2] cmd.exe /C "cd . && "I:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_2ac9d.dir --rc=I:\WINDOW~1\10\bin\100226~1.0\x64\rc.exe --mt=I:\WINDOW~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- I:\PROGRA~2\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1438~1.331\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_2ac9d.dir\testCCompiler.c.obj  /out:cmTC_2ac9d.exe /implib:cmTC_2ac9d.lib /pdb:cmTC_2ac9d.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
FAILED: cmTC_2ac9d.exe
cmd.exe /C "cd . && "I:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_2ac9d.dir --rc=I:\WINDOW~1\10\bin\100226~1.0\x64\rc.exe --mt=I:\WINDOW~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- I:\PROGRA~2\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1438~1.331\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_2ac9d.dir\testCCompiler.c.obj  /out:cmTC_2ac9d.exe /implib:cmTC_2ac9d.lib /pdb:cmTC_2ac9d.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:5 (project)

-- Configuring incomplete, errors occurred! Traceback (most recent call last): File "blutter.py", line 138, in main(args.indir, args.outdir, args.rebuild, args.vs_sln) File "blutter.py", line 101, in main fetch_and_build(dart_version, arch, os_name) File "D:\fridahook\blutter\dartvm_fetch_build.py", line 110, in fetch_and_build cmake_dart(ver, arch, os_name, outdir) File "D:\fridahook\blutter\dartvm_fetch_build.py", line 102, in cmake_dart subprocess.run([CMAKE_CMD, '-GNinja', '-B', builddir, f'-DTARGET_OS={os_name}', f'-DTARGET_ARCH={arch}', '-DCMAKE_BUILD_TYPE=Release', '--log-level=NOTICE'], cwd=target_dir, check=True) File "d:\python37\lib\subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['cmake', '-GNinja', '-B', 'D:\fridahook\blutter\build\dartvm2.19.6_android_arm64', '-DTARGET_OS=android', '-DTARGET_ARCH=arm64', '-DCMAKE_BUILD_TYPE=Release', '--log-level=NOTICE']' returned non-zero exit status 1.

(lwd) D:\fridahook\blutter>`

If you have time, could you please let me know how to handle this error

ai474427793 commented 10 months ago

Sorry, I found that the error was caused by Debian's g++version being less than 13. After the update, it can now be compiled normally. By the way, 大佬牛逼