Re: [Vuln-dev Challenge] Challenge #2

From: Janus N. (janus_at_bananus.dk)
Date: 05/28/03

  • Next message: Robert Hogan: "Re: [Vuln-dev Challenge] Challenge #2"
    To: vuln-dev@securityfocus.com
    Date: 28 May 2003 01:11:39 +0200
    
    

    On Tue, 2003-05-27 at 23:03, Robert Hogan wrote:
    > > We want to set (overflow) the bfp pointer with the address of the printf
    > > command. We subtract two because the db.log file starts with two ';;'.
    > > These will then be written two bytes before printf code starts ---
    > > corrupting whatever is there (but we really don't care about that).
    >
    > One (hopefully final) request for clarification:
    >
    > when fgets finds bfp (with the address of printf there) it jumps to printf and
    > executes the value in bfp (which is now shellcode)???
    >
    > Is this correct?
    We overwrite the bfp pointer (which is stored on the stack) at the
    strcpy(buf, argv[1]) line. Now bfp points to printf function - 2. fgets
    will then read BFSIZE bytes from db.log and write them to the memory
    that bfp points to (address of printf minus 2).

    > I still don't really get the printf_got -2 thing. I would have thought that if
    > printf is at a given address, changing that address would point to something
    > else that is not the printf command! Obviously not, but I don't understand
    > how.
    If you take a look at
    fprintf(f1, ";;%s;;", argv[2]);
    you see, that the first two bytes of db.log will be ';;'. We don't want
    ';;' to overwrite the printf function so that is why we subtract 2 (then
    we will overwrite something else ... but we really do not care. We won't
    need it).

    Hope this makes it clear.

    Regards,
    Janus

    -- 
    Janus N. Tøndering <janus@bananus.dk>
    

  • Next message: Robert Hogan: "Re: [Vuln-dev Challenge] Challenge #2"

    Relevant Pages

    • Re: [Vuln-dev Challenge] Challenge #2
      ... On Monday 26 May 2003 16:59, Janus N. wrote: ... > We want to set the bfp pointer with the address of the printf ... > corrupting whatever is there. ...
      (Vuln-Dev)
    • Re: fgets question
      ... documentation didn't say if fgets put \0 after a string literal. ... If fgets runs out of room it will stop one short ... printf strlen); ... One more character than what was typed printf reported. ...
      (comp.lang.c)
    • Re: Get parents console?
      ... >printf / fgets just didn't work properly. ... After AttachConsole(), set up whatever crt std handles and file descriptors ...
      (microsoft.public.win32.programmer.kernel)
    • Re: fgets question
      ... documentation didn't say if fgets put \0 after a string literal. ... If fgets runs out of room it will stop one short ... printf strlen); ... One more character than what was typed printf reported. ...
      (comp.lang.c)
    • Re: How do I print a 0 in the beginning?
      ... int main ... I have tried using %06d, %.5i, %.5d in the printf statement. ... the thing was i couldn't use functions like fgets() or sscanf. ... Only allowed to use scanf() and printf. ...
      (comp.lang.c)