PHP code example of security-database / cvss
1. Go to this page and download the library: Download security-database/cvss library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
security-database / cvss example snippets
composer
use SecurityDatabase\Cvss\Cvss3;
try {
$cvss = new Cvss3();
$cvss->register("CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:N/E:P/RL:W/CR:L/IR:L/MAV:A/MAC:H/MPR:L/MUI:N/MS:U/MC:L/MI:L/MA:L");
print_r($cvss->getWeight());
print_r($cvss->getScores());
print_r($cvss->getScoresLabel());
print_r($cvss->getSubScores());
print_r($cvss->getSubScoresLabel());
print_r($cvss->getRatings());
print_r($cvss->getFormula());
print_r($cvss->getVector());
(...)
} catch (Exception $e) {
print $e->getCode() . " : " . $e->getMessage();
}
print_r($cvss->getWeight());
/*
array (size=20)
'AV' => float 0.85
'AC' => float 0.44
'PR' => float 0.27
'UI' => float 0.62
'C' => float 0.22
'I' => float 0.22
'A' => float 0
'E' => float 0.94
'RL' => float 0.97
'CR' => float 0.5
'IR' => float 0.5
'MAV' => float 0.62
'MAC' => float 0.44
'MPR' => float 0.62
'MUI' => float 0.85
'MC' => float 0.22
'MI' => float 0.22
'MA' => float 0.22
'RC' => float 1
'AR' => float 1
*/
print_r($cvss->getScores());
/*
array (size=7)
'baseScore' => float 6.7
'impactSubScore' => float 5.7576309677951
'exploitabalitySubScore' => float 0.3924228
'temporalScore' => string 'NA' (length=2)
'envScore' => string 'NA' (length=2)
'envModifiedImpactSubScore' => string 'NA' (length=2)
'overallScore' => float 6.7
*/
print_r($cvss->getScoresLabel());
/*
array (size=7)
'Base Score' => float 6.7
'impact SubScore' => float 5.7576309677951
'Exploitabality Sub Score' => float 0.3924228
'Temporal Score' => string 'NA' (length=2)
'Environmental Score' => string 'NA' (length=2)
'Environmental Modified Impact SubScore' => string 'NA' (length=2)
'Overall CVSS Score' => float 6.7
*/
print_r($cvss->getScores());
/*
array (size=9)
'impactSubScoreMultiplier' => float 0.8064
'impactSubScore' => float 5.7576309677951
'exploitabalitySubScore' => float 0.3924228
'baseScore' => float 6.7
'temporalScore' => float 6.7
'envModifiedExploitabalitySubScore' => float 0.3924228
'envImpactSubScoreMultiplier' => float 0.8064
'envModifiedImpactSubScore' => float 5.7576309677951
'envScore' => float 6.7
*/
print_r($cvss->getScoresLabel());
/*
array (size=9)
'Impact SubScore Multiplier' => float 0.8064
'impact SubScore' => float 5.7576309677951
'Exploitabality Sub Score' => float 0.3924228
'Base Score' => float 6.7
'Temporal Score' => float 6.7
'Environmental Modified Exploitabality SubScore' => float 0.3924228
'Environmental Impact SubScore Multiplier' => float 0.8064
'Environmental Modified Impact SubScore' => float 5.7576309677951
'Environmental Score' => float 6.7
*/
print_r($cvss->getRatings());
/*
array (size=3)
'baseRating' => string 'Low' (length=3)
'tempRating' => string 'Low' (length=3)
'envRating' => string 'Low' (length=3)
*/
print_r($cvss->getFormula());
/*
array (size=9)
'impactSubScoreMultiplier' => string '1 - ( ( 1 - 0.22 ) * ( 1 - 0.22 ) * ( 1 - 0 ) )' (length=47)
'impactSubScore' => string '6.42 * 0.3916' (length=13)
'exploitabalitySubScore' => string '8.22 * 0.85 * 0.44 * 0.27 * 0.62' (length=32)
'baseScore' => string 'roundUp( min( 10 , 2.514072 + 0.514634472 ) )' (length=45)
'temporalScore' => string 'roundUp( 3.1 * 0.94 * 0.97 * 1)' (length=31)
'envModifiedExploitabalitySubScore' => string '8.22 * 0.62 * 0.44 * 0.62 * 0.85' (length=32)
'envImpactSubScoreMultiplier' => string 'min( 0.915, 1 - ( ( 1 - 0.22 * 0.5 ) * ( 1 - 0.22 * 0.5 ) * ( 1 - 0.22 * 1 ) ) )' (length=80)
'envModifiedImpactSubScore' => string '6.42 * 0.382162' (length=15)
'envScore' => string 'roundUp(min(10 , (2.45348004 + 1.181753232 ) * 0.94 * 0.97 * 1),1)' (length=66)
*/
print $cvss->getVector();
/* return a string :
CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:L/I:L/A:N/E:P/RL:W/CR:L/IR:L/MAV:A/MAC:H/MPR:L/MUI:N/MS:U/MC:L/MI:L/MA:L
*/