Current time: 01-12-2008, 09:39 PM | Shoutbox Hello There, Guest! (LoginRegister)


Post Reply  Post Thread 
[Perl] Cross Site Scripting Finder Script
Author Message
Langy
Administrator
*******


Posts: 8.209
Group: Administrators
Joined: Sep 2007
Status: Offline
Reputation: 7
Post: #1
[Perl] Cross Site Scripting Finder Script

Code:
########################################
#
# Author: darkjoker
#
# Site: http://xhacker.altervista.org
#
# Program: XSS Finder
#
# Sintax: perl xss_finder.pl <hostname> <ftp username> <ftp password> [<log file>]
#
# Copyright (C) 2008 darkjoker This program is free software: you can redistribute
# it and/or modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at your option)
# any later version. This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Public License # GNU General for more details.
# You should have received a copy of the GNU General Public License along with this
# program. If not, see <http://www.gnu.org/licenses/>.
#
#
########################################

#!/usr/bin/perl
use IO::Socket;
use Net::FTP;
$host = shift or die "Usage: perl $0 <host> <username> <password> [<log file>]\n";
$user = shift or die "Usage: perl $0 <host> <username> <password> [<log file>]\n";
$pass = shift or die "Usage: perl $0 <host> <username> <password> [<log file>]\n";
$log_file = shift;
$ftp=Net::FTP->new($host) or die "Impossibile connettersi a $host.\n";
$ftp->login ($user, $pass) or die "Errore durante il login.\n";
@file = $ftp->ls ();
$cont4 = 0;
$log = "Scansione sito: $host\n";
while ($cont4 < scalar (@file)){
    my $sock = new IO::Socket::INET (
    PeerHost => $host,
    PeerPort => "80",
    Proto => "tcp",
    ) or die "Impossibile connettersi a $host: $!\n";
    $page = "";
    print $sock "get /@file[$cont4]\n\n";
    while (<$sock>){
            $page .= $_;
    }
    my (@variabili, @var_method);
    $cont2 = 0;
    $cont = 0;
    while ($cont <= length ($page)){
        if ($page =~ /<form.+?method.+?('|")(.+?)("|')/){
            $method = $2;
            $page =~ /<form.+?>(.+?)<\/form>/;
            $cont5 = 0;
            $in_form = $1;
            while ($cont5 <= length ($in_form)){
                if ($in_form =~ /<(input|textarea).+?name.+?('|")(.+?)("|')/){
                    @variabili [$cont2] = $3;
                    @var_method [$cont2] = $method;
                    $in_form =~ s/<(input|textarea).+?name.+?('|")(.+?)("|')/done/;
                }
                $cont5++;
            }
            $page =~ s/<form.+?method.+?('|")(.+?)("|')/done/;
        }
        $cont++;
    }
    close ($sock);
    $cont3 = 0;
    while ($cont3 < scalar (@variabili)){
            my $sock = new IO::Socket::INET(
            PeerHost => $host,
            PeerPort => "80",
        Proto => "tcp",
            ) or die "Impossibile connettersi a $host.\n";
        if (@var_method[$cont3] == "GET"){
                print $sock "get /@file[$cont4]?@variabili[$cont3]=<script>alert(1)</script>\n\n";
        }
        elsif (@var_method[$cont3] == "POST"){    
            $var = "@variabili[$cont3]=<script>alert(1)</script>";
            $to_send = "POST /pagina\n".
                "Host: $host\n".
                      "Content-Type: application/x-www-form-urlencoded\n".
                "Content-Length: ".length($var)."\n\n".
                $var."\n\n";
            print $sock $to_send;
        }
        else {
            die "@var_method[$cont3]: Metodo sconosciuto.\n";
        }
            $page2 = "";
            while (<$sock>){
                    $page2 .= $_;
            }
            if ($page2 =~ /<script>alert\(1\)<\/script>/){
                    print "/@file[$cont4]: @variabili[$cont3] vulnerabile.\n";
            $log .= "\n/@file[$cont4]: @variabili[$cont3] vulnerabile.";
            }
            $cont3++;
            close ($sock);
    }
    $cont4++;
}
if ($log_file != ""){
    open (LOG, $log_file) or die "Errore durante l'apertura del file: $!\n";
    print LOG $log;
    close ($log);
}


"There is no patch for human stupidity" - K. D. M.

This post was last modified: 30-06-2008 06:19 PM by Langy.

unknown browser unknown system
Browser e O.S.: 
30-06-2008 06:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cross Site Scripting - Attack and Defense guide xylitol 2 1.721 18-03-2008 12:07 PM
Last Post: Langy
  [Vulnerability Cross Site Injection] Last XSS on images.google.com Langy 1 404 11-02-2008 07:27 PM
Last Post: code91

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites