1
$\begingroup$

Apologies for the strange title, this is one of those questions I can't find through a Google search just because I don't even know what I'm supposed to be searching for.

As I understand it, programs are ultimately compiled into binary which is then run by a computer.

So say, for example, you have a simple program which takes a user input and then executes some code -- when compiled into binary, there must be some sort of 'signature' that signifies the end of the user input so the computer knows where it ends. Say just for the sake of this example it's something simple like 0110. So after the user has input his data it might look like ...1100 0101 0110 1010 1001..., where the 0110 signifies the end of the string so the computer knows it's ended and that the rest is code from the program.

But what if the user input contained the same signature? Say the user input, after conversion to binary, came out to be ...0110 0010 0110 1010 1001... What is there to prevent the user from 'tricking' the computer into thinking the user input has ended, and then running malicious code now that the PC believes it's part of the program and not the string?

Hope this question makes any sort of sense, I'd be incredibly grateful if someone could explain this to me. It seems so trivial but it's been bugging me that I can't find an answer for it.

$\endgroup$
  • 1
    $\begingroup$ Yes, the answer is indeed trivial. A string will be either be delimited by some special character or by some escaping mechanism or be specified by its length. Have you ever used C? Have you ever seen network packets? $\endgroup$ – Apass.Jack Jul 29 at 23:53
0
$\begingroup$

Both programs in binary form and binary user data are usually stored in files, and normally the filesystem records the length of all its files separately. So, the operating system always knows the end of the binary string, which is supposed to be loaded and executed as a separate process. Please see this question and its answers for more information.

Could an attacker use a binary input with malicious code, added in the end of input string, to modify normal program behavior? Yes, and this method of attacking is called buffer overflow. Fortunately, modern programs normally don't use input functions, which can lead to the buffer overflow.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.