Creando un portscanner
Página 1 de 1.
Creando un portscanner
- Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Net.Sockets;
using System.Windows.Forms;
namespace PortScanner
{
public partial class frmMain : Form
{
protected int StartPort;
protected int EndPort;
public frmMain()
{
InitializeComponent();
}
private void btnScan_Click(object sender, EventArgs e)
{
StartPort = Convert.ToInt32(numStart.Value);
EndPort = Convert.ToInt32(numEnd.Value);
prgScanning.Value = 0;
prgScanning.Maximum = EndPort - StartPort + 1;
Cursor.Current = Cursors.WaitCursor;
for (int CurrPort = StartPort; CurrPort <= EndPort; CurrPort++)
{
TcpClient TcpScan = new TcpClient();
try
{
TcpScan.Connect(txtIP.Text, CurrPort);
txtLog.AppendText("Port " + CurrPort + " open\r\n");
}
catch
{
txtLog.AppendText("Port " + CurrPort + " closed\r\n");
}
prgScanning.PerformStep();
}
Cursor.Current = Cursors.Arrow;
}
private void frmMain_Load(object sender, EventArgs e)
{
}
private void txtIP_TextChanged(object sender, EventArgs e)
{
}
private void numStart_ValueChanged(object sender, EventArgs e)
{
}
private void numEnd_ValueChanged(object sender, EventArgs e)
{
}
}
}
Página 1 de 1.
Permisos de este foro:
No puedes responder a temas en este foro.
|
|