tags:

views:

504

answers:

2

I trying to code a login script for phpmyadmin

<?php    
$user = "Domain";
$passwords = file("passwords.txt");

foreach ( $passwords as $pass){
$source = file_get_contents("http://dbadmin.one.com/index.php?lang=en&amp;server=1&amp;pma_username=$user&amp;pma_password=$pass");
if(preg_match("/Database/", $source)):
echo "Login Worked with: {$pass}";
endif;
}
?>

My Problem is it , it dont works here

echo "Login Worked with: {$pass}";

Can you see the problem?

+1  A: 

Not necessarily the solution to your problem, but some basic error checking might point you in the right direction. Your problem may even begin at the initial call to file.

$passwords = file("passwords.txt");

if (!$passwords) {
 echo 'Unable to read password file';
} //etc

$source = file_get_contents("http://dbadmin.one.com/index.php?lang=en&amp;server=1&amp;pma_username=$user&amp;pma_password=$pass");

if (!$source) {
 echo 'Unable to read file source';
} //etc

Also as a side note if you were calling this function on a file outside your filesystem wouldn't you only get the output (HTML) similar to calling it in your browser (not sure if that was your intention).

Asciant
A: 
$source = file_get_contents("http://dbadmin.one.com/index.php?lang=en&amp;server=1pma_username=$user&amp;pma_password=$pass");
if(preg_match("/Database/", $source)):

The value of $source is going to be the full HTML response of getting the url:

http://dbadmin.one.com/index.php?lang=en&amp;server=1&amp;pma_username=$user&amp;pma_password=$pass

preg_match is only going to match on the first line of that string. You will need to parse the string differently or replace any newline characters so it will match on the whole file.

It also looks like you're testing logins to a database using the username "Domain" with a number of different passwords. Not sure if that was your intention, but it seems a bit odd.