SIGN UP MEMBER LOGIN:    
ARTICLE

Storing Bulk TCP Dump File into SQL Server 2005

Posted by krishna prasad Articles | SQL Server 2012 October 28, 2009
In this article I will explain all steps needed to load tcp dump file into SQL Server 2005.
Reader Level:

In this article I am just trying to explain all steps needed to load tcp dump file into SQL Server 2005. This article is mainly for those who like to do projects like intrusion detection in .net.

As usual people would download the tcp dump file from mit lincoln laboratory website. It would be a .tcp file.runs in gb in space.

First step is to convert the .tcp file into .csv file format. For this we have to use wireshark tool which is freely downloadable. Wireshark is basically a packet sniffer tool. So as u open fireshark select file-->open--> ur .tcp file. Wait untill all tcp files gets loaded. Then select file-->export-->and save it as .csv file....So u are ready with the .csv file...

Next thing is to upload this .csv file  into sqlserver 2005. For this use the following code

using
System.Data;

using System.Data.SqlClient;

using System;

 

public class adoSQLClient

{

    public static void Main()

    {

        String strconnect = "server=CHANDRA-0D36D74;database=snort;uid=snort;pwd=test";

        try

        {

            SqlConnection con = new SqlConnection(strconnect);

            con.Open();

            /*-----------------------Loading the dataset---------------------*/

            SqlCommand command = new SqlCommand();

            command.Connection = con;

            command.CommandText = "BULK INSERT snort.dbo.[Dataset]" + @" FROM 'c:\tuesday'" + "WITH" + "(" + "FIELDTERMINATOR = ','," + "ROWTERMINATOR='\n'" + ")";

            command.CommandTimeout = 300;

            command.ExecuteNonQuery();

            Console.WriteLine("--------Dataset loaded sucessfully-------\n\n");

            con.close()

        }

        catch(Exception objError)

        {

            Console.WriteLine(objError);

            Console.ReadLine();

        }

    }

}

In this code snort is name of the database I have given with fields no, Source, Destination, Protocol, Info etc.

So you have succesfully added the dump file into the SQL Server 2005 database.

Any doubts feel free to ask. Hope this helps people working on network projects in .net.

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor