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

c# 服務(wù)器上傳木馬監(jiān)控代碼(包含可疑文件)

 更新時(shí)間:2010年05月28日 20:15:23   作者:  
c# 監(jiān)控服務(wù)器上傳木馬(包含可疑文件)
復(fù)制代碼 代碼如下:

using System;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using System.Net;
namespace TrojanMonitor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
delegate void SetTextCallback(string text);
private string fname,code,emailkey,ip;
private Thread thr;
private void fsw_Changed(object sender, FileSystemEventArgs e)
{//文件改動(dòng)監(jiān)控(包含了新增)
fname = e.Name;
thr = new Thread(new ThreadStart(chkfile));
thr.IsBackground = true;
thr.Start();
}
private void fsw_Renamed(object sender, RenamedEventArgs e)
{//重命名監(jiān)控
fname = e.Name;
thr = new Thread(new ThreadStart(chkfile));
thr.IsBackground = true;
thr.Start();
}
private void chkfile(){
string filename = fname;
string content="",filepath=fsw.Path+@"\"+filename,fileName="",hzhui="";
fileName = Path.GetFileName(filename);
hzhui = Path.GetExtension(filename).ToLower();
if (hzhui == ".asp" || hzhui == ".aspx" || hzhui == ".php" || hzhui == ".jpg" || hzhui == ".gif")
{
try{
if (IsFileInUse(filename)) { System.Threading.Thread.Sleep(2000); chkfile(); }
StreamReader sr = new StreamReader(filepath);
content = sr.ReadToEnd();
sr.Close();
if (chkcontent(content)){
try{
string bakpath = Application.StartupPath + @"\TrojanMonitorbak",
logfile = bakpath + @"\log" + DateTime.Today.ToShortDateString() + ".dat",
newfile = bakpath + @"\" + DateTime.Today.ToShortDateString() + @"\",
newfilepath = newfile + DateTime.Now.Hour.ToString() + "點(diǎn)" + DateTime.Now.Minute.ToString() + "分" + DateTime.Now.Second.ToString() + "秒" + DateTime.Now.Millisecond.ToString() + "毫秒-" + fileName;
if (!Directory.Exists(bakpath)) { Directory.CreateDirectory(bakpath); }
if (!Directory.Exists(newfile)) { Directory.CreateDirectory(newfile);}
if (File.Exists(newfilepath)){File.Delete(newfilepath);}
File.Move(filepath,newfilepath);
string str = "[" + DateTime.Now + "] 發(fā)現(xiàn)可疑文件: [" + filepath + "] To [" + newfilepath + "]";
addtiem(str);
StreamWriter sw = File.AppendText(logfile);
sw.WriteLine(str + " \r\n");//寫入日志
sw.Flush();
sw.Close();
sw.Dispose();
downurl("http://www.cqeh.com/mail/?EmailSubject=發(fā)現(xiàn)可疑文件(" + ip + ")&EmailKey=" + emailkey + "&SendHtml=[" + ip + "][" + DateTime.Now + "] 發(fā)現(xiàn)可疑文件: [" + filepath + "]");//發(fā)送Email
sw = File.AppendText(filepath);
sw.WriteLine("此文件檢測(cè)到有可疑問題!請(qǐng)聯(lián)系管理員!");
sw.Flush();
sw.Close();
sw.Dispose();
}
catch (Exception ex) { addtiem(ex.ToString()); }
}
}
catch (Exception ex) { addtiem(ex.ToString()); }
}
}
private string downurl(string url){
WebClient client = new WebClient();
string result=client.DownloadString(url);
return result;
}
private void addtiem(string text){
if (this.lb.InvokeRequired){
SetTextCallback d = new SetTextCallback(addtiem);
this.Invoke(d, new object[] { text });
} else {
this.lb.Items.Add(text);
}
}
private bool chkcontent(string content)
{
bool returnval = false;
string[] sArray = code.ToLower().Split('|');
content = content.ToLower();
foreach (string i in sArray)
{
if (content.IndexOf(i)>-1){returnval=true;break;}
}
return returnval;
}
private void Form1_Load(object sender, EventArgs e){
ip = Dns.GetHostEntry(Environment.MachineName).AddressList[0].ToString();
string config = File.ReadAllText(Application.StartupPath + "http://monitorpath.ini");//獲取監(jiān)控路徑 d:\wwwroot
try{
code = downurl("http://www.cqeh.com/txt/trojan.txt");
          //獲取木馬特征庫
filepath.Text = config;
fsw.Path = config;
emailkey = downurl("http://www.cqeh.com/txt/trojanemailkey.txt");
          //獲取發(fā)送email許可key;
this.ShowInTaskbar=false;
this.Visible = false;
}
catch (Exception ex){
MessageBox.Show("錯(cuò)誤:" + ex.Message, "無法啟動(dòng)程序!", MessageBoxButtons.OK); Application.Exit();
}
finally { }
}
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 notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized){
this.ShowInTaskbar = false;
this.Visible = false;
}
}
private void 退出系統(tǒng)ToolStripMenuItem_Click_1(object sender, EventArgs e){
Application.Exit();
}
private void 顯示窗口ToolStripMenuItem_Click(object sender, EventArgs e){
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e){
this.ShowInTaskbar = false;
this.Visible = false;
e.Cancel = true;
}
}
}

源碼包下載

相關(guān)文章

  • c#讀取excel數(shù)據(jù)的兩種方法實(shí)現(xiàn)

    c#讀取excel數(shù)據(jù)的兩種方法實(shí)現(xiàn)

    這篇文章主要介紹了c#讀取excel數(shù)據(jù)的兩種方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • C#使用DllImport調(diào)用非托管的代碼的方法

    C#使用DllImport調(diào)用非托管的代碼的方法

    C#調(diào)用非托管代碼的方式主要有Com調(diào)用、DllImport方式調(diào)用、加載非托管動(dòng)態(tài)鏈接庫、直接執(zhí)行機(jī)器碼等方式?,F(xiàn)在介紹一下我自己常用的DllImport方式調(diào)用MSDN中提到的GetShortPathName方法;
    2013-03-03
  • C# ping網(wǎng)絡(luò)IP 實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)檢測(cè)的方法

    C# ping網(wǎng)絡(luò)IP 實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)檢測(cè)的方法

    下面小編就為大家?guī)硪黄狢# ping網(wǎng)絡(luò)IP 實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)檢測(cè)的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-08-08
  • C#算法之關(guān)于大牛生小牛的問題

    C#算法之關(guān)于大牛生小牛的問題

    這篇文章主要介紹了C#算法之關(guān)于大牛生小牛的問題,是C#非常典型的算法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-01-01
  • C#將PDF轉(zhuǎn)為多種圖像文件格式的方法(Png/Bmp/Emf/Tiff)

    C#將PDF轉(zhuǎn)為多種圖像文件格式的方法(Png/Bmp/Emf/Tiff)

    這里介紹將PDF轉(zhuǎn)換多種不同格式的圖像文件格式,如PNG,BMP,EMF,TIFF等,同時(shí),轉(zhuǎn)換文檔也分為轉(zhuǎn)換全部文檔和轉(zhuǎn)換部分文檔為圖片兩種情況,本文也將作進(jìn)一步介紹
    2018-02-02
  • C#利用雪花算法實(shí)現(xiàn)生成ID工具類

    C#利用雪花算法實(shí)現(xiàn)生成ID工具類

    雪花算法表示生成的ID如雪花般獨(dú)一無二,該算法源自Twitter,主要用于解決分布式系統(tǒng)的唯一Id生成問題,本文主要介紹了C#如何利用利用雪花算法實(shí)現(xiàn)生成ID,需要的可以參考下
    2023-12-12
  • VS中模仿WPF模板創(chuàng)建最簡(jiǎn)單的WPF程序

    VS中模仿WPF模板創(chuàng)建最簡(jiǎn)單的WPF程序

    這篇文章主要為大家詳細(xì)介紹了VS中模仿WPF模板創(chuàng)建最簡(jiǎn)單的WPF程序的相關(guān)資料,感興趣的小伙伴們可以參考一下
    2016-05-05
  • C#事件訪問器詳解

    C#事件訪問器詳解

    C#事件訪問器詳細(xì)解析。下面示例演示了具有訪問器的聲明.兩個(gè)訪問器都有叫做value的隱式值參數(shù),它接受實(shí)例或靜態(tài)方法的引用
    2014-01-01
  • C#數(shù)據(jù)表格(DataGridView)控件的應(yīng)用案例

    C#數(shù)據(jù)表格(DataGridView)控件的應(yīng)用案例

    這篇文章主要介紹了C#數(shù)據(jù)表格(DataGridView)控件的應(yīng)用案例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • C#創(chuàng)建及讀取DAT文件操作

    C#創(chuàng)建及讀取DAT文件操作

    這篇文章主要介紹了C#創(chuàng)建及讀取DAT文件操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-12-12

最新評(píng)論