Signing libertv

Issues relating to the upcoming LiberTV TvOS < 11.2 JB. NO MORON "wen eta" though - unless you want to be banned.
Forum rules
  • NO IDIOTIC QUESTIONS ABOUT "WEN ETA JB".
  • Read the FAQ before asking.
  • Otherwise, open discussion and/or requests welcome.

Signing libertv

Postby creativelyrich » Tue May 09, 2017 12:02 am

I’m trying to sign libertv using iOS App Signer and a shared developer account and am getting the following errors:

Error verifying code signature! Code object is not signed at all in architecture: arm64
Unsealed contents present in the bundle root
Bundle format unrecognized, invalid, or unsuitable


Using Cydia Impactor isn’t an option for me because I only have a team Provisioning Profile and Certificate, no Apple ID/Password.

Any help would be appreciated.
creativelyrich
 
Posts: 4
Joined: Mon May 08, 2017 11:55 pm

Re: Signing libertv

Postby Siguza » Tue May 09, 2017 4:11 pm

Not familiar with iOS App Signer, but if you have the certificate in your keychain and the provisioning profile as a file lying around you can use XCode's command line tools:

Code: Select all
unzip libertv.ipa
cp YOUR_PROVISIONING_PROFILE Payload/LiberTV.app/embedded.mobileprovision
codesign -s YOUR_TEAM_IDENTIFIER_HERE Payload/LiberTV.app
zip -r9 libertv.ipa Payload
User avatar
Siguza
Unicorn
 
Posts: 159
Joined: Thu Jan 28, 2016 10:38 am

Re: Signing libertv

Postby creativelyrich » Tue May 09, 2017 11:43 pm

Thanks Siguza.
Followed your steps but the problem still persists. I get to step 3...
Code: Select all
codesign -s YOUR_TEAM_IDENTIFIER_HERE Payload/LiberTV.app

and I get...
Code: Select all
Payload/LiberTV.app: is already signed

So I zip it back up and try to install anyway via Xcode, but get the error:

No code signature found

Same problem as iOS App Signer. Same thing when I try via iFunbox.

Is anyone able to clarify what's going on/recommend other ways to sideload libertv (not impactor)?
creativelyrich
 
Posts: 4
Joined: Mon May 08, 2017 11:55 pm

Re: Signing libertv

Postby Siguza » Wed May 10, 2017 2:36 pm

Then add an -f flag (as in "force"):

Code: Select all
codesign -f -s YOUR_TEAM_IDENTIFIER_HERE Payload/LiberTV.app
User avatar
Siguza
Unicorn
 
Posts: 159
Joined: Thu Jan 28, 2016 10:38 am

Re: Signing libertv

Postby creativelyrich » Wed May 10, 2017 11:28 pm

Thanks Siguza. Tried forcing per your suggestion but still no luck. I get...
Code: Select all
Payload/LiberTV.app: replacing existing signature

Immediately followed by...
Code: Select all
Payload/LiberTV.app: main executable failed strict validation


Apple Developer site says this about it:
Your Mach-O executable does not conform to modern Mach-O layout rules.
You may be using a third party development product that hasn't been brought up to date, or post-processed your file in unsupported ways.


In case it was a corrupt IPA I downloaded a fresh one from the FAQ. Same problem.

Anyway around this or am I out of luck?
creativelyrich
 
Posts: 4
Joined: Mon May 08, 2017 11:55 pm

Re: Signing libertv

Postby fuzzynuts » Mon May 15, 2017 10:07 am

Just create a new Apple Dev id and use Cydia impactor
fuzzynuts
 
Posts: 26
Joined: Sun Mar 12, 2017 6:11 pm

Re: Signing libertv

Postby Siguza » Mon May 15, 2017 10:17 pm

This seems to be caused by jtool's code signing... first, remove J's signature:

Code: Select all
jtool -rC 22 --inplace liberTV

Next, compile this program (I called it "trunc"):

Code: Select all
// gcc -o trunc trunc.c
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <mach-o/loader.h>

int main(int argc, const char **argv)
{
    int fd = open(argv[1], O_RDONLY);
    struct stat s;
    fstat(fd, &s);
    void *buf = malloc(s.st_size);
    read(fd, buf, s.st_size);
    close(fd);
    struct mach_header_64 *h = buf;
    size_t len = 0;
    struct segment_command_64 *linkedit = NULL;
    for(struct load_command *cmd = (struct load_command*)(h + 1), *end = (struct load_command*)((char*)cmd + h->sizeofcmds); cmd < end; cmd = (struct load_command*)((char*)cmd + cmd->cmdsize))
    {
        struct segment_command_64 *seg = (struct segment_command_64*)cmd;
        struct symtab_command *stab = (struct symtab_command*)cmd;
        if(cmd->cmd == LC_SEGMENT_64 && strcmp(seg->segname, "__LINKEDIT") == 0)
        {
            linkedit = seg;
        }
        else if(cmd->cmd == LC_SYMTAB)
        {
            len = stab->stroff + stab->strsize;
        }
    }
    if(len == 0 || linkedit == NULL)
    {
        fprintf(stderr, "Failed\n");
        return -1;
    }
    linkedit->filesize = len - linkedit->fileoff;
    fd = open(argv[1], O_WRONLY | O_TRUNC);
    write(fd, buf, len);
    close(fd);
    return 0;
}


Then use it to truncate the binary:

Code: Select all
./trunc liberTV


And finally you can sign it:

Code: Select all
codesign -s IDENTITY liberTV


Now, @Morpheus:
The issue is that
1. __LINKEDIT has to span all the way until the end of the file
2. The symbol table pointed to by LC_SYMTAB needs to be the last data in the file for some random reason.
User avatar
Siguza
Unicorn
 
Posts: 159
Joined: Thu Jan 28, 2016 10:38 am

Re: Signing libertv

Postby creativelyrich » Fri May 19, 2017 1:55 am

@Siguza, your script worked perfectly. Thank you.

Not sure why, but I was unable to zip the entire Payload folder and install with Xcode. Every time I’d get the error:

App installation failed. The application could not be verified.

Assuming this had to do with the Release-appletvos folder in the LiberTV IPA, I tried applying the same “trunc” script to Payload/Release-appletvos/liberTV.app/liberTV and following the same steps to sign, but no change when it came to installing with Xcode.

What ended up solving it was…

Code: Select all
zip -r9 libertv.ipa Payload/LiberTV.app


Now my IPA doesn’t include the liberTV.app.dSYM or Release-appletvos folder that came with the original but it installs with Xcode fine. I can jailbreak and get SSH access.
creativelyrich
 
Posts: 4
Joined: Mon May 08, 2017 11:55 pm


Return to LiberTV

Who is online

Users browsing this forum: No registered users and 1 guest