Showing
19 changed files
with
30 additions
and
24 deletions
lab5-2/dhooker/.hooker.ko.cmd
0 → 100644
1 | +cmd_/root/hooking/dhooker/hooker.ko := arm-linux-gnueabihf-ld -EL -r -T ./scripts/module-common.lds --build-id -o /root/hooking/dhooker/hooker.ko /root/hooking/dhooker/hooker.o /root/hooking/dhooker/hooker.mod.o |
1 | -cmd_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o := arm-linux-gnueabihf-gcc -Wp,-MD,/root/OSSPractice/lab5-2/hooking_prac/dhooker/.hooker.mod.o.d -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/5/include -I./arch/arm/include -Iarch/arm/include/generated/uapi -Iarch/arm/include/generated -Iinclude -I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-bcm2709/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -fno-dwarf2-cfi-asm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -fno-ipa-sra -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -funwind-tables -marm -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(hooker.mod)" -D"KBUILD_MODNAME=KBUILD_STR(hooker)" -DMODULE -c -o /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.c | 1 | +cmd_/root/hooking/dhooker/hooker.mod.o := arm-linux-gnueabihf-gcc -Wp,-MD,/root/hooking/dhooker/.hooker.mod.o.d -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/5/include -I./arch/arm/include -Iarch/arm/include/generated/uapi -Iarch/arm/include/generated -Iinclude -I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-bcm2709/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -fno-dwarf2-cfi-asm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -fno-ipa-sra -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -funwind-tables -marm -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(hooker.mod)" -D"KBUILD_MODNAME=KBUILD_STR(hooker)" -DMODULE -c -o /root/hooking/dhooker/hooker.mod.o /root/hooking/dhooker/hooker.mod.c |
2 | 2 | ||
3 | -source_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o := /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.c | 3 | +source_/root/hooking/dhooker/hooker.mod.o := /root/hooking/dhooker/hooker.mod.c |
4 | 4 | ||
5 | -deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o := \ | 5 | +deps_/root/hooking/dhooker/hooker.mod.o := \ |
6 | $(wildcard include/config/module/unload.h) \ | 6 | $(wildcard include/config/module/unload.h) \ |
7 | include/linux/module.h \ | 7 | include/linux/module.h \ |
8 | $(wildcard include/config/modules.h) \ | 8 | $(wildcard include/config/modules.h) \ |
... | @@ -438,6 +438,6 @@ deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o := \ | ... | @@ -438,6 +438,6 @@ deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o := \ |
438 | include/linux/vermagic.h \ | 438 | include/linux/vermagic.h \ |
439 | include/generated/utsrelease.h \ | 439 | include/generated/utsrelease.h \ |
440 | 440 | ||
441 | -/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o: $(deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o) | 441 | +/root/hooking/dhooker/hooker.mod.o: $(deps_/root/hooking/dhooker/hooker.mod.o) |
442 | 442 | ||
443 | -$(deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o): | 443 | +$(deps_/root/hooking/dhooker/hooker.mod.o): | ... | ... |
1 | -cmd_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o := arm-linux-gnueabihf-gcc -Wp,-MD,/root/OSSPractice/lab5-2/hooking_prac/dhooker/.hooker.o.d -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/5/include -I./arch/arm/include -Iarch/arm/include/generated/uapi -Iarch/arm/include/generated -Iinclude -I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-bcm2709/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -fno-dwarf2-cfi-asm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -fno-ipa-sra -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -funwind-tables -marm -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -DMODULE -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(hooker)" -D"KBUILD_MODNAME=KBUILD_STR(hooker)" -c -o /root/OSSPractice/lab5-2/hooking_prac/dhooker/.tmp_hooker.o /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.c | 1 | +cmd_/root/hooking/dhooker/hooker.o := arm-linux-gnueabihf-gcc -Wp,-MD,/root/hooking/dhooker/.hooker.o.d -nostdinc -isystem /usr/lib/gcc-cross/arm-linux-gnueabihf/5/include -I./arch/arm/include -Iarch/arm/include/generated/uapi -Iarch/arm/include/generated -Iinclude -I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-bcm2709/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -fno-dwarf2-cfi-asm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -fno-ipa-sra -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -funwind-tables -marm -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -DMODULE -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(hooker)" -D"KBUILD_MODNAME=KBUILD_STR(hooker)" -c -o /root/hooking/dhooker/.tmp_hooker.o /root/hooking/dhooker/hooker.c |
2 | 2 | ||
3 | -source_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o := /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.c | 3 | +source_/root/hooking/dhooker/hooker.o := /root/hooking/dhooker/hooker.c |
4 | 4 | ||
5 | -deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o := \ | 5 | +deps_/root/hooking/dhooker/hooker.o := \ |
6 | include/linux/kernel.h \ | 6 | include/linux/kernel.h \ |
7 | $(wildcard include/config/lbdaf.h) \ | 7 | $(wildcard include/config/lbdaf.h) \ |
8 | $(wildcard include/config/preempt/voluntary.h) \ | 8 | $(wildcard include/config/preempt/voluntary.h) \ |
... | @@ -824,6 +824,6 @@ deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o := \ | ... | @@ -824,6 +824,6 @@ deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o := \ |
824 | arch/arm/include/generated/asm/local.h \ | 824 | arch/arm/include/generated/asm/local.h \ |
825 | include/asm-generic/local.h \ | 825 | include/asm-generic/local.h \ |
826 | 826 | ||
827 | -/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o: $(deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o) | 827 | +/root/hooking/dhooker/hooker.o: $(deps_/root/hooking/dhooker/hooker.o) |
828 | 828 | ||
829 | -$(deps_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o): | 829 | +$(deps_/root/hooking/dhooker/hooker.o): | ... | ... |
lab5-2/dhooker/.tmp_versions/hooker.mod
0 → 100644
... | @@ -2,6 +2,8 @@ | ... | @@ -2,6 +2,8 @@ |
2 | #include <linux/module.h> | 2 | #include <linux/module.h> |
3 | #include <linux/syscalls.h> | 3 | #include <linux/syscalls.h> |
4 | #include <linux/string.h> | 4 | #include <linux/string.h> |
5 | +#include <linux/sched.h> | ||
6 | + | ||
5 | #define SYSCALL_TABLE_BASE_ADDR (0x8000fc28) | 7 | #define SYSCALL_TABLE_BASE_ADDR (0x8000fc28) |
6 | #define MANAGER_PERMISSION (0xff) | 8 | #define MANAGER_PERMISSION (0xff) |
7 | 9 | ||
... | @@ -10,15 +12,18 @@ unsigned int g_uPrevAP = 0x00; | ... | @@ -10,15 +12,18 @@ unsigned int g_uPrevAP = 0x00; |
10 | unsigned int g_uNewAP = MANAGER_PERMISSION; | 12 | unsigned int g_uNewAP = MANAGER_PERMISSION; |
11 | unsigned int (* sys_write_orig)(int fd, char *byf, size_t count); | 13 | unsigned int (* sys_write_orig)(int fd, char *byf, size_t count); |
12 | 14 | ||
15 | + | ||
13 | //sys_write_orig() 호출 전 pBuF의 내용 수정 | 16 | //sys_write_orig() 호출 전 pBuF의 내용 수정 |
14 | unsigned int sys_write_hooked(int nFD, char *pBuf, size_t nCnt){ | 17 | unsigned int sys_write_hooked(int nFD, char *pBuf, size_t nCnt){ |
15 | - if(nFD == 1 && current->comm != "dmesg"){ | 18 | + |
16 | - printk("current process: %s\n",current->comm); | 19 | + if(nFD == 1){ |
17 | - if(current->comm == "hello_world"){ | 20 | + |
18 | - printk("hello world 호출\n"); | 21 | + if(current->comm != "dmesg" && current->comm != "resolvconf"){ |
19 | - memset(pBuf, 0, nCnt); | 22 | + printk("current process name : %s\n",current->comm); |
20 | - strcpy(pBuf, "Hacked!!!\n"); | ||
21 | } | 23 | } |
24 | + | ||
25 | + memset(pBuf, 0, nCnt); | ||
26 | + strcpy(pBuf, "Hacked!!!\n"); | ||
22 | return sys_write_orig(nFD,pBuf, nCnt); | 27 | return sys_write_orig(nFD,pBuf, nCnt); |
23 | } | 28 | } |
24 | else{ | 29 | else{ |
... | @@ -28,9 +33,9 @@ unsigned int sys_write_hooked(int nFD, char *pBuf, size_t nCnt){ | ... | @@ -28,9 +33,9 @@ unsigned int sys_write_hooked(int nFD, char *pBuf, size_t nCnt){ |
28 | } | 33 | } |
29 | 34 | ||
30 | int __init Hook_Init(void){ | 35 | int __init Hook_Init(void){ |
31 | - | ||
32 | sys_write_orig = (void *)g_puSysTableAddr[__NR_write]; | 36 | sys_write_orig = (void *)g_puSysTableAddr[__NR_write]; |
33 | 37 | ||
38 | + printk("외않되?\n"); | ||
34 | __asm__ __volatile__("mrc p15, 0, %0, c3, c0" : "=r"(g_uPrevAP)); | 39 | __asm__ __volatile__("mrc p15, 0, %0, c3, c0" : "=r"(g_uPrevAP)); |
35 | __asm__ __volatile__("mrc p15, 0, %0, c3, c0" : : "r"(g_uNewAP)); | 40 | __asm__ __volatile__("mrc p15, 0, %0, c3, c0" : : "r"(g_uNewAP)); |
36 | 41 | ||
... | @@ -51,3 +56,4 @@ void __exit Hook_Exit(void){ | ... | @@ -51,3 +56,4 @@ void __exit Hook_Exit(void){ |
51 | 56 | ||
52 | module_init(Hook_Init); | 57 | module_init(Hook_Init); |
53 | module_exit(Hook_Exit); | 58 | module_exit(Hook_Exit); |
59 | +MODULE_LICENSE("GPL"); | ... | ... |
... | @@ -19,8 +19,8 @@ __used | ... | @@ -19,8 +19,8 @@ __used |
19 | __attribute__((section("__versions"))) = { | 19 | __attribute__((section("__versions"))) = { |
20 | { 0xb344870e, __VMLINUX_SYMBOL_STR(module_layout) }, | 20 | { 0xb344870e, __VMLINUX_SYMBOL_STR(module_layout) }, |
21 | { 0x2e5810c6, __VMLINUX_SYMBOL_STR(__aeabi_unwind_cpp_pr1) }, | 21 | { 0x2e5810c6, __VMLINUX_SYMBOL_STR(__aeabi_unwind_cpp_pr1) }, |
22 | - { 0xfa2a45e, __VMLINUX_SYMBOL_STR(__memzero) }, | ||
23 | { 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) }, | 22 | { 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) }, |
23 | + { 0xfa2a45e, __VMLINUX_SYMBOL_STR(__memzero) }, | ||
24 | { 0xb1ad28e0, __VMLINUX_SYMBOL_STR(__gnu_mcount_nc) }, | 24 | { 0xb1ad28e0, __VMLINUX_SYMBOL_STR(__gnu_mcount_nc) }, |
25 | }; | 25 | }; |
26 | 26 | ||
... | @@ -30,4 +30,4 @@ __attribute__((section(".modinfo"))) = | ... | @@ -30,4 +30,4 @@ __attribute__((section(".modinfo"))) = |
30 | "depends="; | 30 | "depends="; |
31 | 31 | ||
32 | 32 | ||
33 | -MODULE_INFO(srcversion, "F027612343C6A28CC173B86"); | 33 | +MODULE_INFO(srcversion, "2F28819604D362F973EB9E8"); | ... | ... |
No preview for this file type
No preview for this file type
lab5-2/dhooker/modules.order
0 → 100644
1 | +kernel//root/hooking/dhooker/hooker.ko |
No preview for this file type
No preview for this file type
1 | -cmd_/root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.ko := arm-linux-gnueabihf-ld -EL -r -T ./scripts/module-common.lds --build-id -o /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.ko /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.o /root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.mod.o |
1 | -kernel//root/OSSPractice/lab5-2/hooking_prac/dhooker/hooker.ko |
-
Please register or login to post a comment