コード例 #1
0
ファイル: main.c プロジェクト: cognoscibilis/KaliQuickstart
//---------------------------------------------------------------------------------------------------------------------------------------------------
int clear_system_layer(const char *user, const char *tty) {
    int r = 0;
	int idx = 0;
	int i;

    printf("\n[***] System layer\n");

	for(i = 0; i < 3; i++) {
	    r = clear_uwb(system_layer_files[idx], user, tty);

	    printf("  [*] Cleaning %s ... ", system_layer_files[idx]);   
		parse_answer_code(r);

		idx++;
    }

    for(i = 0; i < 3; i++) {
	    r = clear_ams(system_layer_files[idx], user, tty);

	    printf("  [*] Cleaning %s ... ", system_layer_files[idx]);  
		parse_answer_code(r);

		idx++;
	}

    r = clear_lastlog(system_layer_files[idx], user);
    printf("  [*] Cleaning %s ... ", system_layer_files[idx]); parse_answer_code(r);

	idx++;
    r = clear_file(system_layer_files[idx]);
    printf("  [*] Cleaning %s ... ", system_layer_files[idx]);   parse_answer_code(r);

    r = clear_bash_history();
    printf("  [*] Cleaning .bash_history ... ");  parse_answer_code(r);

    printf("[***] Cleaning on System layer is complete\n");
	return 0;
}
コード例 #2
0
ファイル: whitecat.c プロジェクト: araone/one
int main(int argc, char *argv[]){
  myname = argv[0];
  char c;
  struct stat statbuf; //buffer for stat()
/* i18n */
//setlocale (LC_ALL, "");
//struct lconv l = *localeconv();
//l.decimal_point = ".";

struct option longopts[]={
{ "user", required_argument, &do_username, 'u'},
{ "tty", required_argument, &do_tty, 't'},
{ "hostname", required_argument, &do_hostname, 'a'},
{ "extended", no_argument, &do_extended, 'e'},
{ "ignore", no_argument, &do_ignorecase, 'i'},
{ "help", no_argument, NULL, 'h'},
{ "version", no_argument, NULL, 'V'},
{ 0, 0, 0, 0 }
};

if ((argc < 2) || (argc > 18)) {
  version();
  usage();
}
while ((c=getopt_long(argc,argv,"u:t:a:reihVW;",longopts,NULL)) != -1) {
  switch (c) {
   case 'u':
    username = compile_pattern(optarg);
    if (errors) usage(); //compile failed
     do_username=1;
    break;
   case 't':
    tty = compile_pattern(optarg);
    if (errors) usage(); //compile failed
     do_tty=1;
    break;
   case 'a':
    hostname = compile_pattern(optarg);
    if (errors) usage(); //compile failed
     do_hostname=1; 
    break;
   case 'e':
    do_extended = 1;
    break; 
   case 'i':
    do_ignorecase = 1;
   break;
   case 'h':
    version();
    usage(); 
   case 'V':
    version();
    exit(0);
   break;
   case 0:
    break;
   case ':':
    fprintf(stderr, "%s: option '-%c' requires an argument\n", myname, optopt);
    usage(); 
   case '?':
    default:
    fprintf(stderr, "%s: option '-%c' is invalid\n", myname, optopt);
    usage(); 
   } 
}
//sanity check
if (!do_username && !do_tty && !do_hostname){
   fprintf(stderr, "%s: did not found any parametr to clean (username, hostname, tty)!\n", myname);
   usage();
} 

version();

#ifdef SUNOS
  if (!clear_uwbtmp(UTMPX_FILE))
   printf("\033[1mutmp cleaning \t\t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
  if (!clear_uwbtmp(WTMPX_FILE))
   printf("\033[1mwtmp cleaning \t\t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
  /* we able to get file attributes, so BTMPX_FILE obviously exists */
  if (stat(BTMPX_FILE, &statbuf) == 0) 
   if (!clear_uwbtmp(BTMPX_FILE))
    printf("\033[1mbtmp cleaning \t\t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
#else 
  if (!clear_uwbtmp(UTMP_FILE))
    printf("\033[1mutmp cleaning \t\t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
  if (!clear_uwbtmp(WTMP_FILE))
    printf("\033[1mwtmp cleaning \t\t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
  /* we able to get file attributes, so BTMP_FILE obviously exists */
  if (stat(BTMP_FILE, &statbuf) == 0)
   if (!clear_uwbtmp(BTMP_FILE))
    printf("\033[1mbtmp cleaning \t\t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
#endif
if (!clear_lastlog(LASTLOG_FILE))
  printf("\033[1mlastlog cleaning \t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
if (!clear_textlog(SYSLOG_FILE))
  printf("\033[1msyslog cleaning \t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
if (stat(SECURE_FILE, &statbuf) == 0) //we able to get file attributes, so SECURE_FILE obviously exists
  if (!clear_textlog(SECURE_FILE))
    printf("\033[1msecure cleaning \t\t\t\t\t\t \033[32;1m[ OK ] \033[0m\n");
/*APACHE LOGS */
int ii=0;
while (APACHE_PATH[ii]!=NULL){
  if (!clear_textlog(APACHE_PATH[ii]))
    printf("\033[1mapache logs cleaning \t\t\t\t\t\t\t \033[32;1m[   OK   ] \033[0m\n");
    ii++;
}
/* END APACHE LOGS */
return 0;
}