From 2cf95c12a07c677ec6ac38a24e1c3aafe0e9389f Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Thu, 7 Jul 2022 15:29:40 -0400 Subject: Add Executable and Identifier to -h --- .gitignore | 1 + ldid.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ba6a0f3..e1bc118 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ ldid .vscode compile_commands.json .cache +*.core diff --git a/ldid.cpp b/ldid.cpp index 5745e9b..24daf47 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -3539,6 +3539,10 @@ int main(int argc, char *argv[]) { } if (flag_h) { + char *buf = _syscall(realpath(file.c_str(), NULL)); + printf("Executable=%s\n", buf); + free(buf); + auto algorithms(GetAlgorithms()); uint32_t data = mach_header.Swap(signature->dataoff); @@ -3552,6 +3556,7 @@ int main(int argc, char *argv[]) { size_t size_; Algorithm &algorithm_; std::string hash_; + uint32_t offset; }; std::map candidates; @@ -3567,7 +3572,7 @@ int main(int argc, char *argv[]) { auto &algorithm(*algorithms[type - 1]); uint8_t hash[algorithm.size_]; algorithm(hash, blob + begin, end - begin); - candidates.insert({type, {directory, end - begin, algorithm, Hex(hash, 20)}}); + candidates.insert({type, {directory, end - begin, algorithm, Hex(hash, 20), begin}}); } } @@ -3578,6 +3583,8 @@ int main(int argc, char *argv[]) { const auto directory(best->second.directory_); const auto flags(Swap(directory->flags)); + printf("Identifier=%s\n", blob + best->second.offset + Swap(directory->identOffset)); + std::string names; if (flags & kSecCodeSignatureHost) names += ",host"; -- cgit v1.2.3-56-ge451