½Ã½ºÅÛ ÇØÅ·

 1576, 1/79 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   ka0r1
   FTZ 18¹ø ¹®Á¦

http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=1912 [º¹»ç]


#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
void shellout(void);
int main()
{
  char string[100];
  int check;
  int x = 0;
  int count = 0;
  fd_set fds;
  printf("Enter your command: ");
  fflush(stdout);
  while(1)
    {
      if(count >= 100)
        printf("what are you trying to do?\n");
      if(check == 0xdeadbeef)
        shellout();
      else
        {
          FD_ZERO(&fds);
          FD_SET(STDIN_FILENO,&fds);

          if(select(FD_SETSIZE, &fds, NULL, NULL, NULL) >= 1)
            {
              if(FD_ISSET(fileno(stdin),&fds))
                {
                  read(fileno(stdin),&x,1);
                  switch(x)
                    {
                      case '\r':
                      case '\n':
                        printf("\a");
                        break;
                      case 0x08:
                        count--;
                        printf("\b \b");
                        break;
                      default:
                        string[count] = x;
                        count++;
                        break;
                    }
                }
            }
        }
    }
}

void shellout(void)
{
  setreuid(3099,3099);
  execl("/bin/sh","sh",NULL);
}  
















check º¯¼ö¸¦ 0xdeadbeef·Î ¹Ù²Ü ¼ö ÀÖ´Â ¹æ¹ýÀÌ ÀÖ³ª¿ä?
ÀԷ¹ÞÀº string¹è¿­º¸´Ù Äڵ尡 ¹Ø¿¡ Àִµ¥
µ¤¾î ¾º¿ì´Â °Íµµ ¾È µÇ°í...

  Hit : 2503     Date : 2018/01/06 01:13



    
±è´äº¯ \x08¸¸³ª¸é index¸¦ --ÇÏ´Â ºÎºÐÀÌÀÖÁÒ
arr[n] Àº &arr + sizeof(element)*n À̶ó¼­
char string[100] ¿¡¼­
string[1000] == &string + 1000
string[-1000] == &string - 1000
ÀÔ´Ï´Ù
string[100]À¸·Î ¼±¾ðÇß´Ù°í 0~99¸¸ Á¢±Ù°¡´ÉÇѰÍÀº ¾Æ´Õ´Ï´Ù
2018/01/07  
ka0r1 ±è´äº¯ // ¸Å¹ø ÁÁÀº ´äº¯À» ÇØÁÖ½Ã´Ï °¨»çÇÒ µû¸§ÀÔ´Ï´Ù. 2018/01/07