Have no title yet! -------------------------- xinsmod.c ----------------------------- /* Donz Anto mixes C code! Tested in Linux node0 2.6.20-17-generic #2 SMP cat /boot/System.map-2.6.20-17-generic |grep sys_call_ta c02f4500 R sys_call_table */ #include #include #include #include #include #include #include #include #include int lock=1; void **sys_call_table = (void *)0xc02f4500; asmlinkage int (*o_unlink) (const char *pathname); asmlinkage int (*o_init) (void *umod,unsigned long len,char *uargs); asmlinkage int my_unlink(const char *pathname) { char *pass="unl0ck3d"; char *locked="kunci"; char *kname=(char *)kmalloc(256,GFP_KERNEL); int ret; copy_from_user(kname,pathname,255); if(strcmp(kname,pass)==0){ lock=0; printk(KERN_INFO "SYS_UNLINK : init_module successfully unlocked\n"); kfree(kname); return 0; } else if(strcmp(kname,locked)==0){ lock=1; printk(KERN_INFO "SYS_UNLINK : init_module successfully locked\n"); kfree(kname); return 0; }else{ kfree(kname); ret=o_unlink(pathname); } return ret; } asmlinkage int my_init(void *umod,unsigned long len,char *uargs) { int ret; if(lock==1){ printk(KERN_INFO "SYS_INIT_MODULE : module loading denied!\n"); return 0; }else{ ret=o_init(umod,len,uargs); printk(KERN_INFO "SYS_INIT_MODULE : module loaded successfully\n"); return ret; } return ret; } int init_module(void) { o_unlink=sys_call_table[__NR_unlink]; sys_call_table[__NR_unlink]=my_unlink; o_init=sys_call_table[__NR_init_module]; sys_call_table[__NR_init_module]=my_init; return 0; } /* permanent module untill rebooted cleanup_module's disabled void cleanup_module(void) { sys_call_table[__NR_unlink]=o_unlink; sys_call_table[__NR_init_module]=o_init; } */ --------------------------- unlock.c --------------------------- #include #include #include int main(int argc, char *argv[]) { if(argc!=3){ printf(" Usage : %s [-l|-u] \n -u to unlock and -l to lock\n",argv[0]); exit(0); } char sw,*pwd; while((sw=getopt(argc,argv,"u:l"))!=EOF){ switch(sw) { case 'u' : printf("Enter secret code to unlock init_module\n"); pwd = getpass("password : "); unlink(pwd); break; case 'l' : unlink("kunci"); break; default : printf("Unsupported option\n"); break; } } } ------------------------- Makefile ---------------------------- obj-m += xinsmod.o CC=cc all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules $(CC) -o unlock unlock.c clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean rm -f unlock ---------------------- ASCI encoded -------------------------- begin 644 alkm.tgz M'XL(`````````^U8ZT_;2!#OU_BO&%).V+F$V'D0B=253CQ.J+P$1:<31='& MWH2MUVO+ZRUP+?_[S?H1$D@I=U>*[LZ_#[$].SMOSZP31K[B]-6SPK9[]J#? MQZOM#/I=?=6WQ37#*\>Q-WK]7J_G#)#N.!N=_JO^\YJ50\F4)*@R("REXNM\ M/J%A],CZOQ1AEO^V$CSR@O7T.GT&';9C8W)[7\N_H^_OY;\[P/S;SV#+`_S/ M\_^:"8\KG\(;)9A,_?7+M\8=#0DL>D#B;*QI!A,IA(0)4]^09.HUP;LD"33P M_M/YA65\-H!-3+VRXG8M?`*($V2>F'4XDV1*81-^DG#>XE]:Z@+>?%0B>/M! M0$M!&D%>DT"$#RVN"?KQ@Z@W,_'VA374`NDU2TU;W]\:N7IYU6S$5SY2KBX9 MIZ8IK]PI3:,XS4S)MC?K:I/7+6O%W3G:S2V35RSU+I'9TD\9"<`CDL*:6H-- MHU::OB-2BEJHE]`4O`B#\46HI6U=`2<`'UQT1*LZY_KZ+$1\^S M9=S'1&`BEWX:)Y0$PWG5/%-=<-4#)3Q6O\_ITPE1/)VW\4Q(%<=1DE(?T'$6 MB<*/L\`^`;_;_;&SR8_SVG,ZCZ_P]`NV%L M1^(/^$5@$PO9-96PE36U%>,]E;I],`'[3*AK$$BUH;.^L=ZQ6\Z@-:6")LR# MUQTX/3@V/))">QQ%:?OT!C>&ZR&)6P^YOTP3&H.\D2./<#Y*B>'9G4FO;]MP M,D\>L#A_X,&2Y&2\.*P*>HI=<;IL)1<6DX2$RY8#F@C* ME^K2C7[IPFR,+K'O1FKGY*(J(L.V(IY'I9Q-53U+7&=H?(J8#XW&8EAPG)CY M@F5?E\$;&BA'#PD]5;4(LQ&-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