zoukankan      html  css  js  c++  java
  • ch1_example25_PerlSubnetIPAddressParsing.txt

    1    #!/usr/bin/perl
    2    if(@ARGV<2){print "Usage: $0 <network> <port>\nExample: $0 10.*.*.* 80 or 10.4.*.* 80 or 10.4.3.* 80\n";exit;}
    3    else{
    4      use IO::Socket;
    5      $sIP="@ARGV[0]";
    6      $port="@ARGV[1]";
    7      ($ip1,$ip2,$ip3,$ip4)=split(/\./,$sIP);
    8        if($ip2 == '*')
    9         {$ip2=1; $ip3=1; $ip4=1; $x='a'; print "Scanning a Class A\n";}
    10        elsif($ip3 == '*')
    11         {$ip3=1; $ip4=1; $x='b'; print "Scanning a Class B\n";}    
    12        elsif($ip4 == '*')
    13         {$ip4=1; $x='c'; print "Scanning a Class C\n";}
    14    
    15       while($ip2<255 && $x == 'a')
    16        {
    17            while($ip3<255 && ($x == 'a' || $x == 'b'))
    18            {
    19                while($ip4<255)
    20                {    
    21                        $ipaddr="$ip1.$ip2.$ip3.$ip4";
    22                    print "$ipaddr\n";
    23                           #IP_connect($ipaddr);
    24                          $ip4++;
    25                }
    26            $ip4=1;
    27            $ip3++;
    28            if($x eq 'c') {$ip3=255; $ip2=255;}
    29            }
    30        $ip4=1;
    31        $ip3=1;
    32        $ip2++;
    33        if($x eq 'c' || $x eq 'b') {$ip3=255; $ip2=255;}
    34       }
    35    }
  • 相关阅读:
    加分二叉树
    逃离牧场
    [Apio2012]dispatching
    靶形数独
    POJ 1459-Power Network(网络流-最大流-ISAP)C++
    题解 最优的挤奶方案(Optimal Milking)
    [HNOI2007]紧急疏散EVACUATE (湖南2007年省选)
    【LCA求最近公共祖先+vector构图】Distance Queries
    BZOJ1143: [CTSC2008]祭祀river
    BZOJ2140: 稳定婚姻
  • 原文地址:https://www.cnblogs.com/shihao/p/2511314.html
Copyright © 2011-2022 走看看