Format String Exploit and overwrite the Global Offset Table - bin 0x13

Поділитися
Вставка
  • Опубліковано 1 лис 2024

КОМЕНТАРІ • 79

  • @mequambluespark8686
    @mequambluespark8686 6 років тому +100

    can't overwrite the return pointer? no prob, we GOT this :P

  • @nikoshalk
    @nikoshalk 5 років тому +23

    Probably one of the hardest exploits to grasp in your series, but once you do, damn! It's beautiful

  • @th3r4nd0m3
    @th3r4nd0m3 5 років тому +29

    now..that's a lot of info to grasp....and again...i'm going to watch this 10 times

    • @begrateful3405
      @begrateful3405 4 роки тому

      better try the other FormatString exploids befor that 4th than it is much easier to understand

  • @epicm999
    @epicm999 2 роки тому +2

    That method of setting the GOT entry from 0x84b4 to 0x0804 is insanely cool. What I did was write the bytes in reverse, where I switched the order of the addresses I used as input and wrote 0x0804 to the first half of the address and then then wrote 0x84b4 to the second half. Worked in format3, but I've got to try your method too.

  • @rakshitawasthi6647
    @rakshitawasthi6647 3 роки тому +1

    This channel is the best for learning Binary Exploitation, thanks for those amazing videos.

  • @stek4511
    @stek4511 4 роки тому +23

    For the "double write", instead of %n(int*), we could use %hn(short int*)

    • @lordtony8276
      @lordtony8276 4 роки тому +8

      This comment probably saved me 2 hours on nactf 2020. I've never heard of using the %hn before and I swear it isn't mentioned anywhere. I just got 300 points because of you. Thanks a bunch.

    • @stek4511
      @stek4511 4 роки тому

      @@lordtony8276 i'm glad to hear that, gg!

    • @cozzel3995
      @cozzel3995 3 роки тому +1

      It is mentioned in Hacking: The Art of Exploitation book

  • @grelyelo
    @grelyelo 3 роки тому

    Thanks this video really helped with my school assignment to overwrite the GOT

  • @nicolasschleicher4263
    @nicolasschleicher4263 7 років тому +5

    I've had to watch this a few times to understand it but I've learned a lot. Carry on doing what you do!

  • @dplastico
    @dplastico 4 роки тому +4

    Im a big fan, I know this is old, but the EXIT_PLT name confuses, cause its actually EXIT at GOT, right? Such a good material keep up the good work!

  • @sciencebug314
    @sciencebug314 4 роки тому +2

    you could also write individual bytes with "%hhn" (half half int = byte)

  • @Anonymouspock
    @Anonymouspock 6 років тому +5

    Python tip @5:10: this pad function should just be .ljust(512, 'X')

  • @typedeaf
    @typedeaf 5 років тому +2

    Question you ask @10:13 "How do we get a lower number, if we can only increase the amount of character?"
    I would respond with , "You write the lower number first?"
    I am guessing that the reason you don't write the lower number first, is because of what you mention later, about the least significant bytes actually overwriting the entire 4 bytes? ie. the second write would clobber the higher bytes from the first write. Is that right?

    • @th3r4nd0m3
      @th3r4nd0m3 5 років тому +2

      that is indeed right, if you ask me

  • @Occcc12
    @Occcc12 8 років тому +5

    Awesome tutorial as usual.
    By the way, do you use the shellcoder's handbook as resource for making these? It seems like you cover the book's topic in sequence pretty smoothly, which also lines up with the exploit exercises.

    • @LiveOverflow
      @LiveOverflow  8 років тому +2

      +orcyngiser I follow exploit-exercises. But didn't intend to follow shellcoders handbook. But imo it's pretty much the most intuitive path to take.

  • @rek2hispagatos498
    @rek2hispagatos498 8 років тому +4

    good stuff.. thanks for showing people how to hack and not to use auto-tools.

    • @GreenyDe
      @GreenyDe 8 років тому +1

      Sure its good to know how it works, but auto-tools are great for format strings ;-P

  • @Saipranav92
    @Saipranav92 7 років тому

    Awesome tutorial, Thanks

  • @niektuytel9519
    @niektuytel9519 4 роки тому +3

    i think actually 4000 people look this video 10 times XD

  • @ezequieldonhauser
    @ezequieldonhauser 8 років тому

    you are the best brow

  • @gliderhnr1633
    @gliderhnr1633 7 років тому

    Hi. Thx for the series. I really enjoy a lot. Can you give more information how you can overwrite the GOT address ? Maybe you overwrite the lower part and high part of address fuzzing until get the correct address ? Is this ? Thx.

  • @tenghaooo3468
    @tenghaooo3468 5 років тому +1

    wow i think this is the most difficult episode so far

  • @SRGamingYT
    @SRGamingYT 2 роки тому

    hey, im doing the same thing on phoenix and for some reason as i saw on the internet sometime %$n doesnt work and you have to manually write for example %x 12 times and only after a %n iif its the 13th param from the SP pov. any explanations please ?

  • @xkjg4808
    @xkjg4808 3 роки тому +1

    6:58 i am not sure what is that supposed to mean: does the size of buffer matter? as long as the 134513844 is not bigger as the max memory limit of the current process(or stack?), we can at the end overwrite address in GOT.

    • @antoineleduc7611
      @antoineleduc7611 Рік тому

      Its a problem even on a vm your network will die, its only not a problem locally

  • @xavibeltran7811
    @xavibeltran7811 3 роки тому

    Really well explained!! Thank you =)

  • @__mk_km__
    @__mk_km__ 6 років тому +1

    We can divide the address further into bytes, so we need to print even less.
    Also, why do you pad the input there? I don't think its required for the exploit to work.

  • @yaseen_elolemy
    @yaseen_elolemy 6 років тому +1

    great video, but i don't get the use of the pad() function, why do we really need it?

    • @LiveOverflow
      @LiveOverflow  6 років тому +2

      To keep a constant length by padding it. So that it always takes up the same amount in memory and doesn’t push other stuff around.

  • @Zuzu-fq2iv
    @Zuzu-fq2iv 2 роки тому +1

    For me, i always use "info functions" in GDB because it will display all the functions and their address in the program

    • @epicm999
      @epicm999 2 роки тому

      Same here. I also sometimes use objdump -d to display the address of functions.

  • @ihebbensalem9502
    @ihebbensalem9502 8 років тому

    excellent !

  • @jorgeortiz378
    @jorgeortiz378 6 років тому

    When I try to run the exploit.py I got this: 0xError while running hook_stop:
    Value can't be converted to integer.
    what can be do?

  • @achyuthvishwamithra
    @achyuthvishwamithra Рік тому

    Why is the global offset table's address remaining the same? Won't it change with ASLR?

  • @gonzajuarez4918
    @gonzajuarez4918 3 роки тому +1

    just trying this in the new 64 bit version of exploit education. Man 64 bit addresses are hard since they are so damn filled with null bytes lol
    had to put the addresses at the end of the exploit since redirecting stdout of the exploit_script to stdout of the programme allowed passing null bytes (thank god) but the format string just wouldn't print since printf would catch the null bytes after the first address if it was kept at the beggining.

  • @d1rtyharry378
    @d1rtyharry378 4 роки тому

    Your outro is so amazing goddamit! When you do something awesome like hacking. this music is to be played as a savage moment lol!

  • @krishanusingh1608
    @krishanusingh1608 6 років тому

    hey you can even write 1 byte and and overwrite the address in 4 passes so that u dont have to print thousands of blank space characters.

    • @fakemail3472
      @fakemail3472 6 років тому

      you would have to write a lot of paddings anyway because of the previous padding... by using the technique to write like the 10804 for each chunk

  • @amlamarra
    @amlamarra 5 років тому

    If put shellcode in the buffer, should I be able to point EIP there and execute it?

    • @robinhood3841
      @robinhood3841 4 роки тому

      You can control the execution flow so you can point your instruction pointer what ever you want

  • @chri-k
    @chri-k 3 роки тому +1

    Is this also a valid solution? : put shellcode at the start of your text input, that way you have a 100% guarantee of knowing the pointer to the shellcode, then just change the EIP to there.

    • @dreamdrunk539
      @dreamdrunk539 3 роки тому

      You may not have execute permissions

    • @otesunki
      @otesunki 3 роки тому

      stack is not always executable
      you can execute the excecutable code though, that's why you point EIP to a defined function

  • @yoavshaharabani9096
    @yoavshaharabani9096 4 роки тому

    For some reason then code inside exit@plt(2:54) execute jmp [ebx+something], i can't understand why, can someone help me please?

  • @Tiddle_s
    @Tiddle_s 4 роки тому

    You should remake this video with %4$hhn which writes 1 byte at a time

  • @yushinkang1870
    @yushinkang1870 4 роки тому

    What's the point of padding? It comes after we've overwritten with %n?

  • @quangvo4563
    @quangvo4563 3 роки тому

    I couldn't write to the 5th,6th value on the stack without modifying the first 2 `84b4` . Can someone help me ?

  • @mrvaibhamit
    @mrvaibhamit 8 років тому

    Can you explain how can we overwrite GOT using buffer overflow of strcpy() ?

    • @LiveOverflow
      @LiveOverflow  8 років тому

      in a later heap related video we do exactly that. But generally you need to be able to control the destination address of the strcpy, so you can choose to write to GOT.

    • @mrvaibhamit
      @mrvaibhamit 8 років тому

      Oh cool, will check it out. Thanks

    • @mrvaibhamit
      @mrvaibhamit 8 років тому

      Just saw the 2 videos.
      Excellent explanation! I have always admired explanations that show the memory in gdb!
      malloc() memory allocation was contiguous and the overwrite changed entries for .
      Just wondering if we can also overwrite GOT entries for a buffer allocated in .data section.
      Something like: char mybuffer[10]; followed by strcpy() ?

    • @mrvaibhamit
      @mrvaibhamit 8 років тому

      Sorry, I just realized that was a stack overflow problem again

  • @pipomeow7463
    @pipomeow7463 4 роки тому +3

    too fast to understand , literally i need to watch this 3 times

  • @zedeleyici.1337
    @zedeleyici.1337 3 роки тому

    fmtstr_payload joined the chat 😅

  • @alkeryn1700
    @alkeryn1700 6 років тому +2

    Couldn't you have done 4 writes instead of two ?

    • @typedeaf
      @typedeaf 5 років тому

      I was thinking the same thing. I think the problem is that each write is actually overwriting 4 bytes (mentioned at 10:20). Since you have to write the smaller numbers/bytes first, sequence of bytes 0x08 0x04 0x84 0xB4, would have to be written 0x04 first, 0x08 second, 0x84 third, then 0xB4. The problem is, the 0x84 would clobber the 0x04 and 0x08 with 0x00000084. Make sense? I am not sure, but I had a similar question and I am going through it in my head. I should just try it with the code.

  • @eggue9598
    @eggue9598 8 років тому +1

    what's the 4$ for?

    • @LiveOverflow
      @LiveOverflow  8 років тому +1

      What do you mean?

    • @LiveOverflow
      @LiveOverflow  8 років тому +5

      ohhh you mean the dollar ($) in the printf format string: stackoverflow.com/questions/19327441/gcc-dollar-sign-in-printf-format-string
      It's part of the format string syntax and this way you can reference the n-th value from the parameters (or generally speaking the stack).

  • @donnaarisson7926
    @donnaarisson7926 3 роки тому

    it's a bit changed, gdb shows me calls and jmpq instead of call and jmp
    it shows me something like this
    jmpq *0x201962(%rip) # 0x602058
    and I cannot access the address

    • @vivekveer3272
      @vivekveer3272 3 роки тому

      type "set disassembly-flavor intel" in gdb whenever you open gdb.

  • @gershunistepan
    @gershunistepan 8 років тому

    nifty

  • @mamafadiga5697
    @mamafadiga5697 6 років тому +1

    I become pro haXOR

  • @krishanusingh1608
    @krishanusingh1608 6 років тому

    Here's poc : drive.google.com/open?id=1NktZ6ne7fpiLwG7RAkeNA3QLTmgVasRJ

  • @Daniel-hz6pt
    @Daniel-hz6pt 8 років тому

    Check your email again :p

  • @alojzybabel4153
    @alojzybabel4153 4 роки тому

    But still, this entire thing relies on someone being so dumb to send user data as a format string to `printf`. Who does that in real code? :q

    • @danielweber9414
      @danielweber9414 4 роки тому

      I can imagine someone not knowing about strcpy and using sprintf instead

    • @chri-k
      @chri-k 3 роки тому

      @@danielweber9414 whether you are writing code, or finding exploits for it, stack overflow is your friend. Just a diffrent stack overflow.