コード例 #1
0
ファイル: CTcpSyn.cs プロジェクト: shijieru/PortScanner
        /// <summary>
        /// ��ȡ��
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void TcpSyn_PacketArrival(object sender, RawSocket.PacketArrivedEventArgs args)
        {
            if (args.Protocol == "TCP" && args.OriginationAddress == aimAddr)
            {
                //�������ݰ�
                byte[] revMsg = args.ReceiveBuffer;
                byte flag = revMsg[33];
                ushort port = BitConverter.ToUInt16(revMsg, 20);
                byte[] rport = BitConverter.GetBytes(port);
                Array.Reverse(rport);
                port = BitConverter.ToUInt16(rport, 0);
                if (flag == 0x0012)
                {
                    Updateportlist1(ui,port);
                    success = true;
                    #region ������յ�SYN|ACK������һ��RST�źŹر�����
                    IPAddress ipAddr = IPAddress.Parse(aimAddr);
                    IPEndPoint iep = new IPEndPoint(ipAddr, Convert.ToInt32(port));
                    Random rand = new Random();
                    uint ip = BitConverter.ToUInt32(ipAddr.GetAddressBytes(), 0);
                    syn rstSock = new syn(ip, port, iep, rand, Convert.ToByte(0x04));
                    rstSock.synFS();
                    #endregion
                }

                if (Scanner.finishPort == System.Math.Abs(endPort - startPort + 1) || rSocket.ErrorOccurred || rSocket.KeepRunning == false )
                {
                    UpdateTBResult(ui, "Finish!\r\n");
                    rSocket.Shutdown();
                    UpdateBtnStart(ui, true);
                }
            }
        }
コード例 #2
0
ファイル: CSynFlood.cs プロジェクト: shijieru/PortScanner
        /// <summary>
        /// ����TcySyn��
        /// </summary>
        /// <param name="aimAddr"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public void SendSynPackets()
        {
            //byte[] szSendBuf = new byte[100];
            try
            {
                //��ȡĿ��������Ϣ IP��ַ
                IPHostEntry ipAddr = Dns.GetHostByName(aimAddr);

                while (keepFlood)
                {
                    for (int port = startPort; port <= endPort; port++)
                    {
                        //ѭ��ɨ������˿�
                        IPEndPoint iep = new IPEndPoint(ipAddr.AddressList[0], port);

                        try
                        {
                            #region ����TCP�� �°�
                            Random rand = new Random();
                            uint ip = Convert.ToUInt32(ipAddr.AddressList[0].Address);
                            syn synSock = new syn(ip, Convert.ToUInt16(port), iep, rand, Convert.ToByte(0x02));
                            synSock.synFS();
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            UpdateTBResult(ui, ex.Message.ToString());
                        }
                        finally
                        {
                            //scanSock.Close();
                        }
                        //���㷢�Ͱ�������
                        packetNum++;
                    }
                }

            }
            catch
            {
            }

            threadFinish++;
            if (threadFinish == threadCount)
            {
                //�����߳�ȫ�����
                //packetNum = packetNum*threadCount;
                string ret = "SynFlood�������������� " + aimAddr + " ������ " +  packetNum.ToString() + " �����ݰ�\r\n";
                UpdateTBResult(ui, ret);
            }
        }
コード例 #3
0
ファイル: CTcpSyn.cs プロジェクト: shijieru/PortScanner
        /// <summary>
        /// ����TcySyn��
        /// </summary>
        /// <param name="aimAddr"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public void ScanPorts()
        {
            try
            {
                //��ȡĿ��������Ϣ IP��ַ
                IPAddress ipAddr = IPAddress.Parse(aimAddr);

                for (int port = startPort; port <= endPort; port++)
                {
                    //ѭ��ɨ������˿�
                    Updateloglist(ui,port);
                    Scanner.finishPort++;
                    IPEndPoint iep = new IPEndPoint(ipAddr, port);
                    try
                    {
                        #region ����TCP�� �°�
                        Random rand = new Random();
                        uint ip = BitConverter.ToUInt32(ipAddr.GetAddressBytes(), 0);
                        syn synSock = new syn(ip, Convert.ToUInt16(port), iep, rand, Convert.ToByte(0x02));
                        synSock.synFS();
                        #endregion
                    }
                    catch(Exception ex)
                    {
                        UpdateTBResult(ui, ex.Message.ToString() + "\r\n");
                    }
                    finally
                    {
                    }
                }
            }
            catch
            {
            }
        }