Python3.xでWindowsロッカーを作成する

Python愛好家へのご挨拶。誤って指をctypesに突き刺したことがあります。そして、あなたが知っている、私はそれが好きだった。特にキーボードとマウスの入力ブロック。そして、最初に頭に浮かんだのは、「キーのようにUSBフラッシュドライブでロックを解除して、PythonでWindows用のロッカーを書いてみませんか」ということでした(理由を聞かないでください、私は自分自身を知りません)。そして、私の想像力は行きました。今、私はあなたがそれを書くために直面​​しなければならないことを書き留めます。



さあ、始めましょう!



最初のステップは、ロッカーのグラフ部分を作成することです。ばかげた白いシートは作成しません。d

名前を付けます。..。..。locker.pyw





なぜpyw?はい、ロッカーを起動するとコンソールが出てきて、悪いおじさんが閉じる可能性があるため、ロッカー全体が覆われますが、必要ありません。





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



locker.pywのライブラリをインポートしています





* hashlibキーをハッシュ形式で保存する必要があるため、スクラップの可能性が低くなります(必要がない場合は、インポートする必要はありません!)







*時間は睡眠のためだけです()







*素敵な出口出口のためのsys()







* osは、ロッカーのシステム()部分のタスクを開始します







* tkinterこれは私たちのグラフ部分です







*マウスを隅に移動するpyautogui(彼に彼の行動について考えさせます)







*マウスオフセットの2番目のスレッドのスレッド化(メインスレッドに干渉しないようにするため)







* lofu。..。..。..。いくつかの関数を別のファイルに入れました。それだけです。私はアーティストです。





ユーザーがどこかをクリックする時間がないように、マウスを横に動かす機能を作ってみましょう。





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, " ".





それで全部です。おめでとうございます!私達はちょうど作ったから入力を完全にブロックして、Pythonの3.xcにWindows用のロッカーを「タスクスケジューラ」のハッシュキーとグラフィカルなインターフェイスで、USBフラッシュドライブを通じてロック解除して、!



PS [ショートカット]フィールドにlocker.pywショートカットを入力して、キーをバインドしてすばやくロックすることもできます。








All Articles