Skip to content
This repository was archived by the owner on Sep 13, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions Vulmap-Linux/vulmap-linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def sendRequest(queryData):

else:
request = urllib2.Request(url, body, headers)
result = urllib2.urlopen(request, timeout=5)
result = urllib2.urlopen(request, timeout=240)
response = json.loads(result.read())
else:
if args.proxy:
Expand Down Expand Up @@ -221,10 +221,32 @@ def ReadFromFile(InventoryOutFile):
outResults(queryData)
outResults(queryData)

def getOSArch():
lines = open('/etc/os-release','r').read().split('\n')
for line in lines:
if "ID_LIKE" in line:
# Get the first entry from ID_LIKE in most cases it will be
# either "debian" or "rhel".
distros = line.lower().split("=")[1].replace('"','').split()
return distros[0]
# By default set it up to be debian.
return "debian"

def getProductList():
global productList
dpkg = "dpkg-query -W -f='${Package} ${Version} ${Architecture}\n'"
action = subprocess.Popen(dpkg, shell = True, stdout = subprocess.PIPE)

# By default exit and fail the query.
command = "exit 1"

# Change the command based on the OS architecture.
osArch = getOSArch()
if osArch == "debian":
command = "dpkg-query -W -f='${Package} ${Version} ${Architecture}\n'"
elif osArch == "rhel":
command = "rpm -qa --queryformat '%{NAME} %{VERSION} %{ARCH}\n'"

# Execute the command for the corresponding distro.
action = subprocess.Popen(command, shell = True, stdout = subprocess.PIPE)
results = action.communicate()[0]
if pV == 2:
tempList = str(results).split('\n')
Expand Down