Tagging Hosts in msfconsole

A host tag is a label that you assign to a host to track, group, and report on hosts according to how they impact an organization. Tags are useful when you want filter hosts based on some commonality, such as the type of data they contain, and add context to your targets. For example, you may want to tag all accounting servers with a label like, 'accounting' to indicate that they contain sensitive financial data. You can also create tags, such as 'High', 'Medium', and 'Low', to isolate hosts based on their criticality levels.

To tag a host, you add the -t option to the hosts command. All tags are case sensitive and should use only alphanumeric characters. You may also want to use the -t option with the -R option to specify a host range, the -S option to search for hosts, and the -d option to delete a tag.

Tagging a Single Host

To tag a single host, use the hosts command and the -t option.

Syntax

1
hosts <address> -t <tag name>

Example

1
msf > hosts 10.20.36.51 -t tag1

Tagging a Range of Hosts

To tag a range of hosts, use the hosts command, the -R option, and the -t option.

Syntax

1
hosts -R <address range> -t <tag name>

Example

1
msf > hosts -R 10.20.36.51-10.20.36.68 -t tag1

Viewing Tags in the Hosts Table

By default, the hosts table shows does not include the tags column. It includes the 'address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', and 'comments' columns. Therefore, if you want to see the tags column, you must use the -c option and specify the 'tags' column and any other columns you want to include.

Syntax

1
hosts -c 'column1, column2, column3'

Example

1
msf > hosts -c 'address,tags'

Searching for Hosts by Tag

To search for hosts by tag, use the hosts command and the -S option.

Syntax

1
hosts -S <tag name>

Example

1
msf > hosts -S tag1

The results will not display the tags column. If you want to include the 'tags' column, you need to include the -c option as well, as shown below:

1
msf > hosts -S tag1 -c 'address,tags'

Deleting a Tag

To delete a tag, use the hosts command and the -d option and -t option. When you delete a tag, it removes the tag from all hosts that use it.

Syntax

1
hosts -t -d <tag name>

Example

1
msf > hosts -t -d tag1

Deleting a Tag for a Specific Host or Range of Hosts

To delete a tag for a specific host or range of hosts, use the hosts command, the -R option, and the -d option.

Syntax

1
hosts -R <IP range> -d -t <tag name>

Example

1
msf > hosts -R 10.20.36.51 -t tag1