metasploit 常用命令汇总

时间:2023-03-08 16:34:48

1.连接数据并显示一些信息

db_connet username:password@ip address/database name

db_destroy 同上

db_import 文件名字

db_hosts -c address,svcs,vulns   // 显示ip地址,服务器,漏洞数

db_vlns   // 显示漏洞名字

2.nmap扫描

db_nmap -sS -nP ip address

db_nmap -h

3.nexpose在metasploit的使用

load nexpose // 加载nexpose插件

nexpose -h

nexpose_connect 用户名:密码@ip地址:端口号  认证字符

nexpose_scan ip地址

db_hosts -c address     // 显示漏洞信息

4.nessus在metasploit的使用

load nessus

nessus_connect 用户名:密码@ip地址:端口号  认证字符

nessus_policy_list //显示策略列表

nessus_scan_new

nessus_scan_new 2 bridge_scan ip地址

nessus_scan_status   //显示状态

nessus_report_list    // 报告列表

nessus_report_get 报告名字   // 显示报告

db_hosts -c address,svcs,vlns

db_autopwn -e -t -r -x -p // 自动运行检测数据库中得到的漏洞

5.搜索漏洞

     search mysql   // 搜索mysql的漏洞

6.保存metasploit用过的命令到文件

makerc  路径/文件名字

自动审计,运行检测

7.脚本如下

echo use 漏洞名字 >autoexploit.rc
echo set RHOST IP地址 >> autoexploit.rc
echo set PAYLOAD shellcode名字 >> autoexploit.rc
echo set LHOST IP地址 >> autoexploit.rc

echo exploit >> autoexploit.rc

8.第1种运行脚本的方法:

msfconsole -r autoexploit.rc

9.第2种运行脚本的方法:

msfconsole
resource autoexploit.rc

10.配置文件说明

<1>.metasploit的全局配置文件在安装目录下,文件名为properties.ini

<2>.properties.ini的信息如下:

[General]    // metasploit通用设置栏

base_stack_name=Metasploit

base_stack_version=4.3.0

installdir=D:\metasploit   //matasploit 安装路径

[Postgres]     // postgresql数据库栏

postgres_binary_directory=D:\metasploit/postgresql/bin   //postgresql数据库bin路径

postgres_port=7337     //postgresql数据库的端口号

postgres_root_directory=D:\metasploit/postgresql   //postgresql数据库的数据目录

postgres_root_password=b83a7446      //postgresql数据库的默认账户为postgres,默认密码就是此栏

postgres_unique_service_name=metasploitPostgreSQL-1  //postgresql数据库的服务名

rapid7_database_password=20f25188

rapid7_database_user=msf3              //postgresql数据库中的新建的账号为msf3,密码为20f25188

[Ruby]

ruby_root_directory=D:\metasploit/ruby        // ruby的安装目录

[NginX]      // nginx服务器设置

nginx_ssl_days=3650

nginx_ssl_name=goodjob-PC

nginx_ssl_port=3790    // nginx服务器的端口号