Home > Articles > Security > Network Security

  • Print
  • + Share This
Like this article? We recommend

You won't generate random test events in a real-world application. Therefore, the question of how to employ a custom counter is important.

You can place the counters anywhere you think you might need to catch a particular security problem. For example, Listing 3 shows a custom counter used to monitor a range change on a text input.



Listing 3 Validating Text Input Length

private: System::Void btnSubmit_Click(
      System::Object * sender, 
      System::EventArgs * e)
{
  // Check the length of the input.
  if (txtMyEntry->Text->Length > 20)
  {
   // Display an error message.
   MessageBox::Show("Enter a value that is 20 characters or less!",
            "Data Entry Error",
            MessageBoxButtons::OK,
            MessageBoxIcon::Error);

   // Increment the counter.
   PerfCount->Increment();

   // Exit.
   return;
  }
}

Making range checks is important for any application you build. Otherwise, someone could place a script in that textbox in place of the simple text you really wanted. In this case, the user sees an error message with the correct text length, and the counter monitors the error. A cracker could continue looking for ways to enter the script using the textbox. Every time the cracker attempts to enter bad data, the counter monitors the situation. An alert network administrator will see the increasing count and take appropriate action. In short, this application assumes that the user will enter bad data, provides help to ensure the user knows what data to enter, and monitors the incorrect entry as part of a security strategy. Smart applications such as this one are the future because they help network administrators detect cracker activities long before they become a real problem.

  • + Share This
  • 🔖 Save To Your Account