Advertisement
Guest User

root.sh

a guest
Jan 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 67.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. VERSION=v0.9
  4. cat << "EOF"
  5.  
  6. ██▓ ▄████▄ ██░ ██ ▓█████ ▒██ ██▒ ██▓███ ██▓ ▒█████ ██▓▄▄▄█████▓▓█████ ██▀███
  7. ▓██▒▒██▀ ▀█ ▓██░ ██▒ ▓█ ▀ ▒▒ █ █ ▒░▓██░ ██▒▓██▒ ▒██▒ ██▒▓██▒▓ ██▒ ▓▒▓█ ▀ ▓██ ▒ ██▒
  8. ▒██▒▒▓█ ▄ ▒██▀▀██░ ▒███ ░░ █ ░▓██░ ██▓▒▒██░ ▒██░ ██▒▒██▒▒ ▓██░ ▒░▒███ ▓██ ░▄█ ▒
  9. ░██░▒▓▓▄ ▄██▒░▓█ ░██ ▒▓█ ▄ ░ █ █ ▒ ▒██▄█▓▒ ▒▒██░ ▒██ ██░░██░░ ▓██▓ ░ ▒▓█ ▄ ▒██▀▀█▄
  10. ░██░▒ ▓███▀ ░░▓█▒░██▓ ░▒████▒▒██▒ ▒██▒▒██▒ ░ ░░██████▒░ ████▓▒░░██░ ▒██▒ ░ ░▒████▒░██▓ ▒██▒
  11. ░▓ ░ ░▒ ▒ ░ ▒ ░░▒░▒ ░░ ▒░ ░▒▒ ░ ░▓ ░▒▓▒░ ░ ░░ ▒░▓ ░░ ▒░▒░▒░ ░▓ ▒ ░░ ░░ ▒░ ░░ ▒▓ ░▒▓░
  12. ▒ ░ ░ ▒ ▒ ░▒░ ░ ░ ░ ░░░ ░▒ ░░▒ ░ ░ ░ ▒ ░ ░ ▒ ▒░ ▒ ░ ░ ░ ░ ░ ░▒ ░ ▒░
  13. ▒ ░░ ░ ░░ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ▒ ▒ ░ ░ ░ ░░ ░
  14. ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
  15. EOF
  16. # bash colors
  17. #txtred="\e[0;31m"
  18. txtred="\e[91;1m"
  19. txtgrn="\e[1;32m"
  20. txtgray="\e[1;30m"
  21. txtblu="\e[0;36m"
  22. txtrst="\e[0m"
  23. bldwht='\e[1;37m'
  24. bldblu='\e[1;34m'
  25. yellow='\e[1;93m'
  26. lightyellow='\e[0;93m'
  27.  
  28. # input data
  29. UNAME_A=""
  30.  
  31. # parsed data for current OS
  32. KERNEL=""
  33. OS=""
  34. DISTRO=""
  35. ARCH=""
  36. PKG_LIST=""
  37.  
  38. # kernel config
  39. KCONFIG=""
  40.  
  41. CVELIST_FILE=""
  42.  
  43. opt_fetch_bins=false
  44. opt_fetch_srcs=false
  45. opt_kernel_version=false
  46. opt_uname_string=false
  47. opt_pkglist_file=false
  48. opt_cvelist_file=false
  49. opt_checksec_mode=false
  50. opt_full=false
  51. opt_summary=false
  52. opt_kernel_only=false
  53. opt_userspace_only=false
  54. opt_show_dos=false
  55. opt_skip_more_checks=false
  56. opt_skip_pkg_versions=false
  57.  
  58. ARGS=
  59. SHORTOPTS="hVfbsu:k:dp:g"
  60. LONGOPTS="help,version,full,fetch-binaries,fetch-sources,uname:,kernel:,show-dos,pkglist-file:,short,kernelspace-only,userspace-only,skip-more-checks,skip-pkg-versions,cvelist-file:,checksec"
  61.  
  62. ## exploits database
  63. declare -a EXPLOITS
  64. declare -a EXPLOITS_USERSPACE
  65.  
  66. ############ LINUX KERNELSPACE EXPLOITS ####################
  67. n=0
  68.  
  69. EXPLOITS[((n++))]=$(cat <<EOF
  70. Name: ${txtgrn}[CVE-2004-1235]${txtrst} elflbl
  71. Reqs: pkg=linux-kernel,ver=2.4.29
  72. Tags:
  73. analysis-url: http://isec.pl/vulnerabilities/isec-0021-uselib.txt
  74. bin-url: https://web.archive.org/web/20111103042904/http://tarantula.by.ru/localroot/2.6.x/elflbl
  75. exploit-db: 744
  76. EOF
  77. )
  78.  
  79. EXPLOITS[((n++))]=$(cat <<EOF
  80. Name: ${txtgrn}[CVE-2004-1235]${txtrst} uselib()
  81. Reqs: pkg=linux-kernel,ver=2.4.29
  82. Tags:
  83. analysis-url: http://isec.pl/vulnerabilities/isec-0021-uselib.txt
  84. exploit-db: 778
  85. Comments: Known to work only for 2.4 series (even though 2.6 is also vulnerable)
  86. EOF
  87. )
  88.  
  89. EXPLOITS[((n++))]=$(cat <<EOF
  90. Name: ${txtgrn}[CVE-2004-1235]${txtrst} krad3
  91. Reqs: pkg=linux-kernel,ver>=2.6.5,ver<=2.6.11
  92. Tags:
  93. exploit-db: 1397
  94. EOF
  95. )
  96.  
  97. EXPLOITS[((n++))]=$(cat <<EOF
  98. Name: ${txtgrn}[CVE-2004-0077]${txtrst} mremap_pte
  99. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.2
  100. Tags:
  101. exploit-db: 160
  102. EOF
  103. )
  104.  
  105. EXPLOITS[((n++))]=$(cat <<EOF
  106. Name: ${txtgrn}[CVE-2006-2451]${txtrst} raptor_prctl
  107. Reqs: pkg=linux-kernel,ver>=2.6.13,ver<=2.6.17
  108. Tags:
  109. exploit-db: 2031
  110. EOF
  111. )
  112.  
  113. EXPLOITS[((n++))]=$(cat <<EOF
  114. Name: ${txtgrn}[CVE-2006-2451]${txtrst} prctl
  115. Reqs: pkg=linux-kernel,ver>=2.6.13,ver<=2.6.17
  116. Tags:
  117. exploit-db: 2004
  118. EOF
  119. )
  120.  
  121. EXPLOITS[((n++))]=$(cat <<EOF
  122. Name: ${txtgrn}[CVE-2006-2451]${txtrst} prctl2
  123. Reqs: pkg=linux-kernel,ver>=2.6.13,ver<=2.6.17
  124. Tags:
  125. exploit-db: 2005
  126. EOF
  127. )
  128.  
  129. EXPLOITS[((n++))]=$(cat <<EOF
  130. Name: ${txtgrn}[CVE-2006-2451]${txtrst} prctl3
  131. Reqs: pkg=linux-kernel,ver>=2.6.13,ver<=2.6.17
  132. Tags:
  133. exploit-db: 2006
  134. EOF
  135. )
  136.  
  137. EXPLOITS[((n++))]=$(cat <<EOF
  138. Name: ${txtgrn}[CVE-2006-2451]${txtrst} prctl4
  139. Reqs: pkg=linux-kernel,ver>=2.6.13,ver<=2.6.17
  140. Tags:
  141. exploit-db: 2011
  142. EOF
  143. )
  144.  
  145. EXPLOITS[((n++))]=$(cat <<EOF
  146. Name: ${txtgrn}[CVE-2006-3626]${txtrst} h00lyshit
  147. Reqs: pkg=linux-kernel,ver>=2.6.8,ver<=2.6.16
  148. Tags:
  149. bin-url: https://web.archive.org/web/20111103042904/http://tarantula.by.ru/localroot/2.6.x/h00lyshit
  150. exploit-db: 2013
  151. EOF
  152. )
  153.  
  154. EXPLOITS[((n++))]=$(cat <<EOF
  155. Name: ${txtgrn}[CVE-2008-0600]${txtrst} vmsplice1
  156. Reqs: pkg=linux-kernel,ver>=2.6.17,ver<=2.6.24
  157. Tags:
  158. exploit-db: 5092
  159. EOF
  160. )
  161.  
  162. EXPLOITS[((n++))]=$(cat <<EOF
  163. Name: ${txtgrn}[CVE-2008-0600]${txtrst} vmsplice2
  164. Reqs: pkg=linux-kernel,ver>=2.6.23,ver<=2.6.24
  165. Tags:
  166. exploit-db: 5093
  167. EOF
  168. )
  169.  
  170. EXPLOITS[((n++))]=$(cat <<EOF
  171. Name: ${txtgrn}[CVE-2008-4210]${txtrst} ftrex
  172. Reqs: pkg=linux-kernel,ver>=2.6.11,ver<=2.6.22
  173. Tags:
  174. exploit-db: 6851
  175. Comments: world-writable sgid directory and shell that does not drop sgid privs upon exec (ash/sash) are required
  176. EOF
  177. )
  178.  
  179. EXPLOITS[((n++))]=$(cat <<EOF
  180. Name: ${txtgrn}[CVE-2008-4210]${txtrst} exit_notify
  181. Reqs: pkg=linux-kernel,ver>=2.6.25,ver<=2.6.29
  182. Tags:
  183. exploit-db: 8369
  184. EOF
  185. )
  186.  
  187. EXPLOITS[((n++))]=$(cat <<EOF
  188. Name: ${txtgrn}[CVE-2009-2692]${txtrst} sock_sendpage (simple version)
  189. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.30
  190. Tags: ubuntu=7.10,RHEL=4,fedora=4|5|6|7|8|9|10|11
  191. exploit-db: 9479
  192. Comments: Works for systems with /proc/sys/vm/mmap_min_addr equal to 0
  193. EOF
  194. )
  195.  
  196. EXPLOITS[((n++))]=$(cat <<EOF
  197. Name: ${txtgrn}[CVE-2009-2692,CVE-2009-1895]${txtrst} sock_sendpage
  198. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.30
  199. Tags: ubuntu=9.04
  200. analysis-url: https://xorl.wordpress.com/2009/07/16/cve-2009-1895-linux-kernel-per_clear_on_setid-personality-bypass/
  201. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9435.tgz
  202. exploit-db: 9435
  203. Comments: /proc/sys/vm/mmap_min_addr needs to equal 0 OR pulseaudio needs to be installed
  204. EOF
  205. )
  206.  
  207. EXPLOITS[((n++))]=$(cat <<EOF
  208. Name: ${txtgrn}[CVE-2009-2692,CVE-2009-1895]${txtrst} sock_sendpage2
  209. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.30
  210. Tags:
  211. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9436.tgz
  212. exploit-db: 9436
  213. Comments: Works for systems with /proc/sys/vm/mmap_min_addr equal to 0
  214. EOF
  215. )
  216.  
  217. EXPLOITS[((n++))]=$(cat <<EOF
  218. Name: ${txtgrn}[CVE-2009-2692,CVE-2009-1895]${txtrst} sock_sendpage3
  219. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.30
  220. Tags:
  221. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9641.tar.gz
  222. exploit-db: 9641
  223. Comments: /proc/sys/vm/mmap_min_addr needs to equal 0 OR pulseaudio needs to be installed
  224. EOF
  225. )
  226.  
  227. EXPLOITS[((n++))]=$(cat <<EOF
  228. Name: ${txtgrn}[CVE-2009-2692,CVE-2009-1895]${txtrst} sock_sendpage (ppc)
  229. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.30
  230. Tags: ubuntu=8.10,RHEL=4|5
  231. exploit-db: 9545
  232. Comments: /proc/sys/vm/mmap_min_addr needs to equal 0
  233. EOF
  234. )
  235.  
  236. EXPLOITS[((n++))]=$(cat <<EOF
  237. Name: ${txtgrn}[CVE-2009-2698]${txtrst} udp_sendmsg (by spender)
  238. Reqs: pkg=linux-kernel,ver>=2.6.1,ver<=2.6.19
  239. Tags:
  240. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/9574.tgz
  241. exploit-db: 9574
  242. EOF
  243. )
  244.  
  245. EXPLOITS[((n++))]=$(cat <<EOF
  246. Name: ${txtgrn}[CVE-2009-2698]${txtrst} udp_sendmsg
  247. Reqs: pkg=linux-kernel,ver>=2.6.1,ver<=2.6.19
  248. Tags: debian=4
  249. exploit-db: 9575
  250. EOF
  251. )
  252.  
  253. EXPLOITS[((n++))]=$(cat <<EOF
  254. Name: ${txtgrn}[CVE-2009-2698]${txtrst} ip_append_data
  255. Reqs: pkg=linux-kernel,ver>=2.6.1,ver<=2.6.19,x86
  256. Tags: fedora=4|5|6,RHEL=4
  257. exploit-db: 9542
  258. EOF
  259. )
  260.  
  261. EXPLOITS[((n++))]=$(cat <<EOF
  262. Name: ${txtgrn}[CVE-2009-3547]${txtrst} pipe.c 1
  263. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.31
  264. Tags:
  265. exploit-db: 33321
  266. EOF
  267. )
  268.  
  269. EXPLOITS[((n++))]=$(cat <<EOF
  270. Name: ${txtgrn}[CVE-2009-3547]${txtrst} pipe.c 2
  271. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.31
  272. Tags:
  273. exploit-db: 33322
  274. EOF
  275. )
  276.  
  277. EXPLOITS[((n++))]=$(cat <<EOF
  278. Name: ${txtgrn}[CVE-2009-3547]${txtrst} pipe.c 3
  279. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.31
  280. Tags:
  281. exploit-db: 10018
  282. EOF
  283. )
  284.  
  285. EXPLOITS[((n++))]=$(cat <<EOF
  286. Name: ${txtgrn}[CVE-2010-3301]${txtrst} ptrace_kmod2
  287. Reqs: pkg=linux-kernel,ver>=2.6.26,ver<=2.6.34
  288. Tags: debian=6,ubuntu=10.04|10.10
  289. bin-url: https://web.archive.org/web/20111103042904/http://tarantula.by.ru/localroot/2.6.x/kmod2
  290. bin-url: https://web.archive.org/web/20111103042904/http://tarantula.by.ru/localroot/2.6.x/ptrace-kmod
  291. bin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/ptrace_kmod2-64
  292. exploit-db: 15023
  293. EOF
  294. )
  295.  
  296. EXPLOITS[((n++))]=$(cat <<EOF
  297. Name: ${txtgrn}[CVE-2010-1146]${txtrst} reiserfs
  298. Reqs: pkg=linux-kernel,ver>=2.6.18,ver<=2.6.34
  299. Tags: ubuntu=9.10
  300. exploit-db: 12130
  301. EOF
  302. )
  303.  
  304. EXPLOITS[((n++))]=$(cat <<EOF
  305. Name: ${txtgrn}[CVE-2010-2959]${txtrst} can_bcm
  306. Reqs: pkg=linux-kernel,ver>=2.6.18,ver<=2.6.36
  307. Tags: ubuntu=10.04
  308. bin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/can_bcm
  309. exploit-db: 14814
  310. EOF
  311. )
  312.  
  313. EXPLOITS[((n++))]=$(cat <<EOF
  314. Name: ${txtgrn}[CVE-2010-3904]${txtrst} rds
  315. Reqs: pkg=linux-kernel,ver>=2.6.30,ver<2.6.37
  316. Tags: debian=6,ubuntu=10.10|9.10,fedora=13{kernel:2.6.33.3-85.fc13.i686.PAE},ubuntu=10.04{kernel:2.6.32-21-generic}
  317. analysis-url: http://www.securityfocus.com/archive/1/514379
  318. src-url: http://web.archive.org/web/20101020044048/http://www.vsecurity.com/download/tools/linux-rds-exploit.c
  319. bin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/rds
  320. bin-url: https://web.archive.org/web/20160602192641/https://www.kernel-exploits.com/media/rds64
  321. exploit-db: 15285
  322. EOF
  323. )
  324.  
  325. EXPLOITS[((n++))]=$(cat <<EOF
  326. Name: ${txtgrn}[CVE-2010-3848,CVE-2010-3850,CVE-2010-4073]${txtrst} half_nelson
  327. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.36
  328. Tags: ubuntu=10.04|9.10
  329. bin-url: http://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/half-nelson3
  330. exploit-db: 17787
  331. EOF
  332. )
  333.  
  334. EXPLOITS[((n++))]=$(cat <<EOF
  335. Name: ${txtgrn}[N/A]${txtrst} caps_to_root
  336. Reqs: pkg=linux-kernel,ver>=2.6.34,ver<=2.6.36,x86
  337. Tags: ubuntu=10.10
  338. exploit-db: 15916
  339. EOF
  340. )
  341.  
  342. EXPLOITS[((n++))]=$(cat <<EOF
  343. Name: ${txtgrn}[N/A]${txtrst} caps_to_root 2
  344. Reqs: pkg=linux-kernel,ver>=2.6.34,ver<=2.6.36
  345. Tags: ubuntu=10.10
  346. exploit-db: 15944
  347. EOF
  348. )
  349.  
  350. EXPLOITS[((n++))]=$(cat <<EOF
  351. Name: ${txtgrn}[CVE-2010-4347]${txtrst} american-sign-language
  352. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.36
  353. Tags:
  354. exploit-db: 15774
  355. EOF
  356. )
  357.  
  358. EXPLOITS[((n++))]=$(cat <<EOF
  359. Name: ${txtgrn}[CVE-2010-3437]${txtrst} pktcdvd
  360. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.36
  361. Tags: ubuntu=10.04
  362. exploit-db: 15150
  363. EOF
  364. )
  365.  
  366. EXPLOITS[((n++))]=$(cat <<EOF
  367. Name: ${txtgrn}[CVE-2010-3081]${txtrst} video4linux
  368. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.33
  369. Tags: RHEL=5
  370. exploit-db: 15024
  371. EOF
  372. )
  373.  
  374. EXPLOITS[((n++))]=$(cat <<EOF
  375. Name: ${txtgrn}[CVE-2012-0056]${txtrst} memodipper
  376. Reqs: pkg=linux-kernel,ver>=3.0.0,ver<=3.1.0
  377. Tags: ubuntu=10.04|11.10
  378. analysis-url: https://git.zx2c4.com/CVE-2012-0056/about/
  379. src-url: https://git.zx2c4.com/CVE-2012-0056/plain/mempodipper.c
  380. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/memodipper
  381. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/memodipper64
  382. exploit-db: 18411
  383. EOF
  384. )
  385.  
  386. EXPLOITS[((n++))]=$(cat <<EOF
  387. Name: ${txtgrn}[CVE-2012-0056,CVE-2010-3849,CVE-2010-3850]${txtrst} full-nelson
  388. Reqs: pkg=linux-kernel,ver>=2.6.0,ver<=2.6.36
  389. Tags: ubuntu=9.10|10.04|10.10,ubuntu=10.04.1
  390. src-url: http://vulnfactory.org/exploits/full-nelson.c
  391. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/full-nelson
  392. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/full-nelson64
  393. exploit-db: 15704
  394. EOF
  395. )
  396.  
  397. EXPLOITS[((n++))]=$(cat <<EOF
  398. Name: ${txtgrn}[CVE-2013-1858]${txtrst} CLONE_NEWUSER|CLONE_FS
  399. Reqs: pkg=linux-kernel,ver=3.8,CONFIG_USER_NS=y
  400. Tags:
  401. src-url: http://stealth.openwall.net/xSports/clown-newuser.c
  402. analysis-url: https://lwn.net/Articles/543273/
  403. exploit-db: 38390
  404. author: Sebastian Krahmer
  405. Comments: CONFIG_USER_NS needs to be enabled
  406. EOF
  407. )
  408.  
  409. EXPLOITS[((n++))]=$(cat <<EOF
  410. Name: ${txtgrn}[CVE-2013-2094]${txtrst} perf_swevent
  411. Reqs: pkg=linux-kernel,ver>=2.6.32,ver<3.8.9
  412. Tags: RHEL=6,ubuntu=12.04
  413. analysis-url: http://timetobleed.com/a-closer-look-at-a-recent-privilege-escalation-bug-in-linux-cve-2013-2094/
  414. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/perf_swevent
  415. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/perf_swevent64
  416. exploit-db: 26131
  417. EOF
  418. )
  419.  
  420. EXPLOITS[((n++))]=$(cat <<EOF
  421. Name: ${txtgrn}[CVE-2013-2094]${txtrst} perf_swevent 2
  422. Reqs: pkg=linux-kernel,ver>=2.6.32,ver<3.8.9,x86_64
  423. Tags: ubuntu=12.04
  424. analysis-url: http://timetobleed.com/a-closer-look-at-a-recent-privilege-escalation-bug-in-linux-cve-2013-2094/
  425. src-url: https://cyseclabs.com/exploits/vnik_v1.c
  426. exploit-db: 33589
  427. EOF
  428. )
  429.  
  430. EXPLOITS[((n++))]=$(cat <<EOF
  431. Name: ${txtgrn}[CVE-2013-0268]${txtrst} msr
  432. Reqs: pkg=linux-kernel,ver>=2.6.18,ver<3.7.6
  433. Tags:
  434. exploit-db: 27297
  435. EOF
  436. )
  437.  
  438. EXPLOITS[((n++))]=$(cat <<EOF
  439. Name: ${txtgrn}[CVE-2013-1959]${txtrst} userns_root_sploit
  440. Reqs: pkg=linux-kernel,ver>=3.0.1,ver<3.8.9
  441. Tags:
  442. analysis-url: http://www.openwall.com/lists/oss-security/2013/04/29/1
  443. exploit-db: 25450
  444. EOF
  445. )
  446.  
  447. EXPLOITS[((n++))]=$(cat <<EOF
  448. Name: ${txtgrn}[CVE-2013-2094]${txtrst} semtex
  449. Reqs: pkg=linux-kernel,ver>=2.6.32,ver<3.8.9
  450. Tags: RHEL=6
  451. analysis-url: http://timetobleed.com/a-closer-look-at-a-recent-privilege-escalation-bug-in-linux-cve-2013-2094/
  452. exploit-db: 25444
  453. EOF
  454. )
  455.  
  456. EXPLOITS[((n++))]=$(cat <<EOF
  457. Name: ${txtgrn}[CVE-2014-0038]${txtrst} timeoutpwn
  458. Reqs: pkg=linux-kernel,ver>=3.4.0,ver<=3.13.1,CONFIG_X86_X32=y
  459. Tags: ubuntu=13.10
  460. analysis-url: http://blog.includesecurity.com/2014/03/exploit-CVE-2014-0038-x32-recvmmsg-kernel-vulnerablity.html
  461. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/timeoutpwn64
  462. exploit-db: 31346
  463. Comments: CONFIG_X86_X32 needs to be enabled
  464. EOF
  465. )
  466.  
  467. EXPLOITS[((n++))]=$(cat <<EOF
  468. Name: ${txtgrn}[CVE-2014-0038]${txtrst} timeoutpwn 2
  469. Reqs: pkg=linux-kernel,ver>=3.4.0,ver<=3.13.1,CONFIG_X86_X32=y
  470. Tags: ubuntu=13.10|13.04
  471. analysis-url: http://blog.includesecurity.com/2014/03/exploit-CVE-2014-0038-x32-recvmmsg-kernel-vulnerablity.html
  472. exploit-db: 31347
  473. Comments: CONFIG_X86_X32 needs to be enabled
  474. EOF
  475. )
  476.  
  477. EXPLOITS[((n++))]=$(cat <<EOF
  478. Name: ${txtgrn}[CVE-2014-0196]${txtrst} rawmodePTY
  479. Reqs: pkg=linux-kernel,ver>=2.6.31,ver<=3.14.3
  480. Tags:
  481. analysis-url: http://blog.includesecurity.com/2014/06/exploit-walkthrough-cve-2014-0196-pty-kernel-race-condition.html
  482. exploit-db: 33516
  483. EOF
  484. )
  485.  
  486. EXPLOITS[((n++))]=$(cat <<EOF
  487. Name: ${txtgrn}[CVE-2014-2851]${txtrst} use-after-free in ping_init_sock() ${bldblu}(DoS)${txtrst}
  488. Reqs: pkg=linux-kernel,ver>=3.0.1,ver<=3.14
  489. Tags:
  490. analysis-url: https://cyseclabs.com/page?n=02012016
  491. exploit-db: 32926
  492. EOF
  493. )
  494.  
  495. EXPLOITS[((n++))]=$(cat <<EOF
  496. Name: ${txtgrn}[CVE-2014-4014]${txtrst} inode_capable
  497. Reqs: pkg=linux-kernel,ver>=3.0.1,ver<=3.13
  498. Tags: ubuntu=12.04
  499. analysis-url: http://www.openwall.com/lists/oss-security/2014/06/10/4
  500. exploit-db: 33824
  501. EOF
  502. )
  503.  
  504. EXPLOITS[((n++))]=$(cat <<EOF
  505. Name: ${txtgrn}[CVE-2014-4699]${txtrst} ptrace/sysret
  506. Reqs: pkg=linux-kernel,ver>=3.0.1,ver<=3.8
  507. Tags: ubuntu=12.04
  508. analysis-url: http://www.openwall.com/lists/oss-security/2014/07/08/16
  509. exploit-db: 34134
  510. EOF
  511. )
  512.  
  513. EXPLOITS[((n++))]=$(cat <<EOF
  514. Name: ${txtgrn}[CVE-2014-4943]${txtrst} PPPoL2TP ${bldblu}(DoS)${txtrst}
  515. Reqs: pkg=linux-kernel,ver>=3.2,ver<=3.15.6
  516. Tags:
  517. analysis-url: https://cyseclabs.com/page?n=01102015
  518. exploit-db: 36267
  519. EOF
  520. )
  521.  
  522. EXPLOITS[((n++))]=$(cat <<EOF
  523. Name: ${txtgrn}[CVE-2014-5207]${txtrst} fuse_suid
  524. Reqs: pkg=linux-kernel,ver>=3.0.1,ver<=3.16.1
  525. Tags:
  526. exploit-db: 34923
  527. EOF
  528. )
  529.  
  530. EXPLOITS[((n++))]=$(cat <<EOF
  531. Name: ${txtgrn}[CVE-2015-9322]${txtrst} BadIRET
  532. Reqs: pkg=linux-kernel,ver>=3.0.1,ver<3.17.5,x86_64
  533. Tags: RHEL<=7,fedora=20
  534. analysis-url: http://labs.bromium.com/2015/02/02/exploiting-badiret-vulnerability-cve-2014-9322-linux-kernel-privilege-escalation/
  535. src-url: http://site.pi3.com.pl/exp/p_cve-2014-9322.tar.gz
  536. exploit-db:
  537. author: Rafal 'n3rgal' Wojtczuk & Adam 'pi3' Zabrocki
  538. EOF
  539. )
  540.  
  541. EXPLOITS[((n++))]=$(cat <<EOF
  542. Name: ${txtgrn}[CVE-2015-3290]${txtrst} espfix64_NMI
  543. Reqs: pkg=linux-kernel,ver>=3.13,ver<4.1.6,x86_64
  544. Tags:
  545. analysis-url: http://www.openwall.com/lists/oss-security/2015/08/04/8
  546. exploit-db: 37722
  547. EOF
  548. )
  549.  
  550. EXPLOITS[((n++))]=$(cat <<EOF
  551. Name: ${txtgrn}[N/A]${txtrst} bluetooth
  552. Reqs: pkg=linux-kernel,ver<=2.6.11
  553. Tags:
  554. exploit-db: 4756
  555. EOF
  556. )
  557.  
  558. EXPLOITS[((n++))]=$(cat <<EOF
  559. Name: ${txtgrn}[CVE-2015-1328]${txtrst} overlayfs
  560. Reqs: pkg=linux-kernel,ver>=3.13.0,ver<=3.19.0
  561. Tags: ubuntu=12.04|14.04|14.10|15.04
  562. analysis-url: http://seclists.org/oss-sec/2015/q2/717
  563. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/ofs_32
  564. bin-url: https://web.archive.org/web/20160602192631/https://www.kernel-exploits.com/media/ofs_64
  565. exploit-db: 37292
  566. EOF
  567. )
  568.  
  569. EXPLOITS[((n++))]=$(cat <<EOF
  570. Name: ${txtgrn}[CVE-2015-8660]${txtrst} overlayfs (ovl_setattr)
  571. Reqs: pkg=linux-kernel,ver>=3.0.0,ver<=4.3.3
  572. Tags:
  573. analysis-url: http://www.halfdog.net/Security/2015/UserNamespaceOverlayfsSetuidWriteExec/
  574. exploit-db: 39230
  575. EOF
  576. )
  577.  
  578. EXPLOITS[((n++))]=$(cat <<EOF
  579. Name: ${txtgrn}[CVE-2015-8660]${txtrst} overlayfs (ovl_setattr)
  580. Reqs: pkg=linux-kernel,ver>=3.0.0,ver<=4.3.3
  581. Tags: ubuntu=14.04|15.10
  582. analysis-url: http://www.halfdog.net/Security/2015/UserNamespaceOverlayfsSetuidWriteExec/
  583. exploit-db: 39166
  584. EOF
  585. )
  586.  
  587. EXPLOITS[((n++))]=$(cat <<EOF
  588. Name: ${txtgrn}[CVE-2016-0728]${txtrst} keyring
  589. Reqs: pkg=linux-kernel,ver>=3.10,ver<4.4.1
  590. Tags:
  591. analysis-url: http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/
  592. exploit-db: 40003
  593. Comments: Exploit takes about ~30 minutes to run. Exploit is not reliable, see: https://cyseclabs.com/blog/cve-2016-0728-poc-not-working
  594. EOF
  595. )
  596.  
  597. EXPLOITS[((n++))]=$(cat <<EOF
  598. Name: ${txtgrn}[CVE-2016-2384]${txtrst} usb-midi
  599. Reqs: pkg=linux-kernel,ver>=3.0.0,ver<=4.4.8
  600. Tags: ubuntu=14.04,fedora=22
  601. analysis-url: https://xairy.github.io/blog/2016/cve-2016-2384
  602. src-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-2384/poc.c
  603. exploit-db: 41999
  604. Comments: Requires ability to plug in a malicious USB device and to execute a malicious binary as a non-privileged user
  605. author: Andrey 'xairy' Konovalov
  606. EOF
  607. )
  608.  
  609. EXPLOITS[((n++))]=$(cat <<EOF
  610. Name: ${txtgrn}[N/A]${txtrst} target_offset
  611. Reqs: pkg=linux-kernel,ver>=4.4.0,ver<=4.4.0,cmd:grep -qi ip_tables /proc/modules
  612. Tags: ubuntu=16.04{kernel:4.4.0-21}
  613. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/40053.zip
  614. Comments: ip_tables.ko needs to be loaded
  615. exploit-db: 40049
  616. author: Vitaly Nikolenko (vnik)
  617. EOF
  618. )
  619.  
  620. EXPLOITS[((n++))]=$(cat <<EOF
  621. Name: ${txtgrn}[CVE-2016-4557]${txtrst} double-fdput()
  622. Reqs: pkg=linux-kernel,ver>=4.4,ver<4.5.5,CONFIG_BPF_SYSCALL=y,sysctl:kernel.unprivileged_bpf_disabled!=1
  623. Tags: ubuntu=16.04{kernel:4.4.0-21-generic}
  624. analysis-url: https://bugs.chromium.org/p/project-zero/issues/detail?id=808
  625. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/39772.zip
  626. Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1
  627. exploit-db: 40759
  628. author: Jann Horn
  629. EOF
  630. )
  631.  
  632. EXPLOITS[((n++))]=$(cat <<EOF
  633. Name: ${txtgrn}[CVE-2016-5195]${txtrst} dirtycow
  634. Reqs: pkg=linux-kernel,ver>=2.6.22,ver<=4.8.3
  635. Tags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7},ubuntu=16.04|14.04|12.04
  636. analysis-url: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
  637. Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh
  638. exploit-db: 40611
  639. author: Phil Oester
  640. EOF
  641. )
  642.  
  643. EXPLOITS[((n++))]=$(cat <<EOF
  644. Name: ${txtgrn}[CVE-2016-5195]${txtrst} dirtycow 2
  645. Reqs: pkg=linux-kernel,ver>=2.6.22,ver<=4.8.3
  646. Tags: debian=7|8,RHEL=5|6|7,ubuntu=14.04|12.04,ubuntu=10.04{kernel:2.6.32-21-generic},ubuntu=16.04{kernel:4.4.0-21-generic}
  647. analysis-url: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
  648. ext-url: https://www.exploit-db.com/download/40847.cpp
  649. Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh
  650. exploit-db: 40839
  651. author: FireFart (author of exploit at EDB 40839); Gabriele Bonacini (author of exploit at 'ext-url')
  652. EOF
  653. )
  654.  
  655. EXPLOITS[((n++))]=$(cat <<EOF
  656. Name: ${txtgrn}[CVE-2016-8655]${txtrst} chocobo_root
  657. Reqs: pkg=linux-kernel,ver>=4.4.0,ver<4.9,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1
  658. Tags: ubuntu=(14.04|16.04){kernel:4.4.0-(21|22|24|28|31|34|36|38|42|43|45|47|51)-generic}
  659. analysis-url: http://www.openwall.com/lists/oss-security/2016/12/06/1
  660. Comments: CAP_NET_RAW capability is needed OR CONFIG_USER_NS=y needs to be enabled
  661. exploit-db: 40871
  662. author: rebel
  663. EOF
  664. )
  665.  
  666. EXPLOITS[((n++))]=$(cat <<EOF
  667. Name: ${txtgrn}[CVE-2016-9793]${txtrst} SO_{SND|RCV}BUFFORCE
  668. Reqs: pkg=linux-kernel,ver>=3.11,ver<4.8.14,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1
  669. Tags:
  670. analysis-url: https://github.com/xairy/kernel-exploits/tree/master/CVE-2016-9793
  671. src-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-9793/poc.c
  672. Comments: CAP_NET_ADMIN caps OR CONFIG_USER_NS=y needed. No SMEP/SMAP/KASLR bypass included. Tested in QEMU only
  673. exploit-db: 41995
  674. author: Andrey 'xairy' Konovalov
  675. EOF
  676. )
  677.  
  678. EXPLOITS[((n++))]=$(cat <<EOF
  679. Name: ${txtgrn}[CVE-2017-6074]${txtrst} dccp
  680. Reqs: pkg=linux-kernel,ver>=2.6.18,ver<=4.9.11,CONFIG_IP_DCCP=[my]
  681. Tags: ubuntu=(14.04|16.04){kernel:4.4.0-62-generic}
  682. analysis-url: http://www.openwall.com/lists/oss-security/2017/02/22/3
  683. Comments: Requires Kernel be built with CONFIG_IP_DCCP enabled. Includes partial SMEP/SMAP bypass
  684. exploit-db: 41458
  685. author: Andrey 'xairy' Konovalov
  686. EOF
  687. )
  688.  
  689. EXPLOITS[((n++))]=$(cat <<EOF
  690. Name: ${txtgrn}[CVE-2017-7308]${txtrst} af_packet
  691. Reqs: pkg=linux-kernel,ver>=3.2,ver<=4.10.6,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1
  692. Tags: ubuntu=16.04{kernel:4.8.0-(34|36|39|41|42|44|45)-generic}
  693. analysis-url: https://googleprojectzero.blogspot.com/2017/05/exploiting-linux-kernel-via-packet.html
  694. src-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-7308/poc.c
  695. ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/cve-2017-7308/CVE-2017-7308/poc.c
  696. Comments: CAP_NET_RAW cap or CONFIG_USER_NS=y needed. Modified version at 'ext-url' adds support for additional kernels
  697. exploit-db: 41994
  698. author: Andrey 'xairy' Konovalov (orginal exploit author); Brendan Coles (author of exploit update at 'ext-url')
  699. EOF
  700. )
  701.  
  702. EXPLOITS[((n++))]=$(cat <<EOF
  703. Name: ${txtgrn}[CVE-2017-16995]${txtrst} eBPF_verifier
  704. Reqs: pkg=linux-kernel,ver>=4.4,ver<=4.14.8,CONFIG_BPF_SYSCALL=y,sysctl:kernel.unprivileged_bpf_disabled!=1
  705. Tags: ubuntu=16.04.4{kernel:4.4.0-116}
  706. analysis-url: https://blog.aquasec.com/ebpf-vulnerability-cve-2017-16995-when-the-doorman-becomes-the-backdoor
  707. Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1
  708. exploit-db: 44298
  709. author: Bruce Leidl
  710. EOF
  711. )
  712.  
  713. EXPLOITS[((n++))]=$(cat <<EOF
  714. Name: ${txtgrn}[CVE-2017-1000112]${txtrst} NETIF_F_UFO
  715. Reqs: pkg=linux-kernel,ver>=4.4,ver<=4.13,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1
  716. Tags: ubuntu=14.04{kernel:4.4.0-*},ubuntu=16.04{kernel:4.8.0-*}
  717. analysis-url: http://www.openwall.com/lists/oss-security/2017/08/13/1
  718. src-url: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-1000112/poc.c
  719. ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/cve-2017-1000112/CVE-2017-1000112/poc.c
  720. Comments: CAP_NET_ADMIN cap or CONFIG_USER_NS=y needed. SMEP/KASLR bypass included. Modified version at 'ext-url' adds support for additional distros/kernels
  721. exploit-db:
  722. author: Andrey 'xairy' Konovalov (orginal exploit author); Brendan Coles (author of exploit update at 'ext-url')
  723. EOF
  724. )
  725.  
  726. EXPLOITS[((n++))]=$(cat <<EOF
  727. Name: ${txtgrn}[CVE-2017-1000253]${txtrst} PIE_stack_corruption
  728. Reqs: pkg=linux-kernel,ver>=3.2,ver<=4.13,x86_64
  729. Tags: RHEL=6,RHEL=7{kernel:3.10.0-514.21.2|3.10.0-514.26.1}
  730. analysis-url: https://www.qualys.com/2017/09/26/linux-pie-cve-2017-1000253/cve-2017-1000253.txt
  731. src-url: https://www.qualys.com/2017/09/26/linux-pie-cve-2017-1000253/cve-2017-1000253.c
  732. exploit-db: 42887
  733. author: Qualys
  734. Comments:
  735. EOF
  736. )
  737.  
  738. ############ USERSPACE EXPLOITS ###########################
  739. n=0
  740.  
  741. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  742. Name: ${txtgrn}[CVE-2004-0186]${txtrst} samba
  743. Reqs: pkg=samba,ver<=2.2.8
  744. Tags:
  745. exploit-db: 23674
  746. EOF
  747. )
  748.  
  749. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  750. Name: ${txtgrn}[CVE-2009-1185]${txtrst} udev
  751. Reqs: pkg=udev,cmd:[[ -f /etc/udev/rules.d/95-udev-late.rules || -f /lib/udev/rules.d/95-udev-late.rules ]]
  752. Tags: ubuntu=8.10|9.04
  753. exploit-db: 8572
  754. Comments: Version<1.4.1 vulnerable but distros use own versioning scheme. Manual verification needed
  755. EOF
  756. )
  757.  
  758. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  759. Name: ${txtgrn}[CVE-2009-1185]${txtrst} udev 2
  760. Reqs: pkg=udev
  761. Tags:
  762. exploit-db: 8478
  763. Comments: SSH access to non privileged user is needed. Version<1.4.1 vulnerable but distros use own versioning scheme. Manual verification needed
  764. EOF
  765. )
  766.  
  767. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  768. Name: ${txtgrn}[CVE-2010-0832]${txtrst} PAM MOTD
  769. Reqs: pkg=libpam-modules,ver<=1.1.1
  770. Tags: ubuntu=9.10|10.04
  771. exploit-db: 14339
  772. Comments: SSH access to non privileged user is needed
  773. EOF
  774. )
  775.  
  776. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  777. Name: ${txtgrn}[CVE-2011-1485]${txtrst} pkexec
  778. Reqs: pkg=polkit,ver=0.96
  779. Tags: RHEL=6,ubuntu=10.04|10.10
  780. exploit-db: 17942
  781. EOF
  782. )
  783.  
  784. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  785. Name: ${txtgrn}[CVE-2012-0809]${txtrst} death_star (sudo)
  786. Reqs: pkg=sudo,ver>=1.8.0,ver<=1.8.3
  787. Tags: fedora=16
  788. analysis-url: http://seclists.org/fulldisclosure/2012/Jan/att-590/advisory_sudo.txt
  789. exploit-db: 18436
  790. EOF
  791. )
  792.  
  793. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  794. Name: ${txtgrn}[CVE-2014-0476]${txtrst} chkrootkit
  795. Reqs: pkg=chkrootkit,ver<0.50
  796. Tags:
  797. analysis-url: http://seclists.org/oss-sec/2014/q2/430
  798. exploit-db: 33899
  799. Comments: Rooting depends on the crontab (up to one day of dealy)
  800. EOF
  801. )
  802.  
  803. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  804. Name: ${txtgrn}[CVE-2014-5119]${txtrst} __gconv_translit_find
  805. Reqs: pkg=glibc|libc6,x86
  806. Tags: debian=6
  807. analysis-url: http://googleprojectzero.blogspot.com/2014/08/the-poisoned-nul-byte-2014-edition.html
  808. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/34421.tar.gz
  809. exploit-db: 34421
  810. EOF
  811. )
  812.  
  813. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  814. Name: ${txtgrn}[CVE-2015-1862]${txtrst} newpid (abrt)
  815. Reqs: pkg=abrt,cmd:grep -qi abrt /proc/sys/kernel/core_pattern
  816. Tags: fedora=20
  817. analysis-url: http://openwall.com/lists/oss-security/2015/04/14/4
  818. src-url: https://gist.githubusercontent.com/taviso/0f02c255c13c5c113406/raw/eafac78dce51329b03bea7167f1271718bee4dcc/newpid.c
  819. exploit-db: 36746
  820. EOF
  821. )
  822.  
  823. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  824. Name: ${txtgrn}[CVE-2015-3315]${txtrst} raceabrt
  825. Reqs: pkg=abrt,cmd:grep -qi abrt /proc/sys/kernel/core_pattern
  826. Tags: fedora=19|20|21,RHEL=7
  827. analysis-url: http://seclists.org/oss-sec/2015/q2/130
  828. src-url: https://gist.githubusercontent.com/taviso/fe359006836d6cd1091e/raw/32fe8481c434f8cad5bcf8529789231627e5074c/raceabrt.c
  829. exploit-db: 36747
  830. EOF
  831. )
  832.  
  833. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  834. Name: ${txtgrn}[CVE-2015-1318]${txtrst} newpid (apport)
  835. Reqs: pkg=apport,ver>=2.13,ver<=2.17,cmd:grep -qi apport /proc/sys/kernel/core_pattern
  836. Tags: ubuntu=14.04
  837. analysis-url: http://openwall.com/lists/oss-security/2015/04/14/4
  838. src-url: https://gist.githubusercontent.com/taviso/0f02c255c13c5c113406/raw/eafac78dce51329b03bea7167f1271718bee4dcc/newpid.c
  839. exploit-db: 36746
  840. EOF
  841. )
  842.  
  843. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  844. Name: ${txtgrn}[CVE-2015-1318]${txtrst} newpid (apport) 2
  845. Reqs: pkg=apport,ver>=2.13,ver<=2.17,cmd:grep -qi apport /proc/sys/kernel/core_pattern
  846. Tags: ubuntu=14.04.2
  847. analysis-url: http://openwall.com/lists/oss-security/2015/04/14/4
  848. exploit-db: 36782
  849. EOF
  850. )
  851.  
  852. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  853. Name: ${txtgrn}[CVE-2015-3202]${txtrst} fuse (fusermount)
  854. Reqs: pkg=fuse,ver<2.9.3
  855. Tags: debian=7.0|8.0,ubuntu=*
  856. analysis-url: http://seclists.org/oss-sec/2015/q2/520
  857. exploit-db: 37089
  858. Comments: Needs cron or system admin interaction
  859. EOF
  860. )
  861.  
  862. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  863. Name: ${txtgrn}[CVE-2015-1815]${txtrst} setroubleshoot
  864. Reqs: pkg=setroubleshoot,ver<3.2.22
  865. Tags: fedora=21
  866. exploit-db: 36564
  867. EOF
  868. )
  869.  
  870. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  871. Name: ${txtgrn}[CVE-2015-3246]${txtrst} userhelper
  872. Reqs: pkg=libuser,ver<=0.60
  873. Tags: RHEL<=7,centos<=7,fedora<=22
  874. analysis-url: https://www.qualys.com/2015/07/23/cve-2015-3245-cve-2015-3246/cve-2015-3245-cve-2015-3246.txt
  875. exploit-db: 37706
  876. EOF
  877. )
  878.  
  879. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  880. Name: ${txtgrn}[CVE-2015-6565]${txtrst} not_an_sshnuke
  881. Reqs: pkg=openssh-server,ver>=6.8,ver<=6.9
  882. Tags:
  883. analysis-url: http://www.openwall.com/lists/oss-security/2017/01/26/2
  884. exploit-db: 41173
  885. author: Federico Bento
  886. Comments: Needs admin interaction (root user needs to login via ssh to trigger exploitation)
  887. EOF
  888. )
  889.  
  890. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  891. Name: ${txtgrn}[CVE-2016-1240]${txtrst} tomcat-rootprivesc-deb.sh
  892. Reqs: pkg=tomcat
  893. Tags: debian=8,ubuntu=16.04
  894. analysis-url: https://legalhackers.com/advisories/Tomcat-DebPkgs-Root-Privilege-Escalation-Exploit-CVE-2016-1240.html
  895. src-url: http://legalhackers.com/exploits/tomcat-rootprivesc-deb.sh
  896. exploit-db: 40450
  897. author: Dawid Golunski
  898. Comments: Affects only Debian-based distros
  899. EOF
  900. )
  901.  
  902. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  903. Name: ${txtgrn}[CVE-2016-1247]${txtrst} nginxed-root.sh
  904. Reqs: pkg=nginx|nginx-full
  905. Tags: debian=8,ubuntu=14.04|16.04|16.10
  906. analysis-url: https://legalhackers.com/advisories/Nginx-Exploit-Deb-Root-PrivEsc-CVE-2016-1247.html
  907. src-url: https://legalhackers.com/exploits/CVE-2016-1247/nginxed-root.sh
  908. exploit-db: 40768
  909. author: Dawid Golunski
  910. Comments: Rooting depends on cron.daily (up to 24h of dealy). Affected: deb8: <1.6.2; 14.04: <1.4.6; 16.04: 1.10.0
  911. EOF
  912. )
  913.  
  914. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  915. Name: ${txtgrn}[CVE-2016-1531]${txtrst} perl_startup (exim)
  916. Reqs: pkg=exim,ver<4.86.2
  917. Tags:
  918. analysis-url: http://www.exim.org/static/doc/CVE-2016-1531.txt
  919. exploit-db: 39549
  920. EOF
  921. )
  922.  
  923. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  924. Name: ${txtgrn}[CVE-2016-1531]${txtrst} perl_startup (exim) 2
  925. Reqs: pkg=exim,ver<4.86.2
  926. Tags:
  927. analysis-url: http://www.exim.org/static/doc/CVE-2016-1531.txt
  928. exploit-db: 39535
  929. EOF
  930. )
  931.  
  932. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  933. Name: ${txtgrn}[CVE-2016-4989]${txtrst} setroubleshoot 2
  934. Reqs: pkg=setroubleshoot
  935. Tags: RHEL=6|7
  936. analysis-url: https://c-skills.blogspot.com/2016/06/lets-feed-attacker-input-to-sh-c-to-see.html
  937. src-url: https://github.com/stealth/troubleshooter/raw/master/straight-shooter.c
  938. exploit-db:
  939. EOF
  940. )
  941.  
  942. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  943. Name: ${txtgrn}[CVE-2016-5425]${txtrst} tomcat-RH-root.sh
  944. Reqs: pkg=tomcat
  945. Tags: RHEL=7
  946. analysis-url: http://legalhackers.com/advisories/Tomcat-RedHat-Pkgs-Root-PrivEsc-Exploit-CVE-2016-5425.html
  947. src-url: http://legalhackers.com/exploits/tomcat-RH-root.sh
  948. exploit-db: 40488
  949. author: Dawid Golunski
  950. Comments: Affects only RedHat-based distros
  951. EOF
  952. )
  953.  
  954. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  955. Name: ${txtgrn}[CVE-2016-6663,CVE-2016-6664|CVE-2016-6662]${txtrst} mysql-exploit-chain
  956. Reqs: pkg=mysql-server|mariadb-server,ver<5.5.52
  957. Tags: ubuntu=16.04.1
  958. analysis-url: https://legalhackers.com/advisories/MySQL-Maria-Percona-PrivEscRace-CVE-2016-6663-5616-Exploit.html
  959. src-url: http://legalhackers.com/exploits/CVE-2016-6663/mysql-privesc-race.c
  960. exploit-db: 40678
  961. author: Dawid Golunski
  962. Comments: Also MariaDB ver<10.1.18 and ver<10.0.28 affected
  963. EOF
  964. )
  965.  
  966. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  967. Name: ${txtgrn}[CVE-2016-9566]${txtrst} nagios-root-privesc
  968. Reqs: pkg=nagios,ver<4.2.4
  969. Tags:
  970. analysis-url: https://legalhackers.com/advisories/Nagios-Exploit-Root-PrivEsc-CVE-2016-9566.html
  971. src-url: https://legalhackers.com/exploits/CVE-2016-9566/nagios-root-privesc.sh
  972. exploit-db: 40921
  973. author: Dawid Golunski
  974. Comments: Allows priv escalation from nagios user or nagios group
  975. EOF
  976. )
  977.  
  978. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  979. Name: ${txtgrn}[CVE-2017-0358]${txtrst} ntfs-3g-modprobe
  980. Reqs: pkg=ntfs-3g
  981. Tags: ubuntu=16.04|16.10,debian=7|8
  982. analysis-url: https://bugs.chromium.org/p/project-zero/issues/detail?id=1072
  983. src-url: https://github.com/offensive-security/exploit-database-bin-sploits/raw/master/bin-sploits/41356.zip
  984. exploit-db: 41356
  985. author: Jann Horn
  986. Comments: Distros use own versioning scheme. Manual verification needed. Linux headers must be installed. System must have at least two CPU cores.
  987. EOF
  988. )
  989.  
  990. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  991. Name: ${txtgrn}[CVE-2017-1000367]${txtrst} Sudoer-to-root
  992. Reqs: pkg=sudo,ver<=1.8.20,cmd:[ -f /usr/sbin/getenforce ]
  993. Tags: RHEL=7{sudo:1.8.6p7}
  994. analysis-url: https://www.sudo.ws/alerts/linux_tty.html
  995. src-url: https://www.qualys.com/2017/05/30/cve-2017-1000367/linux_sudo_cve-2017-1000367.c
  996. exploit-db: 42183
  997. author: Qualys
  998. Comments: Needs to be sudoer. Works only on SELinux enabled systems
  999. EOF
  1000. )
  1001.  
  1002. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  1003. Name: ${txtgrn}[CVE-2017-1000367]${txtrst} sudopwn
  1004. Reqs: pkg=sudo,ver<=1.8.20,cmd:[ -f /usr/sbin/getenforce ]
  1005. Tags:
  1006. analysis-url: https://www.sudo.ws/alerts/linux_tty.html
  1007. src-url: https://raw.githubusercontent.com/c0d3z3r0/sudo-CVE-2017-1000367/master/sudopwn.c
  1008. exploit-db:
  1009. author: c0d3z3r0
  1010. Comments: Needs to be sudoer. Works only on SELinux enabled systems
  1011. EOF
  1012. )
  1013.  
  1014. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  1015. Name: ${txtgrn}[CVE-2017-1000366,CVE-2017-1000370]${txtrst} linux_ldso_hwcap
  1016. Reqs: pkg=glibc|libc6,ver<=2.25,x86
  1017. Tags:
  1018. analysis-url: https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt
  1019. src-url: https://www.qualys.com/2017/06/19/stack-clash/linux_ldso_hwcap.c
  1020. exploit-db: 42274
  1021. author: Qualys
  1022. Comments: Uses "Stack Clash" technique, works against most SUID-root binaries
  1023. EOF
  1024. )
  1025.  
  1026. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  1027. Name: ${txtgrn}[CVE-2017-1000366,CVE-2017-1000371]${txtrst} linux_ldso_dynamic
  1028. Reqs: pkg=glibc|libc6,ver<=2.25,x86
  1029. Tags: debian=9|10,ubuntu=14.04.5|16.04.2|17.04,fedora=23|24|25
  1030. analysis-url: https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt
  1031. src-url: https://www.qualys.com/2017/06/19/stack-clash/linux_ldso_dynamic.c
  1032. exploit-db: 42276
  1033. author: Qualys
  1034. Comments: Uses "Stack Clash" technique, works against most SUID-root PIEs
  1035. EOF
  1036. )
  1037.  
  1038. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  1039. Name: ${txtgrn}[CVE-2017-1000366,CVE-2017-1000379]${txtrst} linux_ldso_hwcap_64
  1040. Reqs: pkg=glibc|libc6,ver<=2.25,x86_64
  1041. Tags: debian=7.7|8.5|9.0,ubuntu=14.04.2|16.04.2|17.04,fedora=22|25,centos=7.3.1611
  1042. analysis-url: https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt
  1043. src-url: https://www.qualys.com/2017/06/19/stack-clash/linux_ldso_hwcap_64.c
  1044. exploit-db: 42275
  1045. author: Qualys
  1046. Comments: Uses "Stack Clash" technique, works against most SUID-root binaries
  1047. EOF
  1048. )
  1049.  
  1050. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  1051. Name: ${txtgrn}[CVE-2017-1000370,CVE-2017-1000371]${txtrst} linux_offset2lib
  1052. Reqs: pkg=glibc|libc6,ver<=2.25,x86
  1053. Tags:
  1054. analysis-url: https://www.qualys.com/2017/06/19/stack-clash/stack-clash.txt
  1055. src-url: https://www.qualys.com/2017/06/19/stack-clash/linux_offset2lib.c
  1056. exploit-db: 42273
  1057. author: Qualys
  1058. Comments: Uses "Stack Clash" technique
  1059. EOF
  1060. )
  1061.  
  1062. EXPLOITS_USERSPACE[((n++))]=$(cat <<EOF
  1063. Name: ${txtgrn}[CVE-2018-1000001]${txtrst} RationalLove
  1064. Reqs: pkg=glibc|libc6,ver<2.27,CONFIG_USER_NS=y,sysctl:kernel.unprivileged_userns_clone==1,x86_64
  1065. Tags: debian=9{glibc:2.24-11+deb9u1},ubuntu=16.04.3{glibc:2.23-0ubuntu9}
  1066. analysis-url: https://www.halfdog.net/Security/2017/LibcRealpathBufferUnderflow/
  1067. src-url: https://www.halfdog.net/Security/2017/LibcRealpathBufferUnderflow/RationalLove.c
  1068. Comments: kernel.unprivileged_userns_clone=1 required
  1069. exploit-db: 43775
  1070. author: halfdog
  1071. EOF
  1072. )
  1073.  
  1074. ###########################################################
  1075. ## security related HW/kernel features
  1076. ###########################################################
  1077. n=0
  1078.  
  1079. FEATURES[((n++))]=$(cat <<EOF
  1080. section: Kernel protection mechanisms:
  1081. EOF
  1082. )
  1083.  
  1084. FEATURES[((n++))]=$(cat <<EOF
  1085. feature: GCC stack protector support
  1086. available: CONFIG_CC_STACKPROTECTOR=y
  1087. analysis-url: https://github.com/mzet-/les-res/blob/master/features/stackprotector-regular.md
  1088. EOF
  1089. )
  1090.  
  1091. FEATURES[((n++))]=$(cat <<EOF
  1092. feature: GCC stack protector STRONG support
  1093. available: CONFIG_CC_STACKPROTECTOR_STRONG=y,ver>=3.14
  1094. analysis-url: https://github.com/mzet-/les-res/blob/master/features/stackprotector-strong.md
  1095. EOF
  1096. )
  1097.  
  1098. FEATURES[((n++))]=$(cat <<EOF
  1099. feature: Low address space to protect from user allocation
  1100. available: CONFIG_DEFAULT_MMAP_MIN_ADDR=[0-9]+
  1101. enabled: sysctl:vm.mmap_min_addr!=0
  1102. analysis-url: https://github.com/mzet-/les-res/blob/master/features/mmap_min_addr.md
  1103. EOF
  1104. )
  1105.  
  1106. FEATURES[((n++))]=$(cat <<EOF
  1107. feature: Hiding kernel pointers in /proc/kallsyms
  1108. available: ver>=2.6.28
  1109. enabled: sysctl:kernel.kptr_restrict!=0
  1110. analysis-url: https://github.com/mzet-/les-res/blob/master/features/kptr_restrict.md
  1111. EOF
  1112. )
  1113.  
  1114. FEATURES[((n++))]=$(cat <<EOF
  1115. feature: Restrict unprivileged access to kernel syslog
  1116. available: ver>=2.6.37
  1117. enabled: sysctl:kernel.dmesg_restrict!=0
  1118. analysis-url: https://github.com/mzet-/les-res/blob/master/features/dmesg_restrict.md
  1119. EOF
  1120. )
  1121.  
  1122. FEATURES[((n++))]=$(cat <<EOF
  1123. feature: Supervisor Mode Execution Protection (SMEP) support
  1124. available: ver>=3.0,cmd:grep -qi smep /proc/cpuinfo
  1125. enabled: cmd:grep -qi smep /proc/cpuinfo
  1126. analysis-url: https://github.com/mzet-/les-res/blob/master/features/smep.md
  1127. EOF
  1128. )
  1129.  
  1130. FEATURES[((n++))]=$(cat <<EOF
  1131. feature: Supervisor Mode Access Prevention (SMAP) support
  1132. available: ver>=3.7,cmd:grep -qi smap /proc/cpuinfo
  1133. enabled: cmd:grep -qi smap /proc/cpuinfo
  1134. analysis-url: https://github.com/mzet-/les-res/blob/master/features/smap.md
  1135. EOF
  1136. )
  1137.  
  1138. FEATURES[((n++))]=$(cat <<EOF
  1139. feature: Randomize the address of the kernel image (KASLR)
  1140. available: CONFIG_RANDOMIZE_BASE=y
  1141. analysis-url: https://github.com/mzet-/les-res/blob/master/features/kaslr.md
  1142. EOF
  1143. )
  1144.  
  1145. FEATURES[((n++))]=$(cat <<EOF
  1146. feature: Hardened user copy support
  1147. available: CONFIG_HARDENED_USERCOPY=y
  1148. analysis-url: https://github.com/mzet-/les-res/blob/master/features/hardened_usercopy.md
  1149. EOF
  1150. )
  1151.  
  1152. FEATURES[((n++))]=$(cat <<EOF
  1153. feature: Make kernel text and rodata read-only
  1154. available: CONFIG_STRICT_KERNEL_RWX=y
  1155. analysis-url: https://github.com/mzet-/les-res/blob/master/features/strict_kernel_rwx.md
  1156. EOF
  1157. )
  1158.  
  1159. FEATURES[((n++))]=$(cat <<EOF
  1160. feature: Set loadable kernel module data as NX and text as RO
  1161. available: CONFIG_STRICT_MODULE_RWX=y
  1162. analysis-url: https://github.com/mzet-/les-res/blob/master/features/strict_module_rwx.md
  1163. EOF
  1164. )
  1165.  
  1166. FEATURES[((n++))]=$(cat <<EOF
  1167. feature: Restrict /dev/mem access
  1168. available: CONFIG_STRICT_DEVMEM=y
  1169. analysis-url: https://github.com/mzet-/les-res/blob/master/features/strict_devmem.md
  1170. EOF
  1171. )
  1172.  
  1173. FEATURES[((n++))]=$(cat <<EOF
  1174. feature: Restrict I/O access to /dev/mem
  1175. available: CONFIG_IO_STRICT_DEVMEM=y
  1176. analysis-url: https://github.com/mzet-/les-res/blob/master/features/io_strict_devmem.md
  1177. EOF
  1178. )
  1179.  
  1180. FEATURES[((n++))]=$(cat <<EOF
  1181. section: Attack Surface:
  1182. EOF
  1183. )
  1184.  
  1185. FEATURES[((n++))]=$(cat <<EOF
  1186. feature: Support for /dev/mem access
  1187. available: CONFIG_DEVMEM=y
  1188. analysis-url: https://github.com/mzet-/les-res/blob/master/features/devmem.md
  1189. EOF
  1190. )
  1191.  
  1192. FEATURES[((n++))]=$(cat <<EOF
  1193. feature: Support for /dev/kmem access
  1194. available: CONFIG_DEVKMEM=y
  1195. analysis-url: https://github.com/mzet-/les-res/blob/master/features/devkmem.md
  1196. EOF
  1197. )
  1198.  
  1199. FEATURES[((n++))]=$(cat <<EOF
  1200. feature: User namespaces for unprivileged accounts
  1201. available: CONFIG_USER_NS=y
  1202. enabled: sysctl:kernel.unprivileged_userns_clone==1
  1203. analysis-url: https://github.com/mzet-/les-res/blob/master/features/user_ns.md
  1204. EOF
  1205. )
  1206.  
  1207. FEATURES[((n++))]=$(cat <<EOF
  1208. feature: Unprivileged access to bpf() system call
  1209. available: CONFIG_BPF_SYSCALL=y
  1210. enabled: sysctl:kernel.unprivileged_bpf_disabled!=1
  1211. analysis-url: https://github.com/mzet-/les-res/blob/master/features/bpf_syscall.md
  1212. EOF
  1213. )
  1214.  
  1215. version() {
  1216. echo "ICH ROOT EXPLOITER "$VERSION", h4m45t3r, indiancyberheros.com, august 2018"
  1217. }
  1218.  
  1219. usage() {
  1220. echo "Usage: linux-exploit-suggester.sh [OPTIONS]"
  1221. echo
  1222. echo " -V | --version - print version of this script"
  1223. echo " -h | --help - print this help"
  1224. echo " -k | --kernel <version> - provide kernel version"
  1225. echo " -u | --uname <string> - provide 'uname -a' string"
  1226. echo " --skip-more-checks - do not perform additional checks (kernel config, sysctl) to determine if exploit is applicable"
  1227. echo " --skip-pkg-versions - skip checking for exact userspace package version (helps to avoid false negatives)"
  1228. echo " -p | --pkglist-file <file> - provide file with 'dpkg -l' or 'rpm -qa' command output"
  1229. echo " --cvelist-file <file> - provide file with Linux kernel CVEs list"
  1230. echo " --checksec - list security related features for your HW/kernel"
  1231. echo " -s | --fetch-sources - automatically downloads source for matched exploit"
  1232. echo " -b | --fetch-binaries - automatically downloads binary for matched exploit if available"
  1233. echo " -f | --full - show full info about matched exploit"
  1234. echo " -g | --short - show shorten info about matched exploit"
  1235. echo " --kernelspace-only - show only kernel vulnerabilities"
  1236. echo " --userspace-only - show only userspace vulnerabilities"
  1237. echo " -d | --show-dos - show also DoSes in results"
  1238. }
  1239.  
  1240. exitWithErrMsg() {
  1241. echo "$1" 1>&2
  1242. exit 1
  1243. }
  1244.  
  1245. # extracts all information from output of 'uname -a' command
  1246. parseUname() {
  1247. local uname=$1
  1248.  
  1249. KERNEL=$(echo "$uname" | awk '{print $3}' | cut -d '-' -f 1)
  1250. KERNEL_ALL=$(echo "$uname" | awk '{print $3}')
  1251. ARCH=$(echo "$uname" | awk '{print $(NF-1)}')
  1252.  
  1253. OS=""
  1254. echo "$uname" | grep -q -i 'deb' && OS="debian"
  1255. echo "$uname" | grep -q -i 'ubuntu' && OS="ubuntu"
  1256. echo "$uname" | grep -q -i '\.fc' && OS="fedora"
  1257. echo "$uname" | grep -q -i '\.el' && OS="RHEL"
  1258.  
  1259. # 'uname -a' output doesn't contain distribution number (at least not in case of all distros)
  1260. }
  1261.  
  1262. getPkgList() {
  1263. local distro=$1
  1264. local pkglist_file=$2
  1265.  
  1266. # take package listing from provided file & detect if it's 'rpm -qa' listing or 'dpkg -l' listing or not recognized listing
  1267. if [ "$opt_pkglist_file" = "true" -a -e "$pkglist_file" ]; then
  1268.  
  1269. # ubuntu/debian package listing file
  1270. if [ $(cat "$pkglist_file" | head -1 | grep 'Desired=Unknown/Install/Remove/Purge/Hold') ]; then
  1271. PKG_LIST=$(cat "$pkglist_file" | awk '{print $2"-"$3}' | sed 's/:amd64//g')
  1272.  
  1273. OS="debian"
  1274. [ "$(cat "$pkglist_file" | grep "ubuntu")" ] && OS="ubuntu"
  1275. # redhat package listing file
  1276. elif [ $(cat "$pkglist_file" | head -1 | grep -E '\.el[1-9]+\.') ]; then
  1277. PKG_LIST=$(cat "$pkglist_file")
  1278. OS="RHEL"
  1279. # file not recognized - skipping
  1280. else
  1281. PKG_LIST=""
  1282. fi
  1283.  
  1284. elif [ "$distro" = "debian" -o "$distro" = "ubuntu" ]; then
  1285. PKG_LIST=$(dpkg -l | awk '{print $2"-"$3}' | sed 's/:amd64//g')
  1286. elif [ "$distro" = "RHEL" -o "$distro" = "fedora" ]; then
  1287. PKG_LIST=$(rpm -qa)
  1288. else
  1289. # packages listing not available
  1290. PKG_LIST=""
  1291. fi
  1292. }
  1293.  
  1294. # from: https://stackoverflow.com/questions/4023830/how-compare-two-strings-in-dot-separated-version-format-in-bash
  1295. verComparision() {
  1296.  
  1297. if [[ $1 == $2 ]]
  1298. then
  1299. return 0
  1300. fi
  1301.  
  1302. local IFS=.
  1303. local i ver1=($1) ver2=($2)
  1304.  
  1305. # fill empty fields in ver1 with zeros
  1306. for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
  1307. do
  1308. ver1[i]=0
  1309. done
  1310.  
  1311. for ((i=0; i<${#ver1[@]}; i++))
  1312. do
  1313. if [[ -z ${ver2[i]} ]]
  1314. then
  1315. # fill empty fields in ver2 with zeros
  1316. ver2[i]=0
  1317. fi
  1318. if ((10#${ver1[i]} > 10#${ver2[i]}))
  1319. then
  1320. return 1
  1321. fi
  1322. if ((10#${ver1[i]} < 10#${ver2[i]}))
  1323. then
  1324. return 2
  1325. fi
  1326. done
  1327.  
  1328. return 0
  1329. }
  1330.  
  1331. doVersionComparision() {
  1332. local reqVersion="$1"
  1333. local reqRelation="$2"
  1334. local currentVersion="$3"
  1335.  
  1336. verComparision $currentVersion $reqVersion
  1337. case $? in
  1338. 0) currentRelation='=';;
  1339. 1) currentRelation='>';;
  1340. 2) currentRelation='<';;
  1341. esac
  1342.  
  1343. if [ "$reqRelation" == "=" ]; then
  1344. [ $currentRelation == "=" ] && return 0
  1345. elif [ "$reqRelation" == ">" ]; then
  1346. [ $currentRelation == ">" ] && return 0
  1347. elif [ "$reqRelation" == "<" ]; then
  1348. [ $currentRelation == "<" ] && return 0
  1349. elif [ "$reqRelation" == ">=" ]; then
  1350. [ $currentRelation == "=" ] && return 0
  1351. [ $currentRelation == ">" ] && return 0
  1352. elif [ "$reqRelation" == "<=" ]; then
  1353. [ $currentRelation == "=" ] && return 0
  1354. [ $currentRelation == "<" ] && return 0
  1355. fi
  1356. }
  1357.  
  1358. compareValues() {
  1359. curVal=$1
  1360. val=$2
  1361. sign=$3
  1362.  
  1363. if [ "$sign" == "==" ]; then
  1364. [ "$val" == "$curVal" ] && return 0
  1365. elif [ "$sign" == "!=" ]; then
  1366. [ "$val" != "$curVal" ] && return 0
  1367. fi
  1368.  
  1369. return 1
  1370. }
  1371.  
  1372. checkRequirement() {
  1373. #echo "Checking requirement: $1"
  1374. local IN="$1"
  1375. local pkgName="${2:4}"
  1376.  
  1377. if [[ "$IN" =~ ^pkg=.*$ ]]; then
  1378.  
  1379. # always true for Linux OS
  1380. [ ${pkgName} == "linux-kernel" ] && return 0
  1381.  
  1382. # verify if package is present
  1383. pkg=$(echo "$PKG_LIST" | grep -E -i "^$pkgName-[0-9]+" | head -1)
  1384. if [ -n "$pkg" ]; then
  1385. return 0
  1386. fi
  1387.  
  1388. elif [[ "$IN" =~ ^ver.*$ ]]; then
  1389. version="${IN//[^0-9.]/}"
  1390. rest="${IN#ver}"
  1391. operator=${rest%$version}
  1392.  
  1393. if [ "$pkgName" == "linux-kernel" -o "$opt_checksec_mode" == "true" ]; then
  1394.  
  1395. # for --cvelist-file mode skip kernel version comparision
  1396. [ "$opt_cvelist_file" = "true" ] && return 0
  1397.  
  1398. doVersionComparision $version $operator $KERNEL && return 0
  1399. else
  1400. # extract package version and check if requiremnt is true
  1401. pkg=$(echo "$PKG_LIST" | grep -E -i "^$pkgName-[0-9]+" | head -1)
  1402.  
  1403. # skip (if run with --skip-pkg-versions) version checking if package with given name is installed
  1404. [ "$opt_skip_pkg_versions" = "true" -a -n "$pkg" ] && return 0
  1405.  
  1406. # versioning:
  1407. #echo "pkg: $pkg"
  1408. pkgVersion=$(echo "$pkg" | grep -E -i -o -e '-[\.0-9\+:p]+[-\+]' | cut -d':' -f2 | sed 's/[\+-]//g' | sed 's/p[0-9]//g')
  1409. #echo "version: $pkgVersion"
  1410. #echo "operator: $operator"
  1411. #echo "required version: $version"
  1412. #echo
  1413. doVersionComparision $version $operator $pkgVersion && return 0
  1414. fi
  1415. elif [[ "$IN" =~ ^x86_64$ ]] && [ "$ARCH" == "x86_64" -o "$ARCH" == "" ]; then
  1416. return 0
  1417. elif [[ "$IN" =~ ^x86$ ]] && [ "$ARCH" == "i386" -o "$ARCH" == "i686" -o "$ARCH" == "" ]; then
  1418. return 0
  1419. elif [[ "$IN" =~ ^CONFIG_.*$ ]]; then
  1420.  
  1421. # skip if check is not applicable (-k or --uname or -p set) or if user said so (--skip-more-checks)
  1422. [ "$opt_skip_more_checks" = "true" ] && return 0
  1423.  
  1424. # if kernel config IS available:
  1425. if [ -n "$KCONFIG" ]; then
  1426. if $KCONFIG | grep -E -qi $IN; then
  1427. return 0;
  1428. # required option wasn't found, exploit is not applicable
  1429. else
  1430. return 1;
  1431. fi
  1432. # config is not available
  1433. else
  1434. return 0;
  1435. fi
  1436. elif [[ "$IN" =~ ^sysctl:.*$ ]]; then
  1437.  
  1438. # skip if check is not applicable (-k or --uname or -p modes) or if user said so (--skip-more-checks)
  1439. [ "$opt_skip_more_checks" = "true" ] && return 0
  1440.  
  1441. sysctlCondition="${IN:7}"
  1442.  
  1443. # extract sysctl entry, relation sign and required value
  1444. if echo $sysctlCondition | grep -qi "!="; then
  1445. sign="!="
  1446. elif echo $sysctlCondition | grep -qi "=="; then
  1447. sign="=="
  1448. else
  1449. exitWithErrMsg "Wrong sysctl condition. There is syntax error in your features DB. Aborting."
  1450. fi
  1451. val=$(echo "$sysctlCondition" | awk -F "$sign" '{print $2}')
  1452. entry=$(echo "$sysctlCondition" | awk -F "$sign" '{print $1}')
  1453.  
  1454. # get current setting of sysctl entry
  1455. curVal=$(/sbin/sysctl -a 2> /dev/null | grep "$entry" | awk -F'=' '{print $2}')
  1456.  
  1457. # special case for --checksec mode: return 2 if there is no such switch in sysctl
  1458. [ -z "$curVal" -a "$opt_checksec_mode" = "true" ] && return 2
  1459.  
  1460. # for other modes: skip if there is no such switch in sysctl
  1461. [ -z "$curVal" ] && return 0
  1462.  
  1463. # compare & return result
  1464. compareValues $curVal $val $sign && return 0
  1465.  
  1466. elif [[ "$IN" =~ ^cmd:.*$ ]]; then
  1467.  
  1468. # skip if check is not applicable (-k or --uname or -p modes) or if user said so (--skip-more-checks)
  1469. [ "$opt_skip_more_checks" = "true" ] && return 0
  1470.  
  1471. cmd="${IN:4}"
  1472. if eval "${cmd}"; then
  1473. return 0
  1474. fi
  1475. fi
  1476.  
  1477. return 1
  1478. }
  1479.  
  1480. getKernelConfig() {
  1481. if [ -f /proc/config.gz ] ; then
  1482. KCONFIG="zcat /proc/config.gz"
  1483. elif [ -f /boot/config-`uname -r` ] ; then
  1484. KCONFIG="cat /boot/config-`uname -r`"
  1485. elif [ -f "${KBUILD_OUTPUT:-/usr/src/linux}"/.config ] ; then
  1486. KCONFIG="cat ${KBUILD_OUTPUT:-/usr/src/linux}/.config"
  1487. else
  1488. KCONFIG=""
  1489. fi
  1490. }
  1491.  
  1492. checksecMode() {
  1493.  
  1494. # start analysis
  1495. for FEATURE in "${FEATURES[@]}"; do
  1496.  
  1497. # create array from current exploit here doc and fetch needed lines
  1498. i=0
  1499. # ('-r' is used to not interpret backslash used for bash colors)
  1500. while read -r line
  1501. do
  1502. arr[i]="$line"
  1503. i=$((i + 1))
  1504. done <<< "$FEATURE"
  1505.  
  1506. NAME="${arr[0]}"
  1507. PRE_NAME="${NAME:0:8}"
  1508. NAME="${NAME:9}"
  1509. if [ "${PRE_NAME}" = "section:" ]; then
  1510. echo
  1511. echo -e "${bldwht}${NAME}${txtrst}"
  1512. echo
  1513. continue
  1514. fi
  1515.  
  1516. AVAILABLE="${arr[1]}" && AVAILABLE="${AVAILABLE:11}"
  1517. ENABLE=$(echo "$FEATURE" | grep "enabled: " | awk -F'ed: ' '{print $2}')
  1518. analysis_url=$(echo "$FEATURE" | grep "analysis-url: " | awk '{print $2}')
  1519.  
  1520. # split line with availability requirements & loop thru all availability reqs one by one & check whether it is met
  1521. IFS=',' read -r -a array <<< "$AVAILABLE"
  1522. AVAILABLE_REQS_NUM=${#array[@]}
  1523. AVAILABLE_PASSED_REQ=0
  1524. for REQ in "${array[@]}"; do
  1525. if (checkRequirement "$REQ"); then
  1526. AVAILABLE_PASSED_REQ=$(($AVAILABLE_PASSED_REQ + 1))
  1527. else
  1528. break
  1529. fi
  1530. done
  1531.  
  1532. # split line with enablement requirements & loop thru all enablement reqs one by one & check whether it is met
  1533. ENABLE_PASSED_REQ=0
  1534. ENABLE_REQS_NUM=-1
  1535. noSysctl=0
  1536. if [ -n "$ENABLE" ]; then
  1537. IFS=',' read -r -a array <<< "$ENABLE"
  1538. ENABLE_REQS_NUM=${#array[@]}
  1539. for REQ in "${array[@]}"; do
  1540. checkRequirement "$REQ"
  1541. retVal=$?
  1542. if [ $retVal -eq 0 ]; then
  1543. ENABLE_PASSED_REQ=$(($ENABLE_PASSED_REQ + 1))
  1544. elif [ $retVal -eq 2 ]; then
  1545. # special case: sysctl entry is not present on given system: signal it as: N/A
  1546. noSysctl=1
  1547. break
  1548. else
  1549. break
  1550. fi
  1551. done
  1552. fi
  1553.  
  1554. feature=$(echo "$FEATURE" | grep "feature: " | cut -d' ' -f 2-)
  1555.  
  1556. available="${txtred}Available${txtrst}"
  1557. enabled=" ${txtgray}N/A${txtrst} "
  1558.  
  1559. if [ $AVAILABLE_PASSED_REQ -eq $AVAILABLE_REQS_NUM ]; then
  1560. available="${txtgrn}Available${txtrst}"
  1561. fi
  1562.  
  1563. if [ $ENABLE_PASSED_REQ -eq $ENABLE_REQS_NUM -a $noSysctl -eq 0 -a -n "$ENABLE" ]; then
  1564. enabled="${txtgrn}Enabled${txtrst}"
  1565. elif [ -n "$ENABLE" -a $noSysctl -eq 0 ]; then
  1566. enabled="${txtred}Disabled${txtrst}"
  1567. fi
  1568.  
  1569. # short (--short) output
  1570. if [ "$opt_summary" = "true" ]; then
  1571. echo -e "[ $available ][ $enabled ] $feature"
  1572. continue
  1573. fi
  1574.  
  1575. echo -e "[+] $feature"
  1576. echo -e "\n [ $available ]: $AVAILABLE"
  1577. [ -n "$ENABLE" ] && echo -e " [ $enabled ]: $ENABLE"
  1578. [ -n "$analysis_url" ] && echo -e " Feature analysis: $analysis_url"
  1579. echo
  1580.  
  1581. done
  1582.  
  1583. }
  1584.  
  1585. # parse command line parameters
  1586. ARGS=$(getopt --options $SHORTOPTS --longoptions $LONGOPTS -- "$@")
  1587. [ $? != 0 ] && exitWithErrMsg "Aborting."
  1588.  
  1589. eval set -- "$ARGS"
  1590.  
  1591. while true; do
  1592. case "$1" in
  1593. -u|--uname)
  1594. shift
  1595. UNAME_A="$1"
  1596. opt_uname_string=true
  1597. ;;
  1598. -V|--version)
  1599. version
  1600. exit 0
  1601. ;;
  1602. -h|--help)
  1603. usage
  1604. exit 0
  1605. ;;
  1606. -f|--full)
  1607. opt_full=true
  1608. ;;
  1609. -g|--short)
  1610. opt_summary=true
  1611. ;;
  1612. -b|--fetch-binaries)
  1613. opt_fetch_bins=true
  1614. ;;
  1615. -s|--fetch-sources)
  1616. opt_fetch_srcs=true
  1617. ;;
  1618. -k|--kernel)
  1619. shift
  1620. KERNEL="$1"
  1621. opt_kernel_version=true
  1622. ;;
  1623. -d|--show-dos)
  1624. opt_show_dos=true
  1625. ;;
  1626. -p|--pkglist-file)
  1627. shift
  1628. PKGLIST_FILE="$1"
  1629. opt_pkglist_file=true
  1630. ;;
  1631. --cvelist-file)
  1632. shift
  1633. CVELIST_FILE="$1"
  1634. opt_cvelist_file=true
  1635. ;;
  1636. --checksec)
  1637. opt_checksec_mode=true
  1638. ;;
  1639. --kernelspace-only)
  1640. opt_kernel_only=true
  1641. ;;
  1642. --userspace-only)
  1643. opt_userspace_only=true
  1644. ;;
  1645. --skip-more-checks)
  1646. opt_skip_more_checks=true
  1647. ;;
  1648. --skip-pkg-versions)
  1649. opt_skip_pkg_versions=true
  1650. ;;
  1651. *)
  1652. shift
  1653. if [ "$#" != "0" ]; then
  1654. exitWithErrMsg "Unknown option '$1'. Aborting."
  1655. fi
  1656. break
  1657. ;;
  1658. esac
  1659. shift
  1660. done
  1661.  
  1662. # check Bash version (associative arrays need Bash in version 4.0+)
  1663. if ((BASH_VERSINFO[0] < 4)); then
  1664. exitWithErrMsg "Script needs Bash in version 4.0 or newer. Aborting."
  1665. fi
  1666.  
  1667. # exit if both --kernel and --uname are set
  1668. [ "$opt_kernel_version" = "true" ] && [ $opt_uname_string = "true" ] && exitWithErrMsg "Switches -u|--uname and -k|--kernel are mutually exclusive. Aborting."
  1669.  
  1670. # exit if both --full and --short are set
  1671. [ "$opt_full" = "true" ] && [ $opt_summary = "true" ] && exitWithErrMsg "Switches -f|--full and -g|--short are mutually exclusive. Aborting."
  1672.  
  1673. # --cvelist-file mode is standalone mode and is not applicable when one of -k | -u | -p | --checksec switches are set
  1674. if [ "$opt_cvelist_file" = "true" ]; then
  1675. [ ! -e "$CVELIST_FILE" ] && exitWithErrMsg "Provided CVE list file does not exists. Aborting."
  1676. [ "$opt_kernel_version" = "true" ] && exitWithErrMsg "Switches -k|--kernel and --cvelist-file are mutually exclusive. Aborting."
  1677. [ "$opt_uname_string" = "true" ] && exitWithErrMsg "Switches -u|--uname and --cvelist-file are mutually exclusive. Aborting."
  1678. [ "$opt_pkglist_file" = "true" ] && exitWithErrMsg "Switches -p|--pkglist-file and --cvelist-file are mutually exclusive. Aborting."
  1679. fi
  1680.  
  1681. # --checksec mode is standalone mode and is not applicable when one of -k | -u | -p | --cvelist-file switches are set
  1682. if [ "$opt_checksec_mode" = "true" ]; then
  1683. [ "$opt_kernel_version" = "true" ] && exitWithErrMsg "Switches -k|--kernel and --checksec are mutually exclusive. Aborting."
  1684. [ "$opt_uname_string" = "true" ] && exitWithErrMsg "Switches -u|--uname and --checksec are mutually exclusive. Aborting."
  1685. [ "$opt_pkglist_file" = "true" ] && exitWithErrMsg "Switches -p|--pkglist-file and --checksec are mutually exclusive. Aborting."
  1686. fi
  1687.  
  1688. # extract kernel version and other OS info like distro name, distro version, etc. 3 possibilities here:
  1689. # case 1: --kernel set
  1690. if [ "$opt_kernel_version" == "true" ]; then
  1691. # TODO: add kernel version number validation
  1692. [ -z "$KERNEL" ] && exitWithErrMsg "Unrecognized kernel version given. Aborting."
  1693. ARCH=""
  1694. OS=""
  1695.  
  1696. # do not perform additional checks on current machine
  1697. opt_skip_more_checks=true
  1698.  
  1699. # do not consider current OS
  1700. getPkgList "" "$PKGLIST_FILE"
  1701.  
  1702. # case 2: --uname set
  1703. elif [ "$opt_uname_string" == "true" ]; then
  1704. [ -z "$UNAME_A" ] && exitWithErrMsg "uname string empty. Aborting."
  1705. parseUname "$UNAME_A"
  1706.  
  1707. # do not perform additional checks on current machine
  1708. opt_skip_more_checks=true
  1709.  
  1710. # do not consider current OS
  1711. getPkgList "" "$PKGLIST_FILE"
  1712.  
  1713. # case 3: --cvelist-file mode
  1714. elif [ "$opt_cvelist_file" = "true" ]; then
  1715.  
  1716. # get kernel configuration in this mode
  1717. [ "$opt_skip_more_checks" = "false" ] && getKernelConfig
  1718.  
  1719. # case 4: --checksec mode
  1720. elif [ "$opt_checksec_mode" = "true" ]; then
  1721.  
  1722. # this switch is not applicable in this mode
  1723. opt_skip_more_checks=false
  1724.  
  1725. # get kernel configuration in this mode
  1726. getKernelConfig
  1727. [ -z "$KCONFIG" ] && exitWithErrMsg "Kernel configuration file not available. Aborting."
  1728.  
  1729. # launch checksec mode
  1730. checksecMode
  1731.  
  1732. exit 0
  1733.  
  1734. # case 5: no --uname | --kernel | --cvelist-file | --checksec set
  1735. else
  1736.  
  1737. # --pkglist-file NOT provided: take all info from current machine
  1738. # case for vanilla execution: ./linux-exploit-suggester.sh
  1739. if [ "$opt_pkglist_file" == "false" ]; then
  1740. UNAME_A=$(uname -a)
  1741. [ -z "$UNAME_A" ] && exitWithErrMsg "uname string empty. Aborting."
  1742. parseUname "$UNAME_A"
  1743.  
  1744. # get kernel configuration in this mode
  1745. [ "$opt_skip_more_checks" = "false" ] && getKernelConfig
  1746.  
  1747. # extract distribution version from /etc/issue
  1748. [ -n "$OS" -a "$opt_skip_more_checks" = "false" ] && DISTRO=$(cat /etc/issue | grep -E -o '[0-9\.]+' | head -1)
  1749.  
  1750. # extract package listing from current OS
  1751. getPkgList "$OS" ""
  1752.  
  1753. # --pkglist-file provided: only consider userspace exploits against provided package listing
  1754. else
  1755. KERNEL=""
  1756. #TODO: extract machine arch from package listing
  1757. ARCH=""
  1758. unset EXPLOITS
  1759. declare -A EXPLOITS
  1760. getPkgList "" "$PKGLIST_FILE"
  1761.  
  1762. # additional checks are not applicable for this mode
  1763. opt_skip_more_checks=true
  1764. fi
  1765. fi
  1766.  
  1767. echo
  1768. echo -e "${bldwht}Available information:${txtrst}"
  1769. echo
  1770. [ -n "$KERNEL" ] && echo -e "Kernel version: ${txtgrn}$KERNEL${txtrst}" || echo -e "Kernel version: ${txtred}N/A${txtrst}"
  1771. echo "Architecture: $([ -n "$ARCH" ] && echo -e "${txtgrn}$ARCH${txtrst}" || echo -e "${txtred}N/A${txtrst}")"
  1772. echo "Distribution: $([ -n "$OS" ] && echo -e "${txtgrn}$OS${txtrst}" || echo -e "${txtred}N/A${txtrst}")"
  1773. echo -e "Distribution version: $([ -n "$DISTRO" ] && echo -e "${txtgrn}$DISTRO${txtrst}" || echo -e "${txtred}N/A${txtrst}")"
  1774.  
  1775. echo "Additional checks (CONFIG_*, sysctl entries, custom Bash commands): $([ "$opt_skip_more_checks" == "false" ] && echo -e "${txtgrn}performed${txtrst}" || echo -e "${txtred}N/A${txtrst}")"
  1776.  
  1777. if [ -n "$PKGLIST_FILE" -a -n "$PKG_LIST" ]; then
  1778. pkgListFile="${txtgrn}$PKGLIST_FILE${txtrst}"
  1779. elif [ -n "$PKGLIST_FILE" ]; then
  1780. pkgListFile="${txtred}unrecognized file provided${txtrst}"
  1781. elif [ -n "$PKG_LIST" ]; then
  1782. pkgListFile="${txtgrn}from current OS${txtrst}"
  1783. fi
  1784.  
  1785. echo -e "Package listing: $([ -n "$pkgListFile" ] && echo -e "$pkgListFile" || echo -e "${txtred}N/A${txtrst}")"
  1786.  
  1787. # handle --kernelspacy-only & --userspace-only filter options
  1788. if [ "$opt_kernel_only" = "true" -o -z "$PKG_LIST" ]; then
  1789. unset EXPLOITS_USERSPACE
  1790. declare -A EXPLOITS_USERSPACE
  1791. fi
  1792.  
  1793. if [ "$opt_userspace_only" = "true" ]; then
  1794. unset EXPLOITS
  1795. declare -A EXPLOITS
  1796. fi
  1797.  
  1798. echo
  1799. echo -e "${bldwht}Searching among:${txtrst}"
  1800. echo
  1801. echo "${#EXPLOITS[@]} kernel space exploits"
  1802. echo "${#EXPLOITS_USERSPACE[@]} user space exploits"
  1803. echo
  1804.  
  1805. echo -e "${bldwht}Possible Exploits:${txtrst}"
  1806. echo
  1807.  
  1808. # start analysis
  1809. for EXP in "${EXPLOITS[@]}" "${EXPLOITS_USERSPACE[@]}"; do
  1810.  
  1811. # create array from current exploit here doc and fetch needed lines
  1812. i=0
  1813. # ('-r' is used to not interpret backslash used for bash colors)
  1814. while read -r line
  1815. do
  1816. arr[i]="$line"
  1817. i=$((i + 1))
  1818. done <<< "$EXP"
  1819.  
  1820. REQS="${arr[1]}" && REQS="${REQS:6}"
  1821. NAME="${arr[0]}" && NAME="${NAME:6}"
  1822. TAGS="${arr[2]}" && TAGS="${TAGS:6}"
  1823.  
  1824. # split line with requirements & loop thru all reqs one by one & check whether it is met
  1825. IFS=',' read -r -a array <<< "$REQS"
  1826. REQS_NUM=${#array[@]}
  1827. PASSED_REQ=0
  1828. for REQ in "${array[@]}"; do
  1829. if (checkRequirement "$REQ" "${array[0]}"); then
  1830. PASSED_REQ=$(($PASSED_REQ + 1))
  1831. else
  1832. break
  1833. fi
  1834. done
  1835.  
  1836. # execute for exploits with all requirements met
  1837. if [ $PASSED_REQ -eq $REQS_NUM ]; then
  1838.  
  1839. # additional requirement for --cvelist-file mode: check if CVE associated with the exploit is on the CVELIST_FILE
  1840. if [ "$opt_cvelist_file" = "true" ]; then
  1841.  
  1842. # extract CVE(s) associated with given exploit (also translates ',' to '|' for easy handling multiple CVEs case - via extended regex)
  1843. cve=$(echo "$NAME" | grep '.*\[.*\].*' | cut -d 'm' -f2 | cut -d ']' -f1 | tr -d '[' | tr "," "|")
  1844. #echo "CVE: $cve"
  1845.  
  1846. # check if it's on CVELIST_FILE list, if no move to next exploit
  1847. [ ! $(cat "$CVELIST_FILE" | grep -E "$cve") ] && continue
  1848. fi
  1849.  
  1850. # process tags and highlight those that match current OS (only for deb|ubuntu|RHEL and if we know distro version - direct mode)
  1851. tags=""
  1852. if [ -n "$TAGS" -a -n "$OS" -a -n "$DISTRO" ]; then
  1853. IFS=',' read -r -a tags_array <<< "$TAGS"
  1854. TAGS_NUM=${#tags_array[@]}
  1855. for TAG in "${tags_array[@]}"; do
  1856. tag_distro=$(echo "$TAG" | cut -d'=' -f1)
  1857. tag_distro_num_all=$(echo "$TAG" | cut -d'=' -f2)
  1858. # in case of tag of form: 'ubuntu=16.04{kernel:4.4.0-21} remove kernel versioning part for comparision
  1859. tag_distro_num="${tag_distro_num_all%{*}"
  1860.  
  1861. # if distro matches:
  1862. if [ "$OS" == "$tag_distro" -a "$(echo "$DISTRO" | grep -E "$tag_distro_num")" ]; then
  1863.  
  1864. # get name (kernel or package name) and version of kernel/pkg if provided:
  1865. tag_pkg=$(echo "$tag_distro_num_all" | cut -d'{' -f 2 | tr -d '}' | cut -d':' -f 1)
  1866. tag_pkg_num=""
  1867. [ $(echo "$tag_distro_num_all" | grep '{') ] && tag_pkg_num=$(echo "$tag_distro_num_all" | cut -d'{' -f 2 | tr -d '}' | cut -d':' -f 2)
  1868.  
  1869. #[ -n "$tag_pkg_num" ] && echo "tag_pkg_num: $tag_pkg_num; kernel: $KERNEL_ALL"
  1870.  
  1871. # if pkg/kernel version is not provided:
  1872. if [ -z "$tag_pkg_num" ]; then
  1873. TAG="${lightyellow}[ ${TAG} ]${txtrst}"
  1874.  
  1875. # kernel version provided, check for match:
  1876. elif [ -n "$tag_pkg_num" -a "$tag_pkg" = "kernel" ]; then
  1877. [ $(echo "$KERNEL_ALL" | grep -E "${tag_pkg_num}") ] && TAG="${yellow}[ ${TAG} ]${txtrst}" || TAG="${lightyellow}[ $tag_distro=$tag_distro_num ]${txtrst}{kernel:$tag_pkg_num}"
  1878.  
  1879. # pkg version provided, check for match (TBD):
  1880. elif [ -n "$tag_pkg_num" -a -n "$tag_pkg" ]; then
  1881. TAG="${lightyellow}[ $tag_distro=$tag_distro_num ]${txtrst}{$tag_pkg:$tag_pkg_num}"
  1882. fi
  1883.  
  1884. fi
  1885.  
  1886. # append current tag to tags list
  1887. tags="${tags}${TAG},"
  1888. done
  1889. # trim ',' added by above loop
  1890. [ -n "$tags" ] && tags="${tags%?}"
  1891. else
  1892. tags="$TAGS"
  1893. fi
  1894.  
  1895. EXPLOIT_DB=$(echo "$EXP" | grep "exploit-db: " | awk '{print $2}')
  1896. analysis_url=$(echo "$EXP" | grep "analysis-url: " | awk '{print $2}')
  1897. ext_url=$(echo "$EXP" | grep "ext-url: " | awk '{print $2}')
  1898. comments=$(echo "$EXP" | grep "Comments: " | cut -d' ' -f 2-)
  1899. reqs=$(echo "$EXP" | grep "Reqs: " | cut -d' ' -f 2)
  1900.  
  1901. # exploit name without CVE number and without commonly used special chars
  1902. name=$(echo "$NAME" | cut -d' ' -f 2- | tr -d ' ()/')
  1903.  
  1904. src_url=$(echo "$EXP" | grep "src-url: " | awk '{print $2}')
  1905. [ -z "$src_url" ] && [ -n "$EXPLOIT_DB" ] && src_url="https://www.exploit-db.com/download/$EXPLOIT_DB"
  1906. [ -z "$src_url" ] && exitWithErrMsg "Both 'src-url' and 'exploit-db' entries are empty for '$NAME' exploit - fix that. Aborting."
  1907.  
  1908. if [ -n "$analysis_url" ]; then
  1909. details="$analysis_url"
  1910. elif $(echo "$src_url" | grep -q 'www.exploit-db.com'); then
  1911. details="https://www.exploit-db.com/exploits/$EXPLOIT_DB/"
  1912. elif [[ "$src_url" =~ ^.*tgz|tar.gz|zip$ && -n "$EXPLOIT_DB" ]]; then
  1913. details="https://www.exploit-db.com/exploits/$EXPLOIT_DB/"
  1914. else
  1915. details="$src_url"
  1916. fi
  1917.  
  1918. # skip DoS by default
  1919. dos=$(echo "$EXP" | grep -o -i "(dos")
  1920. [ "$opt_show_dos" == "false" ] && [ -n "$dos" ] && continue
  1921.  
  1922. # handles --fetch-binaries option
  1923. if [ $opt_fetch_bins = "true" ]; then
  1924. for i in $(echo "$EXP" | grep "bin-url: " | awk '{print $2}'); do
  1925. [ -f "${name}_$(basename $i)" ] && rm -f "${name}_$(basename $i)"
  1926. wget -q -k "$i" -O "${name}_$(basename $i)"
  1927. done
  1928. fi
  1929.  
  1930. # handles --fetch-sources option
  1931. if [ $opt_fetch_srcs = "true" ]; then
  1932. [ -f "${name}_$(basename $src_url)" ] && rm -f "${name}_$(basename $src_url)"
  1933. wget -q -k "$src_url" -O "${name}_$(basename $src_url)" &
  1934. fi
  1935.  
  1936. # display result (short)
  1937. if [ "$opt_summary" = "true" ]; then
  1938. [ -z "$tags" ] && tags="-"
  1939. echo -e "$NAME || $tags || $src_url"
  1940. continue
  1941. fi
  1942.  
  1943. # display result (standard)
  1944. echo -e "[+] $NAME"
  1945. echo -e "\n Details: $details"
  1946. [ -n "$tags" ] && echo -e " Tags: $tags"
  1947. echo -e " Download URL: $src_url"
  1948. [ -n "$ext_url" ] && echo -e " ext-url: $ext_url"
  1949. [ -n "$comments" ] && echo -e " Comments: $comments"
  1950.  
  1951. # handles --full filter option
  1952. if [ "$opt_full" = "true" ]; then
  1953. [ -n "$reqs" ] && echo -e " Requirements: $reqs"
  1954.  
  1955. [ -n "$EXPLOIT_DB" ] && echo -e " exploit-db: $EXPLOIT_DB"
  1956.  
  1957. author=$(echo "$EXP" | grep "author: " | cut -d' ' -f 2-)
  1958. [ -n "$author" ] && echo -e " author: $author"
  1959. fi
  1960.  
  1961. echo
  1962. fi
  1963. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement