Finding main() in Stripped Binary - bin 0x2C

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024
  • Stripped binaries miss the symbol information of functions and variables. Debugging such a binary is a little bit more tricky, but there is a simple method to find the main() function of the program.
    =[ ❤️ 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.

Комментарии • 108

  • @allurbase
    @allurbase 4 года назад +37

    echo "set disassembly-flavor intel" >> ~/.gdbinit

    • @liquidexw
      @liquidexw 4 года назад +1

      @@kreuner11 no, these are gdb commands

    • @Njinx_
      @Njinx_ 4 года назад +3

      @@kreuner11 that's bash

    • @allurbase
      @allurbase 4 года назад

      @@kreuner11 thats to set the disassembly flavor by default to intel

    • @allurbase
      @allurbase 4 года назад

      @@kreuner11 ahh yeah not sure how to do the same in win

    • @allurbase
      @allurbase 4 года назад

      @@kreuner11 ~\.gdbinit would work too? cool

  • @rattatteb
    @rattatteb 4 года назад +29

    I'm really looking forward to every single haxember video! I love the style of these videos.

  • @asanz1665
    @asanz1665 4 года назад +3

    Really helpful dude. Reversing is becoming my hobby and this helps a lot.
    Keep it 1337!

    • @abhisohal4556
      @abhisohal4556 4 года назад

      How did you go about learning Ghidra? I've never used a decompiler before and I'm having a hard time finding beginner resources. This series will be great tho I think.

    • @asanz1665
      @asanz1665 4 года назад

      @@abhisohal4556 I don't use ghidra. I use GDB, Radare2 or Binary Ninja.
      There are a lot of beginner tutorials on the internet with a lot of binaries and walkthroughs if you don't look for specific decompilers.
      I recommend you doing the Crackme challenges with a walkthrough to follow and try to understand what you are doing and looking and of course, learn the syscalls.
      Happy reversing!

  • @lilendian3808
    @lilendian3808 3 года назад +1

    That reaction when you saw the AT&T syntax, relatable :D

  • @w3aSWglu
    @w3aSWglu 4 года назад

    Love the shorter, simpler videos. Also that hoodie is glorious, where would one acquire such a piece?

  • @Guysudai1
    @Guysudai1 4 года назад +2

    4:11 you said RIP is 0x50d but it actually points at the next line so 0x514 is RIP, great video overall though, thank you!

  • @VaradMahashabde
    @VaradMahashabde 4 года назад +9

    RUclips : LiveOverflow last uploaded 2 days ago
    LifeOverflow : I am speed

  • @omardarwish396
    @omardarwish396 4 года назад +5

    4:13 RIP will be pointing at the next instruction after 0x50d so it is 0x514. 0x514+0xe6 = 0x5fa

  • @Sonyim414
    @Sonyim414 4 года назад +2

    Teddy fresh 😎 Very interesting video! Definitely useful. Does this work for windows binaries as well?

  • @stewiegriffin6503
    @stewiegriffin6503 4 года назад +1

    once I wrote int x="cat"; and it compiled. Take that LiveOverflow

    • @w0ttheh3ll
      @w0ttheh3ll 4 года назад

      not that surprising if you know a bit of C

    • @stewiegriffin6503
      @stewiegriffin6503 4 года назад

      how string can be an int ?

    • @BaeBox
      @BaeBox 4 года назад +1

      @@stewiegriffin6503 "cat" isn't returning a string, but the address of that string in memory; if you printf that x as a hexadecimal, you will get the adress of the string "cat" in your ram

    • @stewiegriffin6503
      @stewiegriffin6503 4 года назад

      @Sascha Retzki
      Ooooh, I see. I thought that would throw an error like in C#.

    • @w0ttheh3ll
      @w0ttheh3ll 4 года назад

      @@stewiegriffin6503 in fact, if you compile for a system where int has the same width as a pointer, this will work:
      int x = "cat"; //allocate a zero-terminated string in the readonly data section, store its address in x
      printf("%s", x);
      a modern compiler will throw a lot of warnings your way, but it is valid C

  • @MephistoMods
    @MephistoMods 4 года назад +34

    I see you also like to follow Ben Eater projects ;)

    • @mrcobalt124
      @mrcobalt124 4 года назад +3

      Ohhh thats what that is lol

  • @Adowrath
    @Adowrath 4 года назад +3

    Quick question: How would you go about creating a separate symbol file? Like, in GDB, say "this address is now the function 'main', interpret it as such" and possibly export it later in the session.

    • @sebastianchmielewski6281
      @sebastianchmielewski6281 11 месяцев назад

      look into this script: github.com/taviso/loadlibrary/blob/master/genmapsym.sh

  • @amyshaw893
    @amyshaw893 4 года назад +7

    is there a way to then tell gdb "main is at offset 5fa"?

    • @newgothwhosdis
      @newgothwhosdis 4 года назад

      Probably not, GDB is a debugger. Stuff like renaming functions & variables usually falls under what a de-compiler does.

    • @ProjectPoltergeist
      @ProjectPoltergeist 4 года назад +5

      No. The "main" symbol is just a concept in the C spec. For the actual ELF binaries, the relevant thing is the "Entry" field, which just says where in the file execution should start. This is not where "main" is, but rather the __libc_start_main routine, which runs necessary initializers and basically wraps the main function.
      And functions for gdb need to come from the symbol table, otherwise it does not have concrete knowledge where functions are.
      Fun fact: You could also just declare a static integer array, call it "main" and compile that and c compilers would give you a warning, but comply and compile a binary that then just starts to execute the array.

  • @EvilSapphireR
    @EvilSapphireR 4 года назад +8

    I was breaking my head trying to understand how to figure out the start of the main function in a C compiled windows binary for the last 2 days and you come up with this video today. The coincidence is crazy lol.

  • @JO-sg7wk
    @JO-sg7wk 4 года назад

    Just wait until you find a packer that you can't figure out how to decrypt.you can use a debugger and dump the process but it's a pain re-building the import tables (im still new to rev eng/ malware analysis tho)

  • @aeonitis
    @aeonitis 2 года назад

    Any chance you can do a video on the "??" Mnemonics at the bottom of the screen @2:17?

  • @priyasrikumar5325
    @priyasrikumar5325 4 года назад +2

    Thanks so much for uploading so many interesting videos recently! It's always nice to come home and learn something new.

  • @noxiifoxi
    @noxiifoxi 4 года назад

    Btw, you don't have linked ghidra in the description.

  • @littlenewton6
    @littlenewton6 3 месяца назад

    Hoever, in IoT firmware, there is no __libc_start_main function.

  • @enocknicolas7163
    @enocknicolas7163 4 года назад +4

    how about a stripped windows executable.. they always give me a hard time locating the main func..

    • @kopuz.co.uk.
      @kopuz.co.uk. 4 года назад +1

      c/c++ on windows uses .pdb files for dbg symbols. So if youre not finding main youre either in the wrong module or the binary has been packed.

  • @MiserableDuck95
    @MiserableDuck95 4 года назад +1

    I didn't realize Beck knew so much about debugging?

  • @snom3ad
    @snom3ad 4 года назад +1

    you seem to be talking rather calmly in this new format, not sure if it was always like this but you seemed more enthusiastic when you only did voice over. not complaining, just an observation, I still love the videos!

    • @LiveOverflow
      @LiveOverflow  4 года назад +6

      I’m just experimenting. There is obviously a huge difference in scripted vs free speech. A huge advantage is the time I save, but the length of the video and conciseness is suffering. I really wanted to try out daily videos to see what would happen, and that’s the only way to do it. I also get the chance to cover topics that were too short for a regular dedicated video.
      But don’t worry. Normal liveoverflow videos are still coming and are my main focus. This haxember period is just experimenting and having some fun :)

  • @paulhermes990
    @paulhermes990 4 года назад

    me: likes the video
    me: relizes it has 0 dislikes
    me: relizes it has 69 likes
    me: oh shit.jpeg
    me: unlikes video

  • @bunkerkids1
    @bunkerkids1 4 года назад +2

    Sick hoodie. Any recommendations for where to start when learning more about hacking?

    • @mimizdani8194
      @mimizdani8194 4 года назад +1

      He made a whole playlist just about this topic :)

    • @newgothwhosdis
      @newgothwhosdis 4 года назад

      You're already there. Best starting point is LiveOverflow by far.

    • @asanz1665
      @asanz1665 4 года назад

      You are there. A hacker is always asking: How can I learn more? You will never be a full expert in all the cybersecurity field. Find what you like (SOC, Forensic, Reversing, Exploiting, Pentesting,...) and read, read and play around.
      Get some low/entry lvl courses like Network+, Security+, CEH and read and play.
      Being a hacker is not breaking computers, it is learning and learning. Welcome to the 1337 world.

  • @kooners6961
    @kooners6961 3 месяца назад

    How did you get ghidra to recognize a stripped file?

  • @stryker2k2
    @stryker2k2 4 года назад

    Whooaaa! I ran across this issue before but just thought I compiled it wrong! I switched to gcc and didn't give it a second thought.
    NOW, here I am, just cruising your content because you rock... and BAMM! I found the answer to a problem I didn't know I had!
    You rock!

  • @SM-ho5uc
    @SM-ho5uc 4 года назад

    Ubunta for noobs. Archlinux 4ever

  • @l3n693
    @l3n693 4 года назад +1

    My God! This was exactly what I needed, thanks LO :)

  • @neoXXquick
    @neoXXquick 4 года назад +1

    I am really enjoying this.. Amazing...

  • @cristiadu
    @cristiadu 4 года назад +9

    You look like a Michael Cera + Chris (from Skins UK) mashup.
    EDIT: And that's a compliment, just clarifying.

    • @soundscrispy
      @soundscrispy 4 года назад

      I keep seeing Snot from American Dad 😂

    • @ihdenemalek3485
      @ihdenemalek3485 4 года назад

      @@soundscrispy that's rude 😡

    • @soundscrispy
      @soundscrispy 4 года назад

      @@ihdenemalek3485 umm how? It's a cartoon character.

  • @jaredmeit6127
    @jaredmeit6127 4 года назад

    My GDB (v8.3.1) doesn't show the parameters or parameter names when breaking at __libc_start_main. Is that a GDB setting or plugin you used to do that?
    My output is just:
    Breakpoint 1, 0x00007ffff7dfe060 in __libc_start_main () from /usr/lib/libc.so.6

  • @jigsaw2925
    @jigsaw2925 4 года назад +1

    Awesome work dude keep it up

  • @awdawdawdawdadw5206
    @awdawdawdawdadw5206 4 года назад

    You don't need the JRE if you install the JDK because the JRE comes with the JDK

  • @alexandremarinhodesouzajun8106
    @alexandremarinhodesouzajun8106 3 года назад

    always perfect

  • @omershalev5277
    @omershalev5277 4 года назад

    Good contents. Just saying in 4:15 the rip would be 0x514 and not 0x50d

  • @AdrianDerBitschubser
    @AdrianDerBitschubser 3 года назад

    1:28 I feel you

  • @gnaurai6251
    @gnaurai6251 4 года назад

    i just use cross references in ghidra/IDA to find out the main() entrypoint, but your technique is better when the binary is diabolically small.

  • @jemesmemes9026
    @jemesmemes9026 4 года назад

    Michael Sera kind of looks like LiveOverflow

  • @aumpalosa
    @aumpalosa 4 года назад

    Hey man
    Would you be interested in making a video on how to secure your wifi? I'm a developer, but I know little about network sniffing and wifi hacking and I'm paranoid about having my home wifi broadcasted to the neighbours so I try to connect almost all devices using wires, but still need wifi for phones!
    I thought about using open-source router software such as Open-WRT but it requires knowledge on how to secure it otherwise you will be handing over even easier way to hijack it !

  • @coreyhartman4510
    @coreyhartman4510 4 года назад

    he has a 4 character password! get him! LOL

  • @ムワ-d7n
    @ムワ-d7n 4 года назад

    Do RE on mips arch pliss

  • @Marenthyu
    @Marenthyu 4 года назад

    ... then there is a breakpoint, you get the point!
    Hah.

  • @ganzsichertobi
    @ganzsichertobi 4 года назад

    I really enjoy those Videos :)
    Keep up the good work!

  • @tsunamistate
    @tsunamistate 4 года назад

    Hey LiveOverflow, there is no Gihdra download link in the description!
    For interested, it is here: ghidra-sre.org/

  • @vertical3life
    @vertical3life 4 года назад

    Great video, I love content you are putting out lately! Although I prefer old-style videos of yours, with hand-drawn black on white drawings instead of face cam.

    • @LiveOverflow
      @LiveOverflow  4 года назад

      putting out lately is an exaggeration. This is just an experiment in December and that is the 4th video. I’m just using this style to make daily videos as an experiment - like an advents calendar. Regular videos came before and will still come

  • @kooners6961
    @kooners6961 3 месяца назад

    can you share the test_stripped file?

  • @mathlover7427
    @mathlover7427 4 года назад

    these are the kind of tutorials newbs like me need

  • @Handskemager
    @Handskemager 4 года назад

    Loooovvveee that pastel coloured hoodie!

  • @PetWanties
    @PetWanties 4 года назад

    Short but very useful, thanks!

  • @deltaket6485
    @deltaket6485 4 года назад

    Love your video's. Keep it up.

  • @Pachito420
    @Pachito420 4 года назад

    gamer 😎

  • @johndunlap1143
    @johndunlap1143 4 года назад

    Now show how to find the initial entry point of something wacky and hard like a weird embedded architecture or obfuscated malware

  • @bap9394
    @bap9394 4 года назад

    Can you do video about Checkm8 exploit (bootrom) please?

  • @EvilSapphireR
    @EvilSapphireR 4 года назад

    So I tried using this idea in a MinGW gcc compiled windows binary debugged on x64dbg to find the exact address of the main function. x64dbg shows the entrypoint as 0x4012E0, and I figured out the start of the main function to be 0x40148A by calling printf at the beginning and searching for the string reference that I passed as the argument to printf, but if I check all the instructions between the address 4012E0 and 40148A, I can't find a single instruction that calls main at 40148A. Also I can't find any libgcc_start_main reference in the debugger, is this because I'm using a windows compiler or I have to download some extra symbol file or something? Any help from anyone will be super appreciated!

    • @Njinx_
      @Njinx_ 4 года назад +2

      A windows binary isn't going to have __libc_start_main as libc the C standard library for Linux.

    • @EvilSapphireR
      @EvilSapphireR 4 года назад +1

      @@Njinx_ I did some digging and the windows c library counterpart seems to be the c runtime library which is found in msvcrt.dll. looking at the x32dbg imports I CAN find the executable importing this dll, should debugging the executable with the symbols for this dll loaded from Microsoft website help in understanding where the main function in my source code starts?

    • @Njinx_
      @Njinx_ 4 года назад

      @@EvilSapphireR Hmm, I'm not much of a Windows guy but if I had to take a guess I would have to say no.

  • @bayzed
    @bayzed 4 года назад

    Are you wearing Teddy Fresh?? 🤔😜

  • @WoolieOG
    @WoolieOG 4 года назад

    i liked previous video style without cam more, it adds nothing and takes viewer focus from actual code. Also everything seems too big, partial zooms were better imo

    • @LiveOverflow
      @LiveOverflow  4 года назад

      It’s just for daily videos as part of haxember. This is only the 4th day. Regular videos are still a thing.

  • @michaelt1061
    @michaelt1061 4 года назад +1

    i live for the moment liveoverflow adds peda to gdb

  • @inspectorlunge3887
    @inspectorlunge3887 4 года назад

    4:21

  • @Saimon404
    @Saimon404 3 года назад

    Woow

  • @xc_gwpl
    @xc_gwpl 4 года назад

    Hi

  • @lior_haddad
    @lior_haddad 4 года назад

    Hi

  • @rowan2231
    @rowan2231 4 года назад

    yeet

  • @NoNameAtAll2
    @NoNameAtAll2 4 года назад

    it was so much better before you got a camera...

    • @LiveOverflow
      @LiveOverflow  4 года назад +18

      Ok boomer

    • @rattatteb
      @rattatteb 4 года назад

      He does what he tweets.

    • @rambo6glaz438
      @rambo6glaz438 4 года назад

      LiveOverflow he isn’t wrong tho, also it was much better before you started milking the December RUclips money (increased CPM and more ads)

  • @WelcomeToSex101
    @WelcomeToSex101 4 года назад

    Nice Teddy Fresh hoodie!!