Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
Last active September 16, 2022 19:46
Show Gist options
  • Save mbrownnycnyc/d688a5b9256e6e53dfdf07f24fba54b6 to your computer and use it in GitHub Desktop.
Save mbrownnycnyc/d688a5b9256e6e53dfdf07f24fba54b6 to your computer and use it in GitHub Desktop.
gather interesting cvss data from x-force
$cvelist = "CVE-2022-32868","CVE-2022-32886","CVE-2022-32912","CVE-2022-32891","CVE-2022-32854","CVE-2022-32911","CVE-2022-32864","CVE-2022-32917","CVE-2022-32883","CVE-2022-32908","CVE-2022-32795","CVE-2022-32868","CVE-2022-32872","CVE-2022-32886","CVE-2022-32902","CVE-2022-32896","CVE-2022-32911","CVE-2022-32864","CVE-2022-32917","CVE-2022-32883","CVE-2022-32908","CVE-2022-32900","CVE-2022-32902","CVE-2022-32854","CVE-2022-32896","CVE-2022-32911","CVE-2022-32864","CVE-2022-32894","CVE-2022-32917","CVE-2022-32883","CVE-2022-32908","CVE-2022-32900","CVE-2022-32854","CVE-2022-32911","CVE-2022-32864","CVE-2022-32917","CVE-2022-32883","CVE-2022-32908","CVE-2022-32795","CVE-2022-32868","CVE-2022-32872","CVE-2022-32886","CVE-2022-32912","CVE-2022-32893"
$baseurl = "https://api.xforce.ibmcloud.com/"
$apikey = "xxxx"
$apipass = "yyyy"
$encodeme = $apikey+":"+$apipass
$access_token = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($encodeme))
$headers = @{"Authorization"= "Basic $access_token";
"Accept"= "application/json";
'User-Agent'= 'Mozilla 5.0'}
$cvssdata = @()
foreach ($cve in $cvelist) {
$tempobj = "" | select cve, platforms_affected, cvss_base, cvss_temporal, attack_vector, attack_complexity, user_interaction, privs_required, exploitability, remedy
#get cvedata
$url = $baseurl + "vulnerabilities/search/$cve"
$fullcvedata = ((invoke-webrequest $url -headers $headers).content | convertfrom-json)
$tempobj.cve = $cve
$tempobj.platforms_affected = ($fullcvedata.platforms_affected) -join ", "
$tempobj.cvss_base = $fullcvedata.risk_level
$tempobj.cvss_temporal = $fullcvedata.temporal_score
$tempobj.attack_vector = $fullcvedata.cvss.access_vector
$tempobj.attack_complexity = $fullcvedata.cvss.access_complexity
$tempobj.user_interaction = $fullcvedata.cvss.userinteraction
$tempobj.privs_required = $fullcvedata.cvss.privilegesrequired
$tempobj.exploitability = $fullcvedata.exploitability
$tempobj.remedy = $fullcvedata.remedy
$cvssdata += , $tempobj
}
(($cvssdata | convertto-csv -NoTypeInformation) -replace '","',"`t") -replace '"','' | set-clipboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment