Python spoof code 1: "random popup + warning window + shutdown" hodgepodge

1. Code writing

1. Basic construction

Python can do many boring but " interesting" things, such as writing a spoof sequence, sending it to your friends, letting them relax without tears , such as the following line of code:

import tkinter.messagebox
while True:
    tkinter.messagebox.showwarning('windows警告','你的电脑正在被攻击!')

This is a very simple program, although it is very simple, but its lethality is not small. If the other party cannot kill the process, it will be more interesting, but we can add more codes in it, such as shutting down the computer:

#操作电脑有这两种代码:
现在关机:shutdown /s /t 0

现在注销:shutdown /l /t 0

Here's a reminder: If you don't want to end your friendship, don't log out now! ! !

After adding shutdown, we can add oil and vinegar to the tkinter window, and the final code is as follows:

import tkinter.messagebox
import os
word = '''你的电脑正在被攻击!
请不要关闭正在运行的程序,否则会丢失信息
攻击路径:C://Users/appdata/dghgha/langtgdwqi/poquue/sittings/virus.exe'''
while True:
    tkinter.messagebox.showwarning('windows警告',word)
    tkinter.messagebox.showinfo('info','goodbye!')
    os.system('shutdown /s /t 0')

Renderings:

2. Continue to expand

Only the previous codes are not enough, we can continue to add some programs

  1. Add random popup

We can realize the appearance of random pop-up windows through the tkinter window:

import tkinter
import random
def boom():
    window = tk.Tk()
    width = window.winfo_screenwidth()
    height = window.winfo_screenheight()
    a = random.randrange(0, width)
    b = random.randrange(0, height)
    window.title('嘿嘿')
    window.geometry("200x50" + "+" + str(a) + "+" + str(b))
    tk.Label(window, text='你是一个傻狍子', bg='green',
    font=('宋体', 17), width=20, height=4).pack()
    window.mainloop()
time.sleep(1)



threads = []
for i in range(25):#可以调整括号内的数字,数字代表出现窗口的数量
    t = threading.Thread(target=boom)
    threads.append(t)
    time.sleep(0)#调整出现速度
    threads[i].start()

The above text can be modified arbitrarily, the scene is very exciting

Show some effects:

2. Improve the program

On top of the previous code, we add a few lines of code, and it will become the final result:

import tkinter.messagebox
import tkinter as tk
import random
import threading
import time
import os
n=0
w='''你的电脑正在被攻击!
请不要关闭正在运行的程序,否则会丢失信息
点击‘确定’进行下一步操作'''
f='''你的电脑正在被攻击!
请不要关闭正在运行的程序,否则会丢失信息
攻击路径:C://Users/appdata/dghgha/langtgdwqi/poquue/sittings/virus.exe'''
tkinter.messagebox.askyesno('python3.7','是否要打开此程序?')
tkinter.messagebox.showinfo('提示','你一定要想好了哈')
tkinter.messagebox.askyesno('提示','最后一次警告!你真的要打开吗?')
tkinter.messagebox.showinfo('提示','我对一会要发生的事情没有丝毫歉意,我已经给过你警告了')

def boom():
    window = tk.Tk()
    width = window.winfo_screenwidth()
    height = window.winfo_screenheight()
    a = random.randrange(0, width)
    b = random.randrange(0, height)
    window.title('嘿嘿')
    window.geometry("200x50" + "+" + str(a) + "+" + str(b))
    tk.Label(window, text='嘿嘿嘿嘿嘿嘿嘿', bg='red',
    font=('宋体', 17), width=20, height=4).pack()
    window.mainloop()
time.sleep(1)
tkinter.messagebox.showwarning('warning',w)


threads = []
for i in range(25):
    t = threading.Thread(target=boom)
    threads.append(t)
    time.sleep(0)
    threads[i].start()
time.sleep(2.5)
for h in range(100):
    tkinter.messagebox.showwarning('warning',f)
    time.sleep(0.2)
    tkinter.messagebox.showinfo('提示','Goodbye')
    time.sleep(1)
    os.system('shutdown -s -t 0')

2. Packaging

method one:

The first method is simple, but easy to see through, it is recommended for simple-minded friends

The method is: change the extension to .pyw, so that the window cannot be closed once it is opened.

Method Two:

The second method is troublesome, but it is not easy to see through. It is recommended to use it on old fried dough sticks

  1. First download the package with pip install pyinstaller

  1. Put the py file in a folder, then right click on the folder, click "Run in Terminal" to enter the cmd window

  1. Type pyinstaller -F -w ./filename.py

  1. When you see.......successfully, send the exe file in the dist folder

Guess you like

Origin blog.csdn.net/xyx2023/article/details/128941439