Crafting executables from raw bytes

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

КОМЕНТАРІ • 146

  • @AndrejKarpathy
    @AndrejKarpathy Місяць тому +115

    Wow! I was looking around for exactly this - i.e. echo a bunch of bytes to file, chmod u+x and execute. Super cool. The ELF format turned out to be a bit more complex than I expected and the conversion from assembly to machine code as well. I think the video is a little bit too fast, I'd 1) look at the ~1hr version of it so you can explain each part and maybe add a few more examples, and 2) add ability to sponsor your channel directly here on UA-cam to make it very frictionless. Really appreciate the ELF framework Python code too. Super cool!! 👏

    • @alexgregory5583
      @alexgregory5583 Місяць тому +24

      Holy shit, Karpathy!

    • @andrewdunbar828
      @andrewdunbar828 Місяць тому +3

      Now looking forward to seeing some magic of transformers generating/manipulating machine code file formats directly!

    • @phovos
      @phovos Місяць тому

      Noo way I'm working on the same type of things as AK! Nice1, OP. Elf quines are (skyward) **peenchy_fingers**.

    • @marcsh_dev
      @marcsh_dev Місяць тому +2

      There was a question on Usenet ages ago about what the minimum thing you had to include in a linux distribution
      It came down to the fact that `cat` could append binary things to a file. { echo is a shell command, so cat was the smallest needed executable }.
      {Edit: Though, all that said, Im not sure what the most minimal potential shell is. I presume its something that can only run executables}

    • @nananou1687
      @nananou1687 Місяць тому +2

      Next up, create Neural networks with machine code !

  • @JonathanLettvin
    @JonathanLettvin 29 днів тому

    What a pleasure finding your presentations. I've written boot sectors and master boot records. One of my favorite tricks is to cast a string as a function pointer and call it. I am fond of computed goto. Many of your stories are like my own. Were we not across an ocean, I'd raise a pint with you and we'd swap stories.

  • @kyouko5363
    @kyouko5363 Місяць тому +2

    Thank you for producing this content. There aren't enough resources that cover the lower levels in a manner that's well articulated. I'm no low level expert but everything I do know I had to learn by gathering bits and pieces from across the internet. Sometimes I'd just have to assume certain things, and there are times when those assumptions were very wrong and then my whole mental model changed, several times. I'm glad all this knowledge is being condensed and distilled in such an elegant format all in one place, I wish I'd have had this years ago. Yeah UA-cam videos covering the subject aren't new but they tend to leave relevant details out, aren't well articulated, or sometimes straight up contradict one another. This on the other hand does it perfectly. I struggle to come up with any sort of complaint.. well, there is one actually, just one: the pronunciation of Linux. You earned a sub

  • @lumotroph
    @lumotroph Місяць тому +2

    This is the type of video where I constantly have to pause in the middle of you saying something while my mind is blown by what you said one sentence before. I then go back and really go in to the mind explosion. Then continue.

  • @furycorp
    @furycorp Місяць тому +20

    Your content blows me away. I work at the totally other end of things, as high level as you get. You are a gifted educator. Thank-you!

  • @Sub0x-x40
    @Sub0x-x40 Місяць тому +8

    I pretty much watch these and take notes hoping that I can accidentally learn something via pure osmosis. Awesome content!

  • @syscall-y9i
    @syscall-y9i Місяць тому +1

    I feel at 14:03, the instruction shown should be ::
    mov 0x6000f0, esi
    Since ::
    [C7] = OPCODE for "mov" instruction
    [C6] = Mod R/M Byte => [11] [000] [110], where [110] refers to "esi" register
    [0xf00060] = Little endian for memory address 0x6000f0
    Also because ::
    Linux syscall for write() takes character buffer in "esi" register.
    Thank you for this series, Kay. Really loving it!!

  • @jhswartz
    @jhswartz Місяць тому

    This is a really interesting subject, and really well presented. I think that's the most intutitive way I've ever seen ELF structures presented and explained. I've found that commentary, macros and labels make writing machine language (for any ISA) easier, and with complex instruction sets like x86/amd64 having an interactive assembler for single shot {pseudo,}instruction to machine code is way more convenient than having to manually assemble as required. Look up "mli" (machine language interpreter), "mle" (machine language encoder), and "ias" (the poor man's interactive assembler) if you're interested in some proof of concept.

  • @varnull6120
    @varnull6120 Місяць тому

    Brilliant video, thank you so much for making this! I still struggle to get out of the comfortable abstractions of OOP but this will give me a fun way to start breaking through. I have a strange idea of fun. Can't wait to binge all your other videos too!

  • @zenkira_
    @zenkira_ Місяць тому +1

    Wow, I'll have to rewatch this video a couple of times for all of it to sink in, but this was awesome, thanks! :)
    For Q&A: Would you share a bit more of your personal journey from starting to work in tech to getting into these kinds of low level topics? Was it a necessity for your job or was it more of your personal curiosity that drove you to them?
    You mentioned in your introduction video how people get into tech and start working on kind of boring stuff, and how easy it is to just stay on that side of programming because that's what you're being paid to do, but I wonder how this was for you in your particular situation.

  • @tuckus2003
    @tuckus2003 Місяць тому +1

    Only seen one of these so far but they content and editing are terrific. Keep em coming, thanks

  • @konstantinrebrov675
    @konstantinrebrov675 Місяць тому

    I subscribed for the low level programming tutorials.

  • @lumotroph
    @lumotroph Місяць тому

    How exciting, a new 0DE5 video from only 4 hours ago! 🎉

  • @andrewdunbar828
    @andrewdunbar828 Місяць тому +1

    In the 8-bit days a lot of us used to program machine code kinda this way. The lucky ones had assemblers but many had to POKE bytes into memory. Usually from a BASIC program.
    But the OSes, file formats, and CPUs were all a lot less complex too.

  • @void_ptr32
    @void_ptr32 Місяць тому +2

    enjoying your lovely video with a broken leg😊

  • @DanielKolsi
    @DanielKolsi Місяць тому +1

    Great content and outstanding presentation skills! Not sure if you know anything about demoscene, but this kind of content is closely related to what we (well, personally not that much...) used to do in late 80s and early 90s to get out some visually stunning effects in assembly (e.g., with MC68k). Now, I might be actually referring more to your other assembly videos, not particularly to this ELF. It definitely is worth understanding how computer and microprocessor works at the very low level, even though you're writing your code at the highest level of abstraction, or even using prompt engineering as we do nowadays.
    One interesting detail to cover could be how to demonstrate visual effects with assembly by writing to and manipulating video memory and possibly some specific registers. Then this would get even closer to what we kids did or tried to do in the 80s and 90s. At that time, there were people (gurus and wizards) who just did that magic with their computers and code, but almost no one was able to pedagogically explain well what actually had to be done to achieve those cool effects! It was like secret science that one had to find out by trial and error, with some code snippets, and by reading those dull hardware reference manuals.

    • @neoeno4242
      @neoeno4242  Місяць тому +1

      You know I was actually mulling over doing a series on demoscene today! This has added to my resolve. Looking at the code can be pretty intimidating so it'd be cool to break it down a bit for people. Thanks for the comment :)

  • @dprophecyguy
    @dprophecyguy Місяць тому +5

    i really hope you keep making programming videos for a long run.

    • @robertkiestov3734
      @robertkiestov3734 Місяць тому

      its very unlikely, they tend not to last very long

  • @nolan412
    @nolan412 Місяць тому

    A lot better than the ELF "spec".

  • @FilipSalo
    @FilipSalo Місяць тому

    I really enjoy these videos. Thanks!

  • @Yggdra666
    @Yggdra666 Місяць тому

    I loved crafting the smallest possible elf's. Cool video

  • @gluonsmx
    @gluonsmx Місяць тому

    Thank god you are out here getting into the weeds of these low level mechanisms. It's really difficult to find material on these topics this easy to follow. Please keep going~ Maybe a video about linkers/linker scripts in the future??? :D

    • @neoeno4242
      @neoeno4242  Місяць тому +1

      Thanks! Such a good idea too - I got really interested in linkers when making this video so we'll definitely come back to that topic.

    • @gluonsmx
      @gluonsmx Місяць тому

      @@neoeno4242 yIPIEEE thanks a lot, i had to really dive into linker scripts once i was working on embedded systems, but i still feel i don't understand them that much lol also love the little bits of history you sprinkle throughout your videos~

  • @DanielMojoli
    @DanielMojoli Місяць тому +1

    Thorough introduction, presented so eloquently, thank you!

  • @n3m0-42
    @n3m0-42 Місяць тому

    Really enjoying these!!! Awesome work. Thanks.

  • @moormoor4281
    @moormoor4281 Місяць тому +2

    Thanking you most kindly for all you're information

  • @VoyivodaFTW1
    @VoyivodaFTW1 Місяць тому +1

    OMG!!! All your videos are so amazing!!! Thank you so much. I've learned so much from this entire series.

  • @trinitygod863
    @trinitygod863 Місяць тому +1

    I like my executables artisanally crafted

  • @w4gap
    @w4gap Місяць тому

    This was excellent, thank you so much for sharing your knowledge!! 🙂

  • @jonbikaku6133
    @jonbikaku6133 Місяць тому +1

    The sickest channel with the nicest teacher! Love your explanation, love how 'simple yet pretty complicated' the things you teach are :) Thank you!

  • @helidrones
    @helidrones Місяць тому

    I suggest using the Intel syntax as used in the table of opcodes. Albeit the AT&T syntax is more common on Linux, it is easy to forget swapping source and destination when manually translating assembly to machine code.

  • @VAVS100
    @VAVS100 Місяць тому +3

    Keep it going, Kay. 👍 (:

  • @ShimrraShai
    @ShimrraShai 22 дні тому

    5:53 - yewgh. I remember my first time doing actually _machine language_ coding was in my college CS Computer Architecture class but there we used good ole' Arduino with its AVR4 which is soo much simpler - fixed-length instruction word (though some instructions take 2 words, typically if they involve long addresses). Never did machine language code on messy ass x86. (Right now I primarily run ARM, which I believe also has a fixed length word for most instructions but I have not checked that as I've only looked at the assembler level.)

  • @zman-1x1
    @zman-1x1 Місяць тому +5

    Peak programmers creates executables in raw bytes.

  • @ashutoshtiwari5536
    @ashutoshtiwari5536 Місяць тому +26

    I recently discovered your channel and really enjoy the content you're creating. I'm looking to learn C and need a textbook that doesn’t overly simplify things-something in line with your teaching style. Any recommendations would be greatly appreciated. Thanks, Kay.

    • @lauralhardy5450
      @lauralhardy5450 Місяць тому +5

      Want to get a good grounding without the crap ? Get the K&R text and read it. That's how I learned C with the help of Borland C.

    • @turanamo
      @turanamo Місяць тому +1

      yashwant kanetkar

    • @boneappletee6416
      @boneappletee6416 Місяць тому

      My personal recommendation is C How to Program by Deitel

  • @brekreney5734
    @brekreney5734 Місяць тому

    Great video

  • @rileybaker8294
    @rileybaker8294 Місяць тому +2

    A squectangle is a rectangular squircle.

  • @pyajudeme9245
    @pyajudeme9245 Місяць тому

    Awesome!!

  • @mauroandreolini5278
    @mauroandreolini5278 День тому

    Great content! What font are you using throughout the presentation?

  • @jamesgray6804
    @jamesgray6804 Місяць тому +7

    AFAIK, the 'r' in RAX just stands for register.

    • @channelgogrvk
      @channelgogrvk Місяць тому +1

      also any register starting with R in x86_64 ISA is a general-purpose register. the one sticking point i have with this convention, and the ISA itself, is that RSP, RBP and RIP qualify as general-purpose. changing them has implicit effects for other instructions--and RIP can only be changed with a jump or call--so they're not really general-purpose in my mind.

    • @jamesgray6804
      @jamesgray6804 Місяць тому +2

      @@channelgogrvk Ridiculous that RIP is considered a general purpose register. RBP at least can be used as a general purpose register as long as you don't use it to implement stack frames. So that is something.

    • @kyouko5363
      @kyouko5363 Місяць тому +5

      @@jamesgray6804 I prefer to think of it as *really* extended (:

    • @channelgogrvk
      @channelgogrvk Місяць тому

      @@jamesgray6804 -fomit-frame-pointer 😀
      i need to clarify, because the Rxx convention isn't real, it's one i made up after thinking about it for only two seconds, because it is true that every two- and three-letter register that starts with R is general-purpose with the only exception of RIP. i feel like the names should be meaningful and indicate to the programmer what the purpose is and the R-convention (that i made up) comes very close to an exclusive set of general-purpose registers. the x86 ISA is a bit of a monstrosity anyway, so a meaningful naming convention was probably always impossible.
      as for RBP being a GPR, when i write assembly by hand i tend to always use a frame pointer--just because it's easier for me to keep track of any registers i'm spilling, or any objects i'm using directly on the stack. if you're writing in C you can just tell the compiler -fomit-frame-pointer and it would sometimes generate faster code because now you have an extra register! that was a bigger problem in ia32, though, since for position-independent code the compiler can't use EBX and benefits from the extra GPR. since we have R8-R15 on x64 now, it's a little less useful these days. i often don't see codegen using that many registers anyway (unless you have a function call with like 6 parameters, but i wouldn't write that function)

    • @emilyyyylime-
      @emilyyyylime- Місяць тому +1

      'Register' is what I figured as well.
      ​@@channelgogrvk what do you mean? where did you see anyone consider rip as a general-purpose register just because it starts with 'r'?

  • @pablote325
    @pablote325 Місяць тому

    very very nice vid, thank you very much.. high quality video.

  • @hosseinnajafi2181
    @hosseinnajafi2181 Місяць тому +1

    Ooooooh my goodness, thank you so much, i was looking for this whole my life

  • @mitchmitchell7470
    @mitchmitchell7470 Місяць тому +4

    Having done digital forensics for years, I’ve come to the conclusion after watching all these videos …. This is the woman I should marry.

    • @robertkiestov3734
      @robertkiestov3734 Місяць тому +4

      Uhh... that's not a woman...

    • @justawatchin2
      @justawatchin2 28 днів тому +1

      ​@@robertkiestov3734can you please make an effort to not make people's lives worse with your actions, when you have a choice to do so?

    • @robertkiestov3734
      @robertkiestov3734 28 днів тому

      @@justawatchin2 this man’s “life” has a coin-toss-chance of ending within the next 5 years anyway

    • @chfourchfour
      @chfourchfour 14 днів тому

      ​@@robertkiestov3734 are you maybe projecting a bit?

    • @robertkiestov3734
      @robertkiestov3734 14 днів тому

      @@chfourchfour it just went up to 70%

  • @lelars8323
    @lelars8323 Місяць тому

    I want to learn this party trick, but I'm doubtful anyone I know would be patient enough for it 😂

  • @fizipcfx
    @fizipcfx Місяць тому +44

    hell yeah awesome video, when are you going to do linux kernel from scratch

    • @reversev9778
      @reversev9778 Місяць тому +2

      Can’t wait

    • @robertkiestov3734
      @robertkiestov3734 Місяць тому +2

      he likely won't last that long

    • @raulguerreroflores1460
      @raulguerreroflores1460 Місяць тому

      Wow , this is even lower than Assembly 😊

    • @whatever990
      @whatever990 Місяць тому +3

      @@robertkiestov3734 weirdos cant stand seeing a trans woman thriving

    • @gepacc
      @gepacc Місяць тому

      @@robertkiestov3734cope

  • @goblinjedly9528
    @goblinjedly9528 Місяць тому +1

    Where was this video 5 years ago when I was writing my assembler

  • @sparthir
    @sparthir Місяць тому

    Good lord these videos are so great!

  • @ChandrashekarCN
    @ChandrashekarCN Місяць тому

    💖💖💖💖

  • @jogloran
    @jogloran Місяць тому +5

    Can we support you on Patreon or similar?

  • @fomxgorl
    @fomxgorl Місяць тому +1

    this video is cool! what id recommend doing is making this longer and splitting it into parts so you can go more in depth into how this works. for an idea of how to do that, i highly recommend looking into ben eater's hello world 6502 tutorial. also wanted to ask if there's any way you identify, such as if you're an enby or trans. i couldn't find any info on your about section of your account to make sure i get it correct. ❤️ from a transfem who's researching how computers work and going deeper and deeper into the electron level coming from higher level downward

  • @nberz692
    @nberz692 Місяць тому +1

    What do you use to create illustrations in the vid? 🙏

    • @neoeno4242
      @neoeno4242  Місяць тому +1

      This one was After Effects:)

  • @anon_y_mousse
    @anon_y_mousse Місяць тому

    I was going to ask if you saw the same video as me, but then you wrote up a conversion program in Python. The one I watched a couple of weeks ago, the guy converted hex bytes using `xxd` and `cut` to strip comments. His program, such as it was, was just a `bash` script. Still, I think it'd be a more rewarding project if you just wrote your own assembler. I keep thinking about doing that and perhaps using a completely scratch designed mnemonics set, because I really don't like some of the instruction names on x86 and both nasm and fasm have weird quirks I don't like. Probably wouldn't be a bad idea overall since I need to have an inline assembly mechanism for my compiler anyway.

  • @AyoDamilareMichael
    @AyoDamilareMichael 17 днів тому

    @1:27 please, what software did you use to make these diagrams in your videos

  • @omerfarukkara4138
    @omerfarukkara4138 Місяць тому

    I needed this. Thanks!

  • @modolief
    @modolief Місяць тому

    Thanks!

  • @kasperkuroba1633
    @kasperkuroba1633 22 дні тому

    what do you use to do the visuals?

  • @SecureCrow
    @SecureCrow Місяць тому

    This channel is awesome

  • @12crenshaw
    @12crenshaw Місяць тому

    Alright but how can I center a div?

  • @Tordek
    @Tordek Місяць тому

    Very interesting video, but why do you say Linux like that?

  • @gama3827
    @gama3827 Місяць тому

    ty

  • @Marco-sz6mq
    @Marco-sz6mq Місяць тому

    Thank you for sharing this amazing content. Which books do you suggest to learn this low level stuff?

  • @aryankathawale9269
    @aryankathawale9269 Місяць тому

    how is rhis the first video im seeing from this channel

  • @ArgumentShow
    @ArgumentShow Місяць тому

    This is amazing

  • @GillesLouisReneDeleuze
    @GillesLouisReneDeleuze Місяць тому +1

    now do linking with libc

  • @randomrfkov
    @randomrfkov Місяць тому

    Is that Griffith?

  • @eygs493
    @eygs493 Місяць тому

    Wow

  • @syntaxerorr
    @syntaxerorr Місяць тому +4

    Never heard anyone pronounce Linux like that.

  • @binux5592
    @binux5592 Місяць тому

    Can you do for c

    • @neoeno4242
      @neoeno4242  Місяць тому

      Possibly! I made something a couple videos ago which you may find useful - ua-cam.com/video/5aZiRjgSGQU/v-deo.html

  • @doezage
    @doezage 14 днів тому

    I knew

  • @Matheuzers
    @Matheuzers Місяць тому +1

    crafting raw bytes from using your fingernails to turn each transistor on and off

  • @12crenshaw
    @12crenshaw Місяць тому +1

    lAinux - thanks, I hate it xd

  • @ehippo1
    @ehippo1 Місяць тому

    Oh these seductive click baits with binary data... 😊

  • @ENI_Omega
    @ENI_Omega Місяць тому

    I get it, but really? executables from bytes, seriously?

  • @handelldesulme7900
    @handelldesulme7900 Місяць тому

    85th

  • @sukaisnaini1843
    @sukaisnaini1843 25 днів тому

    truly hardcore hehehe

  • @Notimetootime
    @Notimetootime Місяць тому

    have u considered starting a discord

  • @peterkilian9100
    @peterkilian9100 Місяць тому

    wat

  • @bernardoeulermusic
    @bernardoeulermusic Місяць тому +1

    Parece o felca

    • @Naburgondux
      @Naburgondux Місяць тому +2

      Felca depois do estrogênio

  • @turanamo
    @turanamo Місяць тому

    Sounds like reading an x86 assembly language book at high speed. Not a great idea for a topic as complex as this.

  • @F38U
    @F38U Місяць тому +1

    why does your mouth not really move?

  • @paulcosta8297
    @paulcosta8297 Місяць тому +2

    Too bad I am repulsed and disgusted by the speaker and THEIR CHOICE to appear in such a way, because I really enjoy this excellent content, but I just cant stomach it.

    • @Nesdac-k1l
      @Nesdac-k1l Місяць тому

      pluh

    • @mrpocock
      @mrpocock Місяць тому +2

      You could have chosen to not watch and not comment. Instead, apparently it matters so much to you that you watched and commented. Priorities.

    • @varnull6120
      @varnull6120 Місяць тому

      Firstly, know your fucking history, we owe a lot to queer folks in tech, including trans women. Secondly. since when do computer nerds give a shit what we look like. This isn't a fashion show.
      You're a fucking poser. Fuck off.

    • @JamesDHendrickson
      @JamesDHendrickson Місяць тому +1

      Who gives a shit what you think?

  • @last.journey
    @last.journey Місяць тому +1

    Brother you must either cut your hair or grow your beard
    It's an emergency

    • @weakness9343
      @weakness9343 28 днів тому

      Im not sure but i believe they are trans

    • @last.journey
      @last.journey 28 днів тому

      @@weakness9343 unfortunately it might be true but i don't want to think of him like this

    • @KatarinaClaes-q1p
      @KatarinaClaes-q1p 18 днів тому

      what a disgusting comment to put under such a wonderful teacher.
      go bring your hate somewhere because this is not the place.

  • @ataturkcu908
    @ataturkcu908 Місяць тому

    What the ff sound and vouce totally un match

  • @Yggdra666
    @Yggdra666 Місяць тому

    I loved crafting the smallest possible elf's. Cool video