What is the difference between just setting a command on Linux and entering the same command after executing '/ bin / sh'?

I understand that /bin/shthis is a shell that executes the commands that I typed. But the fact is that although I do not type /bin/sh, I can enter any command I want.

I heard that when a cracker wants to attack someone, he or she usually wants to get it /bin/sh. In particular, I heard /bin/shmentioned in combination with buffer overflows and remote shells, and that crackers can use programs using malicious code executed with / bin / sh, for example exec ("bin/sh", ~something, something);.

I wonder why he or she is trying to “receive” /bin/shor execute it.

I am also not sure of the difference between simply writing a command and entering the same command after execution /bin/sh, as shown in this interaction with the terminal:

johndoe@localhost $ pwd
/home/johndoe
johndoe@localhost $ /bin/sh
sh-3.2 $ pwd
/home/johndoe
sh-3.2 $ whoami
johndoe
sh-3.2 $ 

Although I am not executing /bin/sh, I can still enter any command I want to enter. So why and when will crackers want to use /bin/sh?

+4
source share
3 answers

. /bin/bash /bin/sh ( ) /bin/csh, . /bin/sh, : . , /bin/sh, , . - , , /bin/sh - . , , /bin/sh /bin/bash /bin/csh: , . setuid , root . ( , eject, root, , , , root.)

+2

-, /bin/sh ( , , ):

, . - , . , , , /bin/bash.

, , , fork exec. , /bin/sh, . . . . , , .

, , . , . , . . , . . : - , .

, :

- , exec ( ). . , - . , , . , , - , . -, , . - , . (t23) ( , , exec s). .. , - Google , -. . - - exec (, /bin/sh ) , , . root: . , . .

+2

/bin/sh, , , /bin/sh. , .

-1

Source: https://habr.com/ru/post/1584305/


All Articles