Port scan using ASP.NET
Step 1)Check your internet connection.
Step 2) Put following code in your ASP.Net page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="socket.aspx.cs" Inherits="socket" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Start port:-
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
End port:-
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
Enter URL:-<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Scan" Width="66px" /><br />
<br />
<asp:ListBox ID="ListBox1" runat="server" Height="129px" Width="230px"></asp:ListBox><br />
<br />
</div>
</form>
</body>
</html>
Step 3)Write below code in your code behind of ASP.Net page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Net.Sockets;
public partial class socket : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Int32 start = Convert.ToInt32(this.TextBox1.Text);
Int32 end = Convert.ToInt32(this.TextBox2.Text);
string url = Convert.ToString(this.TextBox3.Text);
IPHostEntry hostname1 = Dns.GetHostByName(url);
IPAddress[] ip1 = hostname1.AddressList;
string ip = ip1[0].ToString();
TcpClient abc = new TcpClient();
for (int i = start; i < end; i++)
{
try
{
abc.Connect(ip, i);
this.ListBox1.Items.Add("Port" + Convert.ToSingle(i) + "open");
}
catch (Exception ex)
{
this.ListBox1.Items.Add("Port" + Convert.ToString(i) + "Close");
}
}
}
}
Step 1)Check your internet connection.
Step 2) Put following code in your ASP.Net page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="socket.aspx.cs" Inherits="socket" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Start port:-
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
End port:-
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
Enter URL:-<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Scan" Width="66px" /><br />
<br />
<asp:ListBox ID="ListBox1" runat="server" Height="129px" Width="230px"></asp:ListBox><br />
<br />
</div>
</form>
</body>
</html>
Step 3)Write below code in your code behind of ASP.Net page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Net.Sockets;
public partial class socket : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Int32 start = Convert.ToInt32(this.TextBox1.Text);
Int32 end = Convert.ToInt32(this.TextBox2.Text);
string url = Convert.ToString(this.TextBox3.Text);
IPHostEntry hostname1 = Dns.GetHostByName(url);
IPAddress[] ip1 = hostname1.AddressList;
string ip = ip1[0].ToString();
TcpClient abc = new TcpClient();
for (int i = start; i < end; i++)
{
try
{
abc.Connect(ip, i);
this.ListBox1.Items.Add("Port" + Convert.ToSingle(i) + "open");
}
catch (Exception ex)
{
this.ListBox1.Items.Add("Port" + Convert.ToString(i) + "Close");
}
}
}
}
No comments:
Post a Comment