Skip to content

Commit

Permalink
upgrade frida to 15.1.25 & ignore Desktop & upgrade version to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhuai committed Jun 20, 2022
1 parent f538932 commit cd06a57
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion download-frida-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
144 changes: 144 additions & 0 deletions src/common/StringUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
//
// Created by xiaozhuai on 2020/11/26.
//

#pragma once

#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

inline char toLowerChar(char c) {
return static_cast<char>(::tolower(c));
}

inline char toUpperChar(char c) {
return static_cast<char>(::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 &ltrim(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<std::string> explode(const std::string &text, const std::string &separator, size_t limit = -1) {
std::vector<std::string> 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;
}
};
10 changes: 9 additions & 1 deletion src/inject-lib/DSStoreHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cd06a57

Please sign in to comment.