Skip to content

Commit 1af8efa

Browse files
committed
+): Make files build.
1 parent ba24b0a commit 1af8efa

File tree

4 files changed

+59
-12
lines changed

4 files changed

+59
-12
lines changed

ch05/build_launchd.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
export PLATFORM=/Applications/Xcode.app/Contents/Developer/Platforms/
3+
4+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
5+
-arch armv7 -c ../ch03/syscalls.S -o syscalls.o
6+
7+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
8+
-arch armv7 -fno-stack-protector -c launchd_keytheft.c -o launchd_keytheft \
9+
-isysroot $PLATFORM/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
10+
-I$PLATFORM/Developer/SDKs/iPhoneOS.sdk/usr/include \
11+
-I.
12+
13+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
14+
-arch armv7 -o launchd_keytheft launchd_keytheft.o syscalls.o \
15+
-static -nostdlib -Wl,-e,_main
16+
17+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
18+
-arch armv7 -fno-stack-protector -c launchd_spytheft.c -o launchd_spytheft \
19+
-isysroot $PLATFORM/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
20+
-I$PLATFORM/Developer/SDKs/iPhoneOS.sdk/usr/include \
21+
-I.
22+
23+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
24+
-arch armv7 -o launchd_spytheft launchd_spytheft.o syscalls.o \
25+
-static -nostdlib -Wl,-e,_main
26+

ch05/build_payload.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export PLATFORM=/Applications/Xcode.app/Contents/Developer/Platforms/
2+
export MACOSX=$PLATFORM/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/
3+
4+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
5+
-arch armv7 -c -o watchdog.o ../ch03/watchdog.c \
6+
-isysroot $PLATFORM/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
7+
-F$MACOSX
8+
9+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
10+
-arch armv7 -c -o usbmux.o ../ch03/usbmux.c \
11+
-isysroot $PLATFORM/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
12+
-F$MACOSX
13+
14+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
15+
-arch armv7 -o payload_keytheft payload_keytheft.c watchdog.o usbmux.o \
16+
-isysroot $PLATFORM/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
17+
-framework IOKit -framework CoreFoundation

ch05/launchd_keytheft.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include <fcntl.h>
22
#include <sys/stat.h>
33
#include <sys/wait.h>
4-
#include "/usr/include/hfs/hfs_mount.h"
4+
#include <unistd.h>
5+
//#include "/usr/include/hfs/hfs_mount.h"
6+
#include "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/hfs/hfs_mount.h"
57

68
#define O_RDONLY 0x0000
79
#define O_WRONLY 0x0001
@@ -17,7 +19,7 @@ const char* fsck_hfs[] =
1719
const char* fsck_hfs_user[] =
1820
{ "/sbin/fsck_hfs", "-y", "/dev/rdisk0s1s2", NULL };
1921

20-
void sleep(unsigned int sec) {
22+
void my_sleep(unsigned int sec) {
2123
int i;
2224
for (i = sec * 10000000; i>0; i--) { }
2325
}
@@ -75,7 +77,7 @@ int fsexec(char* argv[], char* env[], int pause) {
7577
if (pid != 0) {
7678
if (pause) {
7779
while (wait4(pid, NULL, WNOHANG, NULL) <= 0) {
78-
sleep(1);
80+
my_sleep(1);
7981
}
8082
} else {
8183
return pid;
@@ -96,22 +98,22 @@ int main(int argc, char **argv, char **env) {
9698
console = open("/dev/console", O_WRONLY);
9799
dup2(console, 1);
98100

99-
sleep(5);
101+
my_sleep(5);
100102
for(i=0;i<75;i++)
101103
puts("\n");
102104
puts("ramdisk initialized.\n");
103105

104106
puts("searching for disk...\n");
105107
while (stat("/dev/disk0s1s1", &s) != 0) {
106108
puts("waiting for /dev/disk0s1s1 to appear...\n");
107-
sleep(30);
109+
my_sleep(30);
108110
}
109111

110112
puts("mounting root filesystem...\n");
111113
while(1) {
112114
if (hfs_mount("/dev/disk0s1s1", "/mnt", MNT_ROOTFS | MNT_RDONLY) != 0) {
113115
puts("unable to mount filesystem, waiting...\n");
114-
sleep(10);
116+
my_sleep(10);
115117
} else {
116118
break;
117119
}

ch05/launchd_spytheft.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include <fcntl.h>
22
#include <sys/stat.h>
33
#include <sys/wait.h>
4-
#include "/usr/include/hfs/hfs_mount.h"
4+
#include <unistd.h>
5+
//#include "/usr/include/hfs/hfs_mount.h"
6+
#include "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/hfs/hfs_mount.h"
57

68
#define O_RDONLY 0x0000
79
#define O_WRONLY 0x0001
@@ -17,7 +19,7 @@ const char* fsck_hfs[] =
1719
const char* fsck_hfs_user[] =
1820
{ "/sbin/fsck_hfs", "-y", "/dev/rdisk0s1s2", NULL };
1921

20-
void sleep(unsigned int sec) {
22+
void my_sleep(unsigned int sec) {
2123
int i;
2224
for (i = sec * 10000000; i>0; i--) { }
2325
}
@@ -75,7 +77,7 @@ int fsexec(char* argv[], char* env[], int pause) {
7577
if (pid != 0) {
7678
if (pause) {
7779
while (wait4(pid, NULL, WNOHANG, NULL) <= 0) {
78-
sleep(1);
80+
my_sleep(1);
7981
}
8082
} else {
8183
return pid;
@@ -96,22 +98,22 @@ int main(int argc, char **argv, char **env) {
9698
console = open("/dev/console", O_WRONLY);
9799
dup2(console, 1);
98100

99-
sleep(5);
101+
my_sleep(5);
100102
for(i=0;i<75;i++)
101103
puts("\n");
102104
puts("ramdisk initialized.\n");
103105

104106
puts("searching for disk...\n");
105107
while (stat("/dev/disk0s1s1", &s) != 0) {
106108
puts("waiting for /dev/disk0s1s1 to appear...\n");
107-
sleep(30);
109+
my_sleep(30);
108110
}
109111

110112
puts("mounting root filesystem...\n");
111113
while(1) {
112114
if (hfs_mount("/dev/disk0s1s1", "/mnt", MNT_ROOTFS | MNT_RDONLY) != 0) {
113115
puts("unable to mount filesystem, waiting...\n");
114-
sleep(10);
116+
my_sleep(10);
115117
} else {
116118
break;
117119
}

0 commit comments

Comments
 (0)