0

我的设备是带有 ios 7 的 iphone 5s,它是越狱的。

我在越狱ios 7上使用以下代码更改文件属性失败,但如果ios版本小于7,它将成功,我的代码是

int main(int argc, char *argv[])
{
    @autoreleasepool {
    NSString *path = [NSString stringWithUTF8String:argv[0]];
    NSString *directory = [path stringByDeletingLastPathComponent];
    int retValue = -1;

    NSString *payloadPath = [directory stringByAppendingPathComponent:@"exefile"];
    if ([[NSFileManager defaultManager] fileExistsAtPath:payloadPath]) {
        NSDictionary *newAttr = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:755] forKey:NSFilePosixPermissions];
        [[NSFileManager defaultManager] setAttributes:newAttr ofItemAtPath:payloadPath error:nil];

        argv[0] = (char*)[payloadPath UTF8String];
        retValue = execve([payloadPath UTF8String], argv, NULL);

    }
    return retValue;

    }
}

执行后 [[NSFileManager defaultManager] setAttributes:newAttr ofItemAtPath:payloadPath error:nil]; 我可以找到以下信息 vi iphone 控制台。

Jan 18 01:42:15 Martin-iPhone5s sandboxd[104] <Notice>: TestExecutor(561) deny file-write-mode /private/var/mobile/Applications/17A07293-0E73-4D67-BF0E-AB5E806C8960/TestExecutor.app/exefile

Process:         TestExecutor [561]
Path:            /var/mobile/Applications/17A07293-0E73-4D67-BF0E-AB5E806C8960/TestExecutor.app/TestExecutor
Load Address:    0x100038000
Identifier:      TestExecutor
Version:         ??? (???)
Code Type:       arm64 (Native)
Parent Process:  debugserver [559]

Date/Time:       2014-01-18 01:42:15.082 +0800
OS Version:      iOS 7.0.4 (11B554a)
Report Version:  104

Thread 0:
0   libsystem_kernel.dylib          0x000000018ffa173c __chmod + 8
1   libsystem_kernel.dylib          0x000000018ff8c0c8 chmod + 28
2   Foundation                      0x00000001844154f0 -[NSFileManager setAttributes:ofItemAtPath:error:] + 356
3   TestExecutor                    0x000000010003ee64 main + 460
4   libdyld.dylib                   0x000000018fea7aa0 start + 4

Binary Images:
       0x100038000 -        0x10003ffff  TestExecutor arm64 <6363d76973ce3fda891b623df5eb63b3> /var/mobile/Applications/17A07293-0E73-4D67-BF0E-AB5E806C8960/TestExecutor.app/TestExecutor
       0x1843c0000 -        0x1845ffffb  Foundation arm64 <b899c77034783549a78bf3a52730f20f> /System/Library/Frameworks/Foundation.framework/Foundation
       0x18fea4000 -        0x18fea7fff  libdyld.dylib arm64 <315864e397783fed95e9a5c1654c5e80> /usr/lib/system/libdyld.dylib
       0x18ff88000 -        0x18ffa7ffd  libsystem_kernel.dylib arm64 <62e992db941432b19fb88aef8a3cf46c> /usr/lib/system/libsystem_kernel.dylib
4

0 回答 0