Location: PHPKode > projects > Snort Log Monitor and Ticketing System > snortlogmonitor/searchlogs.php
<html><head>
<title>Securetty.com - Snort IDS Monitoring Site</title>
<base target="logdata">
</head>
<?
include ("./myfunctions.php");

# If the includes are not working for the db settings then populate them locally:
include ("./dbconn_out.php");

##  mysql snort database
#  $db_host       = "";  # mysql database server.
#  $db_user       = "";  # mysql user with SELECT, UPDATE, INSERT priveleges.
#  $db_passwd     = "";  # password for mysql user.
#  $db_database   = "";  # database name where snort logs to.

# Connect to the database server:
  $db_connection = mysql_connect($db_host, $db_user, $db_passwd);
  mysql_select_db($db_database);

  $Selstr  = "select distinct iphdr.ip_src from iphdr";
  $Selstr1 = "select distinct iphdr.ip_dst from iphdr";
  $Selstr2 = "select distinct signature.sig_name, signature.sig_id from signature";

  $Result  =mysql_query($Selstr, $db_connection);
  $Result1 =mysql_query($Selstr1, $db_connection);
  $Result2 =mysql_query($Selstr2, $db_connection);

?>


<body bgcolor="gray">
<form action="snortlogdata.php" target="logdata" method="post">
<table width="100%" border="0"><tr><td align="left">
<table border="0">
  <tr><th width="200" align="left" valign="top" rowspan="3">
      <font color="blue"><b>MTS Snort Log Monitor<br>& Ticketing System</b><br>
      by: hide@address.com</font><br></th>
      <th bgcolor="orange" colspan="2" align="left">Time: yyyy-mm-dd hh:mm:ss</th></tr>
      <td>From:</td><td><select name="fromyear" size="1">
<? #----- Handle From And To Date Constraints ---------------------------------------
      for ($X=2002;$X<=2010;$X++)
      {
        $X=str_pad($X,4,0,STR_PAD_LEFT);
        print "<option value=$X>$X</option>";
      }
?>
      </select>-
      <select name="frommonth" size="1">
<?
      for ($X=1;$X<=12;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        print "<option value=$X>$X</option>";
      }
?>
      </select>-
      <select name="fromday" size="1">
<?
      for ($X=1;$X<=31;$X++)
      {

        $X=str_pad($X,2,0,STR_PAD_LEFT);
      print "<option value=$X>$X</option>";
      }
?>
      </select> | 
      <select name="fromhour" size="1">
<?
      for ($X=1;$X<=24;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        print "<option value=$X>$X</option>";
      }
?>
      </select><b>:</b>
      <select name="fromminute" size="1">
<?
      for ($X=0;$X<=59;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        print "<option value=$X>$X</option>";
      }
?>
      </select><b>:</b>
      <select name="fromsecond" size="1">
<?
      for ($X=0;$X<=59;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        print "<option value=$X>$X</option>";
      }
?>
      </select></td></tr>

      <td>To:</td><td><select name="toyear" size="1">
<?
   # Populate To Time fields with current time info
      $Now=getdate(time());

      for ($X=2002;$X<=2010;$X++)
      {
        $X=str_pad($X,4,0,STR_PAD_LEFT);
        if ($X == $Now["year"])
        {
          print "<option selected value=$X>$X</option>";
        } else {
          print "<option value=$X>$X</option>";
        }
      }
?>
      </select>-
      <select name="tomonth" size="1">
<?
      for ($X=1;$X<=12;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        if ($X == $Now["mon"])
        {
          print "<option selected value=$X>$X</option>";
        } else {
          print "<option value=$X>$X</option>";
        }
      }
?>
      </select>-
      <select name="today" size="1">
<?
      for ($X=1;$X<=31;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        if ($X == $Now["mday"])
        {
          print "<option selected value=$X>$X</option>";
        } else {
          print "<option value=$X>$X</option>";
        }       
      }
?>
      </select> | 
      <select name="tohour" size="1">
<?
      for ($X=1;$X<=24;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        if ($X == $Now["hours"])
        {
          print "<option selected value=$X>$X</option>";
        } else {
          print "<option value=$X>$X</option>";
        }
      }
?>
      </select><b>:</b>
      <select name="tominute" size="1">
<?
      for ($X=0;$X<=59;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        if ($X == $Now["minutes"])
        {
          print "<option selected value=$X>$X</option>";
        } else {
          print "<option value=$X>$X</option>";
        }
      }
?>
      </select><b>:</b>
      <select name="tosecond" size="1">
<?
      for ($X=0;$X<=59;$X++)
      {
        $X=str_pad($X,2,0,STR_PAD_LEFT);
        if ($X == $Now["seconds"])
        {
          print "<option selected value=$X>$X</option>";
        } else {
          print "<option value=$X>$X</option>";
        }
      }
#----------- End To And From Date Constraints ---------------------------------
?>
      </select></td></tr></table>

</td><td><tr><td align"left">

<table border="0">
<tr><th bgcolor="orange" rowspan="2" align="center">Protocol:</th>
    <th bgcolor="orange" colspan="2" align="center">Source:</th>
    <th bgcolor="orange" colspan="2" align="center">Destination:</th>
    <th bgcolor="orange" rowspan="2" align="center">Signature Name:</th></tr>
<tr><td bgcolor="orange" align="center">IP</td><td bgcolor="orange" align="center">Port</td>
    <td bgcolor="orange" align="center">IP</td><td bgcolor="orange" align="center">Port</td></tr>
<tr><td><select name="protocol" size="1">
          <option selected value="tcp">tcp</option>
          <option value="udp">udp</option>
          <option value="icmp">icmp</option>
        </select></td>
<td><select name="source_ip[]" multiple size="3">
<? #------------ Handle Source IP Select Box and Port -----------------------------
  if (mysql_num_rows($Result) != 0)
  {
    print "<option selected value=\"any\"0>any</option>";
    for ($X=0; $X < mysql_num_rows($Result); $X++)
    {
      $row = mysql_fetch_row($Result);
      $intIPval=0+$row[0];
      $IPval=IntToIPaddress($intIPval);
      print "<option value=".$intIPval.">".$IPval."</option>";
    }
    mysql_free_result($Result);
  }
?>
</select></td>
<td><input type="text" size="9" maxlength="11" name="sourceport"></td>
<td><select name="destination_ip[]" multiple size="3">
<? #------------ Handle Destination IP Select Box and Port ------------------------
  if (mysql_num_rows($Result1) != 0)
  {
    print "<option selected value=\"any\">any</option>";
    for ($X=0; $X < mysql_num_rows($Result1); $X++)
    {
      $row = mysql_fetch_row($Result1);
      $intIPval=0+$row[0];
      $IPval=IntToIPaddress($intIPval);
      print "<option value=".$intIPval.">".$IPval."</option>";
    }
    mysql_free_result($Result1);
  }
?>
</select></td>
<td><input type="text" size="9" maxlength="11" name="destinationport"></td>
<td><select name="signatureID[]" multiple size="3">
<?
  if (mysql_num_rows($Result2) != 0)
  {
    print "<option selected value=\"any\">any</option>";
    for ($X=0; $X < mysql_num_rows($Result2); $X++)
    {
      $row = mysql_fetch_row($Result2);
      $data=substr($row[0], 0, 32);
      print "<option value=".$row[1].">"."$data...</option>";
    }
    mysql_free_result($Result2);
  }
print "<input type=\"hidden\" name=\"OnRun\" value=\"INIT\">";
?>
</select></td><td align="left" valign="bottom"><input type="submit" target="logdata" value="Search"></td>
</tr>

</tr>
</table>
<hr width="100%" size="3">
</table>
</td></tr>
</td></tr></table>
</body>
</html>

Return current item: Snort Log Monitor and Ticketing System