资源简介
c# 扫描IP Http Header
using 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<Thread> threads = new List<Thread>(); 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; } } }
代码片段和文件信息
using 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() == ““)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-06-23 15:25 HScan\
目录 0 2014-06-23 15:25 HScan\HScan\
目录 0 2014-06-23 15:25 HScan\HScan\bin\
目录 0 2014-06-23 15:25 HScan\HScan\bin\Debug\
文件 434 2014-06-16 14:29 HScan\HScan\bin\Debug\export.txt
文件 19456 2014-06-16 14:00 HScan\HScan\bin\Debug\HScan.exe
文件 42496 2014-06-16 14:00 HScan\HScan\bin\Debug\HScan.pdb
文件 11592 2014-06-16 14:30 HScan\HScan\bin\Debug\HScan.vshost.exe
文件 490 2007-07-21 02:33 HScan\HScan\bin\Debug\HScan.vshost.exe.manifest
文件 6842 2014-06-16 14:06 HScan\HScan\Form1.cs
文件 12240 2014-06-16 10:27 HScan\HScan\Form1.Designer.cs
文件 6019 2014-06-16 10:27 HScan\HScan\Form1.resx
文件 3846 2014-06-15 23:10 HScan\HScan\HScan.csproj
文件 7597 2014-06-16 09:46 HScan\HScan\IPUtility.cs
目录 0 2014-06-23 15:25 HScan\HScan\obj\
目录 0 2014-06-23 15:25 HScan\HScan\obj\Debug\
文件 1578 2014-06-16 14:30 HScan\HScan\obj\Debug\HScan.csproj.FileListAbsolute.txt
文件 847 2014-06-16 13:59 HScan\HScan\obj\Debug\HScan.csproj.GenerateResource.Cache
文件 19456 2014-06-16 14:00 HScan\HScan\obj\Debug\HScan.exe
文件 180 2014-06-16 13:59 HScan\HScan\obj\Debug\HScan.Form1.resources
文件 42496 2014-06-16 14:00 HScan\HScan\obj\Debug\HScan.pdb
文件 180 2014-06-16 13:59 HScan\HScan\obj\Debug\HScan.Properties.Resources.resources
目录 0 2014-06-23 15:25 HScan\HScan\obj\Debug\Refactor\
目录 0 2014-06-23 15:25 HScan\HScan\obj\Debug\TempPE\
文件 486 2014-06-11 14:17 HScan\HScan\Program.cs
目录 0 2014-06-23 15:25 HScan\HScan\Properties\
文件 1346 2014-06-11 14:17 HScan\HScan\Properties\AssemblyInfo.cs
文件 2860 2014-06-11 14:17 HScan\HScan\Properties\Resources.Designer.cs
文件 5612 2014-06-11 14:17 HScan\HScan\Properties\Resources.resx
文件 1090 2014-06-11 14:17 HScan\HScan\Properties\Settings.Designer.cs
文件 249 2014-06-11 14:17 HScan\HScan\Properties\Settings.settings
............此处省略4个文件信息
- 上一篇:c#实现网络嗅探器
- 下一篇:C#版QQ登录助手+源代码(含在线程序升级源码)
相关资源
- httpclient source code by csharp
- 动态抓取IPC#实现
- Multipart解析类库源码(HttpMultipart)
- asp.net 网页静态化组件(shipingx-Stati
- 谷歌插件直接通过C#安装
- DotNetZip 解压缩 以及分卷压缩类
- C#批量解压缩桌面程序源码(ICSharpC
- jquery toolip
- IconPanel ToolTip
-
ExtJS 2.x 与Google Maps ja
vasc ript API - android 开关按钮 SlipButton
- C# 检查代理IP是否可用 程序源码
- http报文抓取工具源码
- 网络(IP)提取器(C# 源码)
- ICSharpCode.SharpZipLib 压缩文件(源码)
- IP地址及手机号码归属地查询
- 自动更换IP地址
- 端口扫描工具源码(PortScanner)
- 单线程IP地址扫描
- NamedPipes-master(附客户端以及服务端)
- 1252056375_ddvip_2352 C#下基于WCF的聊天程
- GDIPlusCFCode GDI+for wince
- TCP-IP C#写的TCP的client和server的程序
- Using-GDIP-on-Windows-Mobile
- STM32F0xx_StdPeriph_Lib_V1.5.0
- iPhoneUI 仿iPHONE UI C#源码
- C#调用摄像头AForge实现扫描条码解析
- C# 气泡提示BalloonTip
- C#通过HTTP协议get、post Webservice并返回
- 西门子S7-200SMART TCP/IP 通讯连接库C#
评论
共有 条评论