Вопрос Помогите с кодом на python (не шарю так что не ругайте)

Регистрация
9 Май 2013
Сообщения
89
Репутация
0
Спасибо
0
Монет
0
короче надо проверить код кейлоггера рабочий ли он вообще я не пон

import json

import os

import io, pyfiglet

import PySimpleGUI as sg

import time

import sys

from tqdm import tqdm

import psutil



os.system("cls")



# Create a pop-up window

sg.theme('DarkPurple2')

layout = [[sg.Text("Do you wish to scan the system? Press OK to continue")], [sg.Button("OK"), sg.Button("Cancel")]]



window = sg.Window("Anti Keylogger Tool", layout)



# Create an event loop

while True:

event, values = window.read()

# End program if user presses Cancel or closes window & runs the program if user presses the OK button

if event == "OK":

break

else:

if event == "Cancel" or event == sg.WIN_CLOSED:

exit()



window.close()



class Process(object):

def __init__(self, proc_info):

print(proc_info)

self.pid = proc_info[1]

self.cmd = proc_info[0]



def name(self):

return '%s' % self.cmd



def procid(self):

return '%s' % self.pid



# Create the action to be taken when a keylogger is identified

def kill_logger(key_pid):

response = input("\n\nDo you want to stop this process: y/n ?")

if response.lower() == "y":

os.system('taskkill /f /im ' + key_pid)

# else:

# pass

exit()



def get_process_list():

process_list = []

for process in psutil.process_iter(['name', 'pid']):

process_list.append((process.info['name'], process.info['pid']))

return process_list



if __name__ == "__main__":

process_list = get_process_list()



def loading():

print(pyfiglet.figlet_format("Anti Keylogger Tool", justify="center", width=110))

print("Searching for KeyLoggers....")

for _ in tqdm(range(100), desc="Loading....", ascii=False, ncols=95):

time.sleep(0.1)

print("Scanning Completed.")



loading()



process_cmd = []

process_pid = []



for process in process_list:

process_cmd.append(process[0])

process_pid.append(process[1])



l1 = open("ioc.json", "r")

l1 = json.loads(l1.read())

dict1 = l1



record = 0

flag = 1



for x in process_cmd:

for y in dict1:

if x.find(y['name']) > -1:

print("KeyLogger Detected: \nThe following process may be a keylogger: \n\n\t" + process_pid[record] +

" ---> " + x)

kill_logger(x)

flag = 0

record += 1



if flag:

print("\nNo Keylogger Detected")



[



{

"name": "logkey"

},

{

"name": "keylog"

},

{

"name": "keysniff"

},

{

"name": "kisni"

},

{

"name": "lkl"

},

{

"name": "ttyrpld"

},

{

"name": "uber"

},

{

"name": "vlogger"

},

{

"name": "logview"

}



]
 
Analyzing Your Python Anti-Keylogger Code:
Functionality:
The provided Python code appears to be designed to detect and potentially terminate processes that might be keyloggers. It operates by:
Scanning Running Processes: It utilizes the psutil library to obtain a list of running processes on the system, including their names and process IDs (PIDs).
Comparing with Indicators of Compromise (IOCs): It reads a JSON file (ioc.json) containing a list of keywords (such as "logkey", "keylog") often associated with keylogger software names.
Identifying Suspicious Processes: It iterates through the running processes, checking if any process
 
Не очень понятно, зачем тебе нужен sleep в цикле
 
вот так, без комментариев, пишут только в случае "мне понятно, а остальным и понимать не надо". Если же вы "не шарите", зачем вам понадобилась такая громоздкая программа. Начинать надо с чего попроще.
 
Назад
Сверху