aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoni <toni@devlap.local>2015-10-27 10:45:36 +0100
committertoni <toni@devlap.local>2015-10-27 10:45:36 +0100
commit5776888c1bf385138f8e87dd62688018ddca4f57 (patch)
tree39e96e5aba46801c5c078c3c4b860bc306912886
parent0dcafee7a035b72d0dacfe270e5937ec98b860e7 (diff)
function jumping tests
-rw-r--r--.gitignore1
-rw-r--r--Makefile2
-rw-r--r--funcjmp_ext.c40
-rw-r--r--funcjmp_simple.c1
4 files changed, 17 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore
index 5008637..bd8d165 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ sc-test
sc-test_x64
funcjmp_simple
funcjmp_ext
+format
diff --git a/Makefile b/Makefile
index ffc2660..8854367 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ CC := gcc
STRIP := strip
LBITS := $(shell getconf LONG_BIT)
CFLAGS += -Wall
-OCFLAGS += -z execstack -fno-stack-protector
+OCFLAGS += -zexecstack -znorelro -fno-stack-protector -fno-pie -ggdb -static
X86_FLAGS = -m32 -mpreferred-stack-boundary=2
X64_FLAGS = -m64 -mpreferred-stack-boundary=4
SOURCES = $(wildcard *.c)
diff --git a/funcjmp_ext.c b/funcjmp_ext.c
index 6174bec..9bf20f4 100644
--- a/funcjmp_ext.c
+++ b/funcjmp_ext.c
@@ -5,48 +5,36 @@
#define INTEL_ASM(_asm_str) asm volatile(".intel_syntax noprefix"); \
asm volatile(_asm_str); \
asm volatile(".att_syntax prefix");
-#define JUMPABLE_FUNC(fname) __attribute__ ((__cdecl__)) int fname(void)
-#define JMP_FUNC_DECL(func) void *fptr = (void *)( &func );
-#define JMP_TO_FUNC \
- INTEL_ASM(" \
- call getip; \
- jmp short donext; \
- cfunc: \
- mov eax,[fptr]; \
- add eax,0x0; \
- jmp eax; \
- ret; \
- getip: \
- nop; \
- jmp short cfunc; \
- donext: \
- ");
-
-#define PRE_JUMP(arg)
-
int hookable(char *arg0, int arg1, int arg2)
{
asm("label:");
- INTEL_ASM("nop; nop; nop; pop eax; pop eax");
+ INTEL_ASM("nop; nop; nop");
+ printf("hookable ..\n");
+ asm("nop; nop; nop; pop %ebx; pop %eax; call *%eax; call *%ebx");
asm("jmp end");
return 0;
}
-int testfkt(void *param)
+int testfkt(void)
{
printf("Subroutine ..\n");
+ return 0;
+}
+
+void testfkt2(void)
+{
+ printf("another Subroutine ..\n");
}
int main(int argc, char **argv)
{
- asm("push %0" : : "m" (hookable));
- asm("push %0" : : "g" (hookable));
+ printf("main(...)\n");
+ asm("push %0" : : "g" (testfkt));
+ asm("push %0" : : "g" (testfkt2));
asm("jmp label; \
end:");
- //hookable(NULL, 0x8, 0x9);
- printf("Hello World!\n");
- testfkt(NULL);
+ printf("EOF!\n");
return 66;
}
diff --git a/funcjmp_simple.c b/funcjmp_simple.c
index 9e756cf..63946c8 100644
--- a/funcjmp_simple.c
+++ b/funcjmp_simple.c
@@ -29,6 +29,7 @@ JUMPABLE_FUNC(testfkt)
{
int var0 = 0x1, var1 = 0x2, var2 = 0x3;
var0 += var1 + var2;
+ printf("Subroutine: %d = %d + %d\n", var0, var1, var2);
return 0;
}