mirror of
https://github.com/cve-search/cpe-guesser.git
synced 2024-11-24 15:57:22 +00:00
new: [lookup] basic version of lookup
This commit is contained in:
parent
84092b975d
commit
98de035a0c
1 changed files with 31 additions and 0 deletions
31
bin/lookup.py
Normal file
31
bin/lookup.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import redis
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
|
rdb = redis.Redis(host='127.0.0.1', port=6379, db=8, decode_responses=True)
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='Find potential CPE names from a list of keyword')
|
||||||
|
parser.add_argument('--word', help='One or more keyword(s) to lookup', action='append')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.word is None:
|
||||||
|
print("Missing keyword(s)")
|
||||||
|
parser.print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
k=[]
|
||||||
|
for keyword in args.word:
|
||||||
|
k.append('w:{}'.format(keyword.lower()))
|
||||||
|
|
||||||
|
maxinter = len(k)
|
||||||
|
cpes = []
|
||||||
|
for x in reversed(range(maxinter)):
|
||||||
|
ret = rdb.sinter(k[x])
|
||||||
|
cpes.append(list(ret))
|
||||||
|
|
||||||
|
|
||||||
|
result = set(cpes[0]).intersection(*cpes)
|
||||||
|
print(result)
|
||||||
|
|
||||||
|
#for cpe in result:
|
||||||
|
# rdb.zrank
|
Loading…
Reference in a new issue