Author Topic: Need to disable codesign  (Read 3430 times)

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: Need to disable codesign
« Reply #15 on: June 01, 2012, 08:41:44 am »
try adding after sys.argv in the if statement.  IE:
Code: [Select]
if sys.argv[i] == "-o":

LeoTh3o

  • Full Member
  • ***
  • Posts: 230
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: Need to disable codesign
« Reply #16 on: June 01, 2012, 01:04:57 pm »
OK, now that's solved, but I still get this:

  File "/usr/bin/gcc", line 9, in <module>
    if not output:
NameError: name 'output' is not defined


My gcc:
#!/usr/bin/env python

import os, sys
os.system("realgcc " + " ".join(sys.argv[1:]))
for i in range(0,len(sys.argv)-1):
    if sys.argv == "-o":
        output = sys.argv[i+1]
        break
if not output:
    output = "a.out"

os.system("ldid -S %s" % output)


Thanks for the support
0xEB        0xFE
jmp short -2

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: Need to disable codesign
« Reply #17 on: June 01, 2012, 02:47:00 pm »
Dude, old post. Anyways, you should use something more like this:

Code: [Select]
#!/usr/bin/env python

import sys, os

output = "a.out"

for i in range(1, len(sys.argv)):
    if sys.argv[i] == "-o":
        output = sys.argv[i+1]
        break

if os.system("realgcc " + " ".join(sys.argv[1:]) + " >err.log 2>&1"):
    os.system("ldid -S '%s'" % (output,))

else:
    print("Compile error(s):\n" + open("err.log").read())

Just so you know, this script could be easily improved by using the subprocess module instead of os.system. I just wrote this as a quick example.

LeoTh3o

  • Full Member
  • ***
  • Posts: 230
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: Need to disable codesign
« Reply #18 on: June 01, 2012, 03:01:03 pm »
Thanks C0deH4cker. Unfortunately, this still does not fix all, as the program is still killed:
./configure: line 4756: 15120 Killed: 9               ./conftest$ac_cv_exeext
configure:4758: $? = 137
configure:4767: error: cannot run C compiled programs.


I think I can read what python is doing, but I don't have the knowledge to (re)write any piece of code in this language.

There have been alternative solutions?
0xEB        0xFE
jmp short -2

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: Need to disable codesign
« Reply #19 on: June 01, 2012, 03:52:31 pm »
Did you save this script as /usr/bin/gcc and move gcc to /usr/bin/realgcc? Also, you might want to run CC=/usr/bin/pygcc ./configure, assuming that the script is saved as /usr/bin/pygcc.

Don't like seeing ads? Click here to register!

LeoTh3o

  • Full Member
  • ***
  • Posts: 230
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: Need to disable codesign
« Reply #20 on: June 03, 2012, 07:20:40 am »
I did save the script as gcc after moving the real gcc aside. I have set chmod +x to the new gcc and still it doesn't seem to work. has anyone this problem? I'm using an iPad2 iOS 5.1.1
0xEB        0xFE
jmp short -2

A12danrulz

  • Leader
  • Hero Member
  • *****
  • Posts: 4018
  • Reputation: 216
  • Badges:
Re: Need to disable codesign
« Reply #21 on: June 03, 2012, 10:15:46 am »
Did you sign it with ldid?

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: Need to disable codesign
« Reply #22 on: June 03, 2012, 09:44:51 pm »
ldid -S /usr/bin/realgcc

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: Need to disable codesign
« Reply #23 on: June 08, 2012, 01:01:24 pm »
I manged to get the configure script to run by telling the system that it was cross compiling. 
Code: [Select]
./configure --host=arm-apple-darwin
additionally I added a working bash script to codesign....not sure if it's doing me any good though. 
Code: [Select]

#!/bin/bash

output='a.out'
next=false
for arg in "$@" ; do
        if [ "$next" == "true" ]; then
                output=$arg
                break
        elif [ "$arg" == "-o" ]; then
                next="true"
        fi
done

realgcc $*

if [ -f "$output" ]; then
        ldid -S "$output"
        ldid -s "$output"
        ldid -S "$output"
        ldid -s "$output"
        echo "Signed with ldid"
fi

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: Need to disable codesign
« Reply #24 on: June 08, 2012, 03:05:52 pm »
Redundant much?

Don't like seeing ads? Click here to register!

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: Need to disable codesign
« Reply #25 on: June 08, 2012, 03:35:25 pm »
Haha, I guess that might be a little over kill, but hey it works.  :P

C0deH4cker

  • Hero Member
  • *****
  • Posts: 2849
  • Reputation: 129
  • I am leaving iNinjas. Contact me via email.
  • Badges:
  • iDevices: iPhone 4S 16gb Black (5.1.1), iPad 2 32gb White (5.0.1), iPod Touch 2G 8gb (4.2.1)
Re: Need to disable codesign
« Reply #26 on: June 08, 2012, 03:51:44 pm »
Lol O0

LeoTh3o

  • Full Member
  • ***
  • Posts: 230
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: Need to disable codesign
« Reply #27 on: June 09, 2012, 04:33:03 am »
Finally it worked! Thanks trcx528
0xEB        0xFE
jmp short -2

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: Need to disable codesign
« Reply #28 on: June 09, 2012, 02:05:14 pm »
Hey, no worries.  Glad to help.  The only catch is you might need some additional arguments to configure in order to give it information about the target system (since it thinks it is cross compiling), but generally speaking that shouldn't be too big of a deal.