[Snort-users] mysql iphdr ip addressing scheme?

Phil Wood cpw at ...440...
Thu Nov 1 07:13:17 EST 2001


You'll probably get a lot of these types of responses.  I had that question
recently from one of the network staff here and thought I'd code it to death.

It's a perl script called int-to-ip which takes input in one of two ways:

  int-to-ip number [another_number]*
  int-to-ip < list_of_numbers_file

Later,

On Thu, Nov 01, 2001 at 12:36:29AM -0500, Jason Straight wrote:
> I'm confused. Snort on mysql has an ip addy that's nothing more than an 
> integer. How do I get a dotted quad IP# from:
> 
> 208436227 ?
> 
> Thanks in advance.
> 
> 
> -- 
> Jeet Kune Do does not beat around the bush. It does not take winding detours. 
> It follows a straight line to the objective. Simplicity is the shortest 
> distance between two points.
> Bruce Lee - Tao of Jeet Kune Do
> 
> 
> Jason Straight -- President
> BlazeConnect -- Cheboygan Michigan
> ISP: www.blazeconnect.net
> Products: www.blazeconnect.com
> Phone: 231-597-0376 -- Fax: 231-597-0393
> 
> _______________________________________________
> Snort-users mailing list
> Snort-users at lists.sourceforge.net
> Go to this URL to change user options or unsubscribe:
> https://lists.sourceforge.net/lists/listinfo/snort-users
> Snort-users list archive:
> http://www.geocrawler.com/redir-sf.php3?list=snort-users

-- 
Phil Wood, cpw at ...440...

-------------- next part --------------
#!/usr/bin/perl

# This perl script take input in one of two ways:
# 1. int-to-ip number [number]*
# 2. int-to-ip < listofnumbersfile
# and outputs the number in three forms as follows:
# <integer> -> <hex> -> <ip address>
# Examples:
# % int-to-ip 1234567890
# 1234567890 -> 499602d2 -> 73.150.2.210
#
# % echo 1234567890 | int-to-ip
# 1234567890 -> 499602d2 -> 73.150.2.210
#
#
if ($ARGV[0])
{
  @integers = @ARGV;
}
else
{
  while (<>)
  {
    chomp;
    $integers[$i++] = $_;
  }
}

foreach (@integers)
{
  $integer = $_;
  $a = ($integer >> 24) & 0xff;
  $b = ($integer >> 16) & 0xff;
  $c = ($integer >> 8) & 0xff;
  $d = ($integer)  & 0xff;

  printf "%d -> %08x -> %d.%d.%d.%d\n", $integer, $integer, $a, $b, $c, $d;
}


More information about the Snort-users mailing list