mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Yara plugin + fix linuxdeployqt plugins (#2924)
This commit is contained in:
parent
247ab94b71
commit
90608117c9
9
.github/workflows/ccpp.yml
vendored
9
.github/workflows/ccpp.yml
vendored
@ -124,6 +124,7 @@ jobs:
|
||||
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON \
|
||||
-DCUTTER_PACKAGE_RZ_GHIDRA=ON \
|
||||
-DCUTTER_PACKAGE_RZ_LIBSWIFT=ON \
|
||||
-DCUTTER_PACKAGE_RZ_LIBYARA=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=appdir/usr \
|
||||
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
|
||||
..
|
||||
@ -142,20 +143,16 @@ jobs:
|
||||
ninja install
|
||||
"../scripts/appimage_embed_python.sh" appdir
|
||||
APP_PREFIX=`pwd`/appdir/usr
|
||||
# export LD_LIBRARY_PATH=${APP_PREFIX}/lib:$Shiboken2_ROOT/lib
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$APP_PREFIX/lib/rizin/plugins"
|
||||
export PATH=$PATH:${APP_PREFIX}/bin
|
||||
"../scripts/jsdec.sh" --prefix=`pwd`/appdir/usr
|
||||
wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
|
||||
chmod a+x linuxdeployqt*.AppImage
|
||||
rm -fv "../cutter-deps/qt/plugins/imageformats/libqjp2.so"
|
||||
# ./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -executable=./appdir/usr/bin/python3 -bundle-non-qt-libs -no-strip -exclude-libs=libnss3.so,libnssutil3.so,libqjp2.so -ignore-glob=usr/lib/python3.9/**/* -verbose=2
|
||||
# exclude librzghidra cutter plugin because cutter and rz plugin is loaded manuallly as they are plugins linuxdeployqt doesn't know this
|
||||
./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop \
|
||||
-executable=./appdir/usr/bin/python3 \
|
||||
-appimage \
|
||||
-no-strip -exclude-libs=libnss3.so,libnssutil3.so,libqjp2.so \
|
||||
-ignore-glob=usr/lib/python3.9/**/* \
|
||||
-ignore-glob=usr/share/rizin/cutter/plugins/native/librz_ghidra_cutter.so \
|
||||
-verbose=2
|
||||
find ./appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
|
||||
export APPIMAGE_FILE="Cutter-${PACKAGE_ID}-x64.Linux.AppImage"
|
||||
@ -192,6 +189,7 @@ jobs:
|
||||
-DCUTTER_PACKAGE_RZ_GHIDRA=ON \
|
||||
-DCUTTER_PACKAGE_JSDEC=ON \
|
||||
-DCUTTER_PACKAGE_RZ_LIBSWIFT=ON \
|
||||
-DCUTTER_PACKAGE_RZ_LIBYARA=ON \
|
||||
-DCPACK_PACKAGE_FILE_NAME="$PACKAGE_NAME" \
|
||||
-DCMAKE_FRAMEWORK_PATH="$BREAKPAD_FRAMEWORK_DIR" \
|
||||
-DCPACK_BUNDLE_APPLE_CERT_APP="-" \
|
||||
@ -231,6 +229,7 @@ jobs:
|
||||
-DCUTTER_PACKAGE_DEPENDENCIES=ON ^
|
||||
-DCUTTER_PACKAGE_RZ_GHIDRA=ON ^
|
||||
-DCUTTER_PACKAGE_RZ_LIBSWIFT=ON ^
|
||||
-DCUTTER_PACKAGE_RZ_LIBYARA=ON ^
|
||||
-DCUTTER_PACKAGE_JSDEC=ON ^
|
||||
-DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON ^
|
||||
-DCUTTER_ENABLE_CRASH_REPORTS=ON ^
|
||||
|
@ -27,6 +27,7 @@ option(CUTTER_ENABLE_SIGDB "Downloads and installs sigdb (only available when CU
|
||||
option(CUTTER_PACKAGE_DEPENDENCIES "During install step include the third party dependencies." OFF)
|
||||
option(CUTTER_PACKAGE_RZ_GHIDRA "Compile and install rz-ghidra during install step." OFF)
|
||||
option(CUTTER_PACKAGE_RZ_LIBSWIFT, "Compile and install rz-libswift demangler during the install step." OFF)
|
||||
option(CUTTER_PACKAGE_RZ_LIBYARA, "Compile and install rz-libyara during the install step." OFF)
|
||||
option(CUTTER_PACKAGE_JSDEC "Compile and install jsdec during install step." OFF)
|
||||
OPTION(CUTTER_QT6 "Use QT6" OFF)
|
||||
|
||||
@ -132,6 +133,14 @@ message(STATUS "- Python Bindings: ${CUTTER_ENABLE_PYTHON_BINDINGS}")
|
||||
message(STATUS "- Crash Handling: ${CUTTER_ENABLE_CRASH_REPORTS}")
|
||||
message(STATUS "- KSyntaxHighlighting: ${KSYNTAXHIGHLIGHTING_STATUS}")
|
||||
message(STATUS "- Graphviz: ${CUTTER_ENABLE_GRAPHVIZ}")
|
||||
message(STATUS "- Downloads dependencies: ${CUTTER_ENABLE_DEPENDENCY_DOWNLOADS}")
|
||||
message(STATUS "- Enable Packaging: ${CUTTER_ENABLE_PACKAGING}")
|
||||
message(STATUS "- Package Dependencies: ${CUTTER_PACKAGE_DEPENDENCIES}")
|
||||
message(STATUS "- Package RzGhidra: ${CUTTER_PACKAGE_RZ_GHIDRA}")
|
||||
message(STATUS "- Package RzLibSwift: ${CUTTER_PACKAGE_RZ_LIBSWIFT}")
|
||||
message(STATUS "- Package RzLibYara: ${CUTTER_PACKAGE_RZ_LIBYARA}")
|
||||
message(STATUS "- Package JSDec: ${CUTTER_PACKAGE_JSDEC}")
|
||||
message(STATUS "- QT6: ${CUTTER_QT6}")
|
||||
message(STATUS "")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
64
dist/CMakeLists.txt
vendored
64
dist/CMakeLists.txt
vendored
@ -28,7 +28,7 @@ if(WIN32)
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
RESULT_VARIABLE SCRIPT_RESULT)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to package jsdec\")
|
||||
message(FATAL_ERROR \"Failed to package jsdec (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
@ -40,7 +40,22 @@ if(WIN32)
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
RESULT_VARIABLE SCRIPT_RESULT)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to package rz-libswift\")
|
||||
message(FATAL_ERROR \"Failed to package rz-libswift (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
if (CUTTER_PACKAGE_RZ_LIBYARA AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
|
||||
install(CODE "
|
||||
set(ENV{RZ_PREFIX} \"\${CMAKE_INSTALL_PREFIX}\")
|
||||
set(ENV{PATH} \"\${CMAKE_INSTALL_PREFIX};\$ENV{PATH}\")
|
||||
execute_process(COMMAND powershell
|
||||
\"${CMAKE_CURRENT_SOURCE_DIR}/bundle_rz_libyara.ps1\"
|
||||
\"\${CMAKE_INSTALL_PREFIX}\"
|
||||
\"-DCUTTER_INSTALL_PLUGDIR=plugins/native\"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
RESULT_VARIABLE SCRIPT_RESULT)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to package rz_libyara (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
@ -93,29 +108,52 @@ if(APPLE)
|
||||
get_filename_component(QT_PREFIX "${MACDEPLOYQT_PATH}/../.." ABSOLUTE)
|
||||
list(APPEND RZ_GHIDRA_PREFIX_PATH "${QT_PREFIX}")
|
||||
set(RIZIN_INSTALL_PLUGDIR "lib/rizin/plugins") # escaped backslash on purpose, should be evaluated later
|
||||
endif()
|
||||
|
||||
if (CUTTER_PACKAGE_JSDEC AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
|
||||
################################################
|
||||
# macOS + Linux
|
||||
################################################
|
||||
|
||||
if(CUTTER_ENABLE_DEPENDENCY_DOWNLOADS AND (NOT WIN32))
|
||||
if (CUTTER_PACKAGE_JSDEC)
|
||||
install(CODE "
|
||||
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/jsdec.sh\" --pkg-config-path=\${CMAKE_INSTALL_PREFIX}/lib/pkgconfig --prefix=\${CMAKE_INSTALL_PREFIX}
|
||||
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/jsdec.sh\"
|
||||
--pkg-config-path=\${CMAKE_INSTALL_PREFIX}/lib/pkgconfig --prefix=\${CMAKE_INSTALL_PREFIX}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
RESULT_VARIABLE SCRIPT_RESULT)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to package jsdec\")
|
||||
message(FATAL_ERROR \"Failed to package jsdec (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
|
||||
if (CUTTER_PACKAGE_RZ_LIBSWIFT AND CUTTER_ENABLE_DEPENDENCY_DOWNLOADS)
|
||||
if (CUTTER_PACKAGE_RZ_LIBSWIFT)
|
||||
install(CODE "
|
||||
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/rz-libswift.sh\" --pkg-config-path=\${CMAKE_INSTALL_PREFIX}/lib/pkgconfig --prefix=\${CMAKE_INSTALL_PREFIX}
|
||||
execute_process(COMMAND \"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/rz-libswift.sh\"
|
||||
--pkg-config-path=\${CMAKE_INSTALL_PREFIX}/lib/pkgconfig --prefix=\${CMAKE_INSTALL_PREFIX}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
RESULT_VARIABLE SCRIPT_RESULT)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to package rz-libswift\")
|
||||
message(FATAL_ERROR \"Failed to package rz-libswift (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
if (CUTTER_PACKAGE_RZ_LIBYARA)
|
||||
if(APPLE)
|
||||
set (YARA_PLUGIN_OPTIONS "-DCUTTER_INSTALL_PLUGDIR=plugins/native")
|
||||
else()
|
||||
set (YARA_PLUGIN_OPTIONS "")
|
||||
endif()
|
||||
install(CODE "
|
||||
execute_process(COMMAND
|
||||
\"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/rz-libyara.sh\"
|
||||
\"\${CMAKE_INSTALL_PREFIX}\" \"${YARA_PLUGIN_OPTIONS}\"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
RESULT_VARIABLE SCRIPT_RESULT)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to package rz-libyara (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
################################################
|
||||
@ -144,7 +182,7 @@ if(CUTTER_PACKAGE_RZ_GHIDRA)
|
||||
\"-DRIZIN_INSTALL_PLUGDIR=\${CMAKE_INSTALL_PREFIX}/${RIZIN_INSTALL_PLUGDIR}\"
|
||||
-DCUTTER_INSTALL_PLUGDIR=plugins/native")
|
||||
else()
|
||||
set (GHIDRA_OPTIONS "")
|
||||
set (GHIDRA_OPTIONS "-DCUTTER_INSTALL_PLUGDIR=\${CMAKE_INSTALL_PREFIX}/share/rizin/cutter/plugins/native")
|
||||
endif()
|
||||
install(CODE "
|
||||
execute_process(
|
||||
@ -161,14 +199,14 @@ if(CUTTER_PACKAGE_RZ_GHIDRA)
|
||||
-G Ninja
|
||||
)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to configure rz-ghidra\")
|
||||
message(FATAL_ERROR \"Failed to configure rz-ghidra (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/rz-ghidra-prefix/src/rz-ghidra-build
|
||||
RESULT_VARIABLE SCRIPT_RESULT
|
||||
COMMAND \${CMAKE_COMMAND} --build . --target install
|
||||
)
|
||||
if (SCRIPT_RESULT)
|
||||
message(FATAL_ERROR \"Failed to install rz-ghidra plugin\")
|
||||
message(FATAL_ERROR \"Failed to install rz-ghidra plugin (returned \${SCRIPT_RESULT})\")
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
|
3
dist/MacOSSetupBundle.cmake.in
vendored
3
dist/MacOSSetupBundle.cmake.in
vendored
@ -60,6 +60,9 @@ run_or_die(COMMAND install_name_tool
|
||||
run_or_die(COMMAND install_name_tool
|
||||
-add_rpath "@executable_path/../Resources/lib"
|
||||
"${EXECUTABLE_DIR}/cutter")
|
||||
run_or_die(COMMAND install_name_tool
|
||||
-add_rpath "@executable_path/../Resources/lib/rizin/plugins"
|
||||
"${EXECUTABLE_DIR}/cutter")
|
||||
|
||||
set(MACDEPLOYQT_COMMAND "${MACDEPLOYQT_PATH}" "${BUNDLE_PATH}" "-verbose=2" "-libpath=${CMAKE_INSTALL_PREFIX}/lib")
|
||||
message("Running macdeployqt \"${MACDEPLOYQT_COMMAND}\"")
|
||||
|
2
dist/bundle_rz_libswift.ps1
vendored
2
dist/bundle_rz_libswift.ps1
vendored
@ -13,4 +13,4 @@ if(![System.IO.File]::Exists($pathdll)) {
|
||||
ls "$dist/lib/plugins/"
|
||||
throw (New-Object System.IO.FileNotFoundException("File not found: $pathdll", $pathdll))
|
||||
}
|
||||
Remove-Item -Recurse -Force $dist/lib/plugins/libswift.lib
|
||||
Remove-Item -Recurse -Force $dist/lib/plugins/swift.lib
|
||||
|
26
dist/bundle_rz_libyara.ps1
vendored
Normal file
26
dist/bundle_rz_libyara.ps1
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
$dist = $args[0]
|
||||
$cmake_opts = $args[1]
|
||||
$python = Split-Path((Get-Command python.exe).Path)
|
||||
|
||||
if (-not (Test-Path -Path 'rz_libyara' -PathType Container)) {
|
||||
git clone https://github.com/rizinorg/rz-libyara.git --depth 1 rz_libyara
|
||||
git -C rz_libyara submodule init
|
||||
git -C rz_libyara submodule update
|
||||
}
|
||||
cd rz_libyara
|
||||
& meson.exe --buildtype=release --prefix=$dist build
|
||||
ninja -C build install
|
||||
$pathdll = "$dist/lib/plugins/rz_yara.dll"
|
||||
if(![System.IO.File]::Exists($pathdll)) {
|
||||
type build/meson-logs/meson-log.txt
|
||||
ls "$dist/lib/plugins/"
|
||||
throw (New-Object System.IO.FileNotFoundException("File not found: $pathdll", $pathdll))
|
||||
}
|
||||
Remove-Item -Recurse -Force $dist/lib/plugins/rz_yara.lib
|
||||
|
||||
cd cutter-plugin
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DRIZIN_INSTALL_PLUGDIR="../build" -DCMAKE_INSTALL_PREFIX="$dist" $cmake_opts ..
|
||||
ninja
|
||||
ninja install
|
2
rizin
2
rizin
@ -1 +1 @@
|
||||
Subproject commit 7665d0f30ef7771b305329502d94842ec4a97a62
|
||||
Subproject commit 1a0ce1faa3b552c4f1756d377ffa5973a9a358bf
|
25
scripts/rz-libyara.sh
Executable file
25
scripts/rz-libyara.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SCRIPTPATH=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
|
||||
INSTALL_PREFIX="$1"
|
||||
EXTRA_CMAKE_OPTS="$2"
|
||||
|
||||
cd "$SCRIPTPATH/.."
|
||||
|
||||
if [[ ! -d rz_libyara ]]; then
|
||||
git clone https://github.com/rizinorg/rz-libyara.git --depth 1 rz_libyara
|
||||
git -C rz_libyara submodule init
|
||||
git -C rz_libyara submodule update
|
||||
fi
|
||||
|
||||
cd rz_libyara
|
||||
|
||||
meson --buildtype=release --pkg-config-path="$INSTALL_PREFIX/lib/pkgconfig" --prefix="$INSTALL_PREFIX" build
|
||||
ninja -C build install
|
||||
|
||||
cd cutter-plugin
|
||||
mkdir build && cd build
|
||||
cmake -G Ninja -DRIZIN_INSTALL_PLUGDIR="../build" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $EXTRA_CMAKE_OPTS ..
|
||||
ninja
|
||||
ninja install
|
@ -163,13 +163,8 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
|
||||
appdir.cdUp(); // appdir
|
||||
|
||||
auto sleighHome = appdir;
|
||||
sleighHome.cd(
|
||||
"share/rizin/plugins/rz_ghidra_sleigh"); // appdir/share/rizin/plugins/rz_ghidra_sleigh
|
||||
sleighHome.cd("lib/rizin/plugins/rz_ghidra_sleigh/"); // appdir/lib/rizin/plugins/rz_ghidra_sleigh/
|
||||
Core()->setConfig("ghidra.sleighhome", sleighHome.absolutePath());
|
||||
|
||||
auto jsdecHome = appdir;
|
||||
jsdecHome.cd("share/rizin/plugins/jsdec"); // appdir/share/rizin/plugins/jsdec
|
||||
qputenv("JSDEC_HOME", jsdecHome.absolutePath().toLocal8Bit());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -65,6 +65,7 @@ void PluginManager::loadPluginsFromDir(const QDir &pluginsDir, bool writable)
|
||||
nativePluginsDir.mkdir("native");
|
||||
}
|
||||
if (nativePluginsDir.cd("native")) {
|
||||
qInfo() << "Native plugins are loaded from" << nativePluginsDir.absolutePath();
|
||||
loadNativePlugins(nativePluginsDir);
|
||||
}
|
||||
|
||||
@ -74,6 +75,7 @@ void PluginManager::loadPluginsFromDir(const QDir &pluginsDir, bool writable)
|
||||
pythonPluginsDir.mkdir("python");
|
||||
}
|
||||
if (pythonPluginsDir.cd("python")) {
|
||||
qInfo() << "Python plugins are loaded from" << pythonPluginsDir.absolutePath();
|
||||
loadPythonPlugins(pythonPluginsDir.absolutePath());
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user