├── logCodesign
├── logCodesign.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
└── logCodesign
│ ├── iOS
│ ├── iOSCodeSign.h
│ └── iOSCodeSign.m
│ ├── Mac
│ ├── CodeSignTask.h
│ └── CodeSignTask.m
│ └── main.m
├── README.md
└── .gitignore
/logCodesign/logCodesign.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CodeSignTask
2 | View the signature structure of app. from codesign
3 |
4 | Usage
5 | ============
6 |
7 | Self-explainatory
8 |
9 | `./logCodesign` `your app.(Demo.app)`
10 |
11 | iOS
12 | ============
13 |
14 | Self-project
15 |
16 | ```NSString *teamIdentifier = CodeSign->bundleTeamIdentifier();```
17 |
18 |
19 | ```NSLog(@"ml == %@",teamIdentifier);```
20 |
21 |
--------------------------------------------------------------------------------
/logCodesign/logCodesign/iOS/iOSCodeSign.h:
--------------------------------------------------------------------------------
1 | //
2 | // iOSCodeSign.h
3 | // logCodesign
4 | //
5 | // Created by zhanglei on 16/6/21.
6 | // Copyright © 2016年 leisuro. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef struct _sign {
12 | NSString* (*bundleTeamIdentifier)(void);
13 | }CodeSign_t ;
14 |
15 | #define CodeSign ([_CodeSign sharedCodeSign])
16 |
17 | @interface _CodeSign : NSObject
18 | + (CodeSign_t *)sharedCodeSign;
19 | @end
20 |
--------------------------------------------------------------------------------
/logCodesign/logCodesign/Mac/CodeSignTask.h:
--------------------------------------------------------------------------------
1 | //
2 | // CodeSignTask.h
3 | // logCodesign
4 | //
5 | // Created by zhanglei on 16/6/20.
6 | // Copyright © 2016年 leisuro. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CodeSignTask : NSObject
12 |
13 | - (BOOL)runProcessAsAdministrator:(NSString*)scriptPath
14 | withArguments:(NSArray *)arguments
15 | output:(NSString **)output
16 | errorDescription:(NSString **)errorDescription;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | # CocoaPods
31 | #
32 | # We recommend against adding the Pods directory to your .gitignore. However
33 | # you should judge for yourself, the pros and cons are mentioned at:
34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
35 | #
36 | # Pods/
37 |
38 | # Carthage
39 | #
40 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
41 | # Carthage/Checkouts
42 |
43 | Carthage/Build
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
51 |
52 | fastlane/report.xml
53 | fastlane/screenshots
54 |
55 | #Code Injection
56 | #
57 | # After new code Injection tools there's a generated folder /iOSInjectionProject
58 | # https://github.com/johnno1962/injectionforxcode
59 |
60 | iOSInjectionProject/
61 |
--------------------------------------------------------------------------------
/logCodesign/logCodesign/Mac/CodeSignTask.m:
--------------------------------------------------------------------------------
1 | //
2 | // CodeSignTask.m
3 | // logCodesign
4 | //
5 | // Created by zhanglei on 16/6/20.
6 | // Copyright © 2016年 leisuro. All rights reserved.
7 | //
8 |
9 | #import "CodeSignTask.h"
10 | #import
11 |
12 | @implementation CodeSignTask
13 |
14 | - (BOOL) runProcessAsAdministrator:(NSString*)scriptPath
15 | withArguments:(NSArray *)arguments
16 | output:(NSString **)output
17 | errorDescription:(NSString **)errorDescription {
18 | NSString * allArgs = [arguments componentsJoinedByString:@" "];
19 | NSString * fullScript = [NSString stringWithFormat:@"%@ %@", scriptPath, allArgs];
20 | NSDictionary *errorInfo = [NSDictionary new];
21 | NSString *script = [NSString stringWithFormat:@"do shell script \"%@\"", fullScript];
22 | NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:script];
23 | NSAppleEventDescriptor * eventResult = [appleScript executeAndReturnError:&errorInfo];
24 |
25 | // Check errorInfo
26 | if (! eventResult)
27 | {
28 | // Describe common errors
29 | *errorDescription = nil;
30 | if ([errorInfo valueForKey:NSAppleScriptErrorNumber])
31 | {
32 | NSNumber * errorNumber = (NSNumber *)[errorInfo valueForKey:NSAppleScriptErrorNumber];
33 | if ([errorNumber intValue] == -128)
34 | *errorDescription = @"The administrator password is required to do this.";
35 | }
36 | // Set error message from provided message
37 | if (*errorDescription == nil)
38 | {
39 | if ([errorInfo valueForKey:NSAppleScriptErrorMessage])
40 | *errorDescription = (NSString *)[errorInfo valueForKey:NSAppleScriptErrorMessage];
41 | }
42 | return NO;
43 | }
44 | else
45 | {
46 | // Set output to the AppleScript's output
47 | *output = [eventResult stringValue];
48 | return YES;
49 | }
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/logCodesign/logCodesign/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // logCodesign
4 | //
5 | // Created by zhanglei on 16/6/20.
6 | // Copyright © 2016年 leisuro. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CodeSignTask.h"
11 | #import "iOSCodeSign.h"
12 |
13 | void checkVerifySign(const char *path, const char *argv)
14 | {
15 |
16 | NSString * output = nil;
17 | NSString * processErrorDescription = nil;
18 |
19 | CodeSignTask *task = [[CodeSignTask alloc] init];
20 |
21 | BOOL success = [task runProcessAsAdministrator:@"/usr/bin/xcrun" withArguments:@[@"codesign",@"-v",[NSString stringWithUTF8String:argv]] output:&output errorDescription:&processErrorDescription];
22 |
23 | if (!success) // Process failed to run
24 | {
25 | // ...process output
26 | NSLog(@"\n **** This is a not complete executable signature file **** \n");
27 | }
28 | else
29 | {
30 | NSLog(@"\n **** This is a complete executable signature file **** \n");
31 | }
32 | }
33 |
34 | void lookSignAppForPath(const char *path, const char *argv)
35 | {
36 | NSTask *task = [[NSTask alloc] init];
37 | task.launchPath = @"/usr/bin/xcrun";
38 | task.currentDirectoryPath = @".";
39 | task.arguments = @[@"codesign",@"-vv",@"-d",[NSString stringWithUTF8String:argv]];
40 | [task launch];
41 | sleep(1.0);
42 | NSLog(@" \n ********** === done === ********** \n");
43 | }
44 |
45 | int main(int argc, const char * argv[])
46 | {
47 | if (argv[1] == NULL) {
48 | NSLog(@"Invalid No App");
49 | return 0;
50 | }
51 |
52 | if (strlen(argv[1]) == 0)
53 | {
54 | NSLog(@"\n **** logCodesign : Invalid path for app execute. **** \n");
55 | return 0;
56 | }
57 |
58 | NSLog(@"\n **** prepare reading app: [%s] **** \n", argv[1]);
59 | checkVerifySign(argv[0],argv[1]);
60 | lookSignAppForPath(argv[0],argv[1]);
61 |
62 | // iOS
63 | CodeSign->bundleTeamIdentifier();
64 |
65 | return 0;
66 | }
67 |
--------------------------------------------------------------------------------
/logCodesign/logCodesign/iOS/iOSCodeSign.m:
--------------------------------------------------------------------------------
1 | //
2 | // iOSCodeSign.m
3 | // logCodesign
4 | //
5 | // Created by zhanglei on 16/6/21.
6 | // Copyright © 2016年 leisuro. All rights reserved.
7 | //
8 |
9 | #import "iOSCodeSign.h"
10 |
11 | static NSString *bundleTeamIdentifier(void)
12 | {
13 | return ({
14 | NSString *mobileProvisionPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"embedded.mobileprovision"];
15 | FILE *fp=fopen([mobileProvisionPath UTF8String],"r");
16 | char ch;
17 | if(fp==NULL) {
18 | printf("file cannot be opened/n");
19 | return NULL;
20 | }
21 | NSMutableString *str = [NSMutableString string];
22 | while((ch=fgetc(fp))!=EOF) {
23 | [str appendFormat:@"%c",ch];
24 | }
25 | fclose(fp);
26 |
27 | NSString *teamIdentifier = nil;
28 | NSRange teamIdentifierRange = [str rangeOfString:@"com.apple.developer.team-identifier"];
29 | if (teamIdentifierRange.location != NSNotFound)
30 | {
31 | NSInteger location = teamIdentifierRange.location + teamIdentifier.length;
32 | NSInteger length = [str length] - location;
33 | if (length > 0 && location >= 0)
34 | {
35 | NSString *newStr = [str substringWithRange:NSMakeRange(location, length)];
36 | NSArray *val = [newStr componentsSeparatedByString:@""];
37 | NSString *v = [val firstObject];
38 | NSRange startRange = [v rangeOfString:@""];
39 |
40 | NSInteger newLocation = startRange.location + startRange.length;
41 | NSInteger newLength = [v length] - newLocation;
42 | if (newLength > 0 && location >= 0)
43 | {
44 | teamIdentifier = [v substringWithRange:NSMakeRange(newLocation, newLength)];
45 | }
46 | }
47 | }
48 | teamIdentifier;
49 | });
50 | }
51 |
52 | static CodeSign_t * util = NULL;
53 |
54 | @implementation _CodeSign
55 |
56 | +(CodeSign_t *)sharedCodeSign
57 | {
58 | static dispatch_once_t onceToken;
59 | dispatch_once(&onceToken, ^{
60 | util = malloc(sizeof(CodeSign_t));
61 | util->bundleTeamIdentifier = bundleTeamIdentifier;
62 | });
63 | return util;
64 | }
65 |
66 | + (void)destroy
67 | {
68 | util ? free(util): 0;
69 | util = NULL;
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/logCodesign/logCodesign.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 480A95771D17DEA9006D8801 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 480A95761D17DEA9006D8801 /* main.m */; };
11 | 480A957F1D17F70C006D8801 /* CodeSignTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 480A957E1D17F70C006D8801 /* CodeSignTask.m */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 480A95711D17DEA9006D8801 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = /usr/share/man/man1/;
19 | dstSubfolderSpec = 0;
20 | files = (
21 | );
22 | runOnlyForDeploymentPostprocessing = 1;
23 | };
24 | /* End PBXCopyFilesBuildPhase section */
25 |
26 | /* Begin PBXFileReference section */
27 | 480A95731D17DEA9006D8801 /* logCodesign */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = logCodesign; sourceTree = BUILT_PRODUCTS_DIR; };
28 | 480A95761D17DEA9006D8801 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
29 | 480A957D1D17F70C006D8801 /* CodeSignTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeSignTask.h; sourceTree = ""; };
30 | 480A957E1D17F70C006D8801 /* CodeSignTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CodeSignTask.m; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 480A95701D17DEA9006D8801 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 480A956A1D17DEA9006D8801 = {
45 | isa = PBXGroup;
46 | children = (
47 | 480A95751D17DEA9006D8801 /* logCodesign */,
48 | 480A95741D17DEA9006D8801 /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 480A95741D17DEA9006D8801 /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 480A95731D17DEA9006D8801 /* logCodesign */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 480A95751D17DEA9006D8801 /* logCodesign */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 480A95761D17DEA9006D8801 /* main.m */,
64 | 480A957D1D17F70C006D8801 /* CodeSignTask.h */,
65 | 480A957E1D17F70C006D8801 /* CodeSignTask.m */,
66 | );
67 | path = logCodesign;
68 | sourceTree = "";
69 | };
70 | /* End PBXGroup section */
71 |
72 | /* Begin PBXNativeTarget section */
73 | 480A95721D17DEA9006D8801 /* logCodesign */ = {
74 | isa = PBXNativeTarget;
75 | buildConfigurationList = 480A957A1D17DEA9006D8801 /* Build configuration list for PBXNativeTarget "logCodesign" */;
76 | buildPhases = (
77 | 480A956F1D17DEA9006D8801 /* Sources */,
78 | 480A95701D17DEA9006D8801 /* Frameworks */,
79 | 480A95711D17DEA9006D8801 /* CopyFiles */,
80 | );
81 | buildRules = (
82 | );
83 | dependencies = (
84 | );
85 | name = logCodesign;
86 | productName = logCodesign;
87 | productReference = 480A95731D17DEA9006D8801 /* logCodesign */;
88 | productType = "com.apple.product-type.tool";
89 | };
90 | /* End PBXNativeTarget section */
91 |
92 | /* Begin PBXProject section */
93 | 480A956B1D17DEA9006D8801 /* Project object */ = {
94 | isa = PBXProject;
95 | attributes = {
96 | LastUpgradeCheck = 0710;
97 | ORGANIZATIONNAME = leisuro;
98 | TargetAttributes = {
99 | 480A95721D17DEA9006D8801 = {
100 | CreatedOnToolsVersion = 7.1;
101 | };
102 | };
103 | };
104 | buildConfigurationList = 480A956E1D17DEA9006D8801 /* Build configuration list for PBXProject "logCodesign" */;
105 | compatibilityVersion = "Xcode 3.2";
106 | developmentRegion = English;
107 | hasScannedForEncodings = 0;
108 | knownRegions = (
109 | en,
110 | );
111 | mainGroup = 480A956A1D17DEA9006D8801;
112 | productRefGroup = 480A95741D17DEA9006D8801 /* Products */;
113 | projectDirPath = "";
114 | projectRoot = "";
115 | targets = (
116 | 480A95721D17DEA9006D8801 /* logCodesign */,
117 | );
118 | };
119 | /* End PBXProject section */
120 |
121 | /* Begin PBXSourcesBuildPhase section */
122 | 480A956F1D17DEA9006D8801 /* Sources */ = {
123 | isa = PBXSourcesBuildPhase;
124 | buildActionMask = 2147483647;
125 | files = (
126 | 480A957F1D17F70C006D8801 /* CodeSignTask.m in Sources */,
127 | 480A95771D17DEA9006D8801 /* main.m in Sources */,
128 | );
129 | runOnlyForDeploymentPostprocessing = 0;
130 | };
131 | /* End PBXSourcesBuildPhase section */
132 |
133 | /* Begin XCBuildConfiguration section */
134 | 480A95781D17DEA9006D8801 /* Debug */ = {
135 | isa = XCBuildConfiguration;
136 | buildSettings = {
137 | ALWAYS_SEARCH_USER_PATHS = NO;
138 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
139 | CLANG_CXX_LIBRARY = "libc++";
140 | CLANG_ENABLE_MODULES = YES;
141 | CLANG_ENABLE_OBJC_ARC = YES;
142 | CLANG_WARN_BOOL_CONVERSION = YES;
143 | CLANG_WARN_CONSTANT_CONVERSION = YES;
144 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
145 | CLANG_WARN_EMPTY_BODY = YES;
146 | CLANG_WARN_ENUM_CONVERSION = YES;
147 | CLANG_WARN_INT_CONVERSION = YES;
148 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
149 | CLANG_WARN_UNREACHABLE_CODE = YES;
150 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
151 | CODE_SIGN_IDENTITY = "-";
152 | COPY_PHASE_STRIP = NO;
153 | DEBUG_INFORMATION_FORMAT = dwarf;
154 | ENABLE_STRICT_OBJC_MSGSEND = YES;
155 | ENABLE_TESTABILITY = YES;
156 | GCC_C_LANGUAGE_STANDARD = gnu99;
157 | GCC_DYNAMIC_NO_PIC = NO;
158 | GCC_NO_COMMON_BLOCKS = YES;
159 | GCC_OPTIMIZATION_LEVEL = 0;
160 | GCC_PREPROCESSOR_DEFINITIONS = (
161 | "DEBUG=1",
162 | "$(inherited)",
163 | );
164 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
165 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
166 | GCC_WARN_UNDECLARED_SELECTOR = YES;
167 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
168 | GCC_WARN_UNUSED_FUNCTION = YES;
169 | GCC_WARN_UNUSED_VARIABLE = YES;
170 | MACOSX_DEPLOYMENT_TARGET = 10.10;
171 | MTL_ENABLE_DEBUG_INFO = YES;
172 | ONLY_ACTIVE_ARCH = YES;
173 | SDKROOT = macosx;
174 | };
175 | name = Debug;
176 | };
177 | 480A95791D17DEA9006D8801 /* Release */ = {
178 | isa = XCBuildConfiguration;
179 | buildSettings = {
180 | ALWAYS_SEARCH_USER_PATHS = NO;
181 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
182 | CLANG_CXX_LIBRARY = "libc++";
183 | CLANG_ENABLE_MODULES = YES;
184 | CLANG_ENABLE_OBJC_ARC = YES;
185 | CLANG_WARN_BOOL_CONVERSION = YES;
186 | CLANG_WARN_CONSTANT_CONVERSION = YES;
187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
188 | CLANG_WARN_EMPTY_BODY = YES;
189 | CLANG_WARN_ENUM_CONVERSION = YES;
190 | CLANG_WARN_INT_CONVERSION = YES;
191 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
192 | CLANG_WARN_UNREACHABLE_CODE = YES;
193 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
194 | CODE_SIGN_IDENTITY = "-";
195 | COPY_PHASE_STRIP = NO;
196 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
197 | ENABLE_NS_ASSERTIONS = NO;
198 | ENABLE_STRICT_OBJC_MSGSEND = YES;
199 | GCC_C_LANGUAGE_STANDARD = gnu99;
200 | GCC_NO_COMMON_BLOCKS = YES;
201 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
202 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
203 | GCC_WARN_UNDECLARED_SELECTOR = YES;
204 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
205 | GCC_WARN_UNUSED_FUNCTION = YES;
206 | GCC_WARN_UNUSED_VARIABLE = YES;
207 | MACOSX_DEPLOYMENT_TARGET = 10.10;
208 | MTL_ENABLE_DEBUG_INFO = NO;
209 | SDKROOT = macosx;
210 | };
211 | name = Release;
212 | };
213 | 480A957B1D17DEA9006D8801 /* Debug */ = {
214 | isa = XCBuildConfiguration;
215 | buildSettings = {
216 | PRODUCT_NAME = "$(TARGET_NAME)";
217 | };
218 | name = Debug;
219 | };
220 | 480A957C1D17DEA9006D8801 /* Release */ = {
221 | isa = XCBuildConfiguration;
222 | buildSettings = {
223 | PRODUCT_NAME = "$(TARGET_NAME)";
224 | };
225 | name = Release;
226 | };
227 | /* End XCBuildConfiguration section */
228 |
229 | /* Begin XCConfigurationList section */
230 | 480A956E1D17DEA9006D8801 /* Build configuration list for PBXProject "logCodesign" */ = {
231 | isa = XCConfigurationList;
232 | buildConfigurations = (
233 | 480A95781D17DEA9006D8801 /* Debug */,
234 | 480A95791D17DEA9006D8801 /* Release */,
235 | );
236 | defaultConfigurationIsVisible = 0;
237 | defaultConfigurationName = Release;
238 | };
239 | 480A957A1D17DEA9006D8801 /* Build configuration list for PBXNativeTarget "logCodesign" */ = {
240 | isa = XCConfigurationList;
241 | buildConfigurations = (
242 | 480A957B1D17DEA9006D8801 /* Debug */,
243 | 480A957C1D17DEA9006D8801 /* Release */,
244 | );
245 | defaultConfigurationIsVisible = 0;
246 | };
247 | /* End XCConfigurationList section */
248 | };
249 | rootObject = 480A956B1D17DEA9006D8801 /* Project object */;
250 | }
251 |
--------------------------------------------------------------------------------