The Heap: How to exploit a Heap Overflow - bin 0x15

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ต.ค. 2024
  • We are solving heap1 from exploit-exercises.com by exploiting a heap overflow.
    =[ ❤️ Support ]=
    → per Video: / liveoverflow
    → per Month: / @liveoverflow
    =[ 🐕 Social ]=
    → Twitter: / liveoverflow
    → Website: liveoverflow.com/
    → Subreddit: / liveoverflow
    → Facebook: / liveoverflow
    =[ 📄 P.S. ]=
    All links with "*" are affiliate links.
    LiveOverflow / Security Flag GmbH is part of the Amazon Affiliate Partner Programm.
    #BinaryExploitation #HeapOverflow

ความคิดเห็น • 71

  • @h3apspray
    @h3apspray 7 ปีที่แล้ว +74

    These tutorials are by far some of the best material on the entire internet focused on this subject. I love the technical explanations as well as the quality of the video editing. Curious what you are using to do your editing? Keep up the excellent work, I've learned quite a lot from these and look forward to learning that much more. Where do you hang out in IRC? Kudos!

  • @arsen3783
    @arsen3783 7 ปีที่แล้ว +27

    ow, that looks fucked
    I love it.
    Great vids by the way, keep it up :)

  • @manfredheinz3066
    @manfredheinz3066 3 ปีที่แล้ว +5

    again this is an older video; but this kind of stuff even it is an "easy" challenge still completely blows my mind. this is CRAZY. I totally love this.

  • @miklosq
    @miklosq 4 ปีที่แล้ว +6

    don't forget to turn ASLR off!

  • @vladmiller5682
    @vladmiller5682 ปีที่แล้ว +1

    "oh, that looks fucked" lol
    Awesome video series!

  • @Zooiest
    @Zooiest 5 ปีที่แล้ว +11

    -Heap overflow-
    -Buffer overflow-
    LiveOverflow

  • @mistermccrack4686
    @mistermccrack4686 5 ปีที่แล้ว +1

    @Liveoverflow you should really start the challenges @ root-me system hacking, THAT WOULD BE EPIC AS FUCK!

  • @kuhluhOG
    @kuhluhOG 4 ปีที่แล้ว +3

    3:45 I didn't know a Compiler can optimize that since it's a function.
    I mean, it's possible but it's a really special purpose optimization.

    • @bamberghh1691
      @bamberghh1691 3 ปีที่แล้ว +1

      Compilers are very specialized now, to the point where this code
      #include
      int bitcount(uint64_t x) {
      int v = 0;
      while(x != 0) {
      x &= x - 1; v++;
      } return v;
      }
      Is optimized to a single instruction
      popcntq %rdi, %rax.
      Unfortunately if you change the code even a little bit the optimization won't work

  • @fredericmeyer8514
    @fredericmeyer8514 7 ปีที่แล้ว +6

    Thanks for the video, I was stuck at this level since yesterday! Watched your video exactly until 1:51 and immediately noticed what I was overseeing/missing all the time. Damn. Further exploitation was pretty straightforward :D

    • @LiveOverflow
      @LiveOverflow  7 ปีที่แล้ว +2

      awesome! congrats!

    • @fredericmeyer8514
      @fredericmeyer8514 7 ปีที่แล้ว

      thanks! keep up the good work! have been following your channel for a while and i must say that it motivated me to dive deeper into the "art of exploitation" after years of mostly doing other (though RE and lowlevel related) stuff :)

  • @robinhood3841
    @robinhood3841 4 ปีที่แล้ว +1

    Why eip is overwrote with the source of string copy after you overwrote the destination of string copy can someone explain please

  • @mohammaddvd844
    @mohammaddvd844 ปีที่แล้ว

    Hi , thank you for your videos, i have a problem , the output of the gdb isnt like you, the part `*__GI_strcpy (dest=0x804a038 "", src=0x0) at strcpy.c:39`
    please help me

  • @shrreturn7288
    @shrreturn7288 7 ปีที่แล้ว +1

    Thank you for this good series of tutorial :)
    I'm a bit confuse on print in GDB. Could you help explain why we have to set $i1 = (struct internet*) 0x08041028 ?
    Shouldn't print work with an existing variable in the current context ?
    I first tried (gdb) print *i1, print i1, x/x i1 but the address of i1 seems to be totally different from the real one 0x08041028.

  • @JennJanesko
    @JennJanesko 7 ปีที่แล้ว +2

    Hi LiveOverflow, I have followed through your tutorial, and it is straightforward and super helpful. I thought that I would try it on an Ubuntu 16.04, 32 bit system, and I have run into a problem. At about 3:10 you have a segfault for your strcpy function, and it is clear which string is being copied and the string's target address (0x46464646). But, when I have a segfault, my error message says:
    __strcpy_sse2 () at ../sysdeps/i386/i686/multiarch/strcpy-sse2.S:1657
    1657 ../sysdeps/i386/i686/multiarch(strcpy-sse2.S: No such file or directory.
    When I use backtrace I get he same error. This error is not nearly as clear and helpful as the one that you receive in your tutorial.
    I have looked around online to see how to solve the "no such file or directory" problem thinking that this might help. I tried installing libc6-dbg, installing build-essentials and setting gdb's debug-file-directory. This didn't help. Is it because I am using a different version of C? Or, is the error message difference due to a configuration in gdb. Thank you.

    • @TheOmarss
      @TheOmarss 6 ปีที่แล้ว

      Try compiling your c file with the '-g' flag maybe

    • @bobbobety
      @bobbobety 4 ปีที่แล้ว

      I get the same error, did you ever find a fix?

  • @syr0xs
    @syr0xs ปีที่แล้ว

    How can you use the run echo command with the chars needed if the programme doesn't work arround the argv argument but a gets() function

  • @dawindersingh6431
    @dawindersingh6431 4 ปีที่แล้ว +1

    How do I get my gdb to show the destination address?

  • @hawk__
    @hawk__ 2 ปีที่แล้ว

    learning in 2022 and it seems that these tutorial vidz of yours are some of the best on the whole www

  • @sharathb814
    @sharathb814 3 ปีที่แล้ว

    This worked because printf on line 34 was optimized to puts(), if it was printf printing with arguments then it could have gone into endless recursion by calling printf & exploit would have failed. The real question is how to exploit this code if line 34 was printf.?

  • @Hello-od2tj
    @Hello-od2tj 5 ปีที่แล้ว

    Hi, I was wondering if there is a way to exploit this on a 64-bit system. The problem is that we have to override 0x00007ffff7ef6070 (address to malloc'd area on heap) to 0x00000000006041d0 (address to puts@got) and strcpy stops copying before a nullbyte.

  • @0xc0ffee_
    @0xc0ffee_ 6 ปีที่แล้ว +1

    You're really good but what I don't understand is that if EIP indicates the next step to process how can you manipulate it if it should be changing every microsecond? Like while Im watching your youtube video isn't eip changing to read new data from memory and send it to the audio card? Maybe it is all process encapsulated?

    • @maciejbacal5562
      @maciejbacal5562 6 ปีที่แล้ว +4

      A CPU by nature can actually only run one program at once (i'm simplifying things here). The fact that you can run multiple programs, even though you only have a single CPU is faked by the OS rapidly switching between running different processes (threads to be exact). These days you likely have multiple cores, but that still stands; the OS has to run thousands of threads on the hand-full cores you have. When the OS switches to running another thread, it'll save the current thread's registers along with the rest of the thread state, and restore the registers and state for the thread that's going to run next, so all the registers you see him access are for the current thread only.

    • @0xc0ffee_
      @0xc0ffee_ 6 ปีที่แล้ว +1

      Wow thank you! :D Thank you so much, really. I love this channel and ctf community. Everyone is so polite. Thank you for existing and making me feel home

  • @gabrielraphaelgarciamontoy1269
    @gabrielraphaelgarciamontoy1269 4 ปีที่แล้ว

    How did it actually change where i2->name was pointing to? Shouldn't it have just changed the value inside? Or does it have to do with overwriting the meta-headers?

  • @sahilsharma-hj4gq
    @sahilsharma-hj4gq 3 ปีที่แล้ว

    why echo is not working insted of /bin/echo ?

  • @rajatumb
    @rajatumb 7 ปีที่แล้ว +2

    I love the videos posted on this channel.The content is very clearly explained in depth.This is the best material I read so far.

  • @ArchanaKumari-ql6ws
    @ArchanaKumari-ql6ws 3 ปีที่แล้ว

    Excellent !!! Amazing videos !! I am so happy to discover these videos . The best video I ever came across on internet 😎

  • @AneeshDogra
    @AneeshDogra 8 ปีที่แล้ว +2

    You're amazing! :)

  • @neerajkumar188
    @neerajkumar188 4 ปีที่แล้ว

    My gdb is not showing the memory address where segmentation fault occurred. Any idea ?
    It says -->> Program received signal SIGSEGV, Segmentation fault.
    __strcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:298
    298 ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: No such file or directory.

    • @zaoyang5514
      @zaoyang5514 ปีที่แล้ว

      I face the same issue. Do you know how to fix it?

  • @Born2KillHF
    @Born2KillHF 7 ปีที่แล้ว +1

    This video was very helpfull but there is something I can't figure out. When you replace the FFFF with the Address of Puts what happens to the code flow.. I mean why the eip is replaced with the firt 4 characters of second argument?? Thanks in advance

    • @LiveOverflow
      @LiveOverflow  7 ปีที่แล้ว +2

      You see a strcpy there. So a string copy. And the destination of the string copy is the global offset table. The global offset table contains the addresses of functions such as puts. So if you overwrite the puts function address with another address, next time you call puts, you redirect code to wherever you want it to be. More info in episode "bin 0x12"

    • @Born2KillHF
      @Born2KillHF 7 ปีที่แล้ว

      Amazing.. Very clear.. I wiil check also that video

  • @noamw3841
    @noamw3841 7 ปีที่แล้ว +1

    And that's why you must use strncpy(copy N chars from src to dest) here, never trust user input :D. Awesome series!

    • @rootabeta9015
      @rootabeta9015 5 ปีที่แล้ว

      Development rule #1 - never ever trust anything that comes from the other guy.

    • @ozjuanpa
      @ozjuanpa 4 ปีที่แล้ว

      @@rootabeta9015 Developer rule #2 - never ever trust any code that came from yourself.

    • @rikkasatrio2285
      @rikkasatrio2285 2 ปีที่แล้ว +1

      Developer rule #3 - never ever trust any code

  • @typedeaf
    @typedeaf 5 ปีที่แล้ว

    @10:00 why doesn't the malloc for the name of the i2 ever get assigned? The name of i2 was 0x0 before the strcpy().

    • @SolomonUcko
      @SolomonUcko 3 ปีที่แล้ว

      I think the breakpoint triggers in between the malloc and the assignment.

  • @alkeryn1700
    @alkeryn1700 6 ปีที่แล้ว

    Of course you aren't the best security researcher, but you are the one making the best informative videos i know of
    and i thank you for that :)

  • @niektuytel9519
    @niektuytel9519 4 ปีที่แล้ว

    to do what he is try to do by the beginning :
    run gdb
    break * after the latest strcpy
    define hook-stop
    info registers
    end
    run with the payload to detect

    • @robinhood3841
      @robinhood3841 4 ปีที่แล้ว

      When i run my payload and step forward from the break point do the hook will stop again or the hook will be in the break point boundaries

    • @niektuytel9519
      @niektuytel9519 4 ปีที่แล้ว

      @@robinhood3841 yeah that is what you need ? i not sure forget most of it already

  • @msing4
    @msing4 4 ปีที่แล้ว +1

    How much it will differ in ×64 system.?
    For heap0 challenge, I was able to get the overflow offset but the address from objdump is different from gdb .
    When I try it in gdb it crashes and from terminal it never jumps to winner.

  • @w0ttheh3ll
    @w0ttheh3ll 5 ปีที่แล้ว

    does anybody know where I can find the sources for these protostar exercises?
    the original website is down, and the bootable image that I downloaded over vulnhub doesn't contain any source code. I have searched the internet, but didn't find anything.

    • @w0ttheh3ll
      @w0ttheh3ll 5 ปีที่แล้ว

      if anybody has the same problem, I found them: github.com/hellosputnik/exploit-exercises

    • @toxicraptor4196
      @toxicraptor4196 5 ปีที่แล้ว

      exploit.education This is where it went. Seems to be the original author

    • @w0ttheh3ll
      @w0ttheh3ll 5 ปีที่แล้ว +1

      @@toxicraptor4196 thanks a lot!

    • @toxicraptor4196
      @toxicraptor4196 5 ปีที่แล้ว

      @@w0ttheh3ll No problem, good luck!

  • @Lfomod1Dubstep
    @Lfomod1Dubstep 5 ปีที่แล้ว

    great video!

  • @dawindersingh6431
    @dawindersingh6431 4 ปีที่แล้ว

    what Linux and gdb are you using

    • @areg7182
      @areg7182 3 ปีที่แล้ว +1

      doesnt matter

  • @sassynatan
    @sassynatan 5 ปีที่แล้ว

    u r wow!

  • @gideonge6188
    @gideonge6188 5 ปีที่แล้ว

    really, awesome!

  • @ChainZzDesigns
    @ChainZzDesigns 8 ปีที่แล้ว

    Hey can i contact you by email?

    • @LiveOverflow
      @LiveOverflow  8 ปีที่แล้ว +6

      of course... @gmail.com

  • @mrmrjims3865
    @mrmrjims3865 6 ปีที่แล้ว +7

    I do not understand

    • @LuXxenatorX
      @LuXxenatorX 6 ปีที่แล้ว

      same

    • @Innosos
      @Innosos 6 ปีที่แล้ว +1

      what exactly?

  • @martinp.4797
    @martinp.4797 6 ปีที่แล้ว

    at 8:49 it'es bits not bytes right ?

  • @Occcc12
    @Occcc12 8 ปีที่แล้ว

    Thanks a lot! Will there be a video on exploiting heap functions such as unlink?

    • @LiveOverflow
      @LiveOverflow  8 ปีที่แล้ว +1

      yep. there will be. We are getting there slowly :)
      My cookbook video write-up (not very well edited) already contains a more advanced heap exploit if you are interested in that.