리눅스

 3916, 1/196 회원가입  로그인  
   ewqqw
   Brute force 를 이용한 공격

http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=4454 [복사]


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>

char password[8];

int generate_otp (void)
{
  int fd = open ("/dev/urandom", O_RDONLY);  
  int readed;

  readed = read (fd, (void *)password, 8);
  close (fd);

  return readed;
}

int main (int argc, char *argv[])
{
  char user_password[8];
  int readed = 0;

  if (generate_otp () != 8) {
    printf ("Something is wrong! Contact to administrator.\n");
    exit (0);        
  }
  
  printf ("Enter password (8 bytes) : \n");

  if (read (0, user_password, 8) != 8) {
    printf ("Please enter 8 bytes.\n");
    exit (0);
  }

  if (!strncmp (password, user_password, 8))
    system ("/bin/cat flag");
  else
    printf ("Wrong password !!!\n");

  return 0;
}

프로그램을 따로 작성해서 실행시켜야겠죠?

  Hit : 4672     Date : 2017/03/30 08:48



    
ewqqw 8자리 입니다... 2017/03/30  
pwnnnt pwnable.kr otp랑 비슷하네요. 2017/03/31