黑客工具之端口扫描器

27 篇文章 0 订阅
17 篇文章 0 订阅
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.Net;
using System.Net.Sockets;
using System.Threading;
using System.Net.NetworkInformation;
namespace eye
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }








  //接收传入参数一作为要扫描的主机   
  static string host;
 static int port;

 int four2,four;
 string one, two, three;




        private void Form1_Load(object sender, EventArgs e)
 {
     this.ShowInTaskbar = true;
     this.Text = "Df's eye!";
     this.Location = new Point(100,100);
     button2.Text = "Exit";
     label1.Text = " 到 ";
     label2.Text = "";
     textBox1.Text = "存活主机\r\n";
     textBox5.Text = "端口状态\r\n";
     button1.Text = "Hunt";
     textBox4.Text = "23";

     timer1.Interval = 1500;
     string hostname = System.Net.Dns.GetHostName();
     System.Net.IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(hostname);
     string ip = ipEntry.AddressList[1].ToString();
     string ipo = ip.Split('.')[0].Trim();
     string iptw = ip.Split('.')[1].Trim();
     string ipth = ip.Split('.')[2].Trim();
     textBox2.Text = ipo + "." + iptw + "." + ipth + "." + "1";
     textBox3.Text = ipo + "." + iptw + "." + ipth + "." + "255";
     label2.Text =ip;

}


        public void x()
        {



                    host = one + "." + two + "." + three + "." + four;

                    Ping p = new Ping();
                    PingReply r = p.Send(host);
                    if (r.Status == IPStatus.Success)
                    {
                        textBox1.Text += host + " is connecting\r\n";
                        scan();
                    }
                    else
                    {
                        textBox1.Text += host + " can't connect\r\n";

                    }
                    four++;



        }


        ///////////////////////////
        public void scan()
        {
            CheckForIllegalCrossThreadCalls = false;



                //我们直接使用比较高级的TcpClient类   
                TcpClient tc = new TcpClient();
                //设置超时时间   
                tc.SendTimeout = tc.ReceiveTimeout = 1000;
                try
                {
                    //尝试连接   
                    tc.Connect(host, port);
                    if (tc.Connected)
                    {
                        //如果连接上,证明此端口为开放状态  
                        textBox5.Text +=host+":" + port.ToString().PadRight(6)+" is open";
                        // Form1.openedPorts.Add(port);
                    }
                }
                catch
                {
                    //容错处理   
                    textBox5.Text += host+":" + port.ToString().PadRight(6) + " is Close";
                }
                finally
                {
                    tc.Close();
                    tc = null;
                    textBox5.Text += "\r\n";


                }






        }
        bool t = true; bool xx = true;
        private void button1_Click(object sender, EventArgs e)
        {
            if (t)
            {
                one = textBox2.Text.Split('.')[0].Trim();
                two = textBox2.Text.Split('.')[1].Trim();
                three = textBox2.Text.Split('.')[2].Trim();
                four = Convert.ToInt32(textBox2.Text.Split('.')[3].Trim());
                four2 = Convert.ToInt32(textBox3.Text.Split('.')[3].Trim());
                port = Convert.ToInt32(textBox4.Text);
                timer1.Start();
                button1.Text = "...";
                t = false;
            }
            else {
                timer1.Stop();
                button1.Text = "Hunt";
                t = true;
                four = 1;
                textBox1.Text = "存活主机\r\n";
                textBox5.Text = "端口状态\r\n";
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {

            x();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (xx)
            {
                timer1.Stop();
                xx = false;
            }
            else
            {
                timer1.Start();
                xx = true;
            }
        }
        private void label3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("3389:xp远程登录\n135:rpc漏洞","各端口的利用:");
        }











    }


}
  • 刚毕业的时候觉得黑客很酷,于是自己写了个扫描器
  • 那时想做黑客
  • 后来慢慢的就真的成黑客了
  • 结果是招来一大堆人找我盗号的
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值