zhlynn / zsign

Maybe it is the most quickly codesign alternative for iOS12+, cross-platform ( macOS, Linux , Windows ), more features.
BSD 3-Clause "New" or "Revised" License
1.24k stars 374 forks source link

Can't Find App Folder! /tmp/zsign_folder_1583398065327202[0m[31m>>> Signed Failed! (0.000s, 113us)[0m[31m>>> Can't Find Payload Directory![0m #48

Closed vistal8 closed 3 years ago

vistal8 commented 4 years ago

Can't Find App Folder! /tmp/zsign_folder_1583398065327202[0m[31m>>> Signed Failed! (0.000s, 113us)[0m[31m>>> Can't Find Payload Directory![0m the os ver is centos 7.7 can any one help me? thanks

vistal8 commented 4 years ago

Mount a new partition Change \ tmp \ of zsign-master \ zsign.cpp to the newly mounted disk Such as / home / new / sign / Enter the zsign directory and re-run g ++ .cpp common / . Cpp -lcrypto -O3 -o zsign 中文 挂载一个新分区 将zsign-master\zsign.cpp 的\tmp\改到新挂载的磁盘 如/home/new/sign/ 进入zsign目录 重新运行 g++ .cpp common/.cpp -lcrypto -O3 -o zsign

vistal8 commented 4 years ago

没有 我已经在github上提交了我的方法。也是挂在一个新硬盘 编辑zsign.cpp 更改签名目录就可以了

------------------ 原始邮件 ------------------ 发件人: "SigniOS"<notifications@github.com>; 发送时间: 2020年3月17日(星期二) 中午11:53 收件人: "zhlynn/zsign"<zsign@noreply.github.com>; 抄送: "价格查询网"<754400895@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [zhlynn/zsign] Can't Find App Folder! /tmp/zsign_folder_1583398065327202[0m[31m>>> Signed Failed! (0.000s, 113us)[0m[31m>>> Can't Find Payload Directory![0m (#48)

Unzip OK! (0.141s, 141402us) Can't Find App Folder! /tmp/zsign_folder_1584414813050811 Signed Failed! (0.000s, 134us) Can't Find Payload Directory!

遇到同样的问题,目前发现多个硬盘会出现这个问题,不知道作者更新没

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

vistal8 commented 4 years ago

需要挂在一个新硬盘到你的系统,然后才可以。。 新硬盘必须是ext4

------------------ 原始邮件 ------------------ 发件人: "SigniOS"<notifications@github.com>; 发送时间: 2020年3月17日(星期二) 中午12:01 收件人: "zhlynn/zsign"<zsign@noreply.github.com>; 抄送: "价格查询网"<754400895@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [zhlynn/zsign] Can't Find App Folder! /tmp/zsign_folder_1583398065327202[0m[31m>>> Signed Failed! (0.000s, 113us)[0m[31m>>> Can't Find Payload Directory![0m (#48)

我这边已经把/tmp/修改为 /home/tmp/ 可是还是不行

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

vistal8 commented 4 years ago

include "common/common.h"

include "common/json.h"

include "openssl.h"

include "macho.h"

include "bundle.h"

include

include

include

const struct option options[] = { { "debug", no_argument, NULL, 'd' }, { "force", no_argument, NULL, 'f' }, { "verbose", no_argument, NULL, 'v' }, { "cert", required_argument, NULL, 'c' }, { "pkey", required_argument, NULL, 'k' }, { "prov", required_argument, NULL, 'm' }, { "password", required_argument, NULL, 'p' }, { "bundleid", required_argument, NULL, 'b' }, { "bundlename", required_argument, NULL, 'n' }, { "entitlements", required_argument, NULL, 'e' }, { "output", required_argument, NULL, 'o' }, { "ziplevel", required_argument, NULL, 'z' }, { "dylib", required_argument, NULL, 'l' }, { "weak", no_argument, NULL, 'w' }, { "install", no_argument, NULL, 'i' }, { "quiet", no_argument, NULL, 'q' }, { "help", no_argument, NULL, 'h' }, { } };

int usage() { ZLog::Print("Usage: zsign [-options] [-k privkey.pem] [-m dev.prov] [-o output.ipa] file|folder\n"); ZLog::Print("options:\n"); ZLog::Print("-k, --pkey\t\tPath to private key or p12 file. (PEM or DER format)\n"); ZLog::Print("-m, --prov\t\tPath to mobile provisioning profile.\n"); ZLog::Print("-c, --cert\t\tPath to certificate file. (PEM or DER format)\n"); ZLog::Print("-d, --debug\t\tGenerate debug output files. (.zsign_debug folder)\n"); ZLog::Print("-f, --force\t\tForce sign without cache when signing folder.\n"); ZLog::Print("-o, --output\t\tPath to output ipa file.\n"); ZLog::Print("-p, --password\t\tPassword for private key or p12 file.\n"); ZLog::Print("-b, --bundleid\t\tNew bundle id to change.\n"); ZLog::Print("-n, --bundlename\tNew bundle name to change.\n"); ZLog::Print("-e, --entitlements\tNew entitlements to change.\n"); ZLog::Print("-z, --ziplevel\t\tCompressed level when output the ipa file. (0-9)\n"); ZLog::Print("-l, --dylib\t\tPath to inject dylib file.\n"); ZLog::Print("-w, --weak\t\tInject dylib as LC_LOAD_WEAK_DYLIB.\n"); ZLog::Print("-i, --install\t\tInstall ipa file using ideviceinstaller command for test.\n"); ZLog::Print("-q, --quiet\t\tQuiet operation.\n"); ZLog::Print("-v, --version\t\tShow version.\n"); ZLog::Print("-h, --help\t\tShow help.\n");

return -1;

}

int main(int argc, char *argv[]) { ZTimer gtimer;

bool bForce = false;
bool bInstall = false;
bool bWeakInject = false;
uint32_t uZipLevel = 0;

string strCertFile;
string strPKeyFile;
string strProvFile;
string strPassword;
string strBundleId;
string strDyLibFile;
string strOutputFile;
string strDisplayName;
string strEntitlementsFile;

int opt = 0;
int argslot = -1;
while (-1 != (opt = getopt_long(argc, argv, "dfvhc:k:m:o:ip:e:b:n:z:ql:w", options, &argslot)))
{
    switch (opt)
    {
    case 'd':
        ZLog::SetLogLever(ZLog::E_DEBUG);
        break;
    case 'f':
        bForce = true;
        break;
    case 'c':
        strCertFile = optarg;
        break;
    case 'k':
        strPKeyFile = optarg;
        break;
    case 'm':
        strProvFile = optarg;
        break;
    case 'p':
        strPassword = optarg;
        break;
    case 'b':
        strBundleId = optarg;
        break;
    case 'n':
        strDisplayName = optarg;
        break;
    case 'e':
        strEntitlementsFile = optarg;
        break;
    case 'l':
        strDyLibFile = optarg;
        break;
    case 'i':
        bInstall = true;
        break;
    case 'o':
        strOutputFile = GetCanonicalizePath(optarg);
        break;
    case 'z':
        uZipLevel = atoi(optarg);
        break;
    case 'w':
        bWeakInject = true;
        break;
    case 'q':
        ZLog::SetLogLever(ZLog::E_NONE);
        break;
    case 'v':
    {
        printf("version: 0.2\n");
        return 0;
    }
    break;
    case 'h':
    case '?':
        return usage();
        break;
    }

    ZLog::DebugV(">>> Option:\t-%c, %s\n", opt, optarg);
}

if (optind >= argc)
{
    return usage();
}

if (ZLog::IsDebug())
{
    CreateFolder("./.zsign_debug");
    for (int i = optind; i < argc; i++)
    {
        ZLog::DebugV(">>> Argument:\t%s\n", argv[i]);
    }
}

string strPath = GetCanonicalizePath(argv[optind]);
if (!IsFileExists(strPath.c_str()))
{
    ZLog::ErrorV(">>> Invalid Path! %s\n", strPath.c_str());
    return -1;
}

bool bZipFile = false;
if (!IsFolder(strPath.c_str()))
{
    bZipFile = IsZipFile(strPath.c_str());
    if (!bZipFile)
    { //macho file
        ZMachO macho;
        if (macho.Init(strPath.c_str()))
        {
            if(!strDyLibFile.empty())
            {//inject dylib
                bool bCreate = false;
                macho.InjectDyLib(bWeakInject, strDyLibFile.c_str(), bCreate);
            }
            else
            {
                macho.PrintInfo();
            }
            macho.Free();
        }
        return 0;
    }
}

ZTimer timer;
ZSignAsset zSignAsset;
if (!zSignAsset.Init(strCertFile, strPKeyFile, strProvFile, strEntitlementsFile, strPassword))
{
    return -1;
}

bool bEnableCache = true;
string strFolder = strPath;
if (bZipFile)
{ //ipa file
    bForce = true;
    bEnableCache = false;
    StringFormat(strFolder, "/home/tmp/zsign_folder_%llu", timer.Reset());
    ZLog::PrintV(">>> Unzip:\t%s (%s) -> %s ... \n", strPath.c_str(), GetFileSizeString(strPath.c_str()).c_str(), strFolder.c_str());
    RemoveFolder(strFolder.c_str());
    if (!SystemExec("unzip -qq -d '%s' '%s'", strFolder.c_str(), strPath.c_str()))
    {
        RemoveFolder(strFolder.c_str());
        ZLog::ErrorV(">>> Unzip Failed!\n");
        return -1;
    }
    timer.PrintResult(true, ">>> Unzip OK!");
}

timer.Reset();
ZAppBundle bundle;
bool bRet = bundle.SignFolder(&zSignAsset, strFolder, strBundleId, strDisplayName, strDyLibFile, bForce, bWeakInject, bEnableCache);
timer.PrintResult(bRet, ">>> Signed %s!", bRet ? "OK" : "Failed");

if (bInstall && strOutputFile.empty())
{
    StringFormat(strOutputFile, "/home/tmp/zsign_temp_%llu.ipa", GetMicroSecond());
}

if (!strOutputFile.empty())
{
    timer.Reset();
    size_t pos = bundle.m_strAppFolder.rfind("/Payload");
    if (string::npos == pos)
    {
        ZLog::Error(">>> Can't Find Payload Directory!\n");
        return -1;
    }

    if (!IsPathSuffix(strOutputFile, ".ipa"))
    {
        strOutputFile += ".ipa";
    }

    ZLog::PrintV(">>> Archiving: \t%s ... \n", strOutputFile.c_str());
    string strBaseFolder = bundle.m_strAppFolder.substr(0, pos);
    char szOldFolder[PATH_MAX] = {0};
    if (NULL != getcwd(szOldFolder, PATH_MAX))
    {
        if (0 == chdir(strBaseFolder.c_str()))
        {
            uZipLevel = uZipLevel > 9 ? 9 : uZipLevel;
            RemoveFile(strOutputFile.c_str());
            SystemExec("zip -q -%u -r '%s' Payload", uZipLevel, strOutputFile.c_str());
            chdir(szOldFolder);
            if (!IsFileExists(strOutputFile.c_str()))
            {
                ZLog::Error(">>> Archive Failed!\n");
                return -1;
            }
        }
    }
    timer.PrintResult(true, ">>> Archive OK! (%s)", GetFileSizeString(strOutputFile.c_str()).c_str());
}

if (bRet && bInstall)
{
    SystemExec("ideviceinstaller -i '%s'", strOutputFile.c_str());
}

if (0 == strOutputFile.find("/home/tmp/zsign_tmp_"))
{
    RemoveFile(strOutputFile.c_str());
}

if (0 == strFolder.find("/home/tmp/zsign_folder_"))
{
    RemoveFolder(strFolder.c_str());
}

gtimer.Print(">>> Done.");
return bRet ? 0 : -1;

}

causeMyHurt commented 4 years ago

更改bundle.cpp中文件类型的判断。就是 IsFolder(ptr->d_name) 方法更改为 DT_DIR == ptr_d_type。IsFolder()方法要进行替换。

vistal8 commented 4 years ago

更改bundle.cpp中文件类型的判断。就是 IsFolder(ptr->d_name) 方法更改为 DC_DIR == ptr_d_type。IsFolder()方法要进行替换。

有空尝试下 不过现在我用的还可以

Dershowitz011 commented 4 years ago

Share the ipa. I'll try resigning it.

vistal8 commented 4 years ago

更改bundle.cpp中文件类型的判断。就是 IsFolder(ptr->d_name) 方法更改为 DC_DIR == ptr_d_type。IsFolder()方法要进行替换。

有没有更改好的成品 分享一下

oneword2018 commented 4 years ago

不错赞一个,是文件系统问题,通过挂载分区可以解决。关于这种“更改bundle.cpp中文件类型的判断。就是 IsFolder(ptr->d_name) 方法更改为 DT_DIR == ptr_d_type。IsFolder()方法要进行替换。 ”解决方式,没研究。。。

xujimu commented 4 years ago

I encountered this problem, but I couldn't find the reason. It was ok to use Docker. Later, I upgraded to CentOS7.8, but there was no problem again