5 Steps for Dealing With Unknown Environments in InsightVM
Discription

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/unknown-environments-insightvm.jpg)

Trying to deal with a large network can be difficult. All too often, engineers and admins don’t know the full scope of their environment and have trouble defining the actual subnets and the systems that exist on those subnets. They know of a couple /24 subnets here or there, but it’s very possible they’re missing a few. Once you get over a couple thousand assets, it can get fairly unruly pretty quick. Different teams own different servers and different network ranges. With regards to InsightVM, how do you know what sites create if you don’t even know what you own?

Luckily, in [InsightVM](), we can use a little bit of SQL, an overarching site with a ping sweep, and a nifty little tag to help get a handle on things – all outside any third-party software or other management tools you may acquire to help you wrangle in your IP space. This method in InsightVM lets you find all live assets and identify all network spaces being used in your environment. Then, we can correlate this list against our known subnets and begin building out defined sites for scanning. As we create our known sites, we can start whittling down the number of unknown or undefined subnets.

## 1. Ping Sweep template

The first step is to create a new scan template dedicated solely to a ping sweep. This template isn’t scanning for any other services or ports, fingerprinting, or performing any other action – it is simply sending pings to see what is alive. If we get a response back, we assume there is a live asset there, and this will help build out our known networks.

Create your template using these screenshots as guidance. Note that pretty much everything is off except ICMP and ARP pings, and we’re not treating TCP resets as live assets (we don’t want firewalls throwing us off). This scan should take just a few minutes to complete, as it’s not doing all the other functions that a typical scan can do.

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/image3.png)

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/image5.png)

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/image2.png)

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/image7.png)

## 2. Overarching site

The second step in this process is to create an overarching site. Give it a simple name like “Full Network” or whatever floats your boat. What’s important is that, within this site, you define as large of a network range as you know of. Think /16 here, or even a couple /16 networks. I don’t know your network, so use your judgment as to what you think exists. The idea is to be as broad as possible.

Now, within this site, set the default scan template as your “.Ping Sweep” template, as in my example above. Set your default scan engine or pool, and then save and scan.

What you should get back now is a full list of every live IP that exists within the defined network. If your defined network includes all the possible IP space, and we are assuming that all assets are online and able to respond, then you should have a pretty robust list of found assets.

## 3. Known Networks report

The next step is to go to the Reports tab and create a SQL Query Export. Throw the following SQL query in the definition, and scope the query from the GUI to your “Full Network” site.

WITH a AS (
SELECT
asset_id,
CONCAT(split_part(ip_address,’.’,1),’.’,split_part(ip_address,’.’,2),’.’,split_part(ip_address,’.’,3),’.0/24′) AS Network
FROM dim_asset
)

SELECT DISTINCT Network
FROM a
ORDER BY Network ASC

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/image4.png)

Save and run this report, and you will get a CSV output of all the /24 networks that have at least one live IP in them. You can use this CSV to compare to your known list of networks and start defining the actual sites within your environment. For example, if this report lists out 10.0.0.0/24 and you know that network as your main corporate server’s VLAN, then you can include that network into a separate site for [vulnerability scanning]().

## 4. Dynamic tagging

Now that we’ve started defining our known networks into sites, we need to create a dynamic tag that gets applied to all assets within any site. Now, in my example, I exclude the Rapid7 Insight Agents site, because depending on your environment and whether people are working from home, the Insight Agent may report the IP of their computer when logged onto their home network. We obviously can’t scan home networks, so we want to exclude this site to deter any of that bad data.

Create a dynamic tag with several lines to include each site. Note that if your site structure is large enough that you have hundreds of sites, you may want to use the API for this part, but we won’t go into that here – that’s a whole other conversation.

In my example below, I only have four sites – keep in mind I did not select the Rapid7 Insight Agents _or_ my Full Network site. Make sure the operator is set to match ANY of the specified filters. Apply a tag called “Defined Network” to this criteria to tag all assets within a defined site.

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/image6.png)

You could also optionally create a secondary tag for “Undefined Networks,” but it’s not exactly necessary for this process. The below query would get you the Undefined Network assets. Basically, the query is just looking for any assets that _don’t_ have the Defined Network tag and are not in the Rapid7 Insight Agents sites.

![5 Steps for Dealing With Unknown Environments in InsightVM](https://blog.rapid7.com/content/images/2022/09/image1-1.png)

## 5. Undefined Networks report

Now, we can set up our secondary SQL report to show us all networks that are not defined within the scope of a site. Once again, go to the Reports tab, create a SQL Query Export report, and throw this query into the definition.

WITH a AS (
SELECT
asset_id,
CONCAT(split_part(ip_address,’.’,1),’.’,split_part(ip_address,’.’,2),’.’,split_part(ip_address,’.’,3),’.0/24′) AS Network
FROM dim_asset
)

SELECT DISTINCT Network
FROM a

WHERE a.asset_id NOT IN (
SELECT DISTINCT asset_id
FROM dim_asset
LEFT JOIN dim_tag_asset USING (asset_id)
LEFT JOIN dim_tag USING (tag_id)
WHERE tag_name = ‘Defined Network’
)

ORDER BY Network ASC

Save and run this report, and you will get a new CSV that lists out all /24 networks where there was at least one live asset found but the assets are within a /24 that has not been defined within the scope of a created site. You can use this CSV to work your way through those networks to determine what they are and who owns them and then ensure they are included in future or current sites.

Large environments with unknown network components can be difficult to manage and monitor for vulnerabilities. These five steps in InsightVM help make the process easier and more intuitive, so you can maintain better oversight and a stronger security posture within your environment.

_**Additional reading:**_

* _[What’s New in InsightVM and Nexpose: Q2 2022 in Review]()_
* _[InsightVM Release Update: Let’s Focus on Remediation for Just a Minute]()_
* _[Maximize Your VM Investment: Fix Vulnerabilities Faster With Automox + Rapid7]()_

#### NEVER MISS A BLOG

Get the latest stories, expertise, and news about security today.

SubscribeRead More

Back to Main

Subscribe for the latest news: