Scanning /16 subnets - PowerShell 7 Cheats

The following is for those needing to scan /16 subnets on the community edition. Requires Powershell7

Long story short, Used Development Tools to scrape the GET/PUT’s from the network traffic so I can make life a little easier. I could have used a similar method in creating the scanning targets as well but I failed to do that initially.

GSM doesn’t allow the scanning of /16 subnets unless you cover every single /24 within the /16 as a target and task. And there is now way to really schedule tasks either. This allows you to kick off the tasks (possibly automatically if you craftily generate the session keys by other means).

#To automate tasks/scans:

$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.Cookies.Add((New-Object System.Net.Cookie(“GSAD_SID”, $myGSADID, “/”, “”)))

#Get all task IDS in XML format from
You can use a similar method to grab any information you need in XML format. It just needs to be XML parsed into powershell using the $var=[XML](gc .\your stuff.txt)

$taskid=“sample task id but you can enumerate through all of them, no idea what effect that would have.”
Invoke-WebRequest -SkipCertificateCheck -Uri “https:///gmp” -Method “POST” -WebSession $session -Form @{token=$mytoken;cmd=“start_task”;task_id=$($taskid)}

The following is a similar method in PowerShell 7 to create the “tasks” themselves from an existing list of targets.

$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.Cookies.Add((New-Object System.Net.Cookie(“GSAD_SID”, $myGSADID, “/”, “”)))
Invoke-WebRequest -SkipCertificateCheck -UseBasicParsing -Uri “https:///gmp” -Method "POST"
-WebSession $session `
-Form @{token=$mytoken;cmd=“create_task”;add_tag:0;apply_overrides:1;auto_delete=“no”;auto_delete_data=5;comment=$($;config_id=$config_id;host_ordering=“sequential”;in_assets=1;max_checks=4;max_hosts=20;min_qod=70;name=$($;scanner_id=$scanner_id;scanner_type=2;schedule_id=0;schedule_periods=0;source_iface=“”;target_id=$($;usage_type=“scan”}

–Logging into GreenBone from Powershell (community Edition)

#credentials for webfront end

#new websession
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession

#grab results of login
$results=Invoke-WebRequest -SkipCertificateCheck -Uri “https:///gmp” -Method “POST” -WebSession $session -Form @{cmd=“login”;login=$username;password=$password}

#parse session info

#add session id
$session.Cookies.Add((New-Object System.Net.Cookie(“GSAD_SID”, $myGSADID, “/”, “”)))