示例#1
0
 void device_OnCaptureStopped(object sender, CaptureStoppedEventStatus status)
 {
     if (status != CaptureStoppedEventStatus.CompletedWithoutError)
     {
         TAMessageBox = new TAMessageBox("Error", "Error stopping capture", false, true);
         TAMessageBox.Show();
     }
 }
示例#2
0
        private void clearLogsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (File.Exists(@logDirectory + "\\" + logFile))
            {
                File.Delete(@logDirectory + "\\" + logFile);

                TAMessageBox = new TAMessageBox("Log's", "Log's cleared", false, false);
                TAMessageBox.Show();
            }
            else
            {
                TAMessageBox = new TAMessageBox("Error", "File not Found", false, true);
                TAMessageBox.Show();
            }
        }
示例#3
0
 private void openLogsFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         TAMessageBox        = new TAMessageBox("Log's", File.ReadAllText(logDirectory + "\\" + logFile), false, false);
         TAMessageBox.Height = 540;
         TAMessageBox.Width  = 490;
         TAMessageBox.Show();
     }
     catch (FileNotFoundException)
     {
         TAMessageBox = new TAMessageBox("Error", "File not Found", false, true);
         TAMessageBox.Show();
     }
 }
        private void buttonSend_Click(object sender, EventArgs e)
        {
            try
            {
                if (LoopSendingCBox.SelectedIndex == -1)
                {
                    TAMessageBox = new TAMessageBox("Traffic Analyzer", "Select send mode", false, false);
                    TAMessageBox.Show();
                }
                else if (LoopSendingCBox.SelectedIndex == 0)
                {
                    captureForm.manipulatedOneSend = false;

                    if (ReadTimeoutBox.SelectedIndex == -1)
                    {
                        captureForm.readTimeout = 1000;
                    }
                    else
                    {
                        captureForm.readTimeout = Convert.ToInt32(LoopSendingCBox.SelectedValue);
                    }
                }
                else if (LoopSendingCBox.SelectedIndex == 1)
                {
                    captureForm.manipulatedOneSend = true;
                }

                // eth packet
                try
                {
                    sourcehw = PhysicalAddress.Parse(textBoxSourceHwAddress.Text.
                                                     Trim(new char[] { ' ' }).Replace(':', '-'));
                    destinationhw = PhysicalAddress.Parse(textBoxDestinationHwAddress.Text.
                                                          Trim(new char[] { ' ' }).Replace(':', '-'));
                }
                catch (FormatException ex)
                {
                    TAMessageBox = new TAMessageBox("Error ETH packet", ex.ToString(), false, true);
                    TAMessageBox.Show();
                    return;
                }
                // ip packet
                try
                {
                    sourceip      = IPAddress.Parse(textBoxSourceAddress.Text.Trim(new char[] { ' ' }));
                    destinationip = IPAddress.Parse(textBoxDestinationAddress.Text.Trim(new char[] { ' ' }));
                    timeToLive    = Convert.ToInt32(textBoxTimeToLive.Text.Trim(new char[] { ' ' }));
                }
                catch (FormatException ex)
                {
                    //TAMessageBox = new TAMessageBox("Error IP packet", ex.ToString(), false, true);
                    //TAMessageBox.Show();
                    //return;
                }
                catch (Exception)
                {
                }
                // tcp packet
                try
                {
                    sourceTcpPort        = Convert.ToUInt16(textBoxTcpSourcePort.Text.Trim(new char[] { ' ' }));
                    destinationTcpPort   = Convert.ToUInt16(textBoxTcpDestinationPort.Text.Trim(new char[] { ' ' }));
                    windowSize           = Convert.ToUInt16(textBoxWindowSize.Text.Trim(new char[] { ' ' }));
                    acknowledgmentNumber = Convert.ToUInt32(textBoxAcknowlegmentNumber.Text.Trim(new char[] { ' ' }));
                    sequence_number      = Convert.ToUInt32(textBoxSequenceNumber.Text.Trim(new char[] { ' ' }));
                    tcpDataPayload       = StringToByteArray(textBoxTcpDataPayload.Text.Trim(new char[] { ' ' }));
                }
                catch (FormatException ex)
                {
                    TAMessageBox = new TAMessageBox("Error TCP packet", ex.ToString(), false, true);
                    TAMessageBox.Show();
                    return;
                }
                // udp packet
                try
                {
                    if (!string.IsNullOrEmpty(textBoxSourcePort.Text) &&
                        !string.IsNullOrEmpty(textBoxTcpDestinationPort.Text))
                    {
                        sourcePort      = Convert.ToUInt16(textBoxSourcePort.Text.Trim(new char[] { ' ' }));
                        destinationPort = Convert.ToUInt16(textBoxDestinationPort.Text.Trim(new char[] { ' ' }));
                    }
                }
                catch (FormatException ex)
                {
                    TAMessageBox = new TAMessageBox("Error UDP packet", ex.ToString(), false, true);
                    TAMessageBox.Show();
                    return;
                }

                captureForm.manipulated = true;
                Close();
            }
            catch (Exception ex)
            {
                TAMessageBox = new TAMessageBox("Error btnSend_Click", ex.ToString(), false, true);
                TAMessageBox.Show();
            }
        }
示例#5
0
        private void manipulationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            manipulationForm             = new ManipulationForm();
            manipulationForm.captureForm = this;
            try
            {
                var packetWrapper = (PacketWrapper)dataGridView.Rows[dataGridView.SelectedCells[0].RowIndex].DataBoundItem;
                var packet        = Packet.ParsePacket(packetWrapper.p.LinkLayerType, packetWrapper.p.Data);
                if (packet is PacketDotNet.EthernetPacket)
                {
                    var eth = ((PacketDotNet.EthernetPacket)packet);
                    logWriting("Original Eth packet: " + eth.ToString());

                    // Manipulate ethernet parameters
                    manipulationForm.sourcehw      = eth.SourceHwAddress;
                    manipulationForm.destinationhw = eth.DestinationHwAddress;

                    var ip = (PacketDotNet.IPPacket)packet.Extract(typeof(PacketDotNet.IPPacket));
                    if (ip != null)
                    {
                        logWriting("Original IP packet: " + ip.ToString());

                        // manipulate IP parameters
                        manipulationForm.sourceip      = ip.SourceAddress;
                        manipulationForm.destinationip = ip.DestinationAddress;
                        manipulationForm.timeToLive    = ip.TimeToLive;

                        var tcp = (PacketDotNet.TcpPacket)packet.Extract(typeof(PacketDotNet.TcpPacket));
                        if (tcp != null)
                        {
                            logWriting("Original TCP packet: " + tcp.ToString());

                            // manipulate TCP parameters
                            manipulationForm.sourceTcpPort        = tcp.SourcePort;
                            manipulationForm.destinationTcpPort   = tcp.DestinationPort;
                            manipulationForm.windowSize           = tcp.WindowSize;
                            manipulationForm.acknowledgmentNumber = tcp.AcknowledgmentNumber;
                            manipulationForm.sequence_number      = tcp.SequenceNumber;
                            manipulationForm.tcpDataPayload       = tcp.PayloadData;
                        }
                    }

                    var udp = (PacketDotNet.UdpPacket)packet.Extract(typeof(PacketDotNet.UdpPacket));
                    if (udp != null)
                    {
                        logWriting("Original UDP packet: " + udp.ToString());

                        // manipulate UDP parameters
                        manipulationForm.sourcePort      = udp.SourcePort;
                        manipulationForm.destinationPort = udp.DestinationPort;
                    }
                }

                manipulationForm.Show();
            }
            catch (ArgumentOutOfRangeException)
            {
                TAMessageBox = new TAMessageBox("Traffic Analyzer", "Select packet for editing", false, false);
                TAMessageBox.Show();
            }
        }