Skip to content

Instantly share code, notes, and snippets.

@psifertex
Last active August 22, 2025 01:23
Show Gist options
  • Select an option

  • Save psifertex/31d9bc3167eca91e466ebaae4382521c to your computer and use it in GitHub Desktop.

Select an option

Save psifertex/31d9bc3167eca91e466ebaae4382521c to your computer and use it in GitHub Desktop.

Revisions

  1. psifertex revised this gist Jul 10, 2025. 1 changed file with 15 additions and 4 deletions.
    19 changes: 15 additions & 4 deletions binexport_binja.zsh
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,9 @@
    #

    if [[ "$OSTYPE" == "darwin"* ]]; then
    SED_CMD="sed -i '' -E -e"
    SED_INPLACE="-i ''"
    else
    SED_CMD="sed -i -E -e"
    SED_INPLACE="-i"
    fi

    if [ -d ~/Downloads ]
    @@ -95,8 +95,19 @@ popd

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    $SED_CMD "s/(1bd42a73e612f50c68d802acda674c21a30e980c|6e2b374dece03f6fb48a1615fa2bfee809ec2157)/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    $SED_CMD "s/2023-05-18/2023-09-24/g" $BE_PATH/cmake/BinExportDeps.cmake

    # Get current Binary Ninja dev hash from BinExportDeps.cmake (dev branch only)
    CURRENT_BN_HASH=$(awk '/else\(\)/{flag=1} flag && /_binexport_binaryninja_git_tag/{getline; print; exit}' $BE_PATH/cmake/BinExportDeps.cmake | grep -o '[a-f0-9]\{40\}')
    echo "Current BN dev hash in BinExportDeps.cmake: $CURRENT_BN_HASH"
    echo "Binary Ninja hash from installation: $BINARY_HASH"

    # Update the Binary Ninja dev hash in BinExportDeps.cmake
    if [ "$CURRENT_BN_HASH" != "$BINARY_HASH" ]; then
    echo "Updating BN dev hash from $CURRENT_BN_HASH to $BINARY_HASH"
    sed $SED_INPLACE "s/$CURRENT_BN_HASH/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    else
    echo "BN dev hash already up to date"
    fi

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
  2. psifertex revised this gist Dec 1, 2024. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions binexport_binja.zsh
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,12 @@
    # that requires applying this patch, remove when resolved
    #

    if [[ "$OSTYPE" == "darwin"* ]]; then
    SED_CMD="sed -i '' -E -e"
    else
    SED_CMD="sed -i -E -e"
    fi

    if [ -d ~/Downloads ]
    then
    DOWNLOADS=~/Downloads
    @@ -89,8 +95,8 @@ popd

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    sed -i '' -E -e "s/(1bd42a73e612f50c68d802acda674c21a30e980c|6e2b374dece03f6fb48a1615fa2bfee809ec2157)/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i '' -E -e "s/2023-05-18/2023-09-24/g" $BE_PATH/cmake/BinExportDeps.cmake
    $SED_CMD "s/(1bd42a73e612f50c68d802acda674c21a30e980c|6e2b374dece03f6fb48a1615fa2bfee809ec2157)/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    $SED_CMD "s/2023-05-18/2023-09-24/g" $BE_PATH/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
  3. psifertex revised this gist May 7, 2024. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions binexport_binja.zsh
    Original file line number Diff line number Diff line change
    @@ -21,16 +21,16 @@ then
    BN_PATH=`cat ~/.binaryninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/api_REVISION.txt 2>/dev/null)
    CORES=$(nproc --all)
    PLUGIN_DEST="~/.binaryninja/plugins/binexport12_binaryninja.so"
    PLUGIN_SRC="~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.so"
    PLUGIN_DEST=~/.binaryninja/plugins/binexport12_binaryninja.so
    PLUGIN_SRC=~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.so
    elif [ -d ~/Library/Application\ Support/Binary\ Ninja ] && [ -f ~/Library/Application\ Support/Binary\ Ninja/lastrun ]
    then
    BN_USER=~/Library/Application\ Support/Binary\ Ninja
    BN_PATH=`cat ~/Library/Application\ Support/Binary\ Ninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/../Resources/api_REVISION.txt 2>/dev/null)
    CORES=$(sysctl -n hw.logicalcpu)
    PLUGIN_DEST="~/Library/Application\ Support/Binary\ Ninja/plugins/binexport12_binaryninja.dylib"
    PLUGIN_SRC="~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib"
    PLUGIN_DEST=~/Library/Application\ Support/Binary\ Ninja/plugins/binexport12_binaryninja.dylib
    PLUGIN_SRC=~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib
    else
    echo "Failed to find appropriate Binary Ninja user directory."
    exit 1
  4. psifertex revised this gist Nov 30, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion binexport_binja.zsh
    Original file line number Diff line number Diff line change
    @@ -90,7 +90,7 @@ popd
    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    sed -i '' -E -e "s/(1bd42a73e612f50c68d802acda674c21a30e980c|6e2b374dece03f6fb48a1615fa2bfee809ec2157)/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i '' -E -e "s/(2023-05-18/2023-09-24/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i '' -E -e "s/2023-05-18/2023-09-24/g" $BE_PATH/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
  5. psifertex revised this gist Nov 15, 2023. 1 changed file with 32 additions and 43 deletions.
    75 changes: 32 additions & 43 deletions binexport_binja.zsh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@

    # Note:
    # CMake, Clang, clang-format, Ninja, git and sed are required to build
    #
    # Note that currently there is a bug (https://github.com/google/binexport/issues/117)
    # that requires applying this patch, remove when resolved
    #

    if [ -d ~/Downloads ]
    then
    @@ -17,12 +21,16 @@ then
    BN_PATH=`cat ~/.binaryninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/api_REVISION.txt 2>/dev/null)
    CORES=$(nproc --all)
    PLUGIN_DEST="~/.binaryninja/plugins/binexport12_binaryninja.so"
    PLUGIN_SRC="~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.so"
    elif [ -d ~/Library/Application\ Support/Binary\ Ninja ] && [ -f ~/Library/Application\ Support/Binary\ Ninja/lastrun ]
    then
    BN_USER=~/Library/Application\ Support/Binary\ Ninja
    BN_PATH=`cat ~/Library/Application\ Support/Binary\ Ninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/../Resources/api_REVISION.txt 2>/dev/null)
    CORES=$(sysctl -n hw.logicalcpu)
    PLUGIN_DEST="~/Library/Application\ Support/Binary\ Ninja/plugins/binexport12_binaryninja.dylib"
    PLUGIN_SRC="~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib"
    else
    echo "Failed to find appropriate Binary Ninja user directory."
    exit 1
    @@ -59,29 +67,30 @@ then
    else
    git clone https://github.com/google/binexport.git $BE_PATH
    fi
    if [ -d $BN_API_PATH ]

    if [ ! -d $BN_API_PATH ]
    then
    pushd $BN_API_PATH
    if git fetch --all
    git clone --recursive --branch dev https://github.com/Vector35/binaryninja-api.git $BN_API_PATH
    fi

    pushd $BN_API_PATH
    if git fetch --all
    then
    if git checkout "$BINARY_HASH"
    then
    if git checkout "$BINARY_HASH"
    then
    git pull
    echo "Binary Ninja API exists, repo updated"
    else
    echo Not a repo or could not match binary hash
    exit
    fi
    git pull
    echo "Binary Ninja API exists, repo updated"
    else
    echo Not a repo or could not match binary hash
    exit
    fi
    popd
    else
    git clone --recursive --branch dev https://github.com/Vector35/binaryninja-api.git $BN_API_PATH
    fi
    popd

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    sed -i'' -e "s/1bd42a73e612f50c68d802acda674c21a30e980c/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i'' -e "s/2023-05-18/modified/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i '' -E -e "s/(1bd42a73e612f50c68d802acda674c21a30e980c|6e2b374dece03f6fb48a1615fa2bfee809ec2157)/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i '' -E -e "s/(2023-05-18/2023-09-24/g" $BE_PATH/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
    @@ -99,33 +108,13 @@ cmake --build . --config Release -- "-j$CORES"

    popd

    case "$OSTYPE" in
    linux*)
    if [ -f ~/.binaryninja/plugins/binexport12_binaryninja.so ]
    then
    echo "\u001b[36m[+] Unable to link .so, file already exists"
    echo "\u001b[0m"
    exit
    fi
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.so ~/.binaryninja/plugins
    ;;
    darwin*)
    if [ -f ~/Library/Application\ Support/Binary\ Ninja/plugins/binexport12_binaryninja.dylib ]
    then
    echo "\u001b[36m[+] Unable to link .dylib, file already exists"
    echo "\u001b[0m"
    exit
    fi
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    ;;
    *)
    ;;
    esac
    if [ -f $PLUGIN_DEST ]
    then
    echo "\u001b[36m[+] Not linking the plugin, file already exists\u001b[0m"
    else
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder\u001b[0m"
    ln -sf $PLUGIN_SRC $PLUGIN_DEST
    fi

    echo "\u001b[32;1m[+] Done!"
    echo "\u001b[0m"

  6. psifertex revised this gist Sep 26, 2023. 1 changed file with 1 addition and 26 deletions.
    27 changes: 1 addition & 26 deletions binexport_binja.zsh
    Original file line number Diff line number Diff line change
    @@ -2,30 +2,6 @@

    # Note:
    # CMake, Clang, clang-format, Ninja, git and sed are required to build
    #
    # Note that currently there is a bug (https://github.com/google/binexport/issues/117)
    # that requires applying this patch, remove when resolved
    #

    patch_boost() {
    cat > /tmp/boost.patch << **
    diff --git a/third_party/boost_parts/boost/container_hash/hash.hpp b/third_party/boost_parts/boost/container_hash/hash.hpp
    index 76de793..32f0559 100644
    --- a/third_party/boost_parts/boost/container_hash/hash.hpp
    +++ b/third_party/boost_parts/boost/container_hash/hash.hpp
    @@ -127,7 +127,7 @@ namespace boost
    };
    #else
    template <typename T>
    - struct hash_base : std::unary_function<T, std::size_t> {};
    + struct hash_base : std::__unary_function<T, std::size_t> {};
    #endif
    struct enable_hash_value { typedef std::size_t type; };
    **
    git apply patch /tmp/boost.patch
    rm /tmp/boost.patch
    }

    if [ -d ~/Downloads ]
    then
    @@ -74,7 +50,6 @@ then
    if git fetch --all
    then
    git reset --hard origin/main # Because previous runs of this script will dirty the repo
    patch_boost
    echo "BinExport exists, repo updated"
    else
    echo Not a repo, remove $BE_PATH to continue
    @@ -119,7 +94,7 @@ pushd $BE_PATH
    echo "\u001b[36m[+] Building BinExport..."
    echo "\u001b[0m"
    rm -rf build && mkdir build && cd build
    cmake .. -G Ninja -DBINEXPORT_BINARYNINJA_CHANNEL=DEV -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    cmake .. -G Ninja -DCMAKE_CXX_FLAGS="-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION" -DBINEXPORT_BINARYNINJA_CHANNEL=DEV -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    cmake --build . --config Release -- "-j$CORES"

    popd
  7. psifertex renamed this gist Sep 26, 2023. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions binexport_binja.sh → binexport_binja.zsh
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@
    #
    # Note that currently there is a bug (https://github.com/google/binexport/issues/117)
    # that requires applying this patch, remove when resolved
    #

    patch_boost() {
    cat > /tmp/boost.patch << **
    @@ -26,8 +27,6 @@ git apply patch /tmp/boost.patch
    rm /tmp/boost.patch
    }

    echo hi

    if [ -d ~/Downloads ]
    then
    DOWNLOADS=~/Downloads
  8. psifertex revised this gist Sep 26, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,8 @@
    # Note:
    # CMake, Clang, clang-format, Ninja, git and sed are required to build
    #
    # Note that currently there is a bug that requires applying this patch, remove when resolved
    # Note that currently there is a bug (https://github.com/google/binexport/issues/117)
    # that requires applying this patch, remove when resolved

    patch_boost() {
    cat > /tmp/boost.patch << **
  9. psifertex revised this gist Sep 26, 2023. 1 changed file with 27 additions and 2 deletions.
    29 changes: 27 additions & 2 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,31 @@
    #!/usr/bin/env zsh

    # Note:
    # CMake, Clang, clang-format, Ninja, and sed are required to build
    # CMake, Clang, clang-format, Ninja, git and sed are required to build
    #
    # Note that currently there is a bug that requires applying this patch, remove when resolved

    patch_boost() {
    cat > /tmp/boost.patch << **
    diff --git a/third_party/boost_parts/boost/container_hash/hash.hpp b/third_party/boost_parts/boost/container_hash/hash.hpp
    index 76de793..32f0559 100644
    --- a/third_party/boost_parts/boost/container_hash/hash.hpp
    +++ b/third_party/boost_parts/boost/container_hash/hash.hpp
    @@ -127,7 +127,7 @@ namespace boost
    };
    #else
    template <typename T>
    - struct hash_base : std::unary_function<T, std::size_t> {};
    + struct hash_base : std::__unary_function<T, std::size_t> {};
    #endif
    struct enable_hash_value { typedef std::size_t type; };
    **
    git apply patch /tmp/boost.patch
    rm /tmp/boost.patch
    }

    echo hi

    if [ -d ~/Downloads ]
    then
    @@ -50,6 +74,7 @@ then
    if git fetch --all
    then
    git reset --hard origin/main # Because previous runs of this script will dirty the repo
    patch_boost
    echo "BinExport exists, repo updated"
    else
    echo Not a repo, remove $BE_PATH to continue
    @@ -85,7 +110,7 @@ sed -i'' -e "s/2023-05-18/modified/g" $BE_PATH/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
    pushd $BE_PATH/third_party/binaryninja_api/
    pushd $BE_PATH/binaryninja/stubs/
    ./regenerate-api-stubs.sh $BN_API_PATH
    popd

  10. psifertex revised this gist Jun 20, 2023. 1 changed file with 29 additions and 16 deletions.
    45 changes: 29 additions & 16 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ then
    DOWNLOADS=~/Downloads
    else
    mdir ~/downloads
    DOWNLOADS=~/downloads
    DOWNLOAD=~/downloads
    fi
    BE_PATH=$DOWNLOADS/binexport
    if [ -d ~/.binaryninja ] && [ -f ~/.binaryninja/lastrun ]
    @@ -80,8 +80,8 @@ fi

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    sed -i'' -e "s/9d8bc846bd213407fb1a7a19af2a96f17501ac3b/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i'' -e "s/2023-02-15/modified/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i'' -e "s/1bd42a73e612f50c68d802acda674c21a30e980c/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i'' -e "s/2023-05-18/modified/g" $BE_PATH/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
    @@ -99,19 +99,32 @@ cmake --build . --config Release -- "-j$CORES"

    popd

    if [ ! -L $BE_PATH/build/binaryninja/binexport12_binaryninja.so ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf $DOWNLOADS/binexport/build/binaryninja/binexport12_binaryninja.so ~/.binaryninja/plugins
    fi

    if [ ! -L $DOWNLOADS/binexport/build/binaryninja/binexport12_binaryninja.dylib ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf $DOWNLOADS/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    fi
    case "$OSTYPE" in
    linux*)
    if [ -f ~/.binaryninja/plugins/binexport12_binaryninja.so ]
    then
    echo "\u001b[36m[+] Unable to link .so, file already exists"
    echo "\u001b[0m"
    exit
    fi
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.so ~/.binaryninja/plugins
    ;;
    darwin*)
    if [ -f ~/Library/Application\ Support/Binary\ Ninja/plugins/binexport12_binaryninja.dylib ]
    then
    echo "\u001b[36m[+] Unable to link .dylib, file already exists"
    echo "\u001b[0m"
    exit
    fi
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    ;;
    *)
    ;;
    esac

    echo "\u001b[32;1m[+] Done!"
    echo "\u001b[0m"
  11. psifertex revised this gist May 8, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ then
    DOWNLOADS=~/Downloads
    else
    mdir ~/downloads
    DOWNLOAD=~/downloads
    DOWNLOADS=~/downloads
    fi
    BE_PATH=$DOWNLOADS/binexport
    if [ -d ~/.binaryninja ] && [ -f ~/.binaryninja/lastrun ]
    @@ -103,14 +103,14 @@ if [ ! -L $BE_PATH/build/binaryninja/binexport12_binaryninja.so ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.so ~/Library/Application\ Support/Binary\ Ninja/plugins
    ln -sf $DOWNLOADS/binexport/build/binaryninja/binexport12_binaryninja.so ~/.binaryninja/plugins
    fi

    if [ ! -L ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ]
    if [ ! -L $DOWNLOADS/binexport/build/binaryninja/binexport12_binaryninja.dylib ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    ln -sf $DOWNLOADS/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    fi

    echo "\u001b[32;1m[+] Done!"
  12. psifertex revised this gist Apr 19, 2023. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -16,11 +16,13 @@ then
    BN_USER=~/.binaryninja
    BN_PATH=`cat ~/.binaryninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/api_REVISION.txt 2>/dev/null)
    CORES=$(nproc --all)
    elif [ -d ~/Library/Application\ Support/Binary\ Ninja ] && [ -f ~/Library/Application\ Support/Binary\ Ninja/lastrun ]
    then
    BN_USER=~/Library/Application\ Support/Binary\ Ninja
    BN_PATH=`cat ~/Library/Application\ Support/Binary\ Ninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/../Resources/api_REVISION.txt 2>/dev/null)
    CORES=$(sysctl -n hw.logicalcpu)
    else
    echo "Failed to find appropriate Binary Ninja user directory."
    exit 1
    @@ -93,7 +95,7 @@ echo "\u001b[36m[+] Building BinExport..."
    echo "\u001b[0m"
    rm -rf build && mkdir build && cd build
    cmake .. -G Ninja -DBINEXPORT_BINARYNINJA_CHANNEL=DEV -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    cmake --build . --config Release -- "-jauto"
    cmake --build . --config Release -- "-j$CORES"

    popd

  13. psifertex revised this gist Apr 19, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -93,7 +93,7 @@ echo "\u001b[36m[+] Building BinExport..."
    echo "\u001b[0m"
    rm -rf build && mkdir build && cd build
    cmake .. -G Ninja -DBINEXPORT_BINARYNINJA_CHANNEL=DEV -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    cmake --build . --config Release -- "-j auto"
    cmake --build . --config Release -- "-jauto"

    popd

  14. psifertex revised this gist Apr 18, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -101,7 +101,7 @@ if [ ! -L $BE_PATH/build/binaryninja/binexport12_binaryninja.so ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.so ~/Library/Application\ Support/Binary\ Ninja/plugins
    fi

    if [ ! -L ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ]
  15. psifertex revised this gist Apr 18, 2023. 1 changed file with 51 additions and 20 deletions.
    71 changes: 51 additions & 20 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,38 @@

    # Note:
    # CMake, Clang, clang-format, Ninja, and sed are required to build
    # !! Change the second git hash to the most recent git commit when using the Binary Ninja development API branch !!
    # !! It's located in the sed part of this script (L#15) !!
    # If you've previously run the BinDiff installer, by default it's going to keep overwritting the plugin.
    # Use this to prevent that:
    #
    # sudo defaults write /Library/LaunchAgents/com.google.security.zynamics.bindiff.plist Disabled -bool YES

    BINARY_HASH=$(sed 's/^.*\///' < /Applications/Binary\ Ninja.app/Contents/Resources/api_REVISION.txt 2>/dev/null)
    if [ -d ~/Downloads ]
    then
    DOWNLOADS=~/Downloads
    else
    mdir ~/downloads
    DOWNLOAD=~/downloads
    fi
    BE_PATH=$DOWNLOADS/binexport
    if [ -d ~/.binaryninja ] && [ -f ~/.binaryninja/lastrun ]
    then
    BN_USER=~/.binaryninja
    BN_PATH=`cat ~/.binaryninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/api_REVISION.txt 2>/dev/null)
    elif [ -d ~/Library/Application\ Support/Binary\ Ninja ] && [ -f ~/Library/Application\ Support/Binary\ Ninja/lastrun ]
    then
    BN_USER=~/Library/Application\ Support/Binary\ Ninja
    BN_PATH=`cat ~/Library/Application\ Support/Binary\ Ninja/lastrun`
    BINARY_HASH=$(sed 's/^.*\///' < $BN_PATH/../Resources/api_REVISION.txt 2>/dev/null)
    else
    echo "Failed to find appropriate Binary Ninja user directory."
    exit 1
    fi
    BN_API_PATH=$DOWNLOADS/binaryninja-api

    echo "Configuration:"
    echo " DOWNLOADS: $DOWNLOADS"
    echo " BE_PATH: $BE_PATH"
    echo " BN_API_PATH: $BN_API_PATH"
    echo " BN_PATH: $BN_PATH"
    echo " BINARY_HASH: $BINARY_HASH"

    if [ -z "$BINARY_HASH" ]
    then
    echo "Failed to find appropriate hash for Binary Ninja"
    @@ -18,24 +42,24 @@ fi

    echo "\u001b[36m[+] Cloning BinExport & Binary Ninja API..."
    echo "\u001b[0m"
    if [ -d ~/Downloads/binexport ]
    if [ -d $BE_PATH ]
    then
    pushd ~/Downloads/binexport
    pushd $BE_PATH
    if git fetch --all
    then
    git reset --hard origin/main # Because previous runs of this script will dirty the repo
    echo "BinExport exists, repo updated"
    else
    echo Not a repo, remove ~/Downloads/binexport to continue
    echo Not a repo, remove $BE_PATH to continue
    exit
    fi
    popd
    else
    git clone https://github.com/google/binexport.git ~/Downloads/binexport
    git clone https://github.com/google/binexport.git $BE_PATH
    fi
    if [ -d ~/Downloads/binaryninja-api ]
    if [ -d $BN_API_PATH ]
    then
    pushd ~/Downloads/binaryninja-api
    pushd $BN_API_PATH
    if git fetch --all
    then
    if git checkout "$BINARY_HASH"
    @@ -49,30 +73,37 @@ then
    fi
    popd
    else
    git clone --recursive --branch dev https://github.com/Vector35/binaryninja-api.git ~/Downloads/binaryninja-api
    git clone --recursive --branch dev https://github.com/Vector35/binaryninja-api.git $BN_API_PATH
    fi

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    sed -i'' -e "s/9d8bc846bd213407fb1a7a19af2a96f17501ac3b/$BINARY_HASH/g" ~/Downloads/binexport/cmake/BinExportDeps.cmake
    sed -i'' -e "s/2023-02-15/modified/g" ~/Downloads/binexport/cmake/BinExportDeps.cmake
    sed -i'' -e "s/9d8bc846bd213407fb1a7a19af2a96f17501ac3b/$BINARY_HASH/g" $BE_PATH/cmake/BinExportDeps.cmake
    sed -i'' -e "s/2023-02-15/modified/g" $BE_PATH/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
    pushd ~/Downloads/binexport/third_party/binaryninja_api/
    ./regenerate-api-stubs.sh ~/Downloads/binaryninja-api
    pushd $BE_PATH/third_party/binaryninja_api/
    ./regenerate-api-stubs.sh $BN_API_PATH
    popd

    pushd ~/Downloads/binexport
    pushd $BE_PATH

    echo "\u001b[36m[+] Building BinExport..."
    echo "\u001b[0m"
    rm -rf build && mkdir build && cd build
    cmake .. -G Ninja -DBINEXPORT_BINARYNINJA_CHANNEL=DEV -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    cmake --build . --config Release -- "-j$(sysctl -n hw.logicalcpu)"
    cmake --build . --config Release -- "-j auto"

    popd

    if [ ! -L $BE_PATH/build/binaryninja/binexport12_binaryninja.so ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    fi

    if [ ! -L ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
  16. psifertex revised this gist Mar 28, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    #
    # sudo defaults write /Library/LaunchAgents/com.google.security.zynamics.bindiff.plist Disabled -bool YES

    BINARY_HASH=$(sed 's/^.*\///' < /Applications/Binary\ Ninja-dev.app/Contents/Resources/api_REVISION.txt 2>/dev/null)
    BINARY_HASH=$(sed 's/^.*\///' < /Applications/Binary\ Ninja.app/Contents/Resources/api_REVISION.txt 2>/dev/null)
    if [ -z "$BINARY_HASH" ]
    then
    echo "Failed to find appropriate hash for Binary Ninja"
  17. psifertex revised this gist Mar 23, 2023. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,10 @@
    # CMake, Clang, clang-format, Ninja, and sed are required to build
    # !! Change the second git hash to the most recent git commit when using the Binary Ninja development API branch !!
    # !! It's located in the sed part of this script (L#15) !!
    # If you've previously run the BinDiff installer, by default it's going to keep overwritting the plugin.
    # Use this to prevent that:
    #
    # sudo defaults write /Library/LaunchAgents/com.google.security.zynamics.bindiff.plist Disabled -bool YES

    BINARY_HASH=$(sed 's/^.*\///' < /Applications/Binary\ Ninja-dev.app/Contents/Resources/api_REVISION.txt 2>/dev/null)
    if [ -z "$BINARY_HASH" ]
  18. psifertex revised this gist Mar 10, 2023. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -32,13 +32,16 @@ fi
    if [ -d ~/Downloads/binaryninja-api ]
    then
    pushd ~/Downloads/binaryninja-api
    if git checkout "$BINARY_HASH"
    if git fetch --all
    then
    git pull
    echo "Binary Ninja API exists, repo updated"
    else
    echo Not a repo or could not match binary hash
    exit
    if git checkout "$BINARY_HASH"
    then
    git pull
    echo "Binary Ninja API exists, repo updated"
    else
    echo Not a repo or could not match binary hash
    exit
    fi
    fi
    popd
    else
  19. psifertex revised this gist Mar 6, 2023. 1 changed file with 54 additions and 12 deletions.
    66 changes: 54 additions & 12 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -5,32 +5,74 @@
    # !! Change the second git hash to the most recent git commit when using the Binary Ninja development API branch !!
    # !! It's located in the sed part of this script (L#15) !!

    BINARY_HASH=$(sed 's/^.*\///' < /Applications/Binary\ Ninja-dev.app/Contents/Resources/api_REVISION.txt 2>/dev/null)
    if [ -z "$BINARY_HASH" ]
    then
    echo "Failed to find appropriate hash for Binary Ninja"
    exit 1
    fi

    echo "\u001b[36m[+] Cloning BinExport & Binary Ninja API..."
    echo "\u001b[0m"
    git clone https://github.com/google/binexport.git ~/Downloads/binexport
    git clone --recursive --branch dev https://github.com/Vector35/binaryninja-api.git ~/Downloads/binaryninja-api
    if [ -d ~/Downloads/binexport ]
    then
    pushd ~/Downloads/binexport
    if git fetch --all
    then
    git reset --hard origin/main # Because previous runs of this script will dirty the repo
    echo "BinExport exists, repo updated"
    else
    echo Not a repo, remove ~/Downloads/binexport to continue
    exit
    fi
    popd
    else
    git clone https://github.com/google/binexport.git ~/Downloads/binexport
    fi
    if [ -d ~/Downloads/binaryninja-api ]
    then
    pushd ~/Downloads/binaryninja-api
    if git checkout "$BINARY_HASH"
    then
    git pull
    echo "Binary Ninja API exists, repo updated"
    else
    echo Not a repo or could not match binary hash
    exit
    fi
    popd
    else
    git clone --recursive --branch dev https://github.com/Vector35/binaryninja-api.git ~/Downloads/binaryninja-api
    fi

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    sed -i -e 's/9d8bc846bd213407fb1a7a19af2a96f17501ac3b/b62dd911b325e637d48bcb2098766510955c1599/g' ~/Downloads/binexport/cmake/BinExportDeps.cmake
    sed -i -e 's/2023-02-15/modified/g' ~/Downloads/binexport/cmake/BinExportDeps.cmake
    sed -i'' -e "s/9d8bc846bd213407fb1a7a19af2a96f17501ac3b/$BINARY_HASH/g" ~/Downloads/binexport/cmake/BinExportDeps.cmake
    sed -i'' -e "s/2023-02-15/modified/g" ~/Downloads/binexport/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
    cd ~/Downloads/binexport/third_party/binaryninja_api/
    pushd ~/Downloads/binexport/third_party/binaryninja_api/
    ./regenerate-api-stubs.sh ~/Downloads/binaryninja-api
    popd

    cd ~/Downloads/binexport
    pushd ~/Downloads/binexport

    echo "\u001b[36m[+] Building BinExport..."
    echo "\u001b[0m"
    mkdir build && cd build
    cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    rm -rf build && mkdir build && cd build
    cmake .. -G Ninja -DBINEXPORT_BINARYNINJA_CHANNEL=DEV -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    cmake --build . --config Release -- "-j$(sysctl -n hw.logicalcpu)"

    echo "\u001b[36m[+] Moving BinExport plugin to Binary Ninja plugins folder"
    echo "\u001b[0m"
    mv ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    popd

    if [ ! -L ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ]
    then
    echo "\u001b[36m[+] Linking BinExport plugin to Binary Ninja plugin folder"
    echo "\u001b[0m"
    ln -sf ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
    fi

    echo "\u001b[32;1m[+] Done!"
    echo "\u001b[0m"
    echo "\u001b[0m"

  20. 0x8ff revised this gist Mar 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    echo "\u001b[36m[+] Cloning BinExport & Binary Ninja API..."
    echo "\u001b[0m"
    git clone https://github.com/google/binexport.git ~/Downloads/binexport
    git clone --recursive https://github.com/Vector35/binaryninja-api.git ~/Downloads/binaryninja-api
    git clone --recursive --branch dev https://github.com/Vector35/binaryninja-api.git ~/Downloads/binaryninja-api

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
  21. 0x8ff revised this gist Mar 5, 2023. No changes.
  22. 0x8ff created this gist Mar 5, 2023.
    36 changes: 36 additions & 0 deletions binexport_binja.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/usr/bin/env zsh

    # Note:
    # CMake, Clang, clang-format, Ninja, and sed are required to build
    # !! Change the second git hash to the most recent git commit when using the Binary Ninja development API branch !!
    # !! It's located in the sed part of this script (L#15) !!

    echo "\u001b[36m[+] Cloning BinExport & Binary Ninja API..."
    echo "\u001b[0m"
    git clone https://github.com/google/binexport.git ~/Downloads/binexport
    git clone --recursive https://github.com/Vector35/binaryninja-api.git ~/Downloads/binaryninja-api

    echo "\u001b[36m[+] Updating the git hash..."
    echo "\u001b[0m"
    sed -i -e 's/9d8bc846bd213407fb1a7a19af2a96f17501ac3b/b62dd911b325e637d48bcb2098766510955c1599/g' ~/Downloads/binexport/cmake/BinExportDeps.cmake
    sed -i -e 's/2023-02-15/modified/g' ~/Downloads/binexport/cmake/BinExportDeps.cmake

    echo "\u001b[36m[+] Running regenerate-api-stubs..."
    echo "\u001b[0m"
    cd ~/Downloads/binexport/third_party/binaryninja_api/
    ./regenerate-api-stubs.sh ~/Downloads/binaryninja-api

    cd ~/Downloads/binexport

    echo "\u001b[36m[+] Building BinExport..."
    echo "\u001b[0m"
    mkdir build && cd build
    cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PWD" -DBINEXPORT_ENABLE_IDAPRO=OFF -DBINEXPORT_ENABLE_BINARYNINJA=ON
    cmake --build . --config Release -- "-j$(sysctl -n hw.logicalcpu)"

    echo "\u001b[36m[+] Moving BinExport plugin to Binary Ninja plugins folder"
    echo "\u001b[0m"
    mv ~/Downloads/binexport/build/binaryninja/binexport12_binaryninja.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins

    echo "\u001b[32;1m[+] Done!"
    echo "\u001b[0m"