Advertisement
Guest User

Untitled

a guest
Jun 25th, 2022
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. '''import os
  2. import re
  3.  
  4. cvecsvpath = input("CVE allitems.csv location. (Download from https://www.cve.org/Downloads): ")
  5. if not os.path.isfile(cvecsvpath):
  6. print("File path isn't correct!")
  7. exit(0)
  8.  
  9. with open(cvecsvpath, "r", encoding="Latin-1") as rfh:
  10. cvecsv = rfh.read()
  11.  
  12. cvecsv = cvecsv.split("\n")
  13.  
  14. for line in cvecsv:
  15. line = line.split(",", 2)
  16. cvenum = line[0]
  17. wholedesc = line[2]
  18. desc = desc[1:]
  19. desc = desc[:-1]
  20. print(cvenum + ";" + desc)'''
  21.  
  22. import csv
  23. import os
  24.  
  25. def appendToVulns(line):
  26. line = line.encode("ascii", "ignore")
  27. line = line.decode()
  28. with open("cve.csv", "a") as afh:
  29. afh.write(line)
  30.  
  31. cvecsvpath = input("CVE allitems.csv location. (Download from https://www.cve.org/Downloads): ")
  32. if not os.path.isfile(cvecsvpath):
  33. print("File path isn't correct!")
  34. exit(0)
  35.  
  36. with open(cvecsvpath, "r", encoding="Latin-1") as rfh:
  37. csvread = csv.reader(rfh)
  38. print(csvread)
  39. for line in csvread:
  40. cvenum = line[0]
  41. desc = line[2]
  42. line = cvenum + ";" + desc + "\n"
  43. appendToVulns(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement