gcc 스텍 깨지는거 검사하기

Posted by 빵빵빵
2011/11/24 15:58 전산(컴퓨터)/리눅스



스텍 깨지는거 검사 linux ubuntu 
출처 : http://stackoverflow.com/questions/1345670/stack-smashing-detected

ab@cd-x:$ cat test_overflow.c 
#include <stdio.h>
#include <string.h>

int check_password(char *password){
   
int flag = 0;
   
char buffer[20];
    strcpy
(buffer, password);

   
if(strcmp(buffer, "mypass") == 0){
        flag
= 1;
   
}
   
if(strcmp(buffer, "yourpass") == 0){
        flag
= 1;
   
}
   
return flag;
}

int main(int argc, char *argv[]){
   
if(argc >= 2){
       
if(check_password(argv[1])){
            printf
("%s", "Access grainted\n");
       
}else{
            printf
("%s", "Access denined\n");
       
}
   
}else{
        printf
("%s", "Please enter password!\n");
   
}
}
ab@cd
-x:$ gcc -g -fno-stack-protector test_overflow.c
ab@cd
-x:$ ./a.out mypass
Access grainted
ab@cd
-x:$ ./a.out yourpass
Access grainted
ab@cd
-x:$ ./a.out wepass
Access denined
ab@cd
-x:$ ./a.out wepassssssssssssssssss
Access grainted

ab@cd
-x:$ gcc -g -fstack-protector test_overflow.c
ab@cd
-x:$ ./a.out wepass
Access denined
ab@cd
-x:$ ./a.out mypass
Access grainted
ab@cd
-x:$ ./a.out yourpass
Access grainted
ab@cd
-x:$ ./a.out wepassssssssssssssssss
*** stack smashing detected ***: ./a.out terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xce0ed8]
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x0)[0xce0e90]
./a.out[0x8048524]
./a.out[0x8048545]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xc16b56]
./a.out[0x8048411]
======= Memory map: ========
007d9000-007f5000 r-xp 00000000 08:06 5776       /lib/libgcc_s.so.1
007f5000-007f6000 r--p 0001b000 08:06 5776       /lib/libgcc_s.so.1
007f6000-007f7000 rw-p 0001c000 08:06 5776       /lib/libgcc_s.so.1
0090a000-0090b000 r-xp 00000000 00:00 0          [vdso]
00c00000-00d3e000 r-xp 00000000 08:06 1183       /lib/tls/i686/cmov/libc-2.10.1.so
00d3e000-00d3f000 ---p 0013e000 08:06 1183       /lib/tls/i686/cmov/libc-2.10.1.so
00d3f000-00d41000 r--p 0013e000 08:06 1183       /lib/tls/i686/cmov/libc-2.10.1.so
00d41000-00d42000 rw-p 00140000 08:06 1183       /lib/tls/i686/cmov/libc-2.10.1.so
00d42000-00d45000 rw-p 00000000 00:00 0
00e0c000-00e27000 r-xp 00000000 08:06 4213       /lib/ld-2.10.1.so
00e27000-00e28000 r--p 0001a000 08:06 4213       /lib/ld-2.10.1.so
00e28000-00e29000 rw-p 0001b000 08:06 4213       /lib/ld-2.10.1.so
08048000-08049000 r-xp 00000000 08:05 1056811    /dos/hacking/test/a.out
08049000-0804a000 r--p 00000000 08:05 1056811    /dos/hacking/test/a.out
0804a000-0804b000 rw-p 00001000 08:05 1056811    /dos/hacking/test/a.out
08675000-08696000 rw-p 00000000 00:00 0          [heap]
b76fe000
-b76ff000 rw-p 00000000 00:00 0
b7717000
-b7719000 rw-p 00000000 00:00 0
bfc1c000
-bfc31000 rw-p 00000000 00:00 0          [stack]
Aborted
ab@cd
-x:$
2011/11/24 15:58 2011/11/24 15:58

서비스(데몬) 조회 및 서비스 실행

Posted by 빵빵빵
2011/11/17 18:18 전산(컴퓨터)/리눅스



우분투에서 ubuntu

서비스 조회

dpkg -l "*sys*log*" | grep ^ii




서비스 중지
service rsyslog stop

서비스 실행
service rsyslog start

서비스 재실행
service rsyslog restart



# 1 millisecond == 1000 microseconds
usleep
(1000);
# 1 microsecond == 1000 nanoseconds
nanosleep
(1000000);
2011/11/17 18:18 2011/11/17 18:18

regsvr32를 코드로 자동 등록 해보자...

Posted by 빵빵빵
2011/10/27 15:06 전산(컴퓨터)/PC-Windows



ocx나 dll 등... regsvr32 로 등록해야 하는 녀석들이 있지요?

이걸 VC++ 로 걍 등록해서 써 봅시다.

그냥 실행만 하면 되니 등록이 되던 말던 신경 안써도 되것죠...

2011/10/27 15:06 2011/10/27 15:06