Forerunner怎么使用

本篇内容主要讲解“Forerunner怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Forerunner怎么使用”吧!

Forerunner

Forerunner是一个快速的、轻量级的并且可扩展的网络库,它可以帮助研究人员开发一个以网络为中心的健壮的应用程序,比如说IP扫描器、端口扫描器、客户端以及服务器等等。当前版本的Forerunner,能够支持针对端口和IP地址进行同步或异步扫描,并收集关于目标设备的地理位置信息和终端信息,比如说IP地址是否在线以及设备的物理MAC地址等等。这个库是一个完全面向对象和基于事件的库,这意味着扫描数据都将包含在精心编制的“scan”对象之中,而这些对象旨在处理涵盖从结果到异常的所有数据。

工具依赖

1、.NET Framework v4.6.1

功能介绍

方法名描述使用样例
Scan扫描单个IP地址并收集信息Scan("192.168.1.1");
ScanRange扫描IP地址范围并收集信息ScanRange("192.168.1.1", "192.168.1.255")
ScanList扫描IP地址列表并收集信息ScanList("192.168.1.1, 192.168.1.2, 192.168.1.3")
PortKnock扫描单个IP地址的所有端口PortKnock("192.168.1.1");
PortKnockRange扫描IP地址范围内的所有端口PortKnockRange("192.168.1.1", "192.168.1.255");
PortKnockList扫描IP地址列表中的所有端口PortKnockList("192.198.1.1, 192.168.1.2, 192.168.1.3");
IsHostAlive每多少毫秒扫描一台主机N次IsHostAlive("192.168.1.1", 5, 1000);
GetAveragePingResponse获取目标主机的平均ping响应GetAveragePingResponse("192.168.1.1", 5, 1000);
IsPortOpen通过TCP&UDP来ping单个端口IsPortOpen("192.168.1.1", 45000, new TimeSpan(1000), false);

工具下载

广大研究人员可以使用下列命令将项目源码克隆至本地:

git clone https://github.com/jasondrawdy/Forerunner.git

工具使用样例

IP扫描

在网络安全研究过程中,扫描一个网络是一种非常常见的任务了,因此我们应该通过尽可能简单的方法来实现这个目标,以方便未来的安全研究人员去做同样的事情。Forerunner是一个完全面向对象的功能库,因此非常适合所谓“即插即用”的情况。其中,用于IP扫描的对象被称之为IPScanObject,这个对象包含了下列几种参数属性:

Address (String)

IP (IPAddress)

Ping (Long)

Hostname (String)

MAC (String)

isOnline (Bool)

Errors (Exception)

有了对象的概念之后,我们可以尝试创建一个新的对象,并使用它来执行一次扫描任务。最简单的方法就是先创建一个新的Scanner对象,并通过它来访问我们的扫描方法。接下来,创建一个IPScanObject对象,并使用目标IP地址来设置其Scan方法。

同步扫描:

using System;using Forerunner; // Remember to import our library.namespace Example{    class Program    {        static void Main(string[] args)        {            // Our IP we would like to scan.            string ip = "192.168.1.1";            // Create a new scanner object.            Scanner s = new Scanner();            // Create a new scan object and perform a scan.            IPScanObject result = s.Scan(ip);            // Output that we have finished the scan.            if (result.Errors != null)                Console.WriteLine("[x] An error occurred during the scan.");            else                Console.WriteLine("[+] " + ip + " has been successfully scanned!")            // Allow the user to exit at any time.            Console.Read();        }    }}

另一种方法是创建Scanner对象并订阅ScanAsyncProgressChangedScanAsyncComplete之类的事件处理程序,这样我可以完全控制异步方法,我可以控制它们影响应用程序的进度状态等等。

异步扫描:

using System;using System.Threading.Tasks;using Forerunner; // Remember to import our library.namespace Example{    class Program    {        static void Main(string[] args)        {            // Our IP we would like to scan.            string ip = "192.168.1.1";            // Setup our scanner object.            Scanner s = new Scanner();            s.ScanAsyncProgressChanged += new ScanAsyncProgressChangedHandler(ScanAsyncProgressChanged);            s.ScanAsyncComplete += new ScanAsyncCompleteHandler(ScanAsyncComplete);            // Start a new scan task with our ip.            TaskFactory task = new TaskFactory();            task.StartNew(() => s.ScanAsync(ip));            // Allow the user to exit at any time.            Console.Read();        }        static void ScanAsyncProgressChanged(object sender, ScanAsyncProgressChangedEventArgs e)        {            // Do something here with e.Progress, or you could leave this event            // unsubscribed so you wouldn't have to do anything.        }        static void ScanAsyncComplete(object sender, ScanAsyncCompleteEventArgs e)        {           // Do something with the IPScanObject aka e.Result.            if (e.Result.Errors != null)                Console.WriteLine("[x] An error occurred during the scan.");            else                Console.WriteLine("[+] " + e.Result.IP + " has been successfully scanned!")        }    }}

端口扫描

跟IP地址扫描一样,端口扫描可以通过一组预定义的端口来尝试进行端口连接,并检查目标端口是否真正开启。它将尝试通过与每个端口进行连接并发送数据包来进行端口探测。这个功能同样是通过一个自定义对象来实现的,即"Port Knock Scan Object",简称为“PKScanObject”。 PKScanObject对象实际上包含一个PKServiceObjects列表,该列表将保存返回的全部端口数据,该服务对象包含下列参数属性:

IP (String)

Port (Int)

Protocol (PortType)

Status (Bool)

首先,我们需要创建一个Scanner对象,然后创建一个新的PKScanObject对象并使用目标IP来设置PortKnock方法,然后工具将显示扫描结果给我们。

同步扫描:

using System;using Forerunner; // Remember to import our library.namespace Example{    class Program    {        static void Main(string[] args)        {            // Our IP we would like to scan.            string ip = "192.168.1.1";            // Create a new scanner object.            Scanner s = new Scanner();            // Create a new scan object and perform a scan.            PKScanObject result = s.PortKnock(ip);            // Output that we have finished the scan.            if (result.Errors != null)                Console.WriteLine("[x] An error occurred during the scan.");            else                Console.WriteLine("[+] " + ip + " has been successfully scanned!")           // Display our results.           foreach (PKServiceObject port in result.Services)           {                Console.WriteLine("[+] IP: " + port.IP + " | " +                                  "Port: " + port.Port.ToString() + " | " +                                  "Protocol: " + port.Protocol.ToString() + " | " +                                  "Status: " + port.Status.ToString());           }           // Allow the user to exit at any time.           Console.Read();        }    }}

异步扫描:

using System;using System.Threading.Tasks;using Forerunner; // Remember to import our library.namespace Example{    class Program    {        static void Main(string[] args)        {            // Our IP we would like to scan.            string ip = "192.168.1.1";            // Setup our scanner object.            Scanner s = new Scanner();            s.PortKnockAsyncProgressChanged += new PortKnockAsyncProgressChangedHandler(PortKnockAsyncProgressChanged);            s.PortKnockAsyncComplete += new PortKnockAsyncCompleteHandler(PortKnockAsyncComplete);            // Start a new scan task with our ip.            TaskFactory task = new TaskFactory();            task.StartNew(() => s.PortKnockAsync(ip));            // Allow the user to exit at any time.            Console.Read();        }        static void PortKnockAsyncProgressChanged(object sender, PortKnockAsyncProgressChangedEventArgs e)        {            // Display our progress so we know the ETA.            if (e.Progress == 99)            {                Console.Write(e.Progress.ToString() + "%...");                Console.WriteLine("100%!");            }            else                Console.Write(e.Progress.ToString() + "%...");        }        static void PortKnockAsyncComplete(object sender, PortKnockAsyncCompleteEventArgs e)        {            // Tell the user that the port knock was complete.            Console.WriteLine("[+] Port Knock Complete!");            // Check if we resolved an error.            if (e.Result == null)                Console.WriteLine("[X] The port knock did not return any data!");            else            {                // Check if we have any ports recorded.                if (e.Result.Services.Count == 0)                    Console.WriteLine("[!] No ports were open during the knock.");                else                {                    // Display our ports and their details.                    foreach (PKServiceObject port in e.Result.Services)                    {                         Console.WriteLine("[+] IP: " + port.IP + " | " +                                          "Port: " + port.Port.ToString() + " | " +                                          "Protocol: " + port.Protocol.ToString() + " | " +                                          "Status: " + port.Status.ToString());                    }                }            }        }    }}

许可证协议

Forerunner项目的开发和发布遵循MIT开源许可证协议。

到此,相信大家对“Forerunner怎么使用”有了更深的了解,不妨来实际操作一番吧!这里是蜗牛博客网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接