Created
April 2, 2021 18:44
-
-
Save NSEcho/e15d1a6db8ba36278b4d86f37ff7b296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to get labels which will become vulnrefs inside Owasp table | |
# You need to pass one parameter to the script, the path where | |
# the vulns/ directory is located | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[1;33m' | |
END='\033[0m' | |
message() { | |
echo -e "${GREEN}[*] $1${END}" | |
} | |
print_information() { | |
echo -e "${YELLOW}\t\t[+] $1${END}" | |
} | |
error() { | |
echo -e "${RED}[-] $1${END}" | |
exit 1 | |
} | |
DIRECTORY="." | |
if [ $# -eq 1 ]; then | |
DIRECTORY="$1" | |
fi | |
if [ ! -d "${DIRECTORY}/vulns" ]; then | |
error "Directory ${DIRECTORY}/vulns does not exist." | |
fi | |
pushd "${DIRECTORY}/vulns" | |
for filename in *.igo; do | |
message "In file ${filename}" | |
vulnRef=$(pcregrep -o1 -M "label %.*\n(.*)$" "${filename}") | |
name=$(pcregrep -o1 -M "name %.*\n(.*)$" "${filename}") | |
print_information "vulnRef:\t${vulnRef}" | |
print_information "name:\t${name}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment