News for hackers. Stuff that matters.
Re:Embedding an EXE inside a .REG file with automatic execution by LtWorf on Thursday July 28, 2022 @07:27PM (#32271298)
The shell will NOT call the file command unless you type "file" and hit enter.

Executables are executed by the kernel. They have the x bit set and a header that the kernel reads to decide what to do with them.

Re:Embedding an EXE inside a .REG file with automatic execution by GekkePrutser on Friday July 29, 2022 @01:02AM (#32273325)
I agree that I've simplified things a bit, 'file' is rather the user facing tool that does the same kind of inspection, and of course the X bit is a prerequisite. I know this but I didn't want to write a whole elaboration on my phone :)

But my main point was that extensions aren't really a thing used at OS level to determine file type like on Windows, like the OP said.

Re:Embedding an EXE inside a .REG file with automatic execution by IX-103 on Thursday July 28, 2022 @08:19PM (#32271639)
Actually the header is read by the shell so it can call the appropriate loader. That may include running the file tool (or an internal equivalent that uses "database" of magic files).
Re:Embedding an EXE inside a .REG file with automatic execution by slabity on Thursday July 28, 2022 @09:06PM (#32271951)
That's completely incorrect. Where did you get that information from?

A regular POSIX shell will simply call the `exec` syscall on the path provided. It may set up some environment variables or parse some arguments, but it will not actually read the file. In fact you can have a file with executable permissions, but not read permissions.

The kernel determines how to execute the file based on its Magic Numbers, which are the first few bytes in certain file formats that will specify what type of file it is. It just so happens that the one for scripts are `#!`.