为什么 hydra 没有返回有效的用户名和密码,并且提供了有效的用户名和密码

为什么 hydra 没有返回有效的用户名和密码,并且提供了有效的用户名和密码

我刚刚在 OSX Yosemite 上试用了 hydra,使用 brew 安装

brew info hydra
hydra: stable 8.0 (bottled), HEAD
https://www.thc.org/thc-hydra/
/usr/local/Cellar/hydra/8.0_1 (14 files, 1.2M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/hydra.rb
==> Dependencies
Build: pkg-config ✔
Required: openssl ✔
Optional: libidn ✘, libssh ✘, pcre ✔, gtk+ ✘
==> Options
--with-gtk+
    Build with gtk+ support
--with-libidn
    Build with libidn support
--with-libssh
    Build with libssh support
--with-pcre
    Build with pcre support
--HEAD
    install HEAD version

测试html表单post,就是这种情况。

我有一个使用 apache web 服务器运行的 php 文件,名为“index.php”,如下所示:

<?php

$login = 'admin';
$password = 'r00t';

?>

<html>
<head>
    <title>PHP Form Auth</title>
</head>
<body>
    <?php

    if (isset($_POST['go_field']))
    {
        if ($_POST['login_field'] == $login && $_POST['password_field'] == $password)
        {
            echo 'Logged in';
        }
        else
        {
            echo 'Error';
        }
    }
    else
    {
    ?>
        <form method="POST">
            <input type="text" name="login_field" /> Login <br />
            <input type="password" name="password_field" /> Password <br />
            <input type="submit" name="go_field" value="Login" />
        </form>
    <?php
    }
    ?>
</body>

它正在我的机器上运行,即

http://localhost/security/3/php/index.php

基本上,它是一个 html 表单,如果登录成功,则打印出“Logged in”字符串,否则打印出“Error”字符串。

我在浏览器中使用用户:admin 密码:r00t 进行了测试,它显示“已登录”。而我使用失败的凭证,它显示“错误”

然而,我使用 hydra 尝试过:

hydra -l admin -p r00t localhost http-post-form "/security/3/php/index.php:login_field=^USER^&password_field=^PASS^&go_field=Login:Error"

我得到了这个输出:

Hydra v8.0 (c) 2014 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes.

Hydra (http://www.thc.org/thc-hydra) starting at 2014-12-03 21:58:40
[DATA] max 1 task per 1 server, overall 1 tasks, 1 login try (l:1/p:1), ~1 try per task
[DATA] attacking service http-post-form on port 80
1 of 1 target completed, 0 valid passwords found
Hydra (http://www.thc.org/thc-hydra) finished at 2014-12-03 21:58:41

我不太清楚我错在哪里。有人能注意到我或者给我一些建议吗?

以下是我在浏览器中使用 http 表单 post 时的 http 标头:

POST /security/3/php/ HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:33.0) Gecko/20100101 Firefox/33.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://localhost/security/3/php/ Cookie: __vjstorage=%7B%7D Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 52 login_field=admin&password_field=r00t&go_field=Login

在我尝试将这些标题构建到 hydra 中之后,我发出:

hydra -v -V -l admin -p r00t -s 80 localhost http-post-form "/security/3/php/index.php:login_field=^USER^&password_field=^PASSWORD^&go_field=Login:Error:H=Host: localhost:H=User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:33.0) Gecko/20100101 Firefox/33.0:H=Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8:H=Accept-Language: en-US,en;q=0.5:H=Accept-Encoding: gzip, deflate:H=Referer: http://localhost/security/3/php/:H=Cookie: __vjstorage=%7B%7D:H=Connection: keep-alive:H=Content-Type: application/x-www-form-urlencoded:H=Content-Length: 52"

输出

Hydra v8.0 (c) 2014 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes.

Hydra (http://www.thc.org/thc-hydra) starting at 2014-12-05 17:33:10
[DATA] max 1 task per 1 server, overall 1 tasks, 1 login try (l:1/p:1), ~1 try per task
[DATA] attacking service http-post-form on port 80
[VERBOSE] Resolving addresses ... done
[ATTEMPT] target localhost - login "admin" - pass "r00t" - 1 of 1 [child 0]
[STATUS] 1.00 tries/min, 1 tries in 00:01h, 1 todo in 00:01h, 1 active
[STATUS] 0.50 tries/min, 1 tries in 00:02h, 1 todo in 00:01h, 1 active
[STATUS] 0.33 tries/min, 1 tries in 00:03h, 1 todo in 00:01h, 1 active

看起来没什么作用。

答案1

正如变更日志所述,这是版本 8.2-pre 中的一个已修复错误https://github.com/vanhauser-thc/thc-hydra/blob/master/CHANGES#L7

相关内容