好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 zbby 于 2023-7-27 16:50 编辑
powershell执行命令
数据包id: 3 8 9
下发数据: 命令文本
返回数据: 执行结果
写文件
数据包id: 4
下发数据: 文件名 文件数据
返回数据: 执行结果(成功写出返回“OK”)
读文件
数据包id: 5
下发数据: 文件名
返回数据: 文件数据
powershell执行命令2
数据包id: 10 12
下发数据: 命令文本
返回数据: 命令执行数据
ping(似乎是检查连接用的)
数据包id: 11
下发数据: 无
返回数据: 未知
山寨远控客户端(用于获取/解密攻击指令):
import time
import random
import socket
init = False
ip_port = ('47.100.65.182',8081)
sk = socket.socket()
sk.connect(ip_port)
def getdesc(cmdid):
if cmdid == 3 or cmdid == 8 or cmdid == 9:
return "powershell执行命令"
if cmdid == 4:
return "写文件"
if cmdid == 5:
return "读文件"
if cmdid == 10 or cmdid == 12:
return "powershell执行命令2"
if cmdid == 11:
return "ping检查连接"
return "unknown"
def xor(data):
return bytes([a ^ 0x42 for a in data])
def xor_rnd(rnd):
result = bytearray()
for x, y in zip(rnd, b'\x69\xA4'):
result.append(x ^ y)
return bytes(result)
while True:
try:
if not init:
timestamp = int(time.time())
print("timestamp:", timestamp)
rnd = random.randint(0, 65535).to_bytes(2,byteorder='little', signed=False)
sk.sendall(rnd + xor_rnd(rnd)) # [随机数(2bytes)] + [之前的随机数 ^ 0x69A4 (2bytes)]
sk.sendall(xor(b'\x02\x00\x00\x00\x04' + timestamp.to_bytes(4,byteorder='little', signed=False))) # [0x02000000 (数据包id 4bytes) + 0x04 (长度 1bytes) + 时间戳(4bytes)]
init = True
print("--------------------------------------------------")
header_bytes = sk.recv(5)
header = xor(header_bytes)
cmdid = int.from_bytes(header[:4], 'little', signed=False)
size = int.from_bytes(header[4:5], 'little', signed=False)
print("cmdid:", cmdid)
print("desc:" , getdesc(cmdid))
print("size:", size)
payload_bytes = b''
while len(payload_bytes) < size:
payload_bytes += sk.recv(size)
payload = xor(payload_bytes)
print("payload:", payload)
sk.sendall(xor(b'\x01\x00\x00\x00\x0B\x00\x00\x00\x07\x73\x75\x63\x63\x65\x73\x73')) # 数据包id(4bytes) + 长度 (1bytes) + 数据(?bytes)
except:
print("connection was lost.")
break
|
|