Menulis loker Windows dengan Python 3.x

Salam untuk pecinta python. Suatu kali saya secara tidak sengaja memasukkan jari saya ke dalam ctypes. Dan tahukah Anda, saya menyukainya. Terutama blok input keyboard dan mouse. Dan hal pertama yang terlintas di benak saya adalah, "Mengapa tidak menulis loker untuk Windows dengan python, dengan membuka kunci di USB flash drive, seperti kunci" (Jangan tanya mengapa, saya sendiri tidak tahu). Dan kemudian imajinasi saya pergi. Sekarang saya akan menuliskan apa yang harus Anda hadapi untuk menuliskannya.



Baiklah, mari kita mulai!



Langkah pertama adalah membuat bagian grafik dari loker. Kami tidak akan membuat lembaran putih yang bodoh: d

Kami akan menamainya. ... ... locker.pyw





Mengapa pyw? Ya, karena ketika Anda memulai loker, konsol akan keluar, yang dapat ditutup oleh paman jahat potensial, maka seluruh loker akan ditutup, tetapi kami tidak membutuhkannya.





import hashlib
import time
import sys
import os
from tkinter import Tk, Entry, Label
import tkinter
import pyautogui
import threading
from lofu import *
      
      



Mengimpor perpustakaan untuk locker.pyw





* hashlib kita perlu menyimpan kunci dalam bentuk hash, sehingga kemungkinan scrap lebih kecil (jika Anda tidak membutuhkannya, Anda tidak perlu mengimpornya!)







* waktu hanya untuk tidur ()







* sys untuk pintu keluar yang bagus ()







* os untuk memulai tugas sistem () bagian dari loker







* tkinter ini adalah bagian grafik kami







* pyautogui untuk memindahkan mouse ke sudut (biarkan dia memikirkan perilakunya)







* threading untuk thread kedua offset mouse (agar tidak mengganggu thread utama)







* lofu. ... ... ... Saya meletakkan beberapa fungsi, hanya di file lain dan hanya itu, saya seorang seniman, seperti yang saya lihat!





Mari kita buat fungsi menggerakkan mouse ke samping sehingga pengguna tidak punya waktu untuk mengklik di mana pun.





def mouse_trac(screen_width, screen_height):
	while True:
		pyautogui.moveTo(screen_width, screen_height)
      
      



pyautogui.moveTo(screen_width, screen_height) - ( , )





screen_width, screen_height

Tk(), ,





root = Tk()

root.attributes('-fullscreen', True)
pyautogui.FAILSAFE = False
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
      
      



root.attributes('-fullscreen', True) - .





pyautogui.FAILSAFE = False - , .





screen_width = root.winfo_screenwidth() screen_height = root.winfo_screenheight() - ,





,





x = threading.Thread(target=mouse_trac, args=(screen_width, screen_height), daemon=True)
x.start()
      
      



target=mouse_trac - ,



args=(screen_width, screen_height) -



daemon=True -





Threading









label = Label(root, text='Enter flesh drive with code!', font='Courier 15', fg='#C71585')
label.place(relx=.5, rely=.94, anchor="center")

label3 = Label(root, text='USBCODE waiting...', font='Courier 20', fg='#00BFFF')
label3.place(relx=.5, rely=.40, anchor="center")

label4 = Label(root, text='Powered by .... wait....by who?', font='Courier 15', fg='#C71585')
label4.place(relx=.1, rely=.95, anchor="center")

root.update()
      
      



label = Label(root, text='Enter flesh drive with code!', font='Courier 15', fg='#C71585') label.place(relx=.5, rely=.94, anchor="center") -



root -



text - :G



font -



fg - HTML ( https://colorscheme.ru/html-colors.html )



relx - X



rely - Y



anchor="center" -





root.update() - ( CTRL+S)





Tkinter





.

.





, . , " " , windows. windows " ". , , . ( , , ).





  • " "





  • "" ( )





  • " "





  • , ""





  • ""





  • : " " " (, 1 , )"





  • ""





  • " "





  • ! ? . . .





. input_block.pyw





from ctypes import *
import time
import sys
from lofu import *

while True:
	statusl = status_lock()
	if str(statusl) == '0':
		windll.user32.BlockInput(False)
	elif str(statusl) == '1':
		windll.user32.BlockInput(True)
      
      



lofu





def status_lock():
	filee = open(r'  ', 'r')
	return filee.read()
	filee.close()

def disable_lock():
	filee = open(r'  ', 'w')
	text = 0
	filee.write(str(text))
	filee.close()

def enable_lock():
	filee = open(r'  ', 'w')
	text = 1
	filee.write(str(text))
	filee.close()
      
      



, : " , ? JSON ! !"





json, sqlite3 . . . !





input_block.pyw >> input_block.exe

pyinstaller





pyinstall input_block.pyw --onefile
      
      



? pyinstaller?





pip install pyinstaller
      
      



" ".





" " " " .





locker.pyw





os.system('schtasks.exe /run /tn "     "')
      
      



, ,





while True:
	try:
		enable_lock()
		file = open(r'F:\key.txt','r')
		file_t = str(file.read())
		file.close()
		hash_object = hashlib.sha256(file_t.encode())
		hex_dig = hash_object.hexdigest()
		if ' -' == str(hex_dig):
			label3.configure(text='USBCODE correct. Unlocking...', fg='#00FF00', font="Courier 30")
			root.update()
			time.sleep(4)
			disable_lock()
			sys.exit()
		else:
			label3.configure(text='USBCODE incorrect. Try again!', fg='#FF0000', font="Courier 30")
			enable_lock()
			root.update()
	except SystemExit:
		sys.exit()
	except:
		time.sleep(10)
		label3.configure(text='USBCODE not found! Waiting...', fg='#FF1493', font="Courier 20")
		enable_lock()
		root.update()
      
      



, . ,





enable_lock() - lofu





disable_lock() - lofu -





time.sleep(N) -





file = open(r'F:\key.txt','r')

file_t = str(file.read())

file.close() - ,





hash_object = hashlib.sha256(file_t.encode())

hex_dig = hash_object.hexdigest() -





if ' ' == str(hex_dig): - :d

:

* - ( , , , )

* ( )

* ( - locker.pyw)





, locker.pyw.





, shell:startup, " ".





Itu saja. Ucapan selamatku! Kami baru saja membuat loker untuk Windows dengan Python 3.xc dengan pemblokiran lengkap input melalui "Penjadwal Tugas" , dengan membuka kunci melalui flash drive USB, dengan kunci hash dan antarmuka grafis!



PS Anda juga dapat memasukkan pintasan locker.pyw di bidang " Pintasan " untuk mengikat tombol untuk penguncian cepat.








All Articles