<< Click to Display Table of Contents >> Raynet One > 1.1 > User Guide > Technical overview > API Use case: Windows web server list with REST API |
Microsoft's IIS is a popular web server solution for businesses. In this use-case, we scan the device inventory for IIS evidence and report the related device list. Extra care should be taken to manage the web servers of your IT landscape, as they are easily accessible services, possibly connected to hundreds of users at once to serve as software infrastructure endpoints. Sufficient resources should be allocated to devices running web services to prevent service outage. Use the list generated by the following program to help you keep good watch over your network infrastructure.
•Python 3+
•Requests library (https://docs.python-requests.org/en/latest/)
•API key
•frontend URL
import requests
APIKEY = "PUT API KEY HERE"
FRONTEND = "PUT FRONTEND URL HERE"
HEADERS = { "ApiKey": APIKEY }
def obtain_paged(EP):
P = {}
P["count"] = 1000
items = []
while True:
result = requests.get(EP, params=P, headers=HEADERS)
if result.ok == False:
break
objs = result.json()
if objs == None:
return
if len(objs) == 0:
return
items.extend(objs)
lastobj = objs[len(objs)-1]
P["LastId"] = lastobj["id"]
return items
def main():
features = obtain_paged(FRONTEND + "/api/v1/ServerFeatures")
devs = obtain_paged(FRONTEND + "/api/v1/Devices")
if features == None or devs == None:
print("invalid frontend API data (" + FRONTEND + ")")
return
print("Windows Web Server list")
print("======================")
any_ws = False
for D in devs:
has_ws = False
for F in features:
if "deviceId" in F and F["deviceId"] == D["id"]:
if "name" in F and F["name"] == "Web Server":
has_ws = True
break
if has_ws:
if "name" in D:
print( "* " + D["name"] )
else:
print( "- " + D["id"] )
any_ws = True
if any_ws == False:
print("? none")