=_maxThreads)break;System.ObjectlockThis=newSystem.Object();lock(lockThis){_currentThreads;if(_currentThreads>_maxThreads)_currentThreads=_maxThreads;stringtip=curIp;Threadt=newThread(newParameterizedThreadStart(Run));t.Start(tip);threads.Add(t);curIp=IPUtility.getLastIp(curIp,p.EndIp,1);}}else{break;}}}}protectedvoidRun(objectob){stringip=ob.ToString();SocketGetHeadh=newSocketGetHead();stringret=h.GetHtml(ip,80);if(ret.IndexOf("DVRDVS-Webs")>0){ListViewItemitem=newListViewItem();item.SubItems[0].Text=(listView1.Items.Count1).ToString();ListViewItem.ListViewSubItemlvSubItem=newListViewItem.ListViewSubItem();lvSubItem.Text=ip;item.SubItems.Add(lvSubItem);lvSubItem=newListViewItem.ListViewSubItem();lvSubItem.Text="DVRDVS-Webs";item.SubItems.Add(lvSubItem);listView1.Items.Add(item);}System.ObjectlockThis=newSystem.Object();lock(lockThis){lblCurIp.Text=ip;_currentThreads--;if(_currentThreads<0)_currentThreads=0;}}privatevoidtsmCopy_Click(objectsender,EventArgse){if(listView1.SelectedItems.Count>0){stringip=listView1.SelectedItems[0].SubItems[1].Text;Clipboard.SetText(ip);}}privatevoidtsmExport_Click(objectsender,EventArgse){StreamWriterwriter=newStreamWriter(AppDomain.CurrentDomain.BaseDirectory"\export.txt",true);foreach(ListViewItemiteminlistView1.Items){stringip=item.SubItems[1].Text;writer.WriteLine(ip);writer.Flush();}writer.Flush();writer.Close();MessageBox.Show("导出成功!");}privatevoidForm1_FormClosing(objectsender,FormClosingEventArgse){try{if(mt!=null){mt.Interrupt();mt.Abort();}foreach(Threadtinthreads){t.Interrupt();t.Abort();}if(main!=null){main.Interrupt();main.Abort();}}catch{}Thread.Sleep(5000);}privatevoidbtnStop_Click(objectsender,EventArgse){try{if(mt!=null){mt.Interrupt();mt.Abort();}foreach(Threadtinthreads){t.Interrupt();t.Abort();}if(main!=null){main.Interrupt();main.Abort();}}catch{}btnStart.Enabled=true;}}}-IMDN开发者社群-imdn.cn"> =_maxThreads)break;System.ObjectlockThis=newSystem.Object();lock(lockThis){_currentThreads;if(_currentThreads>_maxThreads)_currentThreads=_maxThreads;stringtip=curIp;Threadt=newThread(newParameterizedThreadStart(Run));t.Start(tip);threads.Add(t);curIp=IPUtility.getLastIp(curIp,p.EndIp,1);}}else{break;}}}}protectedvoidRun(objectob){stringip=ob.ToString();SocketGetHeadh=newSocketGetHead();stringret=h.GetHtml(ip,80);if(ret.IndexOf("DVRDVS-Webs")>0){ListViewItemitem=newListViewItem();item.SubItems[0].Text=(listView1.Items.Count1).ToString();ListViewItem.ListViewSubItemlvSubItem=newListViewItem.ListViewSubItem();lvSubItem.Text=ip;item.SubItems.Add(lvSubItem);lvSubItem=newListViewItem.ListViewSubItem();lvSubItem.Text="DVRDVS-Webs";item.SubItems.Add(lvSubItem);listView1.Items.Add(item);}System.ObjectlockThis=newSystem.Object();lock(lockThis){lblCurIp.Text=ip;_currentThreads--;if(_currentThreads<0)_currentThreads=0;}}privatevoidtsmCopy_Click(objectsender,EventArgse){if(listView1.SelectedItems.Count>0){stringip=listView1.SelectedItems[0].SubItems[1].Text;Clipboard.SetText(ip);}}privatevoidtsmExport_Click(objectsender,EventArgse){StreamWriterwriter=newStreamWriter(AppDomain.CurrentDomain.BaseDirectory"\export.txt",true);foreach(ListViewItemiteminlistView1.Items){stringip=item.SubItems[1].Text;writer.WriteLine(ip);writer.Flush();}writer.Flush();writer.Close();MessageBox.Show("导出成功!");}privatevoidForm1_FormClosing(objectsender,FormClosingEventArgse){try{if(mt!=null){mt.Interrupt();mt.Abort();}foreach(Threadtinthreads){t.Interrupt();t.Abort();}if(main!=null){main.Interrupt();main.Abort();}}catch{}Thread.Sleep(5000);}privatevoidbtnStop_Click(objectsender,EventArgse){try{if(mt!=null){mt.Interrupt();mt.Abort();}foreach(Threadtinthreads){t.Interrupt();t.Abort();}if(main!=null){main.Interrupt();main.Abort();}}catch{}btnStart.Enabled=true;}}} - IMDN开发者社群-imdn.cn">
登录
首页 » C# » c# 扫描IP Http Header

c# 扫描IP Http Header

于 2014-06-23 发布
0 119
下载积分: 1 下载次数: 0

代码说明:

c# 扫描IP Http Headerusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Threading;using System.IO;namespace HScan{ public partial class Form1 : Form { int _currentThreads = 0; int _maxThreads = 100; Thread main = null; Thread mt = null; List threads = new List(); public Form1() { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; } private void btnStart_Click(object sender, EventArgs e) { btnStart.Enabled = false; if (txtStart.Text.Trim() == "") { MessageBox.Show("起始IP不能为空."); return; } if (txtEnd.Text.Trim() == "") { MessageBox.Show("结束IP不能为空."); return; } int ts = Convert.ToInt32(txtThreads.Text); _maxThreads = ts; string startIp = txtStart.Text; string endIp = txtEnd.Text; TParameter tp=new TParameter(); tp.StartIp=startIp; tp.EndIp=endIp; tp.ThreadCount=ts; main = new Thread(new ParameterizedThreadStart(StartMe)); main.Start(tp); } protected void ThreadManage() { Thread c=null; while (true) { System.Object lockThis = new System.Object(); lock (lockThis) { for (int i = 0; i < threads.Count; i ) { if (threads[i] != null && !threads[i].IsAlive) { c = threads[i]; break; } } if (c != null) { threads.Remove(c); } } } } protected void StartMe(object ob) { mt = new Thread(new ThreadStart(ThreadManage)); mt.Start(); TParameter p = ob as TParameter; string curIp = p.StartIp; while (true) { for (int i = 0; i < _maxThreads; i ) { if (curIp != "") { if (_currentThreads >= _maxThreads) break; System.Object lockThis = new System.Object(); lock (lockThis) { _currentThreads ; if (_currentThreads > _maxThreads) _currentThreads = _maxThreads; string tip = curIp; Thread t = new Thread(new ParameterizedThreadStart(Run)); t.Start(tip); threads.Add(t); curIp = IPUtility.getLastIp(curIp, p.EndIp, 1); } } else { break; } } } } protected void Run(object ob) { string ip = ob.ToString(); SocketGetHead h = new SocketGetHead(); string ret = h.GetHtml(ip, 80); if (ret.IndexOf("DVRDVS-Webs") > 0) { ListViewItem item = new ListViewItem(); item.SubItems[0].Text = (listView1.Items.Count 1).ToString(); ListViewItem.ListViewSubItem lvSubItem = new ListViewItem.ListViewSubItem(); lvSubItem.Text = ip; item.SubItems.Add(lvSubItem); lvSubItem = new ListViewItem.ListViewSubItem(); lvSubItem.Text = "DVRDVS-Webs"; item.SubItems.Add(lvSubItem); listView1.Items.Add(item); } System.Object lockThis = new System.Object(); lock(lockThis) { lblCurIp.Text = ip; _currentThreads--; if (_currentThreads < 0) _currentThreads = 0; } } private void tsmCopy_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { string ip = listView1.SelectedItems[0].SubItems[1].Text; Clipboard.SetText(ip); } } private void tsmExport_Click(object sender, EventArgs e) { StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory "\export.txt",true); foreach (ListViewItem item in listView1.Items) { string ip=item.SubItems[1].Text; writer.WriteLine(ip); writer.Flush(); } writer.Flush(); writer.Close(); MessageBox.Show("导出成功!"); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { try { if (mt != null) { mt.Interrupt(); mt.Abort(); } foreach (Thread t in threads) { t.Interrupt(); t.Abort(); } if (main != null) { main.Interrupt(); main.Abort(); } } catch { } Thread.Sleep(5000); } private void btnStop_Click(object sender, EventArgs e) { try { if (mt != null) { mt.Interrupt(); mt.Abort(); } foreach (Thread t in threads) { t.Interrupt(); t.Abort(); } if (main != null) { main.Interrupt(); main.Abort(); } } catch { } btnStart.Enabled = true; } }}

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 多功能聊天
    利用VC++6.0来实现一个类似QQ的聊天程序。本程序只实现添加好友,文字聊天,文件传输和语音聊天4大功能。(VC 6.0 to achieve a similar QQ chat program. This procedure will only add to achieve good friend, text chat, file transfer, and voice chat four major functions.)
    2020-06-26 08:00:02下载
    积分:1
  • a
    说明:  直接功率控制仿真,易于理解,有功无功接偶,开关表选择正常(Direct power control simulation, easy to understand, active and reactive connection, switch table selection is normal)
    2019-08-21 08:36:47下载
    积分:1
  • filetransserver
    务器端基于select I/O模型。为防止程序界面阻塞,有一个子线程用于不断接收socket并select其中的处理。客户端只有一个线程函数,不过其利用率很高,可用于远程目录交换,请求文件大小,创建若干线程来下载文件。文件传输有上传和下载,还有对等传输,这个项目中,传输文件具体指下载。 (side is based on the Treasury select I/O model. To prevent the program interface obstruction, a son threaded socket for receiving continuous and select which of treatment. Only one client thread function, but its high efficiency, long-distance directory can be used to exchange documents requested size, creating a number of threads to download files. Upload a file transfer and downloading, and the transmission of the project, specifically referring to transfer files downloaded.)
    2007-04-19 10:07:59下载
    积分:1
  • TCP_Server
    tcp服务器端程序;tcp/ip协议;vc++编写(tcp server-side program tcp/ip protocol vc++ write)
    2011-07-14 20:33:20下载
    积分:1
  • InstantMessaging
    简单的网络聊天文件传输程序 可以 0.普通聊天(文字、图片) 1.聊天室 2.传输文件(断点续传) 3.共享屏幕 4.白板 5.视频、音频聊天(Simple network chat file transfer program can 0. General chat (text, images) a chatroom 2. Transfer files (HTTP) 3. Shared screen 4. Whiteboard 5 video and audio chat)
    2013-08-26 22:14:23下载
    积分:1
  • 波束形成定位
    波束形成定位算法MATLAB仿真程序,声源定位算法,阵列信号处理算法仿真(Beamforming localization algorithm MATLAB simulation program, sound source localization algorithm, array signal processing algorithm simulation)
    2020-11-22 22:59:35下载
    积分:1
  • kmeans_wsn
    无线传感器网络中使用kmeans算法对网络节点进行分簇(wsn kmeans)
    2020-12-07 22:19:20下载
    积分:1
  • bcast
    此程序实现了IPX/UDP/TCP三种协议的广播( This procedure has realized the IPX/UDP/TCP three kind of agreements broadcasts )
    2020-06-26 12:20:02下载
    积分:1
  • 44810407
    说明:  Desktop drawing program, for beginners to understand the vc code is a good example, performance fun and easy to learn
    2018-12-31 11:33:10下载
    积分:1
  • net
    网络编程代码,包含UDP,TCP和NET的源码,每种都保护服务器端和客户端(Network programming code, including UDP, TCP and NET source code, each protected server and client)
    2012-02-21 16:04:37下载
    积分:1
  • 696518资源总数
  • 104349会员总数
  • 32今日下载