打开数据库 service postgresql start

image-20210324093029311

然后打开msfocnsole后可以查看数据库连接状态

image-20210324093316076

我们可以来学习一下基本命令

image-20210324093730650

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
banner:显示一个令人敬畏的metasploit横幅

toggic color:切换颜色

connect :与主机通信

handler:监听

back:返回上一级

unset:取消设置的选项

background:当前操作在后台运行

info:显示一个或者多个模块的信息

我们用show来查看都有哪些模块

image-20220430171508596

比如exploits就是漏洞利用模块,比如包含ms17_010漏洞,auxiliary为辅助模块,payloads为载荷。

1
show all显示所有模块

如果是exploits模块,我们看顶上的分类,分别为漏洞等级,检查能否使用,描述(一般为应用场景)

image-20220430171623743

如果是payloads模块就是 操作系统/类型/名称

然后info 可以查看模块详细信息

我们可以用search来寻找想要的模块,search命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
msf6 > search
Usage: search [<options>] [<keywords>:<value>]

Prepending a value with '-' will exclude any matching results.
If no options or keywords are provided, cached results are displayed.

OPTIONS:
-h Show this help information
-o <file> Send output to a file in csv format
-S <string> Regex pattern used to filter search results
-u Use module if there is one result
-s <search_column> Sort the research results based on <search_column> in ascending order
-r Reverse the search results order to descending order

Keywords:
aka : Modules with a matching AKA (also-known-as) name
author : Modules written by this author
arch : Modules affecting this architecture
bid : Modules with a matching Bugtraq ID
cve : Modules with a matching CVE ID
edb : Modules with a matching Exploit-DB ID
check : Modules that support the 'check' method
date : Modules with a matching disclosure date
description : Modules with a matching description
fullname : Modules with a matching full name
mod_time : Modules with a matching modification date
name : Modules with a matching descriptive name
path : Modules with a matching path
platform : Modules affecting this platform
port : Modules with a matching port
rank : Modules with a matching rank (Can be descriptive (ex: 'good') or numeric with comparison operators (ex: 'gte400'))
ref : Modules with a matching ref
reference : Modules with a matching reference
target : Modules affecting this target
type : Modules of a specific type (exploit, payload, auxiliary, encoder, evasion, post, or nop)

Supported search columns:
rank : Sort modules by their exploitabilty rank
date : Sort modules by their disclosure date. Alias for disclosure_date
disclosure_date : Sort modules by their disclosure date
name : Sort modules by their name
type : Sort modules by their type
check : Sort modules by whether or not they have a check method

Examples:
search cve:2009 type:exploit
search cve:2009 type:exploit platform:-linux
search cve:2009 -s name
search type:exploit -s type -r

举例

1
search type:auxiliary name:ms17

比如info windows/smb/ms17_010_eternalblue

image-20210324144317899

可以用上面的方式查找我们需要的模块

image-20210324144441780

然后使用

打开win7靶机

之后我们看options哪些需要自己设置

image-20210324145253259

445端口不用动,所以rhost需要设置

1
set RHOST 靶机

445端口:用于远程桌面连接

这里弄错了哈,既然是exploit攻击,就要用exploit模块,我们来搜索exploit

image-20210324150342968

然后我们回来,用第一个,第二个是针对win8+的。

image-20210324150454422

看我们需要设置rhost

但是注意,我们需要拿到会话,需要设置payload

搜索payload

search type:payload

再从中找反向连接tcp的

search type:payload name:reverse

然后就出现了几百个模块image-20210324151031896

然后我们设置载荷image-20210324151801744

set payload即可

image-20210324151930958

现在我们查看需要设置的变量就可以看出来结构,exploit模块是用来渗透的,payload是用来获取会话的,他们是近乎并列关系都需要设置参数,即主机或本机之类的ip地址,

image-20210324153419899

攻击之后我们可以看到应该将强制攻击设置为true

设置完之后再次攻击