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

  • socket
    SOCKET通信,一个服务端,一个客户端的通信。(SOCKET communications, a server, a client communication.)
    2013-11-04 16:50:40下载
    积分:1
  • 9304697
    完成补码加减乘除的硬件执行过程模拟,用VC6开发()
    2017-10-29 08:40:58下载
    积分:1
  • CS
    说明:  csharp的通讯程序 很好学习资料 希望大家能获得帮助(csharp' s a good learning materials communication program hope that we can get help)
    2009-11-29 23:16:12下载
    积分:1
  • socket
    这是一个简单的socket编程例子,非常适合刚接触socket编程者。程序简单、可用、易于理解。是个很好的socket范例。(A simple socket programming examples. Suitable for beginners. Program is simple, available, easy to understand. Is a good example of socket programming.)
    2013-09-16 15:38:21下载
    积分:1
  • SQLite
    说明:  c#使用SQLite操作数据库,window桌面应用(Using SQLite to operate database)
    2020-03-31 13:40:59下载
    积分:1
  • huoqu
    获取本地计算机信息的小代码,比较简单,适合初学网络编程(a simple program of geting information from computer)
    2013-11-28 23:56:56下载
    积分:1
  • vanet
    车载自组网的发展与现状,包括网络结构 主要特点,应用举例,难点与重点,研究现状,物理层参数,MAC 层协议,帧结构,接入方式,802.11DCF,RR-ALOHA,CSMA/CA 和RR-ALOHA 的比较,路由协议 (Vehicle Development and Status of ad hoc networks, including the main features of network structure, application examples, difficulties with focused, current research, physical layer parameters, MAC layer protocol, frame structure, access methods, 802.11DCF, RR-ALOHA, CSMA/CA and RR-ALOHA comparison of routing protocols)
    2010-06-10 11:04:59下载
    积分:1
  • ssocks-0.0.14.tar
    sSocks是一个socks代理工具套装,可用来开启socks代理服务,支持socks5验证,支持IPV6和UDP,并提供反向socks代理服务,即将远程计算机作为socks代理服务端,反弹回本地,极大方便内网的渗透测试,其最新版为0.0.13(sSocks is a socks proxy tool sets, can be used to open the socks proxy services, support socks5 authentication, support for IPV6 and UDP, and to provide reverse socks proxy services, about the remote computer as socks proxy server, bounce back to the local, which greatly facilitates network penetration testing, and its latest version is 0.0.13,)
    2020-12-10 16:09:19下载
    积分: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
  • st_asio_wrapper
    它是一个c/s网络编程框架,基于对boost.asio的包装(最低在boost-1.49.0上调试过),目的是快速的构建一个c/s系统;效率高、跨平台、完全异步,当然这是从boost.asio继承而来; 自动重连,数据透明传输,自动解决分包粘包问题(这一特性表现得与udp一样); 只支持tcp和udp协议;(It is a c/s network programming framework, based on boost.asio package (minimum tried to increase the boost-1.49.0), the purpose is to build a fast c/s systems efficient, cross-platform, fully asynchronous, Of course, this is from boost.asio inherited Auto-reconnect, transparent data transmission, automatic sub-stick package to solve the problem (this feature behave the same with udp) Only supports tcp and udp protocol )
    2013-08-22 10:10:54下载
    积分:1
  • 696518资源总数
  • 105547会员总数
  • 4今日下载