From cd06a5710dc92439089407fe2010e2e5c47b209f Mon Sep 17 00:00:00 2001 From: xiaozhuai <798047000@qq.com> Date: Mon, 20 Jun 2022 13:36:38 +0800 Subject: [PATCH] upgrade frida to 15.1.25 & ignore Desktop & upgrade version to 1.1.0 --- CMakeLists.txt | 2 +- download-frida-libs.sh | 2 +- src/common/StringUtils.h | 144 +++++++++++++++++++++++++++++++ src/inject-lib/DSStoreHelper.cpp | 10 ++- 4 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 src/common/StringUtils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f33ed7..03ed530 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ set(wxBUILD_PRECOMP OFF) add_subdirectory(vendor/wxWidgets) -set(ODOURLESS_VERSION 1.0.0) +set(ODOURLESS_VERSION 1.1.0) set(ODOURLESS_MUST_INSTALL_TO_APPLICATIONS ON) diff --git a/download-frida-libs.sh b/download-frida-libs.sh index ac375a0..c07d1a4 100755 --- a/download-frida-libs.sh +++ b/download-frida-libs.sh @@ -4,7 +4,7 @@ set -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "${DIR}" -VERSION="15.1.1" +VERSION="15.1.25" rm -rf vendor/frida-core rm -rf vendor/frida-gum diff --git a/src/common/StringUtils.h b/src/common/StringUtils.h new file mode 100644 index 0000000..7e4c65a --- /dev/null +++ b/src/common/StringUtils.h @@ -0,0 +1,144 @@ +// +// Created by xiaozhuai on 2020/11/26. +// + +#pragma once + +#include +#include +#include +#include + +inline char toLowerChar(char c) { + return static_cast(::tolower(c)); +} + +inline char toUpperChar(char c) { + return static_cast(::toupper(c)); +} + +class StringUtils { +public: + StringUtils() = delete; + + static inline std::string trimCopy(std::string str, const char *characters = " \t\r\n") { + return str.erase(0, str.find_first_not_of(characters)) + .erase(str.find_last_not_of(characters) + 1); + } + + static inline std::string ltrimCopy(std::string str, const char *characters = " \t\r\n") { + return str.erase(0, str.find_first_not_of(characters)); + } + + static inline std::string rtrimCopy(std::string str, const char *characters = " \t\r\n") { + return str.erase(str.find_last_not_of(characters) + 1); + } + + static inline std::string &trim(std::string &str, const char *characters = " \t\r\n") { + return str.erase(0, str.find_first_not_of(characters)) + .erase(str.find_last_not_of(characters) + 1); + } + + static inline std::string <rim(std::string &str, const char *characters = " \t\r\n") { + return str.erase(0, str.find_first_not_of(characters)); + } + + static inline std::string &rtrim(std::string &str, const char *characters = " \t\r\n") { + return str.erase(str.find_last_not_of(characters) + 1); + } + + static inline std::string toLowerCopy(std::string str) { + std::transform(str.begin(), str.end(), str.begin(), toLowerChar); + return str; + } + + static inline std::string toUpperCopy(std::string str) { + std::transform(str.begin(), str.end(), str.begin(), toUpperChar); + return str; + } + + static inline std::string &toLower(std::string &str) { + std::transform(str.begin(), str.end(), str.begin(), toLowerChar); + return str; + } + + static inline std::string &toUpper(std::string &str) { + std::transform(str.begin(), str.end(), str.begin(), toUpperChar); + return str; + } + + static std::string replaceCopy(std::string text, const std::string &search, const std::string &replace) { + if (search == replace) { + return text; + } + size_t index = text.find(search, 0); + size_t searchLength = search.length(); + size_t replaceLength = replace.length(); + + while (std::string::npos != index) { + text.replace(index, searchLength, replace); + index = text.find(search, index - searchLength + replaceLength + 1); + } + return text; + } + + static std::string &replace(std::string &text, const std::string &search, const std::string &replace) { + if (search == replace) { + return text; + } + size_t index = text.find(search, 0); + size_t searchLength = search.length(); + size_t replaceLength = replace.length(); + + while (std::string::npos != index) { + text.replace(index, searchLength, replace); + index = text.find(search, index - searchLength + replaceLength + 1); + } + return text; + } + + static std::vector explode(const std::string &text, const std::string &separator, size_t limit = -1) { + std::vector result; + size_t pos = 0; + size_t separatorPos = text.find(separator, pos); + while (separatorPos != std::string::npos) { + std::string token = text.substr(pos, separatorPos - pos); + result.push_back(token); + pos = separatorPos + separator.length(); + if (result.size() + 1 == limit) { + break; + } + separatorPos = text.find(separator, pos); + } + result.push_back(text.substr(pos)); + return result; + } + + static bool startsWith(const std::string &str, const std::string &prefix, bool ignoreCase = false) { + size_t s = str.size(); + size_t ps = prefix.size(); + if (ignoreCase) { + return s >= ps && StringUtils::toLowerCopy(str.substr(0, ps)) == StringUtils::toLowerCopy(prefix); + } else { + return s >= ps && str.substr(0, ps) == prefix; + } + } + + static bool endsWith(const std::string &str, const std::string &suffix, bool ignoreCase = false) { + size_t s = str.size(); + size_t ss = suffix.size(); + if (ignoreCase) { + return s >= ss && StringUtils::toLowerCopy(str.substr(s - ss, s)) == StringUtils::toLowerCopy(suffix); + } else { + return s >= ss && str.substr(s - ss, s) == suffix; + } + } + + static std::string padLeft(const std::string &str, char c, int size) { + return str.size() < size ? (std::string(size - str.size(), c) + str) : str; + } + + static std::string padRight(const std::string &str, char c, int size) { + return str.size() < size ? (str + std::string(size - str.size(), c)) : str; + } +}; diff --git a/src/inject-lib/DSStoreHelper.cpp b/src/inject-lib/DSStoreHelper.cpp index 2a8e594..046837c 100644 --- a/src/inject-lib/DSStoreHelper.cpp +++ b/src/inject-lib/DSStoreHelper.cpp @@ -5,10 +5,18 @@ #include "DSStoreHelper.h" #include "FileSystemHelper.h" #include "OdourlessUtils.h" +#include "StringUtils.h" bool DSStoreHelper::isDSStore(const std::string &path) { + auto tokens = StringUtils::explode(path, "/"); + bool isDesktop = + tokens[0].empty() + && tokens[1] == "Users" + && tokens[3] == "Desktop" + && tokens[4] == ".DS_Store"; return FileSystemHelper::getName(path) == ".DS_Store" - && path.find(CAGE_DIRECTORY_PATH) != 0 + && !StringUtils::startsWith(path, CAGE_DIRECTORY_PATH) + && !isDesktop && path.find("/.Trashes/") == std::string::npos && path.find("/.Trash/") == std::string::npos; }