dawnscanner 1.6.9 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Changelog.md +8 -0
  4. data/LICENSE.txt +1 -1
  5. data/Rakefile +6 -239
  6. data/VERSION +1 -1
  7. data/bin/dawn +6 -46
  8. data/dawnscanner.gemspec +6 -1
  9. data/doc/change.sh +13 -0
  10. data/doc/knowledge_base.rb +650 -0
  11. data/lib/dawn/cli/dawn_cli.rb +103 -0
  12. data/lib/dawn/engine.rb +9 -11
  13. data/lib/dawn/gemfile_lock.rb +2 -2
  14. data/lib/dawn/kb/basic_check.rb +1 -0
  15. data/lib/dawn/kb/combo_check.rb +1 -1
  16. data/lib/dawn/kb/dependency_check.rb +1 -1
  17. data/lib/dawn/kb/pattern_match_check.rb +1 -1
  18. data/lib/dawn/kb/ruby_version_check.rb +11 -10
  19. data/lib/dawn/kb/{gem_check.rb → rubygem_check.rb} +1 -1
  20. data/lib/dawn/kb/version_check.rb +25 -25
  21. data/lib/dawn/knowledge_base.rb +211 -588
  22. data/lib/dawn/utils.rb +5 -2
  23. data/lib/dawn/version.rb +5 -5
  24. data/lib/dawnscanner.rb +4 -3
  25. metadata +23 -450
  26. data/lib/dawn/kb/cve_2004_0755.rb +0 -33
  27. data/lib/dawn/kb/cve_2004_0983.rb +0 -31
  28. data/lib/dawn/kb/cve_2005_1992.rb +0 -31
  29. data/lib/dawn/kb/cve_2005_2337.rb +0 -33
  30. data/lib/dawn/kb/cve_2006_1931.rb +0 -30
  31. data/lib/dawn/kb/cve_2006_2582.rb +0 -28
  32. data/lib/dawn/kb/cve_2006_3694.rb +0 -31
  33. data/lib/dawn/kb/cve_2006_4112.rb +0 -27
  34. data/lib/dawn/kb/cve_2006_5467.rb +0 -28
  35. data/lib/dawn/kb/cve_2006_6303.rb +0 -28
  36. data/lib/dawn/kb/cve_2006_6852.rb +0 -27
  37. data/lib/dawn/kb/cve_2006_6979.rb +0 -29
  38. data/lib/dawn/kb/cve_2007_0469.rb +0 -29
  39. data/lib/dawn/kb/cve_2007_5162.rb +0 -28
  40. data/lib/dawn/kb/cve_2007_5379.rb +0 -27
  41. data/lib/dawn/kb/cve_2007_5380.rb +0 -29
  42. data/lib/dawn/kb/cve_2007_5770.rb +0 -30
  43. data/lib/dawn/kb/cve_2007_6077.rb +0 -31
  44. data/lib/dawn/kb/cve_2007_6612.rb +0 -30
  45. data/lib/dawn/kb/cve_2008_1145.rb +0 -38
  46. data/lib/dawn/kb/cve_2008_1891.rb +0 -38
  47. data/lib/dawn/kb/cve_2008_2376.rb +0 -30
  48. data/lib/dawn/kb/cve_2008_2662.rb +0 -33
  49. data/lib/dawn/kb/cve_2008_2663.rb +0 -32
  50. data/lib/dawn/kb/cve_2008_2664.rb +0 -33
  51. data/lib/dawn/kb/cve_2008_2725.rb +0 -31
  52. data/lib/dawn/kb/cve_2008_3655.rb +0 -37
  53. data/lib/dawn/kb/cve_2008_3657.rb +0 -37
  54. data/lib/dawn/kb/cve_2008_3790.rb +0 -30
  55. data/lib/dawn/kb/cve_2008_3905.rb +0 -36
  56. data/lib/dawn/kb/cve_2008_4094.rb +0 -27
  57. data/lib/dawn/kb/cve_2008_4310.rb +0 -100
  58. data/lib/dawn/kb/cve_2008_5189.rb +0 -27
  59. data/lib/dawn/kb/cve_2008_7248.rb +0 -27
  60. data/lib/dawn/kb/cve_2009_4078.rb +0 -29
  61. data/lib/dawn/kb/cve_2009_4124.rb +0 -30
  62. data/lib/dawn/kb/cve_2009_4214.rb +0 -27
  63. data/lib/dawn/kb/cve_2010_1330.rb +0 -28
  64. data/lib/dawn/kb/cve_2010_2489.rb +0 -60
  65. data/lib/dawn/kb/cve_2010_3933.rb +0 -27
  66. data/lib/dawn/kb/cve_2011_0188.rb +0 -67
  67. data/lib/dawn/kb/cve_2011_0446.rb +0 -28
  68. data/lib/dawn/kb/cve_2011_0447.rb +0 -28
  69. data/lib/dawn/kb/cve_2011_0739.rb +0 -28
  70. data/lib/dawn/kb/cve_2011_0995.rb +0 -61
  71. data/lib/dawn/kb/cve_2011_1004.rb +0 -34
  72. data/lib/dawn/kb/cve_2011_1005.rb +0 -31
  73. data/lib/dawn/kb/cve_2011_2197.rb +0 -27
  74. data/lib/dawn/kb/cve_2011_2686.rb +0 -29
  75. data/lib/dawn/kb/cve_2011_2705.rb +0 -32
  76. data/lib/dawn/kb/cve_2011_2929.rb +0 -27
  77. data/lib/dawn/kb/cve_2011_2930.rb +0 -28
  78. data/lib/dawn/kb/cve_2011_2931.rb +0 -30
  79. data/lib/dawn/kb/cve_2011_2932.rb +0 -27
  80. data/lib/dawn/kb/cve_2011_3009.rb +0 -28
  81. data/lib/dawn/kb/cve_2011_3186.rb +0 -29
  82. data/lib/dawn/kb/cve_2011_3187.rb +0 -29
  83. data/lib/dawn/kb/cve_2011_4319.rb +0 -30
  84. data/lib/dawn/kb/cve_2011_4815.rb +0 -28
  85. data/lib/dawn/kb/cve_2011_5036.rb +0 -26
  86. data/lib/dawn/kb/cve_2012_1098.rb +0 -30
  87. data/lib/dawn/kb/cve_2012_1099.rb +0 -27
  88. data/lib/dawn/kb/cve_2012_1241.rb +0 -27
  89. data/lib/dawn/kb/cve_2012_2139.rb +0 -26
  90. data/lib/dawn/kb/cve_2012_2140.rb +0 -27
  91. data/lib/dawn/kb/cve_2012_2660.rb +0 -28
  92. data/lib/dawn/kb/cve_2012_2661.rb +0 -27
  93. data/lib/dawn/kb/cve_2012_2671.rb +0 -28
  94. data/lib/dawn/kb/cve_2012_2694.rb +0 -30
  95. data/lib/dawn/kb/cve_2012_2695.rb +0 -27
  96. data/lib/dawn/kb/cve_2012_3424.rb +0 -29
  97. data/lib/dawn/kb/cve_2012_3463.rb +0 -27
  98. data/lib/dawn/kb/cve_2012_3464.rb +0 -27
  99. data/lib/dawn/kb/cve_2012_3465.rb +0 -26
  100. data/lib/dawn/kb/cve_2012_4464.rb +0 -27
  101. data/lib/dawn/kb/cve_2012_4466.rb +0 -27
  102. data/lib/dawn/kb/cve_2012_4481.rb +0 -26
  103. data/lib/dawn/kb/cve_2012_4522.rb +0 -27
  104. data/lib/dawn/kb/cve_2012_5370.rb +0 -27
  105. data/lib/dawn/kb/cve_2012_5371.rb +0 -27
  106. data/lib/dawn/kb/cve_2012_5380.rb +0 -28
  107. data/lib/dawn/kb/cve_2012_6109.rb +0 -25
  108. data/lib/dawn/kb/cve_2012_6134.rb +0 -27
  109. data/lib/dawn/kb/cve_2012_6496.rb +0 -28
  110. data/lib/dawn/kb/cve_2012_6497.rb +0 -28
  111. data/lib/dawn/kb/cve_2012_6684.rb +0 -28
  112. data/lib/dawn/kb/cve_2013_0155.rb +0 -29
  113. data/lib/dawn/kb/cve_2013_0156.rb +0 -27
  114. data/lib/dawn/kb/cve_2013_0162.rb +0 -28
  115. data/lib/dawn/kb/cve_2013_0175.rb +0 -27
  116. data/lib/dawn/kb/cve_2013_0183.rb +0 -25
  117. data/lib/dawn/kb/cve_2013_0184.rb +0 -25
  118. data/lib/dawn/kb/cve_2013_0233.rb +0 -26
  119. data/lib/dawn/kb/cve_2013_0256.rb +0 -59
  120. data/lib/dawn/kb/cve_2013_0262.rb +0 -26
  121. data/lib/dawn/kb/cve_2013_0263.rb +0 -26
  122. data/lib/dawn/kb/cve_2013_0269.rb +0 -27
  123. data/lib/dawn/kb/cve_2013_0276.rb +0 -28
  124. data/lib/dawn/kb/cve_2013_0277.rb +0 -25
  125. data/lib/dawn/kb/cve_2013_0284.rb +0 -27
  126. data/lib/dawn/kb/cve_2013_0285.rb +0 -27
  127. data/lib/dawn/kb/cve_2013_0333.rb +0 -28
  128. data/lib/dawn/kb/cve_2013_0334.rb +0 -25
  129. data/lib/dawn/kb/cve_2013_1607.rb +0 -25
  130. data/lib/dawn/kb/cve_2013_1655.rb +0 -65
  131. data/lib/dawn/kb/cve_2013_1656.rb +0 -28
  132. data/lib/dawn/kb/cve_2013_1756.rb +0 -26
  133. data/lib/dawn/kb/cve_2013_1800.rb +0 -26
  134. data/lib/dawn/kb/cve_2013_1801.rb +0 -27
  135. data/lib/dawn/kb/cve_2013_1802.rb +0 -27
  136. data/lib/dawn/kb/cve_2013_1812.rb +0 -27
  137. data/lib/dawn/kb/cve_2013_1821.rb +0 -28
  138. data/lib/dawn/kb/cve_2013_1854.rb +0 -26
  139. data/lib/dawn/kb/cve_2013_1855.rb +0 -25
  140. data/lib/dawn/kb/cve_2013_1856.rb +0 -26
  141. data/lib/dawn/kb/cve_2013_1857.rb +0 -27
  142. data/lib/dawn/kb/cve_2013_1875.rb +0 -27
  143. data/lib/dawn/kb/cve_2013_1898.rb +0 -27
  144. data/lib/dawn/kb/cve_2013_1911.rb +0 -28
  145. data/lib/dawn/kb/cve_2013_1933.rb +0 -27
  146. data/lib/dawn/kb/cve_2013_1947.rb +0 -27
  147. data/lib/dawn/kb/cve_2013_1948.rb +0 -27
  148. data/lib/dawn/kb/cve_2013_2065.rb +0 -29
  149. data/lib/dawn/kb/cve_2013_2090.rb +0 -28
  150. data/lib/dawn/kb/cve_2013_2105.rb +0 -26
  151. data/lib/dawn/kb/cve_2013_2119.rb +0 -27
  152. data/lib/dawn/kb/cve_2013_2512.rb +0 -26
  153. data/lib/dawn/kb/cve_2013_2513.rb +0 -25
  154. data/lib/dawn/kb/cve_2013_2516.rb +0 -26
  155. data/lib/dawn/kb/cve_2013_2615.rb +0 -27
  156. data/lib/dawn/kb/cve_2013_2616.rb +0 -27
  157. data/lib/dawn/kb/cve_2013_2617.rb +0 -28
  158. data/lib/dawn/kb/cve_2013_3221.rb +0 -27
  159. data/lib/dawn/kb/cve_2013_4164.rb +0 -30
  160. data/lib/dawn/kb/cve_2013_4203.rb +0 -25
  161. data/lib/dawn/kb/cve_2013_4389.rb +0 -26
  162. data/lib/dawn/kb/cve_2013_4413.rb +0 -27
  163. data/lib/dawn/kb/cve_2013_4457.rb +0 -29
  164. data/lib/dawn/kb/cve_2013_4478.rb +0 -26
  165. data/lib/dawn/kb/cve_2013_4479.rb +0 -26
  166. data/lib/dawn/kb/cve_2013_4489.rb +0 -28
  167. data/lib/dawn/kb/cve_2013_4491.rb +0 -29
  168. data/lib/dawn/kb/cve_2013_4492.rb +0 -29
  169. data/lib/dawn/kb/cve_2013_4562.rb +0 -27
  170. data/lib/dawn/kb/cve_2013_4593.rb +0 -27
  171. data/lib/dawn/kb/cve_2013_5647.rb +0 -29
  172. data/lib/dawn/kb/cve_2013_5671.rb +0 -26
  173. data/lib/dawn/kb/cve_2013_6414.rb +0 -30
  174. data/lib/dawn/kb/cve_2013_6415.rb +0 -29
  175. data/lib/dawn/kb/cve_2013_6416.rb +0 -29
  176. data/lib/dawn/kb/cve_2013_6417.rb +0 -30
  177. data/lib/dawn/kb/cve_2013_6421.rb +0 -28
  178. data/lib/dawn/kb/cve_2013_6459.rb +0 -28
  179. data/lib/dawn/kb/cve_2013_6460.rb +0 -53
  180. data/lib/dawn/kb/cve_2013_6461.rb +0 -57
  181. data/lib/dawn/kb/cve_2013_7086.rb +0 -27
  182. data/lib/dawn/kb/cve_2014_0036.rb +0 -27
  183. data/lib/dawn/kb/cve_2014_0080.rb +0 -29
  184. data/lib/dawn/kb/cve_2014_0081.rb +0 -27
  185. data/lib/dawn/kb/cve_2014_0082.rb +0 -27
  186. data/lib/dawn/kb/cve_2014_0130.rb +0 -27
  187. data/lib/dawn/kb/cve_2014_1233.rb +0 -27
  188. data/lib/dawn/kb/cve_2014_1234.rb +0 -26
  189. data/lib/dawn/kb/cve_2014_2322.rb +0 -28
  190. data/lib/dawn/kb/cve_2014_2525.rb +0 -59
  191. data/lib/dawn/kb/cve_2014_2538.rb +0 -26
  192. data/lib/dawn/kb/cve_2014_3482.rb +0 -28
  193. data/lib/dawn/kb/cve_2014_3483.rb +0 -28
  194. data/lib/dawn/kb/cve_2014_3916.rb +0 -29
  195. data/lib/dawn/kb/cve_2014_4975.rb +0 -28
  196. data/lib/dawn/kb/cve_2014_7818.rb +0 -27
  197. data/lib/dawn/kb/cve_2014_7819.rb +0 -31
  198. data/lib/dawn/kb/cve_2014_7829.rb +0 -30
  199. data/lib/dawn/kb/cve_2014_8090.rb +0 -30
  200. data/lib/dawn/kb/cve_2014_9490.rb +0 -29
  201. data/lib/dawn/kb/cve_2015_1819.rb +0 -34
  202. data/lib/dawn/kb/cve_2015_1840/cve_2015_1840_a.rb +0 -28
  203. data/lib/dawn/kb/cve_2015_1840/cve_2015_1840_b.rb +0 -28
  204. data/lib/dawn/kb/cve_2015_2963.rb +0 -27
  205. data/lib/dawn/kb/cve_2015_3224.rb +0 -26
  206. data/lib/dawn/kb/cve_2015_3225.rb +0 -28
  207. data/lib/dawn/kb/cve_2015_3226.rb +0 -27
  208. data/lib/dawn/kb/cve_2015_3227.rb +0 -28
  209. data/lib/dawn/kb/cve_2015_3448.rb +0 -29
  210. data/lib/dawn/kb/cve_2015_4020.rb +0 -34
  211. data/lib/dawn/kb/cve_2015_5312.rb +0 -30
  212. data/lib/dawn/kb/cve_2015_7497.rb +0 -32
  213. data/lib/dawn/kb/cve_2015_7498.rb +0 -32
  214. data/lib/dawn/kb/cve_2015_7499.rb +0 -32
  215. data/lib/dawn/kb/cve_2015_7500.rb +0 -32
  216. data/lib/dawn/kb/cve_2015_7519.rb +0 -31
  217. data/lib/dawn/kb/cve_2015_7541.rb +0 -31
  218. data/lib/dawn/kb/cve_2015_7576.rb +0 -35
  219. data/lib/dawn/kb/cve_2015_7577.rb +0 -34
  220. data/lib/dawn/kb/cve_2015_7578.rb +0 -30
  221. data/lib/dawn/kb/cve_2015_7579.rb +0 -30
  222. data/lib/dawn/kb/cve_2015_7581.rb +0 -33
  223. data/lib/dawn/kb/cve_2015_8241.rb +0 -32
  224. data/lib/dawn/kb/cve_2015_8242.rb +0 -32
  225. data/lib/dawn/kb/cve_2015_8317.rb +0 -32
  226. data/lib/dawn/kb/cve_2016_0751.rb +0 -32
  227. data/lib/dawn/kb/cve_2016_0752.rb +0 -35
  228. data/lib/dawn/kb/cve_2016_0753.rb +0 -31
  229. data/lib/dawn/kb/cve_2016_2097.rb +0 -35
  230. data/lib/dawn/kb/cve_2016_2098.rb +0 -35
  231. data/lib/dawn/kb/cve_2016_5697.rb +0 -30
  232. data/lib/dawn/kb/cve_2016_6316.rb +0 -33
  233. data/lib/dawn/kb/cve_2016_6317.rb +0 -32
  234. data/lib/dawn/kb/cve_2016_6582.rb +0 -43
  235. data/lib/dawn/kb/not_revised_code.rb +0 -22
  236. data/lib/dawn/kb/osvdb_105971.rb +0 -29
  237. data/lib/dawn/kb/osvdb_108530.rb +0 -27
  238. data/lib/dawn/kb/osvdb_108563.rb +0 -28
  239. data/lib/dawn/kb/osvdb_108569.rb +0 -28
  240. data/lib/dawn/kb/osvdb_108570.rb +0 -27
  241. data/lib/dawn/kb/osvdb_115654.rb +0 -33
  242. data/lib/dawn/kb/osvdb_116010.rb +0 -30
  243. data/lib/dawn/kb/osvdb_117903.rb +0 -30
  244. data/lib/dawn/kb/osvdb_118579.rb +0 -31
  245. data/lib/dawn/kb/osvdb_118830.rb +0 -32
  246. data/lib/dawn/kb/osvdb_118954.rb +0 -33
  247. data/lib/dawn/kb/osvdb_119878.rb +0 -32
  248. data/lib/dawn/kb/osvdb_119927.rb +0 -33
  249. data/lib/dawn/kb/osvdb_120415.rb +0 -31
  250. data/lib/dawn/kb/osvdb_120857.rb +0 -34
  251. data/lib/dawn/kb/osvdb_121701.rb +0 -30
  252. data/lib/dawn/kb/osvdb_132234.rb +0 -34
  253. data/lib/dawn/kb/owasp_ror_cheatsheet.rb +0 -33
  254. data/lib/dawn/kb/owasp_ror_cheatsheet/check_for_backup_files.rb +0 -18
  255. data/lib/dawn/kb/owasp_ror_cheatsheet/check_for_safe_redirect_and_forward.rb +0 -57
  256. data/lib/dawn/kb/owasp_ror_cheatsheet/command_injection.rb +0 -28
  257. data/lib/dawn/kb/owasp_ror_cheatsheet/csrf.rb +0 -29
  258. data/lib/dawn/kb/owasp_ror_cheatsheet/mass_assignment_in_model.rb +0 -33
  259. data/lib/dawn/kb/owasp_ror_cheatsheet/security_related_headers.rb +0 -35
  260. data/lib/dawn/kb/owasp_ror_cheatsheet/sensitive_files.rb +0 -29
  261. data/lib/dawn/kb/owasp_ror_cheatsheet/session_stored_in_database.rb +0 -31
  262. data/lib/dawn/kb/simpleform_xss_20131129.rb +0 -28
  263. data/lib/dawn/knowledge_base_experimental.rb +0 -245
  264. data/spec/lib/kb/cve_2011_2705_spec.rb +0 -35
  265. data/spec/lib/kb/cve_2011_2930_spec.rb +0 -31
  266. data/spec/lib/kb/cve_2011_3009_spec.rb +0 -25
  267. data/spec/lib/kb/cve_2011_3187_spec.rb +0 -24
  268. data/spec/lib/kb/cve_2011_4319_spec.rb +0 -44
  269. data/spec/lib/kb/cve_2011_5036_spec.rb +0 -95
  270. data/spec/lib/kb/cve_2012_1098_spec.rb +0 -36
  271. data/spec/lib/kb/cve_2012_2139_spec.rb +0 -20
  272. data/spec/lib/kb/cve_2012_2671_spec.rb +0 -23
  273. data/spec/lib/kb/cve_2012_6109_spec.rb +0 -112
  274. data/spec/lib/kb/cve_2012_6684_spec.rb +0 -16
  275. data/spec/lib/kb/cve_2013_0162_spec.rb +0 -23
  276. data/spec/lib/kb/cve_2013_0183_spec.rb +0 -54
  277. data/spec/lib/kb/cve_2013_0184_spec.rb +0 -115
  278. data/spec/lib/kb/cve_2013_0256_spec.rb +0 -34
  279. data/spec/lib/kb/cve_2013_0262_spec.rb +0 -44
  280. data/spec/lib/kb/cve_2013_0263_spec.rb +0 -11
  281. data/spec/lib/kb/cve_2013_0334_spec.rb +0 -35
  282. data/spec/lib/kb/cve_2013_1607_spec.rb +0 -15
  283. data/spec/lib/kb/cve_2013_1655_spec.rb +0 -31
  284. data/spec/lib/kb/cve_2013_1756_spec.rb +0 -23
  285. data/spec/lib/kb/cve_2013_2090_spec.rb +0 -15
  286. data/spec/lib/kb/cve_2013_2105_spec.rb +0 -11
  287. data/spec/lib/kb/cve_2013_2119_spec.rb +0 -27
  288. data/spec/lib/kb/cve_2013_2512_spec.rb +0 -15
  289. data/spec/lib/kb/cve_2013_2513_spec.rb +0 -15
  290. data/spec/lib/kb/cve_2013_2516_spec.rb +0 -15
  291. data/spec/lib/kb/cve_2013_4203_spec.rb +0 -15
  292. data/spec/lib/kb/cve_2013_4413_spec.rb +0 -16
  293. data/spec/lib/kb/cve_2013_4489_spec.rb +0 -63
  294. data/spec/lib/kb/cve_2013_4491_spec.rb +0 -16
  295. data/spec/lib/kb/cve_2013_4593_spec.rb +0 -16
  296. data/spec/lib/kb/cve_2013_5647_spec.rb +0 -19
  297. data/spec/lib/kb/cve_2013_5671_spec.rb +0 -27
  298. data/spec/lib/kb/cve_2013_6414_spec.rb +0 -26
  299. data/spec/lib/kb/cve_2013_6416_spec.rb +0 -31
  300. data/spec/lib/kb/cve_2013_6459_spec.rb +0 -15
  301. data/spec/lib/kb/cve_2013_7086_spec.rb +0 -22
  302. data/spec/lib/kb/cve_2014_0036_spec.rb +0 -15
  303. data/spec/lib/kb/cve_2014_0080_spec.rb +0 -33
  304. data/spec/lib/kb/cve_2014_0081_spec.rb +0 -50
  305. data/spec/lib/kb/cve_2014_0082_spec.rb +0 -52
  306. data/spec/lib/kb/cve_2014_0130_spec.rb +0 -19
  307. data/spec/lib/kb/cve_2014_1233_spec.rb +0 -15
  308. data/spec/lib/kb/cve_2014_1234_spec.rb +0 -16
  309. data/spec/lib/kb/cve_2014_2322_spec.rb +0 -15
  310. data/spec/lib/kb/cve_2014_2538_spec.rb +0 -15
  311. data/spec/lib/kb/cve_2014_3482_spec.rb +0 -15
  312. data/spec/lib/kb/cve_2014_3483_spec.rb +0 -27
  313. data/spec/lib/kb/cve_2014_7818_spec.rb +0 -42
  314. data/spec/lib/kb/cve_2014_7819_spec.rb +0 -139
  315. data/spec/lib/kb/cve_2014_7829_spec.rb +0 -50
  316. data/spec/lib/kb/cve_2014_9490_spec.rb +0 -17
  317. data/spec/lib/kb/cve_2015_1819_spec.rb +0 -16
  318. data/spec/lib/kb/cve_2015_1840_spec.rb +0 -39
  319. data/spec/lib/kb/cve_2015_2963_spec.rb +0 -17
  320. data/spec/lib/kb/cve_2015_3224_spec.rb +0 -16
  321. data/spec/lib/kb/cve_2015_3225_spec.rb +0 -27
  322. data/spec/lib/kb/cve_2015_3226_spec.rb +0 -35
  323. data/spec/lib/kb/cve_2015_3227_spec.rb +0 -31
  324. data/spec/lib/kb/cve_2015_3448_spec.rb +0 -16
  325. data/spec/lib/kb/cve_2015_4020_spec.rb +0 -24
  326. data/spec/lib/kb/cve_2015_5312_spec.rb +0 -31
  327. data/spec/lib/kb/cve_2015_7497_spec.rb +0 -31
  328. data/spec/lib/kb/cve_2015_7498_spec.rb +0 -31
  329. data/spec/lib/kb/cve_2015_7499_spec.rb +0 -31
  330. data/spec/lib/kb/cve_2015_7500_spec.rb +0 -31
  331. data/spec/lib/kb/cve_2015_7519_spec.rb +0 -23
  332. data/spec/lib/kb/cve_2015_7541_spec.rb +0 -15
  333. data/spec/lib/kb/cve_2015_7576_spec.rb +0 -51
  334. data/spec/lib/kb/cve_2015_7577_spec.rb +0 -63
  335. data/spec/lib/kb/cve_2015_7578_spec.rb +0 -15
  336. data/spec/lib/kb/cve_2015_7579_spec.rb +0 -23
  337. data/spec/lib/kb/cve_2015_7581_spec.rb +0 -51
  338. data/spec/lib/kb/cve_2015_8241_spec.rb +0 -31
  339. data/spec/lib/kb/cve_2015_8242_spec.rb +0 -31
  340. data/spec/lib/kb/cve_2015_8317_spec.rb +0 -31
  341. data/spec/lib/kb/cve_2016_0751_spec.rb +0 -55
  342. data/spec/lib/kb/cve_2016_0752_spec.rb +0 -51
  343. data/spec/lib/kb/cve_2016_0753_spec.rb +0 -51
  344. data/spec/lib/kb/cve_2016_2097_spec.rb +0 -35
  345. data/spec/lib/kb/cve_2016_2098_spec.rb +0 -59
  346. data/spec/lib/kb/cve_2016_5697_spec.rb +0 -15
  347. data/spec/lib/kb/cve_2016_6316_spec.rb +0 -44
  348. data/spec/lib/kb/cve_2016_6317_spec.rb +0 -35
  349. data/spec/lib/kb/cve_2016_6582_spec.rb +0 -29
  350. data/spec/lib/kb/osvdb_105971_spec.rb +0 -15
  351. data/spec/lib/kb/osvdb_108530_spec.rb +0 -22
  352. data/spec/lib/kb/osvdb_108563_spec.rb +0 -18
  353. data/spec/lib/kb/osvdb_108569_spec.rb +0 -17
  354. data/spec/lib/kb/osvdb_108570_spec.rb +0 -17
  355. data/spec/lib/kb/osvdb_115654_spec.rb +0 -15
  356. data/spec/lib/kb/osvdb_116010_spec.rb +0 -15
  357. data/spec/lib/kb/osvdb_117903_spec.rb +0 -23
  358. data/spec/lib/kb/osvdb_118579_spec.rb +0 -8
  359. data/spec/lib/kb/osvdb_118830_spec.rb +0 -16
  360. data/spec/lib/kb/osvdb_118954_spec.rb +0 -20
  361. data/spec/lib/kb/osvdb_119878_spec.rb +0 -92
  362. data/spec/lib/kb/osvdb_119927_spec.rb +0 -16
  363. data/spec/lib/kb/osvdb_120415_spec.rb +0 -16
  364. data/spec/lib/kb/osvdb_120857_spec.rb +0 -32
  365. data/spec/lib/kb/osvdb_121701_spec.rb +0 -15
  366. data/spec/lib/kb/osvdb_132234_spec.rb +0 -15
@@ -0,0 +1,103 @@
1
+ require 'thor'
2
+
3
+ module Dawn
4
+ module Cli
5
+
6
+ # This class is responsible for the "dawn kb" command and related
7
+ # subcommands.
8
+ class Kb < Thor
9
+ desc "search", "Searches the knowledge base for a given security test"
10
+ def search(string)
11
+ kb = Dawn::KnowledgeBase.instance
12
+ kb.find(string)
13
+ end
14
+
15
+ desc "status", "Checks the status of the knowledge base"
16
+ def status
17
+ $logger.helo APPNAME, Dawn::VERSION
18
+ Dawn::KnowledgeBase.path="/home/thesp0nge/src/hacking/dawnscanner/db"
19
+ Dawn::KnowledgeBase.enabled_checks=[:bulletin, :generic_check]
20
+ kb = Dawn::KnowledgeBase.instance
21
+ kb.load
22
+ if kb.is_packed?
23
+ $logger.error "The knowledge base is packed. It must be unpacked with the 'unpack' command before it can be used"
24
+ else
25
+ if kb.is_valid?
26
+ $logger.info "Good Knowledge base found"
27
+ else
28
+ $logger.error "Invalid knowledge base found"
29
+ end
30
+ end
31
+ $logger.bye
32
+ Kernel.exit(0)
33
+ end
34
+ end
35
+
36
+ class DawnCli < Thor
37
+ class_option :verbose, :type=>:boolean
38
+
39
+ map %w[--version -v] => :__print_version
40
+
41
+ desc "--version, -v", "Prints the dawnscanner version"
42
+ def __print_version
43
+ puts Dawn::VERSION
44
+ Kernel.exit(0)
45
+ end
46
+
47
+ desc "kb SUBCOMMAND ... ARGS", "Interacts with the knowledge base"
48
+ subcommand "kb", Dawn::Cli::Kb
49
+
50
+ desc "scan", "scans a folder for security issues"
51
+ option :gemfile, :type=>:boolean
52
+ option :exit_on_warn, :type=>:boolean
53
+ option :debug, :type=>:boolean
54
+ option :verbose, :type=>:boolean
55
+ option :count, :type=>:boolean
56
+ option :output
57
+
58
+ def scan(target)
59
+ $logger.helo APPNAME, Dawn::VERSION
60
+ $logger.debug "scanning #{target}"
61
+ trap("INT") { $logger.die('[INTERRUPTED]') }
62
+
63
+ $logger.die("invalid directory (#{target})") unless Dawn::Core.is_good_target?(target)
64
+
65
+ $debug = true if options[:debug]
66
+ $verbose = true if options[:verbose]
67
+
68
+
69
+ engine = Dawn::GemfileLock.new(target) if options[:gemfile]
70
+
71
+ if engine.nil?
72
+ $logger.error("MVC detection failure. Please open an issue at https://github.com/thesp0nge/dawnscanner/issues")
73
+ $logger.die('ruby framework auto detect failed.')
74
+ end
75
+
76
+ if options[:exit_on_warn]
77
+ Kernel.at_exit do
78
+ if engine.count_vulnerabilities != 0
79
+ Kernel.exit(engine.count_vulnerabilities)
80
+ end
81
+ end
82
+ end
83
+
84
+
85
+ engine.load_knowledge_base
86
+ ret = engine.apply_all
87
+ if options[:output]
88
+ STDERR.puts (ret)? engine.vulnerabilities.count : "-1" unless options[:output] == "json"
89
+ STDERR.puts (ret)? {:status=>"OK", :vulnerabilities_count=>engine.count_vulnerabilities}.to_json : {:status=>"KO", :vulnerabilities_count=>-1}.to_json if options[:output] == "json"
90
+
91
+ # r.do_save({:target=>engine.target, :scan_started=>engine.scan_start, :scan_duration => engine.scan_time.round(3), :issues_found=>engine.vulnerabilities.count, :output_dir=>engine.output_dir_name, :scan_status=>:completed})
92
+ $logger.bye
93
+ Kernel.exit(0)
94
+ end
95
+
96
+ Dawn::Reporter.new({:engine=>engine, :apply_all_code=>ret}).report
97
+
98
+ Kernel.exit(0)
99
+
100
+ end
101
+ end
102
+ end
103
+ end
@@ -61,8 +61,6 @@ module Dawn
61
61
  @applied = []
62
62
  @reflected_xss = []
63
63
  @engine_error = false
64
- @debug = false
65
- @debug = options[:debug] unless options[:debug].nil?
66
64
  @applied_checks = 0
67
65
  @skipped_checks = 0
68
66
  @gemfile_lock_sudo = false
@@ -83,7 +81,6 @@ module Dawn
83
81
  require 'logger'
84
82
  $logger = Logger.new(STDOUT)
85
83
  $logger.helo "dawn-engine", Dawn::VERSION
86
-
87
84
  end
88
85
  $logger.warn "pattern matching security checks are disabled for Gemfile.lock scan" if @name == "Gemfile.lock"
89
86
  $logger.warn "combo security checks are disabled for Gemfile.lock scan" if @name == "Gemfile.lock"
@@ -169,13 +166,13 @@ module Dawn
169
166
 
170
167
  def load_knowledge_base(enabled_checks=[])
171
168
  debug_me("load_knowledge_base called. Enabled checks are: #{enabled_checks}")
172
- if @name == "Gemfile.lock"
173
- @checks = Dawn::KnowledgeBase.new({:enabled_checks=>enabled_checks}).all if @force.empty?
174
- @checks = Dawn::KnowledgeBase.new({:enabled_checks=>enabled_checks}).all_by_mvc(@force) unless @force.empty?
175
- else
176
- @checks = Dawn::KnowledgeBase.new({:enabled_checks=>enabled_checks}).all_by_mvc(@name)
177
169
 
178
- end
170
+ Dawn::KnowledgeBase.path="/home/thesp0nge/src/hacking/dawnscanner/db"
171
+ Dawn::KnowledgeBase.enabled_checks=[:bulletin, :generic_check]
172
+ kb = Dawn::KnowledgeBase.instance
173
+ $logger.warn "KB path is forced @ /home/thesp0nge/src/hacking/dawnscanner/db"
174
+
175
+ @checks=kb.load
179
176
  debug_me("#{@checks.count} checks loaded")
180
177
  @checks
181
178
  end
@@ -306,6 +303,7 @@ module Dawn
306
303
  return false
307
304
  end
308
305
  if @checks.empty?
306
+ $logger.warn "no security checks found. This is strange"
309
307
  @scan_stop = Time.now
310
308
  debug_me("SCAN STOPPED: #{@scan_stop}")
311
309
  return false
@@ -373,13 +371,13 @@ module Dawn
373
371
  def get_rvm_ruby_ver
374
372
  return {:version=>"", :patchlevel=>""} unless File.exist?(File.join(@target, ".ruby-version"))
375
373
  hash = File.read(File.join(@target, '.ruby-version')).split('-')
376
- return {:version=>hash[0], :patchlevel=>hash[1]}
374
+ return {:version=>hash[0].chop, :patchlevel=>hash[1]}
377
375
  end
378
376
  def _do_apply(check)
379
377
  unless ((check.kind == Dawn::KnowledgeBase::PATTERN_MATCH_CHECK || check.kind == Dawn::KnowledgeBase::COMBO_CHECK ) && @gemfile_lock_sudo)
380
378
 
381
379
  @applied << { :name => name }
382
- debug_me "applying check #{check.name}"
380
+ debug_me "applying check #{check.name} - #{check.kind}"
383
381
  @applied_checks += 1
384
382
 
385
383
  check.ruby_version = @ruby_version[:version]
@@ -2,8 +2,8 @@ module Dawn
2
2
  class GemfileLock
3
3
  include Dawn::Engine
4
4
 
5
- def initialize(dir = "./", filename = "", guessed_mvc)
6
- super(dir, "Gemfile.lock", {:gemfile_name=>filename, :guessed_mvc=>guessed_mvc})
5
+ def initialize(dir = "./")
6
+ super(dir, "Gemfile.lock", {:gemfile_name=>"Gemfile.lock", :guessed_mvc=>Dawn::Core.guess_mvc(File.join(dir, "Gemfile.lock"))})
7
7
  end
8
8
 
9
9
  end
@@ -239,6 +239,7 @@ module Dawn
239
239
 
240
240
  ret
241
241
  end
242
+
242
243
  end
243
244
  end
244
245
  end
@@ -1,6 +1,6 @@
1
1
  module Dawn
2
2
  module Kb
3
- module ComboCheck
3
+ class ComboCheck
4
4
  include BasicCheck
5
5
 
6
6
  attr_reader :checks
@@ -1,6 +1,6 @@
1
1
  module Dawn
2
2
  module Kb
3
- module DependencyCheck
3
+ class DependencyCheck
4
4
  include BasicCheck
5
5
 
6
6
  attr_accessor :dependencies
@@ -2,7 +2,7 @@ require 'ptools'
2
2
 
3
3
  module Dawn
4
4
  module Kb
5
- module PatternMatchCheck
5
+ class PatternMatchCheck
6
6
  include BasicCheck
7
7
 
8
8
 
@@ -1,6 +1,6 @@
1
1
  module Dawn
2
2
  module Kb
3
- module RubyVersionCheck
3
+ class RubyVersionCheck
4
4
  include BasicCheck
5
5
  # Array of hashes in the {:engine=>"ruby", :version=>"1.9.3", :patchlevel=>"p342"} form
6
6
  attr_accessor :safe_rubies
@@ -29,9 +29,9 @@ module Dawn
29
29
  ve = self.is_same_version?(detected_ruby[:version], vv_a)
30
30
  vp = is_vulnerable_patchlevel?(detected_ruby[:version], detected_ruby[:patchlevel])
31
31
 
32
- debug_me("#{__FILE__}@#{__LINE__}: check: #{self.name}, engine is vulnerable?=#{vengine}, version is vulnerable?=#{vv}, is same version?=#{ve}, is_vulnerable_patchlevel?=#{vp}->#{vv && vengine}, #{(ve && vp && vengine )}")
33
- debug_me("#{__FILE__}@#{__LINE__}: safe ruby is: #{@safe_rubies}")
34
- debug_me("#{__FILE__}@#{__LINE__}: detected ruby is: #{@detected_ruby}")
32
+ debug_verbosely("#{__FILE__}@#{__LINE__}: check: #{self.name}, engine is vulnerable?=#{vengine}, version is vulnerable?=#{vv}, is same version?=#{ve}, is_vulnerable_patchlevel?=#{vp}->#{vv && vengine}, #{(ve && vp && vengine )}")
33
+ debug_verbosely("#{__FILE__}@#{__LINE__}: safe ruby is: #{@safe_rubies}")
34
+ debug_verbosely("#{__FILE__}@#{__LINE__}: detected ruby is: #{@detected_ruby}")
35
35
 
36
36
 
37
37
 
@@ -42,7 +42,7 @@ module Dawn
42
42
  @status = (ve && vp && vengine )
43
43
  end
44
44
 
45
- debug_me("STATUS:#{@status}")
45
+ debug_verbosely("STATUS:#{@status}")
46
46
  self.evidences << "#{@detected_ruby[:engine]} v#{@detected_ruby[:version]}-#{@detected_ruby[:patchlevel]} detected" if @status
47
47
  return @status
48
48
 
@@ -58,7 +58,7 @@ module Dawn
58
58
 
59
59
  def is_same_version?(target, fixes = [])
60
60
  fixes.each do |f|
61
- debug_me("F=#{f}, TARGET=#{target}")
61
+ debug_verbosely("F=#{f}, TARGET=#{target}")
62
62
  return true if f == target
63
63
  end
64
64
  false
@@ -66,23 +66,24 @@ module Dawn
66
66
 
67
67
  def is_vulnerable_patchlevel?(version, patchlevel)
68
68
  fixes = []
69
- debug_me "is_vulnerable_patchlevel? called with VERSION=#{version} and PLEVEL=#{patchlevel}"
69
+ debug_verbosely "is_vulnerable_patchlevel? called with VERSION=#{version} and PLEVEL=#{patchlevel}"
70
70
  @safe_rubies.each do |ss|
71
71
  fixes << ss[:patchlevel].split("p")[1].to_i if ss[:version] == version
72
72
  end
73
73
 
74
- debug_me "FIXES IS EMPTY" if fixes.empty?
75
- debug_me "FIXES LIST IS #{fixes}" unless fixes.empty?
74
+ debug_verbosely "FIXES IS EMPTY" if fixes.empty?
75
+ debug_verbosely "FIXES LIST IS #{fixes}" unless fixes.empty?
76
76
  return true if fixes.empty?
77
77
 
78
78
  t = patchlevel.split("p")[1].to_i if patchlevel.include? 'p'
79
79
  t = patchlevel.to_i unless patchlevel.include? 'p'
80
80
  fixes.each do |f|
81
- debug_me "PATCHLEVEL FIXES = #{f}, PATCHLEVEL TARGET = #{t}"
81
+ debug_verbosely "PATCHLEVEL FIXES = #{f}, PATCHLEVEL TARGET = #{t}"
82
82
  return true if f > t
83
83
  end
84
84
  false
85
85
  end
86
+
86
87
  end
87
88
  end
88
89
  end
@@ -1,7 +1,7 @@
1
1
  # This module handles security checks for RubyGems framework.
2
2
  module Dawn
3
3
  module Kb
4
- module GemCheck
4
+ class RubygemCheck
5
5
  include BasicCheck
6
6
 
7
7
  attr_accessor :safe_versions
@@ -23,16 +23,16 @@ module Dawn
23
23
  @save_major ||= options[:save_major]
24
24
  @debug ||= options[:debug]
25
25
  @enable_warning ||= options[:enable_warning]
26
- debug_me "VersionCheck initialized"
26
+ debug_verbosely "VersionCheck initialized"
27
27
  end
28
28
 
29
29
  def vuln?
30
- debug_me "Detected version is #{@detected}"
31
- debug_me "Safe versions array is #{@safe}"
32
- debug_me "Deprecated versions array is #{@deprecated}. I'll mark them as vulnerable" unless @deprecated.nil?
33
- debug_me "Excluded versions array is #{@excluded}. I'll mark them as not vulnerable" unless @excluded.nil?
34
- debug_me "SAVE_MINOR FLAG = #{@save_minor}"
35
- debug_me "SAVE_MAJOR FLAG = #{@save_major}"
30
+ debug_verbosely "Detected version is #{@detected}"
31
+ debug_verbosely "Safe versions array is #{@safe}"
32
+ debug_verbosely "Deprecated versions array is #{@deprecated}. I'll mark them as vulnerable" unless @deprecated.nil?
33
+ debug_verbosely "Excluded versions array is #{@excluded}. I'll mark them as not vulnerable" unless @excluded.nil?
34
+ debug_verbosely "SAVE_MINOR FLAG = #{@save_minor}"
35
+ debug_verbosely "SAVE_MAJOR FLAG = #{@save_major}"
36
36
 
37
37
  @status = :deprecated if is_detected_deprecated?
38
38
  return debug_me_and_return_false("detected version #{detected} is marked to be excluded for vulnerable ones") if is_detected_excluded?
@@ -54,12 +54,12 @@ module Dawn
54
54
  break
55
55
  end
56
56
 
57
- debug_me "vuln?: limited check_versions: #{check_versions.inspect}"
57
+ debug_verbosely "vuln?: limited check_versions: #{check_versions.inspect}"
58
58
  check_versions ||= @safe
59
- debug_me "vuln?: fallback check_versions: #{check_versions.inspect}"
59
+ debug_verbosely "vuln?: fallback check_versions: #{check_versions.inspect}"
60
60
 
61
61
  check_versions.sort.each do |s|
62
- debug_me "vuln?: evaluating #{@detected} against save version: #{s}"
62
+ debug_verbosely "vuln?: evaluating #{@detected} against save version: #{s}"
63
63
 
64
64
  @save_minor_fix = save_minor_fix
65
65
  @save_major_fix = save_major_fix
@@ -67,7 +67,7 @@ module Dawn
67
67
 
68
68
  vuln = is_vulnerable_version?(s, @detected)
69
69
 
70
- debug_me "DETECTED #{@detected} is marked VULN=#{vuln} against #{s} ( SAVE_MINOR_FIX=#{@save_minor_fix} SAVE_MAJOR_FIX=#{@save_major_fix})"
70
+ debug_verbosely "DETECTED #{@detected} is marked VULN=#{vuln} against #{s} ( SAVE_MINOR_FIX=#{@save_minor_fix} SAVE_MAJOR_FIX=#{@save_major_fix})"
71
71
  return true if vuln
72
72
  end
73
73
 
@@ -84,7 +84,7 @@ module Dawn
84
84
  def is_detected_highest?
85
85
  higher= @detected
86
86
  @safe.sort.each do |s|
87
- debug_me("higher is #{higher}")
87
+ debug_verbosely("higher is #{higher}")
88
88
  higher=s if is_higher?(s, higher)
89
89
  end
90
90
  return (higher == @detected)
@@ -137,7 +137,7 @@ module Dawn
137
137
  ret = ver && beta && rc unless same
138
138
  ret = beta && rc if same
139
139
 
140
- debug_me("is_higher? a=#{a}, b=#{b} VER=#{ver} - BETA=#{beta} - RC=#{rc} - SAME=#{same} - a>b? = (#{ret})")
140
+ debug_verbosely("is_higher? a=#{a}, b=#{b} VER=#{ver} - BETA=#{beta} - RC=#{rc} - SAME=#{same} - a>b? = (#{ret})")
141
141
  return ret
142
142
  end
143
143
 
@@ -146,7 +146,7 @@ module Dawn
146
146
  dva = version_string_to_array(@detected)[:version]
147
147
  @safe.sort.each do |s|
148
148
  sva = version_string_to_array(s)[:version]
149
- debug_me "is_there_an_higher_major_version? DVA=#{dva} - SVA=#{sva}"
149
+ debug_verbosely "is_there_an_higher_major_version? DVA=#{dva} - SVA=#{sva}"
150
150
  return debug_me_and_return_true("is_there_an_higher_major_version? is returning true for #{@detected}") if dva[0] < sva[0]
151
151
  end
152
152
  return debug_me_and_return_false("is_there_an_higher_major_version? is returning false")
@@ -188,8 +188,8 @@ module Dawn
188
188
  sva = version_string_to_array(s)[:version]
189
189
  sM = is_same_major?(sva, dva)
190
190
  sm = is_same_minor?(sva, dva)
191
- debug_me("save_minor_fix: SVA=#{sva};DVA=#{dva};SAME_MAJOR? = #{sM}; SAME_MINOR?=#{sm}; ( dva[2] >= sva[2] )=#{(dva[2] >= sva[2])}")
192
- debug_me("save_minor_fix: is_there_higher_minor_version? = #{hm}")
191
+ debug_verbosely("save_minor_fix: SVA=#{sva};DVA=#{dva};SAME_MAJOR? = #{sM}; SAME_MINOR?=#{sm}; ( dva[2] >= sva[2] )=#{(dva[2] >= sva[2])}")
192
+ debug_verbosely("save_minor_fix: is_there_higher_minor_version? = #{hm}")
193
193
  return true if sM and sm and dva[2] >= sva[2] && hm
194
194
  return true if sM and hm
195
195
  end
@@ -229,7 +229,7 @@ module Dawn
229
229
  return (safe_version[2] > detected_version[2])
230
230
  end
231
231
  def is_vulnerable_aux_patch?(safe_version, detected_version)
232
- debug_me "is_vulnerable_aux_patch?: SV[3]=#{safe_version[3]}, DV[3]=#{detected_version[3]}"
232
+ debug_verbosely "is_vulnerable_aux_patch?: SV[3]=#{safe_version[3]}, DV[3]=#{detected_version[3]}"
233
233
  return true if detected_version[3].nil? and ! safe_version[3].nil?
234
234
  return false if safe_version[3].nil? || detected_version[3].nil?
235
235
  return (safe_version[3] > detected_version[3])
@@ -272,11 +272,11 @@ module Dawn
272
272
  # eg. in case of a beta release, the array is [5,0,0,1] meaning
273
273
  # 5.0.0.beta1. Of course it must be handled in a different way than
274
274
  # 5.0.0.1 release that it will result in the same array
275
- debug_me "is_same_version? with limit=TRUE"
275
+ debug_verbosely "is_same_version? with limit=TRUE"
276
276
  ret = true if (safe_version_array[0] == detected_version_array[0]) && (safe_version_array[1] == detected_version_array[1]) && (safe_version_array[2] == detected_version_array[2])
277
277
  end
278
278
 
279
- debug_me "is_same_version? SVA=#{safe_version_array} DVA=#{detected_version_array} RET=#{ret}"
279
+ debug_verbosely "is_same_version? SVA=#{safe_version_array} DVA=#{detected_version_array} RET=#{ret}"
280
280
 
281
281
  return ret
282
282
  end
@@ -293,7 +293,7 @@ module Dawn
293
293
  # if the safe_version_beta is 0 then the detected_version_beta is
294
294
  # vulnerable by design, since the safe version is a stable and we
295
295
  # detected a beta.
296
- debug_me("is_vulnerable_beta?: safe_version_beta=#{safe_version_beta} - detected_version_beta=#{detected_version_beta}")
296
+ debug_verbosely("is_vulnerable_beta?: safe_version_beta=#{safe_version_beta} - detected_version_beta=#{detected_version_beta}")
297
297
  return debug_me_and_return_false("is_vulnerable_beta? = FALSE") if safe_version_beta != -1 and detected_version_beta == -1
298
298
  return debug_me_and_return_true("is_vulnerable_beta? = TRUE") if safe_version_beta == -1 and detected_version_beta != -1
299
299
  return debug_me_and_return_true("is_vulnerable_beta? = TRUE") if safe_version_beta == 0 && detected_version_beta != -1
@@ -317,7 +317,7 @@ module Dawn
317
317
  # if the safe_version_rc is 0 then the detected_version_rc is
318
318
  # vulnerable by design, since the safe version is a stable and we
319
319
  # detected a rc.
320
- debug_me "entering is_vulnerable_rc?: s=#{safe_version_rc}, d=#{detected_version_rc}"
320
+ debug_verbosely "entering is_vulnerable_rc?: s=#{safe_version_rc}, d=#{detected_version_rc}"
321
321
  return debug_me_and_return_false("is_vulnerable_rc? = FALSE") if detected_version_rc == -1
322
322
 
323
323
  return debug_me_and_return_false("is_vulnerable_rc? = FALSE") if safe_version_rc != -1 and detected_version_rc == -1
@@ -357,8 +357,8 @@ module Dawn
357
357
  def is_vulnerable_version?(safe_version, detected_version)
358
358
  sva = version_string_to_array(safe_version)
359
359
  dva = version_string_to_array(detected_version)
360
- debug_me("SVA=#{sva.inspect}")
361
- debug_me("DVA=#{dva.inspect}")
360
+ debug_verbosely("SVA=#{sva.inspect}")
361
+ debug_verbosely("DVA=#{dva.inspect}")
362
362
  safe_version_array = sva[:version]
363
363
  detected_version_array = dva[:version]
364
364
 
@@ -370,7 +370,7 @@ module Dawn
370
370
  patch = is_vulnerable_patch?(safe_version_array, detected_version_array)
371
371
  aux_patch = is_vulnerable_aux_patch?(safe_version_array, detected_version_array)
372
372
 
373
- debug_me "is_vulnerable_version? SAVE_VERSION=#{safe_version},DETECTED=#{detected_version} -> IS_VULN_MAJOR?=#{major} IS_VULN_MINOR?=#{minor} IS_VULN_PATCH?=#{patch} IS_VULN_AUX_PATCH=#{aux_patch} SAVE_MINOR_FIX=#{@save_minor_fix} SAVE_MAJOR_FIX=#{@save_major_fix}"
373
+ debug_verbosely "is_vulnerable_version? SAVE_VERSION=#{safe_version},DETECTED=#{detected_version} -> IS_VULN_MAJOR?=#{major} IS_VULN_MINOR?=#{minor} IS_VULN_PATCH?=#{patch} IS_VULN_AUX_PATCH=#{aux_patch} SAVE_MINOR_FIX=#{@save_minor_fix} SAVE_MAJOR_FIX=#{@save_major_fix}"
374
374
 
375
375
  return debug_me_and_return_false("#{detected_version} doesn't have a vulnerable MAJOR number") if is_higher_major?(detected_version, safe_version) #and minor and patch
376
376
 
@@ -417,7 +417,7 @@ module Dawn
417
417
  # I'll support also nonsense checks.
418
418
 
419
419
  $logger.warn "Setting the predicate #{dep} will mark all versions as deprecated" unless self.enable_warning.nil?
420
- debug_me "You kindly mark #{detected_version} as deprecated with this predicate #{dep}"
420
+ debug_verbosely "You kindly mark #{detected_version} as deprecated with this predicate #{dep}"
421
421
  return true
422
422
  end
423
423
 
@@ -1,3 +1,14 @@
1
+ require 'singleton'
2
+
3
+ # For HTTPS communication to check for KB updates and to fetch them
4
+ require 'net/http'
5
+ require 'uri'
6
+
7
+ require 'yaml'
8
+ require 'digest'
9
+
10
+ require 'date'
11
+
1
12
  # Core KB
2
13
  require "dawn/kb/basic_check"
3
14
  require "dawn/kb/pattern_match_check"
@@ -7,298 +18,51 @@ require "dawn/kb/operating_system_check"
7
18
  require "dawn/kb/combo_check"
8
19
  require "dawn/kb/version_check"
9
20
  require "dawn/kb/deprecation_check"
10
- require "dawn/kb/gem_check"
11
-
12
- # Q&A related checks
13
- ## Not revised code
14
- require "dawn/kb/not_revised_code"
15
-
16
- ## Owasp ROR Cheatsheet
17
- require 'dawn/kb/owasp_ror_cheatsheet/command_injection'
18
- require 'dawn/kb/owasp_ror_cheatsheet/csrf'
19
- require 'dawn/kb/owasp_ror_cheatsheet/session_stored_in_database'
20
- require 'dawn/kb/owasp_ror_cheatsheet/mass_assignment_in_model'
21
- require 'dawn/kb/owasp_ror_cheatsheet/security_related_headers'
22
- require 'dawn/kb/owasp_ror_cheatsheet/check_for_safe_redirect_and_forward'
23
- require 'dawn/kb/owasp_ror_cheatsheet/sensitive_files'
24
-
25
- # Security checks with no or pending CVE
26
-
27
- # A XSS issue on Simple Form gem reported by Rafael Mendonça França on
28
- # November, 29 2013
29
- #
30
- # https://groups.google.com/forum/#!topic/ruby-security-ann/flHbLMb07tE
31
- require "dawn/kb/simpleform_xss_20131129"
32
-
33
- # CVE - 2004
34
- require "dawn/kb/cve_2004_0755"
35
- require "dawn/kb/cve_2004_0983"
36
-
37
- # CVE - 2005
38
- require "dawn/kb/cve_2005_1992"
39
- require "dawn/kb/cve_2005_2337"
40
-
41
- # CVE - 2006
42
- require "dawn/kb/cve_2006_1931"
43
- require "dawn/kb/cve_2006_2582"
44
- require "dawn/kb/cve_2006_3694"
45
- require "dawn/kb/cve_2006_4112"
46
- require "dawn/kb/cve_2006_5467"
47
- require "dawn/kb/cve_2006_6303"
48
- require "dawn/kb/cve_2006_6852"
49
- require "dawn/kb/cve_2006_6979"
50
-
51
- # CVE - 2007
52
- require "dawn/kb/cve_2007_0469"
53
- require "dawn/kb/cve_2007_5162"
54
- require "dawn/kb/cve_2007_5379"
55
- require "dawn/kb/cve_2007_5380"
56
- require "dawn/kb/cve_2007_5770"
57
- require "dawn/kb/cve_2007_6077"
58
- require "dawn/kb/cve_2007_6612"
59
-
60
- # CVE - 2008
61
-
62
- require "dawn/kb/cve_2008_1145"
63
- require "dawn/kb/cve_2008_1891"
64
- require "dawn/kb/cve_2008_2376"
65
- require "dawn/kb/cve_2008_2662"
66
- require "dawn/kb/cve_2008_2663"
67
- require "dawn/kb/cve_2008_2664"
68
- require "dawn/kb/cve_2008_2725"
69
- require "dawn/kb/cve_2008_3655"
70
- require "dawn/kb/cve_2008_3657"
71
- require "dawn/kb/cve_2008_3790"
72
- require "dawn/kb/cve_2008_3905"
73
- require "dawn/kb/cve_2008_4094"
74
- require "dawn/kb/cve_2008_4310"
75
- require "dawn/kb/cve_2008_5189"
76
- require "dawn/kb/cve_2008_7248"
77
-
78
- # CVE - 2009
79
- require "dawn/kb/cve_2009_4078"
80
- require "dawn/kb/cve_2009_4124"
81
- require "dawn/kb/cve_2009_4214"
82
-
83
- # CVE - 2010
84
- require "dawn/kb/cve_2010_1330"
85
- require "dawn/kb/cve_2010_2489"
86
- require "dawn/kb/cve_2010_3933"
87
-
88
- # CVE - 2011
89
- require "dawn/kb/cve_2011_0188"
90
- require "dawn/kb/cve_2011_0446"
91
- require "dawn/kb/cve_2011_0447"
92
- require "dawn/kb/cve_2011_0739"
93
- require "dawn/kb/cve_2011_0995"
94
- require "dawn/kb/cve_2011_1004"
95
- require "dawn/kb/cve_2011_1005"
96
- require "dawn/kb/cve_2011_2197"
97
- require "dawn/kb/cve_2011_2686"
98
- require "dawn/kb/cve_2011_2705"
99
- require "dawn/kb/cve_2011_2929"
100
- require "dawn/kb/cve_2011_2930"
101
- require "dawn/kb/cve_2011_2931"
102
- require "dawn/kb/cve_2011_2932"
103
- require "dawn/kb/cve_2011_3009"
104
- require "dawn/kb/cve_2011_3186"
105
- require "dawn/kb/cve_2011_3187"
106
- require "dawn/kb/cve_2011_4319"
107
- require "dawn/kb/cve_2011_4815"
108
- require "dawn/kb/cve_2011_5036"
109
-
110
- # CVE - 2012
111
- require "dawn/kb/cve_2012_1098"
112
- require "dawn/kb/cve_2012_1099"
113
- require "dawn/kb/cve_2012_1241"
114
- require "dawn/kb/cve_2012_2139"
115
- require "dawn/kb/cve_2012_2140"
116
- require "dawn/kb/cve_2012_2660"
117
- require "dawn/kb/cve_2012_2661"
118
- require "dawn/kb/cve_2012_2671"
119
- require "dawn/kb/cve_2012_2694"
120
- require "dawn/kb/cve_2012_2695"
121
- require "dawn/kb/cve_2012_3424"
122
- require "dawn/kb/cve_2012_3463"
123
- require "dawn/kb/cve_2012_3464"
124
- require "dawn/kb/cve_2012_3465"
125
- require "dawn/kb/cve_2012_4464"
126
- require "dawn/kb/cve_2012_4466"
127
- require "dawn/kb/cve_2012_4481"
128
- require "dawn/kb/cve_2012_4522"
129
- require "dawn/kb/cve_2012_5370"
130
- require "dawn/kb/cve_2012_5371"
131
- require "dawn/kb/cve_2012_5380"
132
- require "dawn/kb/cve_2012_6109"
133
- require "dawn/kb/cve_2012_6134"
134
- require "dawn/kb/cve_2012_6496"
135
- require "dawn/kb/cve_2012_6497"
136
- require "dawn/kb/cve_2012_6684"
137
-
138
- # CVE - 2013
139
- require "dawn/kb/cve_2013_0155"
140
- require "dawn/kb/cve_2013_0156"
141
- require "dawn/kb/cve_2013_0162"
142
- require "dawn/kb/cve_2013_0175"
143
- require "dawn/kb/cve_2013_0183"
144
- require "dawn/kb/cve_2013_0184"
145
- require "dawn/kb/cve_2013_0233"
146
- require "dawn/kb/cve_2013_0256"
147
- require "dawn/kb/cve_2013_0262"
148
- require "dawn/kb/cve_2013_0263"
149
- require "dawn/kb/cve_2013_0269"
150
- require "dawn/kb/cve_2013_0276"
151
- require "dawn/kb/cve_2013_0277"
152
- require "dawn/kb/cve_2013_0284"
153
- require "dawn/kb/cve_2013_0285"
154
- require "dawn/kb/cve_2013_0333"
155
- require "dawn/kb/cve_2013_0334"
156
- require "dawn/kb/cve_2013_1607"
157
- require "dawn/kb/cve_2013_1655"
158
- require "dawn/kb/cve_2013_1656"
159
- require "dawn/kb/cve_2013_1756"
160
- require "dawn/kb/cve_2013_1800"
161
- require "dawn/kb/cve_2013_1801"
162
- require "dawn/kb/cve_2013_1802"
163
- require "dawn/kb/cve_2013_1812"
164
- require "dawn/kb/cve_2013_1821"
165
- require "dawn/kb/cve_2013_1854"
166
- require "dawn/kb/cve_2013_1855"
167
- require "dawn/kb/cve_2013_1856"
168
- require "dawn/kb/cve_2013_1857"
169
- require "dawn/kb/cve_2013_1875"
170
- require "dawn/kb/cve_2013_1898"
171
- require "dawn/kb/cve_2013_1911"
172
- require "dawn/kb/cve_2013_1933"
173
- require "dawn/kb/cve_2013_1947"
174
- require "dawn/kb/cve_2013_1948"
175
- require "dawn/kb/cve_2013_2065"
176
- require "dawn/kb/cve_2013_2090"
177
- require "dawn/kb/cve_2013_2105"
178
- require "dawn/kb/cve_2013_2119"
179
- require "dawn/kb/cve_2013_2512"
180
- require "dawn/kb/cve_2013_2513"
181
- require "dawn/kb/cve_2013_2516"
182
- require "dawn/kb/cve_2013_2615"
183
- require "dawn/kb/cve_2013_2616"
184
- require "dawn/kb/cve_2013_2617"
185
- require "dawn/kb/cve_2013_3221"
186
- require "dawn/kb/cve_2013_4164"
187
- require "dawn/kb/cve_2013_4203"
188
- require "dawn/kb/cve_2013_4389"
189
- require "dawn/kb/cve_2013_4413"
190
- require "dawn/kb/cve_2013_4457"
191
- require "dawn/kb/cve_2013_4478"
192
- require "dawn/kb/cve_2013_4479"
193
- require "dawn/kb/cve_2013_4489"
194
- require "dawn/kb/cve_2013_4491"
195
- require "dawn/kb/cve_2013_4492"
196
- require "dawn/kb/cve_2013_4562"
197
- require "dawn/kb/cve_2013_4593"
198
- require "dawn/kb/cve_2013_5647"
199
- require "dawn/kb/cve_2013_5671"
200
- require "dawn/kb/cve_2013_6414"
201
- require "dawn/kb/cve_2013_6415"
202
- require "dawn/kb/cve_2013_6416"
203
- require "dawn/kb/cve_2013_6417"
204
- require "dawn/kb/cve_2013_6421"
205
- require "dawn/kb/cve_2013_6459"
206
- require "dawn/kb/cve_2013_6460"
207
- require "dawn/kb/cve_2013_6461"
208
- require "dawn/kb/cve_2013_7086"
209
-
210
- # CVE - 2014
211
-
212
- require "dawn/kb/cve_2014_0036"
213
- require "dawn/kb/cve_2014_0080"
214
- require "dawn/kb/cve_2014_0081"
215
- require "dawn/kb/cve_2014_0082"
216
- require "dawn/kb/cve_2014_0130"
217
- require "dawn/kb/cve_2014_1233"
218
- require "dawn/kb/cve_2014_1234"
219
- require "dawn/kb/cve_2014_2322"
220
- require "dawn/kb/cve_2014_2525"
221
- require "dawn/kb/cve_2014_2538"
222
- require "dawn/kb/cve_2014_3482"
223
- require "dawn/kb/cve_2014_3483"
224
- require "dawn/kb/cve_2014_3916"
225
- require "dawn/kb/cve_2014_4975"
226
- require "dawn/kb/cve_2014_7818"
227
- require "dawn/kb/cve_2014_7819"
228
- require "dawn/kb/cve_2014_7829"
229
- require "dawn/kb/cve_2014_8090"
230
- require "dawn/kb/cve_2014_9490"
231
-
232
- # CVE - 2015
233
-
234
-
235
- require "dawn/kb/cve_2015_1819"
236
- # CVE-2015-1840 is spread in two classes because a single CVE is assigned to a
237
- # vulnerability affecting two differents but related gems.
238
- require "dawn/kb/cve_2015_1840/cve_2015_1840_a"
239
- require "dawn/kb/cve_2015_1840/cve_2015_1840_b"
240
- require "dawn/kb/cve_2015_2963"
241
- require "dawn/kb/cve_2015_3224"
242
- require "dawn/kb/cve_2015_3225"
243
- require "dawn/kb/cve_2015_3226"
244
- require "dawn/kb/cve_2015_3227"
245
- require "dawn/kb/cve_2015_3448"
246
- require "dawn/kb/cve_2015_4020"
247
- require "dawn/kb/cve_2015_5312"
248
- require "dawn/kb/cve_2015_7497"
249
- require "dawn/kb/cve_2015_7498"
250
- require "dawn/kb/cve_2015_7499"
251
- require "dawn/kb/cve_2015_7500"
252
- require "dawn/kb/cve_2015_7519"
253
- require "dawn/kb/cve_2015_7541"
254
- require "dawn/kb/cve_2015_7576"
255
- require "dawn/kb/cve_2015_7577"
256
- require "dawn/kb/cve_2015_7578"
257
- require "dawn/kb/cve_2015_7579"
258
- require "dawn/kb/cve_2015_7581"
259
- require "dawn/kb/cve_2015_8241"
260
- require "dawn/kb/cve_2015_8242"
261
- require "dawn/kb/cve_2015_8317"
262
-
263
- # CVE - 2016
264
-
265
- require "dawn/kb/cve_2016_0751"
266
- require "dawn/kb/cve_2016_0752"
267
- require "dawn/kb/cve_2016_0753"
268
- require "dawn/kb/cve_2016_2097"
269
- require "dawn/kb/cve_2016_2098"
270
- require "dawn/kb/cve_2016_5697"
271
- require "dawn/kb/cve_2016_6316"
272
- require "dawn/kb/cve_2016_6317"
273
- require "dawn/kb/cve_2016_6582"
274
-
275
- # OSVDB
276
-
277
- require "dawn/kb/osvdb_105971"
278
- require "dawn/kb/osvdb_108569"
279
- require "dawn/kb/osvdb_108570"
280
- require "dawn/kb/osvdb_108530"
281
- require "dawn/kb/osvdb_108563"
282
- require "dawn/kb/osvdb_115654"
283
- require "dawn/kb/osvdb_116010"
284
- require "dawn/kb/osvdb_117903"
285
- require "dawn/kb/osvdb_118579"
286
- require "dawn/kb/osvdb_118830"
287
- require "dawn/kb/osvdb_118954"
288
- require "dawn/kb/osvdb_119878"
289
- require "dawn/kb/osvdb_119927"
290
- require "dawn/kb/osvdb_120415"
291
- require "dawn/kb/osvdb_120857"
292
- require "dawn/kb/osvdb_121701"
293
- require "dawn/kb/osvdb_132234"
294
-
295
-
21
+ require "dawn/kb/rubygem_check"
296
22
 
297
23
  module Dawn
298
- # XXX: Check if it best using a singleton here
24
+ # This is the YAML powered experimental knowledge base
25
+ #
26
+ # When the old KB format, using Ruby classes will be marked as deprecated,
27
+ # than this one will be the official.
28
+ #
29
+ # Dawnscanner KB will be a bunch of YAML file, stored in a hierachy of
30
+ # directories resembling security checks family. A digital signature will be
31
+ # also available to prevent KB tampering.
32
+ #
33
+ # This class will be accountable for:
34
+ # + check for KB upgrade
35
+ # + fetching the KB file from the Internet
36
+ # + verifying the database signature
37
+ # + reading YAML file, creating the security check array
38
+ #
39
+ # Another big change will be the MVC passed as constructor parameter, so only
40
+ # the checks regarding the particular app, will be loaded in the security
41
+ # check array. This should speed up BasicCheck internal routines.
42
+ #
43
+ # Class usage will be very simple. After getting the singleton instance, you
44
+ # will load the KB content. The load method will be also responsible about
45
+ # all relevant checks.
46
+ #
47
+ # Example
48
+ #
49
+ # require "dawn/knowledge_base_experimental"
50
+ #
51
+ # ...
52
+ #
53
+ # d = Dawn::KnowledgeBase.instance
54
+ # d.update if d.update?
55
+ # d.load
56
+ #
57
+ # Last update: gio 29 nov 2018, 17.34.57, CET
299
58
  class KnowledgeBase
300
-
301
59
  include Dawn::Utils
60
+ include Singleton
61
+
62
+ @@path = ""
63
+ @@error = ""
64
+ @@enabled_checks = [:generic_check, :code_quality, :bulletin, :code_style, :owasp_top_10]
65
+
302
66
 
303
67
  GEM_CHECK = :rubygem_check
304
68
  DEPENDENCY_CHECK = :dependency_check
@@ -308,330 +72,129 @@ module Dawn
308
72
  COMBO_CHECK = :combo_check
309
73
  CUSTOM_CHECK = :custom_check
310
74
 
75
+ REMOTE_KB_URL_PREFIX = "https://dawnscanner.org/data/"
76
+ FILES = %w(kb.yaml bulletin.tar.gz generic_check.tar.gz owasp_ror_cheatsheet.tar.gz code_style.tar.gz code_quality.tar.gz owasp_top_10.tar.gz signatures.tar.gz)
77
+
78
+ VERSION = "0.0.1"
79
+
80
+ attr_reader :security_checks
81
+ attr_reader :descriptor
82
+ attr_reader :path
83
+
311
84
  def initialize(options={})
312
- @enabled_checks = Dawn::Kb::BasicCheck::ALLOWED_FAMILIES
313
- @enabled_checks = options[:enabled_checks] unless options[:enabled_checks].nil?
85
+ if $logger.nil?
86
+ require 'dawn/logger'
87
+ $logger = Logger.new(STDOUT)
88
+ $logger.helo "knowledge-base-experimental", Dawn::VERSION
89
+ end
90
+ @path=@@path
91
+ @enabled_checks = @@enabled_checks
314
92
 
315
- @security_checks = load_security_checks
93
+ $logger.debug "KB root path is #{@path}"
316
94
  end
317
95
 
318
- def self.find(checks=nil, name)
319
- return nil if name.nil? or name.empty?
320
- checks = Dawn::KnowledgeBase.new.load_security_checks if checks.nil?
96
+ def self.enabled_checks= checks
97
+ @@enabled_checks=checks
98
+ end
321
99
 
322
- checks.each do |sc|
323
- return sc if sc.name == name
324
- end
325
- nil
100
+
101
+ def self.path= path_name
102
+ @@path=path_name
326
103
  end
327
104
 
328
- def find(name)
329
- Dawn::KnowledgeBase.find(@security_checks, name)
105
+ def is_packed?
106
+ return __packed?
330
107
  end
331
108
 
332
- def all
333
- @security_checks
109
+ def is_valid?
110
+ return __valid?
334
111
  end
335
112
 
336
- # TODO - next big refactoring will include also a change in this API.
337
- #
338
- # So to match Semantic Version, it must bring to a major version bump.
339
- # MVC name should be passed as constructor option, so the all_by_mvc can
340
- #
341
- # be called without parameter, having a nice-to-read code.
342
- # @checks = Dawn::KnowledgeBase.new({:enabled_checks=>@enabled_checks}).all_by_mvc(@name)
343
- def all_by_mvc(mvc)
344
- ret = []
345
- @security_checks.each do |sc|
346
- ret << sc if sc.applies_to?(mvc)
347
- end
348
- ret
113
+
114
+ def find(name)
115
+ $logger.debug "I'm asked to find #{name}"
349
116
  end
350
117
 
351
- def all_sinatra_checks
352
- self.all_by_mvc("sinatra")
118
+ def unpack
119
+ $logger.warn "unpack is not yet implemented"
120
+
353
121
  end
354
122
 
355
- def all_rails_checks
356
- self.all_by_mvc("rails")
123
+ def self.kb_descriptor
124
+ {:kb=>{:version=>VERSION, :revision=>Time.now.strftime("%Y%m%d"), :api=>Dawn::VERSION}}.to_yaml
357
125
  end
358
126
 
359
- def all_padrino_checks
360
- self.all_by_mvc("padrino")
127
+ def update?
128
+ FileUtils.mkdir_p("tmp")
129
+ begin
130
+ response = Net::HTTP.get URI(REMOTE_KB_URL_PREFIX + "kb.yaml")
131
+ open("tmp/kb.yaml", "w") do |f|
132
+ f.puts(response)
133
+ end
134
+ response = Net::HTTP.get URI(REMOTE_KB_URL_PREFIX + "kb.yaml.sig")
135
+ open("tmp/kb.yaml.sig", "w") do |f|
136
+ f.puts(response)
137
+ end
138
+ rescue Exception => e
139
+ $logger.error e.to_s
140
+ return false
141
+ end
142
+
143
+ # Verify kb.yaml signature
144
+
145
+ YAML.load(response)
361
146
  end
362
147
 
363
- def all_rack_checks
364
- self.all_by_mvc("rack")
148
+ def all
149
+ @security_checks
365
150
  end
366
151
 
367
- def load_security_checks
368
-
369
- # START @cve_security_checks array
370
- @cve_security_checks =
371
- [
372
- Dawn::Kb::CVE_2004_0755.new,
373
- Dawn::Kb::CVE_2004_0983.new,
374
- Dawn::Kb::CVE_2005_1992.new,
375
- Dawn::Kb::CVE_2005_2337.new,
376
- Dawn::Kb::CVE_2006_1931.new,
377
- Dawn::Kb::CVE_2006_2582.new,
378
- Dawn::Kb::CVE_2006_3694.new,
379
- Dawn::Kb::CVE_2006_4112.new,
380
- Dawn::Kb::CVE_2006_5467.new,
381
- Dawn::Kb::CVE_2006_6303.new,
382
- Dawn::Kb::CVE_2006_6852.new,
383
- Dawn::Kb::CVE_2006_6979.new,
384
- Dawn::Kb::CVE_2007_0469.new,
385
- Dawn::Kb::CVE_2007_5162.new,
386
- Dawn::Kb::CVE_2007_5379.new,
387
- Dawn::Kb::CVE_2007_5380.new,
388
- Dawn::Kb::CVE_2007_5770.new,
389
- Dawn::Kb::CVE_2007_6077.new,
390
- Dawn::Kb::CVE_2007_6612.new,
391
- Dawn::Kb::CVE_2008_1145.new,
392
- Dawn::Kb::CVE_2008_1891.new,
393
- Dawn::Kb::CVE_2008_2376.new,
394
- Dawn::Kb::CVE_2008_2662.new,
395
- Dawn::Kb::CVE_2008_2663.new,
396
- Dawn::Kb::CVE_2008_2664.new,
397
- Dawn::Kb::CVE_2008_2725.new,
398
- Dawn::Kb::CVE_2008_3655.new,
399
- Dawn::Kb::CVE_2008_3657.new,
400
- Dawn::Kb::CVE_2008_3790.new,
401
- Dawn::Kb::CVE_2008_3905.new,
402
- Dawn::Kb::CVE_2008_4094.new,
403
- Dawn::Kb::CVE_2008_4310.new,
404
- Dawn::Kb::CVE_2008_5189.new,
405
- Dawn::Kb::CVE_2008_7248.new,
406
- Dawn::Kb::CVE_2009_4078.new,
407
- Dawn::Kb::CVE_2009_4124.new,
408
- Dawn::Kb::CVE_2009_4214.new,
409
- Dawn::Kb::CVE_2010_1330.new,
410
- Dawn::Kb::CVE_2010_2489.new,
411
- Dawn::Kb::CVE_2010_3933.new,
412
- Dawn::Kb::CVE_2011_0188.new,
413
- Dawn::Kb::CVE_2011_0446.new,
414
- Dawn::Kb::CVE_2011_0447.new,
415
- Dawn::Kb::CVE_2011_0739.new,
416
- Dawn::Kb::CVE_2011_0995.new,
417
- Dawn::Kb::CVE_2011_1004.new,
418
- Dawn::Kb::CVE_2011_1005.new,
419
- Dawn::Kb::CVE_2011_2197.new,
420
- Dawn::Kb::CVE_2011_2686.new,
421
- Dawn::Kb::CVE_2011_2705.new,
422
- Dawn::Kb::CVE_2011_2929.new,
423
- Dawn::Kb::CVE_2011_2930.new,
424
- Dawn::Kb::CVE_2011_2931.new,
425
- Dawn::Kb::CVE_2011_2932.new,
426
- Dawn::Kb::CVE_2011_3009.new,
427
- Dawn::Kb::CVE_2011_3186.new,
428
- Dawn::Kb::CVE_2011_3187.new,
429
- Dawn::Kb::CVE_2011_4319.new,
430
- Dawn::Kb::CVE_2011_4815.new,
431
- Dawn::Kb::CVE_2011_5036.new,
432
- Dawn::Kb::CVE_2012_1098.new,
433
- Dawn::Kb::CVE_2012_1099.new,
434
- Dawn::Kb::CVE_2012_1241.new,
435
- Dawn::Kb::CVE_2012_2139.new,
436
- Dawn::Kb::CVE_2012_2140.new,
437
- Dawn::Kb::CVE_2012_2660.new,
438
- Dawn::Kb::CVE_2012_2661.new,
439
- Dawn::Kb::CVE_2012_2671.new,
440
- Dawn::Kb::CVE_2012_2694.new,
441
- Dawn::Kb::CVE_2012_2695.new,
442
- Dawn::Kb::CVE_2012_3424.new,
443
- Dawn::Kb::CVE_2012_3463.new,
444
- Dawn::Kb::CVE_2012_3464.new,
445
- Dawn::Kb::CVE_2012_3465.new,
446
- Dawn::Kb::CVE_2012_4464.new,
447
- Dawn::Kb::CVE_2012_4466.new,
448
- Dawn::Kb::CVE_2012_4481.new,
449
- Dawn::Kb::CVE_2012_4522.new,
450
- Dawn::Kb::CVE_2012_5370.new,
451
- Dawn::Kb::CVE_2012_5371.new,
452
- Dawn::Kb::CVE_2012_5380.new,
453
- Dawn::Kb::CVE_2012_6109.new,
454
- Dawn::Kb::CVE_2012_6134.new,
455
- Dawn::Kb::CVE_2012_6496.new,
456
- Dawn::Kb::CVE_2012_6497.new,
457
- Dawn::Kb::CVE_2012_6684.new,
458
- Dawn::Kb::CVE_2013_0155.new,
459
- Dawn::Kb::CVE_2013_0156.new,
460
- Dawn::Kb::CVE_2013_0162.new,
461
- Dawn::Kb::CVE_2013_0175.new,
462
- Dawn::Kb::CVE_2013_0183.new,
463
- Dawn::Kb::CVE_2013_0184.new,
464
- Dawn::Kb::CVE_2013_0233.new,
465
- Dawn::Kb::CVE_2013_0256.new,
466
- Dawn::Kb::CVE_2013_0262.new,
467
- Dawn::Kb::CVE_2013_0263.new,
468
- Dawn::Kb::CVE_2013_0269.new,
469
- Dawn::Kb::CVE_2013_0276.new,
470
- Dawn::Kb::CVE_2013_0277.new,
471
- Dawn::Kb::CVE_2013_0284.new,
472
- Dawn::Kb::CVE_2013_0285.new,
473
- Dawn::Kb::CVE_2013_0333.new,
474
- Dawn::Kb::CVE_2013_0334.new,
475
- Dawn::Kb::CVE_2013_1607.new,
476
- Dawn::Kb::CVE_2013_1655.new,
477
- Dawn::Kb::CVE_2013_1656.new,
478
- Dawn::Kb::CVE_2013_1756.new,
479
- Dawn::Kb::CVE_2013_1800.new,
480
- Dawn::Kb::CVE_2013_1801.new,
481
- Dawn::Kb::CVE_2013_1802.new,
482
- Dawn::Kb::CVE_2013_1812.new,
483
- Dawn::Kb::CVE_2013_1821.new,
484
- Dawn::Kb::CVE_2013_1854.new,
485
- Dawn::Kb::CVE_2013_1855.new,
486
- Dawn::Kb::CVE_2013_1856.new,
487
- Dawn::Kb::CVE_2013_1857.new,
488
- Dawn::Kb::CVE_2013_1875.new,
489
- Dawn::Kb::CVE_2013_1898.new,
490
- Dawn::Kb::CVE_2013_1911.new,
491
- Dawn::Kb::CVE_2013_1933.new,
492
- Dawn::Kb::CVE_2013_1947.new,
493
- Dawn::Kb::CVE_2013_1948.new,
494
- Dawn::Kb::CVE_2013_2065.new,
495
- Dawn::Kb::CVE_2013_2090.new,
496
- Dawn::Kb::CVE_2013_2105.new,
497
- Dawn::Kb::CVE_2013_2119.new,
498
- Dawn::Kb::CVE_2013_2512.new,
499
- Dawn::Kb::CVE_2013_2513.new,
500
- Dawn::Kb::CVE_2013_2516.new,
501
- Dawn::Kb::CVE_2013_2615.new,
502
- Dawn::Kb::CVE_2013_2616.new,
503
- Dawn::Kb::CVE_2013_2617.new,
504
- Dawn::Kb::CVE_2013_3221.new,
505
- Dawn::Kb::CVE_2013_4164.new,
506
- Dawn::Kb::CVE_2013_4203.new,
507
- Dawn::Kb::CVE_2013_4389.new,
508
- Dawn::Kb::CVE_2013_4413.new,
509
- Dawn::Kb::CVE_2013_4457.new,
510
- Dawn::Kb::CVE_2013_4478.new,
511
- Dawn::Kb::CVE_2013_4479.new,
512
- Dawn::Kb::CVE_2013_4489.new,
513
- Dawn::Kb::CVE_2013_4491.new,
514
- Dawn::Kb::CVE_2013_4492.new,
515
- Dawn::Kb::CVE_2013_4562.new,
516
- Dawn::Kb::CVE_2013_4593.new,
517
- Dawn::Kb::CVE_2013_5647.new,
518
- Dawn::Kb::CVE_2013_5671.new,
519
- Dawn::Kb::CVE_2013_6414.new,
520
- Dawn::Kb::CVE_2013_6415.new,
521
- Dawn::Kb::CVE_2013_6416.new,
522
- Dawn::Kb::CVE_2013_6417.new,
523
- Dawn::Kb::CVE_2013_6421.new,
524
- Dawn::Kb::CVE_2013_6459.new,
525
- Dawn::Kb::CVE_2013_6460.new,
526
- Dawn::Kb::CVE_2013_6461.new,
527
- Dawn::Kb::CVE_2013_7086.new,
528
- Dawn::Kb::CVE_2014_0036.new,
529
- Dawn::Kb::CVE_2014_0080.new,
530
- Dawn::Kb::CVE_2014_0081.new,
531
- Dawn::Kb::CVE_2014_0082.new,
532
- Dawn::Kb::CVE_2014_0130.new,
533
- Dawn::Kb::CVE_2014_1233.new,
534
- Dawn::Kb::CVE_2014_1234.new,
535
- Dawn::Kb::CVE_2014_2322.new,
536
- Dawn::Kb::CVE_2014_2525.new,
537
- Dawn::Kb::CVE_2014_2538.new,
538
- Dawn::Kb::CVE_2014_3482.new,
539
- Dawn::Kb::CVE_2014_3483.new,
540
- Dawn::Kb::CVE_2014_3916.new,
541
- Dawn::Kb::CVE_2014_4975.new,
542
- Dawn::Kb::CVE_2014_7818.new,
543
- Dawn::Kb::CVE_2014_7819.new,
544
- Dawn::Kb::CVE_2014_7829.new,
545
- Dawn::Kb::CVE_2014_8090.new,
546
- Dawn::Kb::CVE_2014_9490.new,
547
- Dawn::Kb::CVE_2015_1819.new,
548
- Dawn::Kb::CVE_2015_1840_a.new,
549
- Dawn::Kb::CVE_2015_1840_b.new,
550
- Dawn::Kb::CVE_2015_2963.new,
551
- Dawn::Kb::CVE_2015_3224.new,
552
- Dawn::Kb::CVE_2015_3225.new,
553
- Dawn::Kb::CVE_2015_3226.new,
554
- Dawn::Kb::CVE_2015_3227.new,
555
- Dawn::Kb::CVE_2015_3448.new,
556
- Dawn::Kb::CVE_2015_4020.new,
557
- Dawn::Kb::CVE_2015_5312.new,
558
- Dawn::Kb::CVE_2015_7497.new,
559
- Dawn::Kb::CVE_2015_7498.new,
560
- Dawn::Kb::CVE_2015_7499.new,
561
- Dawn::Kb::CVE_2015_7500.new,
562
- Dawn::Kb::CVE_2015_7519.new,
563
- Dawn::Kb::CVE_2015_7541.new,
564
- Dawn::Kb::CVE_2015_7576.new,
565
- Dawn::Kb::CVE_2015_7577.new,
566
- Dawn::Kb::CVE_2015_7578.new,
567
- Dawn::Kb::CVE_2015_7579.new,
568
- Dawn::Kb::CVE_2015_7581.new,
569
- Dawn::Kb::CVE_2015_8241.new,
570
- Dawn::Kb::CVE_2015_8242.new,
571
- Dawn::Kb::CVE_2015_8317.new,
572
- Dawn::Kb::CVE_2016_0751.new,
573
- Dawn::Kb::CVE_2016_0752.new,
574
- Dawn::Kb::CVE_2016_0753.new,
575
- Dawn::Kb::CVE_2016_2097.new,
576
- Dawn::Kb::CVE_2016_2098.new,
577
- Dawn::Kb::CVE_2016_5697.new,
578
- Dawn::Kb::CVE_2016_6316.new,
579
- Dawn::Kb::CVE_2016_6317.new,
580
- Dawn::Kb::CVE_2016_6582.new,
581
-
582
-
583
- # OSVDB Checks are still here since are all about dependencies
584
- Dawn::Kb::OSVDB_105971.new,
585
- Dawn::Kb::OSVDB_108569.new,
586
- Dawn::Kb::OSVDB_108570.new,
587
- Dawn::Kb::OSVDB_108530.new,
588
- Dawn::Kb::OSVDB_108563.new,
589
- Dawn::Kb::OSVDB_115654.new,
590
- Dawn::Kb::OSVDB_116010.new,
591
- Dawn::Kb::OSVDB_117903.new,
592
- Dawn::Kb::OSVDB_118579.new,
593
- Dawn::Kb::OSVDB_118830.new,
594
- Dawn::Kb::OSVDB_118954.new,
595
- Dawn::Kb::OSVDB_119878.new,
596
- Dawn::Kb::OSVDB_119927.new,
597
- Dawn::Kb::OSVDB_120415.new,
598
- Dawn::Kb::OSVDB_120857.new,
599
- Dawn::Kb::OSVDB_121701.new,
600
- Dawn::Kb::OSVDB_132234.new,
601
- ]
602
- # END @cve_security_checks array
603
- # START @owasp_ror_cheatsheet_checks array
604
- @owasp_ror_cheatsheet_checks = [
605
- Dawn::Kb::OwaspRorCheatSheet::CommandInjection.new,
606
- Dawn::Kb::OwaspRorCheatSheet::Csrf.new,
607
- Dawn::Kb::OwaspRorCheatSheet::SessionStoredInDatabase.new,
608
- Dawn::Kb::OwaspRorCheatSheet::MassAssignmentInModel.new,
609
- Dawn::Kb::OwaspRorCheatSheet::SecurityRelatedHeaders.new,
610
- Dawn::Kb::OwaspRorCheatSheet::CheckForSafeRedirectAndForward.new,
611
- Dawn::Kb::OwaspRorCheatSheet::SensitiveFiles.new,
612
- ]
613
- # END @owasp_ror_cheatsheet_checks array
614
- @code_quality_checks = [
615
- Dawn::Kb::NotRevisedCode.new,
616
- ]
617
- @aux_checks =
618
- [
619
- Dawn::Kb::SimpleForm_Xss_20131129.new,
620
- ]
621
-
622
- ret = []
623
- ret += @aux_checks
624
- ret += @cve_security_checks if @enabled_checks.include?(:bulletin)
625
- ret += @owasp_ror_cheatsheet_checks if @enabled_checks.include?(:owasp_ror_cheatsheet)
626
- ret += @code_quality_checks if @enabled_checks.include?(:code_quality)
627
-
628
- ret
152
+ # Load security checks from db/ folder.
153
+ #
154
+ # Returns an array of security checks, matching the mvc to be reviewed and
155
+ # the enabled check list or an empty array if an error occured.
156
+ def load
157
+ @security_checks = []
158
+ # $path = File.join(Dir.pwd, "db")
159
+
160
+ unless __valid?
161
+ @@error = "An invalid library it has been found. Please use --recovery flag to force fresh install from dawnscanner.org"
162
+ return []
163
+ end
164
+
165
+ unless __load?
166
+ @@error = "The library must be consumed with dawnscanner up to v#{@descriptor[:kb][:api]}. You are using dawnscanner v#{Dawn::VERSION}"
167
+ return []
168
+ end
169
+
170
+ @enabled_checks.each do |d|
171
+
172
+ dir = File.join(@path, d.to_s)
173
+
174
+ # Please note that if we enter in this branch, it means someone
175
+ # tampered the KB between the previous __valid? check and this point.
176
+ # Of course this is a very rare situation, but we must handle it.
177
+ unless Dir.exists?(dir)
178
+ $logger.warn "Missing check directory #{dir}"
179
+ else
180
+ Dir.glob(dir+"/**/*.yml").each do |f|
181
+ data = YAML.load_file(f)
182
+ @security_checks << data
183
+ end
184
+
185
+ end
186
+
187
+
188
+ end
189
+
190
+ $logger.debug "#{@security_checks.count}"
191
+ return @security_checks
629
192
  end
630
193
 
631
- def self.dump(verbose=false)
194
+ def dump(verbose=false)
632
195
  puts "Security checks currently supported:"
633
196
  i=0
634
- self.new.all.each do |check|
197
+ KnowledgeBase.instance.all.each do |check|
635
198
  i+=1
636
199
  if verbose
637
200
  puts "Name: #{check.name}\tCVSS: #{check.cvss_score}\tReleased: #{check.release_date}"
@@ -644,6 +207,66 @@ module Dawn
644
207
  puts "-----\nTotal: #{i}"
645
208
 
646
209
  end
647
- end
648
210
 
211
+ private
212
+
213
+ def __verify_hash(original, computed)
214
+ t=original.split(' ')
215
+ return false if t.length != 2
216
+ return (t[0] == computed)
217
+ end
218
+
219
+ def __valid?
220
+
221
+ lines = ""
222
+
223
+ unless File.exists?(File.join(@path, "kb.yaml"))
224
+ $logger.error "Missing kb.yaml in #{path}. Giving up"
225
+ return false
226
+ end
227
+
228
+ unless File.exists?(File.join(@path, "kb.yaml.sig"))
229
+ $logger.error "Missing kb.yaml signature in #{path}. Giving up"
230
+ return false
231
+ end
232
+
233
+ lines = File.read(File.join(@path, "kb.yaml"))
234
+ hash_file = Digest::SHA256.hexdigest lines
235
+ hash_orig = File.read(File.join(@path, "kb.yaml.sig"))
236
+
237
+ v = __verify_hash(hash_orig, hash_file)
238
+ if v
239
+ $logger.info("good kb.yaml file found. Reading knowledge base descriptor")
240
+ @descriptor = YAML.load(lines)
241
+ else
242
+ $logger.error("kb.yaml signature mismatch. Found #{hash_file} while expecting #{hash_orig}. Giving up")
243
+ return false
244
+ end
245
+
246
+ return true
247
+ end
248
+
249
+ # Check if the local KB is packet or not.
250
+ #
251
+ # Returns true if at least one KB tarball file it has been found in the
252
+ # local DB path
253
+ def __packed?
254
+ FILES.each do |fn|
255
+ return true if fn.end_with? 'tar.gz' and File.exists?(File.join(@path, fn))
256
+ end
257
+ return false
258
+ end
259
+
260
+ def __load?
261
+ api = @descriptor[:kb][:api]
262
+ v = Dawn::VERSION
263
+ require "dawn/kb/version_check"
264
+
265
+ vc = Dawn::Kb::VersionCheck.new
266
+ return true if vc.is_higher?(api, v) # => true if v > api
267
+ return false
268
+ end
269
+
270
+
271
+ end
649
272
  end