=_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 218
下载积分: 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 个回复

  • wireless
    用于无线网络编程的学习,很实用,作为初学者的入门教材还是很有用的。(Wireless network programming for learning)
    2013-12-02 17:25:50下载
    积分:1
  • torbrowser
    torborwser 洋葱路由安装包,隐藏IP地址。(Torborwser onion routing package, hide IP address.)
    2016-07-19 13:16:42下载
    积分:1
  • ACE自适配通信环境中文技术文档-下篇
    说明:  ACE自适配通信环境(ADAPTIVE Communication Environment)是可以自由使用、开放源码的面向对象(OO)框架(Framework),在其中实现了许多用于并发通信软件的核心模式。ACE提供了一组丰富的可复用C++ Wrapper Facade(包装外观)和框架组件,可跨越多种平台完成通用的通信软件任务,其中包括:事件多路分离和事件处理器分派、信号处理、服务初始化、进程间通信、共享内存管理、消息路由、分布式服务动态(重)配置、并发执行和同步,等等。(Ace adaptive communication environment is a free-to-use, open-source object-oriented (OO) framework, in which many core patterns for concurrent communication software are implemented. Ace provides a rich set of reusable C + + wrappers Facade and framework components can complete common communication software tasks across multiple platforms, including event multiplexing and event processor dispatch, signal processing, service initialization, inter process communication, shared memory management, message routing, dynamic (RE) configuration of distributed services, concurrent execution and synchronization, etc.)
    2020-03-15 08:30:58下载
    积分:1
  • CSharpremoting
    仿照飞信,网络编程。像飞信一样,自由添加客户端用户。(Modeled Fetion, network programming.)
    2014-06-16 14:25:11下载
    积分:1
  • wifi
    WiFi模块的资料,有需要的请自行下载,望多多支持。(Data WiFi module, there is a need to download your own, hope a lot of support.)
    2014-07-15 14:19:47下载
    积分:1
  • C# 局域聊天室 源码下载
     
    2014-11-29下载
    积分:1
  • 图象压缩与传输
    这个源码涉及到网络编程,图像处理,数据压缩与传输。(source involved in the programming of the network, image processing, data compression and transmission.)
    2005-07-06 14:52:04下载
    积分:1
  • C# wpf wifi共享源码
    【实例简介】
    2021-06-12 00:31:20下载
    积分:1
  • NetworkAICPro
    网络爬虫工具,下载指定网址的图片并保存本地(The picture of the web crawler tool, download the specified url and save)
    2018-04-17 18:36:03下载
    积分:1
  • IPMonitor
    本程序可以用来监控本地网络,捕获一段时间内以本机为源地址或目的地址的IP数据包(不包括以广播形式发出的数据包),统计IP数据包的信息,列出本机与其他主机之间不同协议类型IP数据包的流量。(This procedure can be used to monitor the local network, capturing a period of time to this machine as the source or destination addresses of IP packets (including broadcast packets sent), statistics of IP packets, lists the machine with The flow of data packets IP between different protocol types in other hosts.)
    2020-11-02 23:29:53下载
    积分:1
  • 696518资源总数
  • 106259会员总数
  • 28今日下载