欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c# 可疑文件掃描代碼(找到木馬)(簡(jiǎn))

 更新時(shí)間:2010年05月28日 19:47:02   作者:  
c# 可疑文件掃描代碼(找到木馬),需要的朋友可以參考下。
復(fù)制代碼 代碼如下:

using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Net;
namespace TrojanScanning
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
delegate void SetTextCallback(string text);
delegate void SetTextCallback2(bool b);
delegate void SetTextCallback3(ListViewItem item);
private string fname, code;
private Thread thr;
private string[] sArray;
private void button1_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
scanpath.Text = folderBrowserDialog1.SelectedPath;
}
}
private void startbtn_Click(object sender, EventArgs e)
{
list.Items.Clear();
fname = scanpath.Text;
thr = new Thread(new ThreadStart(scan));
thr.IsBackground = true;
thr.Start();
}
private void scan(){
FileSystemInfo s = GetFileSystemInfo(fname);
if (s != null) { scanbtn(false); ListFiles(s); scantext("掃描完成"); scanbtn(true); } else { MessageBox.Show("請(qǐng)先選擇要掃描的目錄"); }
}
public FileSystemInfo GetFileSystemInfo(string path){
if (File.Exists(path))
return new FileInfo(path);
else if (Directory.Exists(path))
return new DirectoryInfo(path);
else
return null;
}

private void ListFiles(FileSystemInfo info){
if (info.Exists){
DirectoryInfo dir = info as DirectoryInfo;
if (dir == null) return;
try{
FileSystemInfo[] files = dir.GetFileSystemInfos();
for (int i = 0; i < files.Length; i++){
FileInfo file = files[i] as FileInfo;
if (file != null && (file.Extension.ToLower() == ".asp" || file.Extension.ToLower() == ".php" || file.Extension.ToLower() == ".aspx" || file.Extension.ToLower() == ".master"))
{
scantext("掃描 " + file.FullName);
chkfile(file.FullName,file.Length);
}else{
ListFiles(files[i]);
}
}
}
catch{}
}
}
private void chkfile(string filepath,long filesize)
{
try{
if (IsFileInUse(filepath)) { System.Threading.Thread.Sleep(2000); chkfile(filepath,filesize); }
StreamReader sr = new StreamReader(filepath);
string content = sr.ReadToEnd();
sr.Close();
string chkr=chkcontent(content);
if (chkr!=""){
ListViewItem item = new ListViewItem("可疑");
item.SubItems.Add(File.GetLastAccessTime(filepath).ToString());
item.SubItems.Add(chkr);
item.SubItems.Add(filepath);
item.SubItems.Add((filesize/1024).ToString() + " kb");
addtiem(item);
}
}
catch { }
}
private string downurl(string url)
{
WebClient client = new WebClient();
string result = client.DownloadString(url);
return result;
}
private void addtiem(ListViewItem item)
{
if (this.list.InvokeRequired){
SetTextCallback3 d = new SetTextCallback3(addtiem);
this.Invoke(d, new object[] { item });
}else{
this.list.Items.Add(item);
}
}
private void scantext(string text)
{
if (this.scanstate.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(scantext);
this.Invoke(d, new object[] { text });
}else{
this.scanstate.Text=text;
}
}
private void scanbtn(bool b){
if (this.startbtn.InvokeRequired){
SetTextCallback2 d = new SetTextCallback2(scanbtn);
this.Invoke(d, new object[] { b });
}else{
this.startbtn.Enabled = b;
this.scanpath.Enabled = b;
this.button1.Enabled = b;
}
}
private string chkcontent(string content){
string returnval = "";
content = content.ToLower();
foreach (string i in sArray)
{
if (content.IndexOf(i)> -1){ returnval+=i+","; }
}
if (returnval != "") { returnval=returnval.Substring(0, returnval.Length - 1); }
return returnval;
}
bool IsFileInUse(string fileName)
{
bool inUse = true;
if (File.Exists(fileName))
{
FileStream fs = null;
try { fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None); inUse = false; }
catch { }
finally { if (fs != null)fs.Close(); }
return inUse;
}
else { return false; }
}
private void Form1_Load(object sender, EventArgs e)
{
try{
code = downurl("http://www.cqeh.com/txt/trojan.txt");
sArray = code.ToLower().Split('|');
}
catch (Exception ex)
{
MessageBox.Show("錯(cuò)誤:" + ex.Message, "無法啟動(dòng)程序!", MessageBoxButtons.OK); Application.Exit();
}
}
private void list_DoubleClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("NOTEPAD.EXE", list.SelectedItems[0].SubItems[3].Text);
}
}
}

/201005/tools/TrojanScanning.rar
哦 寫錯(cuò)了個(gè)地方 最后修改時(shí)間 GetLastAccessTime -> GetLastWriteTime

復(fù)制代碼 代碼如下:

if (file != null && (file.Extension.ToLower() == ".asp" || file.Extension.ToLower() == ".php" || file.Extension.ToLower() == ".aspx" || file.Extension.ToLower() == ".master"))
{
scantext("掃描 " + file.FullName);
chkfile(file.FullName,file.Length);


可改


復(fù)制代碼 代碼如下:

if (file != null)
{
string fe=file.Extension.ToLower();
if (fe == ".asp" || fe == ".php" || fe == ".aspx" || fe == ".master"){
  scantext("掃描 " + file.FullName);
   chkfile(file.FullName, file.Length);
  }

相關(guān)文章

  • C#操作配置文件app.config、web.config增刪改

    C#操作配置文件app.config、web.config增刪改

    這篇文章介紹了C#操作配置文件app.config、web.config增刪改的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05
  • 對(duì)int array進(jìn)行排序的實(shí)例講解

    對(duì)int array進(jìn)行排序的實(shí)例講解

    下面小編就為大家分享一篇對(duì)int array進(jìn)行排序的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2017-12-12
  • 服務(wù)器端C#實(shí)現(xiàn)的CSS解析器

    服務(wù)器端C#實(shí)現(xiàn)的CSS解析器

    服務(wù)器端C#實(shí)現(xiàn)的CSS解析器
    2008-09-09
  • C#四舍五入MidpointRounding.AwayFromZero解析

    C#四舍五入MidpointRounding.AwayFromZero解析

    這篇文章主要介紹了C#四舍五入MidpointRounding.AwayFromZero,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • C#使用ML.Net完成人工智能預(yù)測(cè)

    C#使用ML.Net完成人工智能預(yù)測(cè)

    這篇文章主要介紹了C#使用ML.Net完成人工智能預(yù)測(cè)的詳細(xì)教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-12-12
  • 淺談c#中const與readonly區(qū)別

    淺談c#中const與readonly區(qū)別

    C#引入了readonly修飾符來表示只讀域,const來表示不變常量。顧名思義對(duì)只讀域不能進(jìn)行寫操作,不變常量不能被修改,這兩者到底有什么區(qū)別呢?
    2015-06-06
  • 淺析C#數(shù)據(jù)類型轉(zhuǎn)換的幾種形式

    淺析C#數(shù)據(jù)類型轉(zhuǎn)換的幾種形式

    本篇文章是對(duì)C#中數(shù)據(jù)類型轉(zhuǎn)換的幾種形式進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-07-07
  • C# 字符串string和內(nèi)存流MemoryStream及比特?cái)?shù)組byte[]之間相互轉(zhuǎn)換

    C# 字符串string和內(nèi)存流MemoryStream及比特?cái)?shù)組byte[]之間相互轉(zhuǎn)換

    本文主要介紹字符串string和內(nèi)存流MemoryStream及比特?cái)?shù)組byte[]之間相互轉(zhuǎn)換的方法,需要的小伙伴可以參考一下。
    2016-05-05
  • C# .NET中Socket簡(jiǎn)單實(shí)用框架的使用教程

    C# .NET中Socket簡(jiǎn)單實(shí)用框架的使用教程

    最近一個(gè)項(xiàng)目因?yàn)橐玫絊ocket傳輸問題,所以決定學(xué)習(xí)一下,將自己學(xué)習(xí)的內(nèi)容總結(jié)分享出來,下面這篇文章主要給大家介紹了關(guān)于C# .NET中Socket簡(jiǎn)單實(shí)用框架使用的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下。
    2017-09-09
  • Unity中的Tilemap流程分析

    Unity中的Tilemap流程分析

    這篇文章給大家介紹Unity中的Tilemap流程分析,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2021-07-07

最新評(píng)論