feat: prompt & version output; note for ctf challenge makers
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "ASTree.h"
|
||||
|
||||
const char* VERSION = "v0.2.0+";
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* infile = nullptr;
|
||||
@@ -75,9 +77,31 @@ int main(int argc, char* argv[])
|
||||
const char* dispname = strrchr(infile, PATHSEP);
|
||||
dispname = (dispname == NULL) ? infile : dispname + 1;
|
||||
|
||||
formatted_print(das_out_file, "%s (Python %d.%d%s)\n", dispname,
|
||||
mod.majorVer(), mod.minorVer(),
|
||||
(mod.majorVer() < 3 && mod.isUnicode()) ? " -U" : "");
|
||||
formatted_print(
|
||||
das_out_file,
|
||||
R"(# Disassembly generated by Pyarmor-Static-Unpack-1shot (%s), powered by pycdas
|
||||
# File: %s (Python %d.%d)
|
||||
|
||||
# Pyarmor notes:
|
||||
# - Pyarmor bytecode and code objects match standard Python, but special calls to Pyarmor runtime functions exist.
|
||||
# - Calls on strings are not mistakes but markers, which are processed by Pyarmor at runtime.
|
||||
#
|
||||
# Decompilation guidance (without runtime):
|
||||
# 1. Ignore encrypted bytes after `#`; use only the string before `#`.
|
||||
# 2. Remove `"__pyarmor_enter_xxx__"(b"<COAddr>...")` and `"__pyarmor_leave_xxx__"(b"<COAddr>...")` (prologue/epilogue).
|
||||
# 3. For `"__pyarmor_assert_xxx__"(A)`, it is not a real assert statement.
|
||||
# - If `A` is a name or readable string: replace with `A`.
|
||||
# - If `A` is `(X, "Y")`: replace with `X.Y`.
|
||||
# - If `A` is `(X, "Y", Z)`: replace with `X.Y = Z`.
|
||||
# - Otherwise: choose the most reasonable replacement.
|
||||
# 4. `"__pyarmor_bcc_xxx__"(...)` indicates native code; function body is not available. Add a comment.
|
||||
|
||||
)",
|
||||
VERSION,
|
||||
dispname,
|
||||
mod.majorVer(),
|
||||
mod.minorVer()
|
||||
);
|
||||
try {
|
||||
output_object(mod.code().try_cast<PycObject>(), &mod, 0, disasm_flags,
|
||||
das_out_file);
|
||||
@@ -89,10 +113,21 @@ int main(int argc, char* argv[])
|
||||
das_out_file.flush();
|
||||
das_out_file.close();
|
||||
|
||||
dc_out_file << "# Source Generated with Decompyle++\n";
|
||||
formatted_print(dc_out_file, "# File: %s (Python %d.%d%s)\n\n", dispname,
|
||||
mod.majorVer(), mod.minorVer(),
|
||||
(mod.majorVer() < 3 && mod.isUnicode()) ? " Unicode" : "");
|
||||
formatted_print(
|
||||
dc_out_file,
|
||||
R"(# Source generated by Pyarmor-Static-Unpack-1shot (%s), powered by Decompyle++ (pycdc)
|
||||
# File: %s (Python %d.%d)
|
||||
|
||||
# Note: Decompiled code can be incomplete and incorrect.
|
||||
# Please also check the correct and complete disassembly file: %s.das
|
||||
|
||||
)",
|
||||
VERSION,
|
||||
dispname,
|
||||
mod.majorVer(),
|
||||
mod.minorVer(),
|
||||
prefix_name.c_str()
|
||||
);
|
||||
try {
|
||||
decompyle(mod.code(), &mod, dc_out_file);
|
||||
} catch (std::exception& ex) {
|
||||
|
||||
Reference in New Issue
Block a user