freedombone-tests 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Run tests on the system
  12. # License
  13. # =======
  14. #
  15. # Copyright (C) 2015-2016 Bob Mottram <bob@freedombone.net>
  16. #
  17. # This program is free software: you can redistribute it and/or modify
  18. # it under the terms of the GNU Affero General Public License as published by
  19. # the Free Software Foundation, either version 3 of the License, or
  20. # (at your option) any later version.
  21. #
  22. # This program is distributed in the hope that it will be useful,
  23. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. # GNU Affero General Public License for more details.
  26. #
  27. # You should have received a copy of the GNU Affero General Public License
  28. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. PROJECT_NAME='freedombone'
  30. export TEXTDOMAIN=${PROJECT_NAME}-tests
  31. export TEXTDOMAINDIR="/usr/share/locale"
  32. source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-setup
  33. # Whether to run STIG tests
  34. RUN_STIG=
  35. # Whether to show both passes and fails of STIG tests
  36. SHOW_ALL_TESTS=
  37. function show_help {
  38. echo ''
  39. echo $"${PROJECT_NAME}-tests"
  40. echo ''
  41. echo $'Runs tests on the system'
  42. echo ''
  43. echo $' --stig [yes|no|fix] Run STIG tests'
  44. echo $' --help Show help'
  45. echo ''
  46. exit 0
  47. }
  48. function test_app_function_type {
  49. filename=$1
  50. fn_type=$2
  51. app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
  52. app_function=$(cat "${filename}" | grep "function ${fn_type}_${app_name} {" | awk -F "${fn_type}_" '{print $2}' | awk -F ' ' '{print $1}')
  53. if [ ! ${app_function} ]; then
  54. echo $"Application ${app_name} does not contain a function called '${fn_type}_${app_name}'"
  55. echo ''
  56. echo "See ${filename}"
  57. exit 72852
  58. fi
  59. }
  60. function test_app_functions {
  61. if [ $RUN_STIG ]; then
  62. return
  63. fi
  64. FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
  65. # check that these functions exist
  66. interface_functions=( install remove backup_local backup_remote restore_local restore_remote upgrade reconfigure )
  67. # for all the app scripts
  68. for filename in $FILES
  69. do
  70. # for each expected interface function
  71. for f in "${interface_functions[@]}"
  72. do
  73. test_app_function_type ${filename} $f
  74. done
  75. done
  76. }
  77. function test_unique_onion_ports {
  78. if [ $RUN_STIG ]; then
  79. return
  80. fi
  81. # test that some services are not assigned the same onion port
  82. FILES=src/${PROJECT_NAME}-app-*
  83. ports=$(grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq | awk -F '=' '{print $2}')
  84. unique_ports=$(grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq | awk -F '=' '{print $2}' | uniq)
  85. if [[ "$ports" != "$unique_ports" ]]; then
  86. echo $'Some onion ports are clashing'
  87. grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq
  88. exit 637252
  89. fi
  90. }
  91. function stig_log_msg {
  92. ESTATUS=$1
  93. RED=$(tput setaf 1)
  94. BOLD=$(tput bold)
  95. GREEN=$(tput setaf 2)
  96. NORMAL=$(tput sgr0)
  97. MSG="$2"
  98. if [ $ESTATUS -eq 0 ];then
  99. printf "%s %s" "$GREEN$BOLD[ PASS ]$NORMAL" "$MSG"
  100. echo
  101. else
  102. printf "%s %s" "$RED$BOLD[ FAIL ]$NORMAL" "$MSG"
  103. echo
  104. fi
  105. }
  106. function stig_spinner {
  107. local pid=$1
  108. local delay=0.1
  109. while [ "$(ps -a | awk '{print $1}' | grep "$pid")" ];
  110. do
  111. sleep $delay
  112. done
  113. printf " \b"
  114. wait $1
  115. }
  116. function disallow_package {
  117. package_name=$1
  118. if service --status-all | grep "+.*${package_name}";then
  119. apt-get -yq remove --purge ${package_name}
  120. apt -yq autoremove
  121. fi
  122. }
  123. function fix_stig {
  124. if [[ $RUN_STIG != 'fix' ]]; then
  125. return
  126. fi
  127. disallow_package xinetd
  128. lockdown_permissions
  129. }
  130. function test_stig {
  131. if [ ! $RUN_STIG ]; then
  132. return
  133. fi
  134. STIG_TESTS_DIR=tests
  135. if [ ! -d $STIG_TESTS_DIR ]; then
  136. STIG_TESTS_DIR=~/${PROJECT_NAME}/tests
  137. if [ ! -d $STIG_TESTS_DIR ]; then
  138. echo $'No tests were found'
  139. exit 62725
  140. fi
  141. fi
  142. CATCOLOR=1
  143. SETLANG="en"
  144. source $STIG_TESTS_DIR/output.sh
  145. ##RHEL-06-000001
  146. ##The system must use a separate file system for /tmp.
  147. mount | grep "on /tmp " >/dev/null 2>&1 &
  148. stig_spinner $!
  149. output "V-38455" $? ${SETLANG}
  150. ################
  151. ##RHEL-06-000008
  152. ##Vendor-provided cryptographic certificates must be installed to verify the integrity of system software.
  153. bash $STIG_TESTS_DIR/check-apt-key.sh >/dev/null 2>&1 &
  154. stig_spinner $!
  155. output "V-38476" $? ${SETLANG}
  156. ################
  157. ##RHEL-06-000016
  158. ##A file integrity tool must be installed.
  159. dpkg -s tripwire >/dev/null 2>&1 &
  160. stig_spinner $!
  161. output "V-38489" $? ${SETLANG}
  162. ################
  163. ##RHEL-06-000019
  164. ##There must be no .rhosts or hosts.equiv files on the system.
  165. bash $STIG_TESTS_DIR/check-rhosts.sh > /dev/null 2>&1 &
  166. stig_spinner $!
  167. output "V-38491" $? ${SETLANG}
  168. ################
  169. ##RHEL-06-000027
  170. ##The system must prevent the root account from logging in from virtual consoles.
  171. bash $STIG_TESTS_DIR/check-consoles.sh virtual > /dev/null 2>&1 &
  172. stig_spinner $!
  173. output "V-38492" $? ${SETLANG}
  174. ################
  175. ##RHEL-06-000028
  176. ##The system must prevent the root account from logging in from serial consoles.
  177. bash $STIG_TESTS_DIR/check-consoles.sh serial > /dev/null 2>&1 &
  178. stig_spinner $!
  179. output "V-38494" $? ${SETLANG}
  180. ################
  181. ##RHEL-06-000029
  182. ##Default operating system accounts, other than root, must be locked.
  183. bash $STIG_TESTS_DIR/check-default-account.sh > /dev/null 2>&1 &
  184. stig_spinner $!
  185. output "V-38496" $? ${SETLANG}
  186. ################
  187. ##RHEL-06-000031
  188. ##The /etc/passwd file must not contain password hashes.
  189. awk -F: '($2 != "x") {print; err=1} END {exit err}' /etc/passwd > /dev/null 2>&1 &
  190. stig_spinner $!
  191. output "V-38499" $? ${SETLANG}
  192. ################
  193. ##RHEL-06-000032
  194. ##The root account must be the only account having a UID of 0.
  195. bash $STIG_TESTS_DIR/check-root-uid.sh > /dev/null 2>&1 &
  196. stig_spinner $!
  197. output "V-38500" $? ${SETLANG}
  198. ################
  199. ##RHEL-06-000033
  200. ##The /etc/shadow file must be owned by root.
  201. ls -l /etc/shadow | awk '{print $3}' | grep "^root$" > /dev/null 2>&1 &
  202. stig_spinner $!
  203. output "V-38502" $? ${SETLANG}
  204. ################
  205. ##RHEL-06-000034
  206. ##The /etc/shadow file must be group-owned by root.
  207. ls -l /etc/shadow | awk '{print $4}' | grep "^root$" > /dev/null 2>&1 &
  208. stig_spinner $!
  209. output "V-38503" $? ${SETLANG}
  210. ################
  211. ##RHEL-06-000035
  212. ##The /etc/shadow file must have mode 0000.
  213. ls -l /etc/shadow | awk '{print $1}' | grep "^----------$" > /dev/null 2>&1 &
  214. stig_spinner $!
  215. output "V-38504" $? ${SETLANG}
  216. ################
  217. ##RHEL-06-000036
  218. ##The /etc/gshadow file must be owned by root.
  219. ls -l /etc/gshadow | awk '{print $3}' | grep "^root$" > /dev/null 2>&1 &
  220. stig_spinner $!
  221. output "V-38443" $? ${SETLANG}
  222. ################
  223. ##RHEL-06-000037
  224. ##The /etc/gshadow file must be group-owned by root.
  225. ls -l /etc/gshadow | awk '{print $4}' | grep "^root$" > /dev/null 2>&1 &
  226. stig_spinner $!
  227. output "V-38448" $? ${SETLANG}
  228. ################
  229. ##RHEL-06-000038
  230. ##The /etc/gshadow file must have mode 0000.
  231. ls -l /etc/gshadow | awk '{print $1}' | grep "^----------$" > /dev/null 2>&1 &
  232. stig_spinner $!
  233. output "V-38449" $? ${SETLANG}
  234. ################
  235. ##RHEL-06-000039
  236. ##The /etc/passwd file must be owned by root.
  237. ls -l /etc/passwd | awk '{print $3}' | grep "^root$" > /dev/null 2>&1 &
  238. stig_spinner $!
  239. output "V-38450" $? ${SETLANG}
  240. ################
  241. ##RHEL-06-000040
  242. ##The /etc/passwd file must be group-owned by root.
  243. ls -l /etc/passwd | awk '{print $4}' | grep "^root$" > /dev/null 2>&1 &
  244. stig_spinner $!
  245. output "V-38451" $? ${SETLANG}
  246. ################
  247. ##RHEL-06-000041
  248. ##The /etc/passwd file must have mode 0644 or less permissive.
  249. bash $STIG_TESTS_DIR/check-mode.sh /etc/passwd 644 > /dev/null 2>&1 &
  250. stig_spinner $!
  251. output "V-38457" $? ${SETLANG}
  252. ################
  253. ##RHEL-06-000042
  254. ##The /etc/group file must be owned by root.
  255. ls -l /etc/group | awk '{print $3}' | grep "^root$" > /dev/null 2>&1 &
  256. stig_spinner $!
  257. output "V-38458" $? ${SETLANG}
  258. ################
  259. ##RHEL-06-000043
  260. ##The /etc/group file must be group-owned by root.
  261. ls -l /etc/group | awk '{print $4}' | grep "^root$" > /dev/null 2>&1 &
  262. stig_spinner $!
  263. output "V-38459" $? ${SETLANG}
  264. ################
  265. ##RHEL-06-000044
  266. ##The /etc/group file must have mode 0644 or less permissive.
  267. bash $STIG_TESTS_DIR/check-mode.sh "/etc/group" 644 > /dev/null 2>&1 &
  268. stig_spinner $!
  269. output "V-38461" $? ${SETLANG}
  270. ################
  271. ##RHEL-06-000045
  272. ##Library files must have mode 0755 or less permissive.
  273. bash $STIG_TESTS_DIR/check-libs-mode.sh > /dev/null 2>&1 &
  274. stig_spinner $!
  275. output "V-38465" $? ${SETLANG}
  276. ################
  277. ##RHEL-06-000046
  278. ##Library files must be owned by root.
  279. bash $STIG_TESTS_DIR/check-libs-owner.sh > /dev/null 2>&1 &
  280. stig_spinner $!
  281. output "V-38466" $? ${SETLANG}
  282. ################
  283. ##RHEL-06-000047
  284. ##All system command files must have mode 755 or less permissive.
  285. bash $STIG_TESTS_DIR/check-cmd-mode.sh > /dev/null 2>&1 &
  286. stig_spinner $!
  287. output "V-38469" $? ${SETLANG}
  288. ################
  289. ##RHEL-06-000048
  290. ##All system command files must be owned by root.
  291. bash $STIG_TESTS_DIR/check-cmd-owner.sh > /dev/null 2>&1 &
  292. stig_spinner $!
  293. output "V-38472" $? ${SETLANG}
  294. ################
  295. ##RHEL-06-000061
  296. ##The system must disable accounts after ten consecutive unsuccessful logon attempts.
  297. bash $STIG_TESTS_DIR/check-password.sh /etc/pam.d/common-auth pam_tally deny gt 10 > /dev/null 2>&1 &
  298. stig_spinner $!
  299. output "V-38573" $? ${SETLANG}
  300. ################
  301. ##RHEL-06-000062
  302. ##The system must use a FIPS 140-2 approved cryptographic hashing algorithm for generating account password hashes (system-auth).
  303. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/pam.d/* | grep password | grep pam_unix.so | grep sha512 > /dev/null 2>&1 &
  304. stig_spinner $!
  305. output "V-38574" $? ${SETLANG}
  306. ################
  307. ##RHEL-06-000063
  308. ##The system must use a FIPS 140-2 approved cryptographic hashing algorithm for generating account password hashes (login.defs).
  309. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/login.defs | grep "ENCRYPT_METHOD.*SHA512" > /dev/null 2>&1 &
  310. stig_spinner $!
  311. output "V-38576" $? ${SETLANG}
  312. ################
  313. ##RHEL-06-000064
  314. ##The system must use a FIPS 140-2 approved cryptographic hashing algorithm for generating account password hashes (libuser.conf).
  315. bash $STIG_TESTS_DIR/check-depends.sh > /dev/null 2>&1 &
  316. stig_spinner $!
  317. output "V-38577" $? ${SETLANG}
  318. ################
  319. ##RHEL-06-000071
  320. ##The system must allow locking of the console screen in text mode.
  321. dpkg -s screen >/dev/null 2>&1 &
  322. stig_spinner $!
  323. output "V-38590" $? ${SETLANG}
  324. ################
  325. ##RHEL-06-000078
  326. ##The system must implement virtual address space randomization.
  327. bash $STIG_TESTS_DIR/check-sysctl.sh kernel.randomize_va_space ne 2 >/dev/null 2>&1 &
  328. stig_spinner $!
  329. output "V-38596" $? ${SETLANG}
  330. ################
  331. ##RHEL-06-000080
  332. ##The system must not send ICMPv4 redirects by default.
  333. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.default.send_redirects ne 0 >/dev/null 2>&1 &
  334. stig_spinner $!
  335. output "V-38600" $? ${SETLANG}
  336. ################
  337. ##RHEL-06-000081
  338. ##The system must not send ICMPv4 redirects from any interface.
  339. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.all.send_redirects ne 0 >/dev/null 2>&1 &
  340. stig_spinner $!
  341. output "V-38601" $? ${SETLANG}
  342. ################
  343. ##RHEL-06-000082
  344. ##IP forwarding for IPv4 must not be enabled, unless the system is a router.
  345. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.ip_forward ne 0 >/dev/null 2>&1 &
  346. stig_spinner $!
  347. output "V-38511" $? ${SETLANG}
  348. ################
  349. ##RHEL-06-000083
  350. ##The system must not accept IPv4 source-routed packets on any interface.
  351. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.all.accept_source_route ne 0 >/dev/null 2>&1 &
  352. stig_spinner $!
  353. output "V-38523" $? ${SETLANG}
  354. ################
  355. ##RHEL-06-000084
  356. ##The system must not accept ICMPv4 redirect packets on any interface.
  357. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.all.accept_redirects ne 0 >/dev/null 2>&1 &
  358. stig_spinner $!
  359. output "V-38524" $? ${SETLANG}
  360. ################
  361. ##RHEL-06-000086
  362. ##The system must not accept ICMPv4 secure redirect packets on any interface.
  363. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.all.secure_redirects ne 0 >/dev/null 2>&1 &
  364. stig_spinner $!
  365. output "V-38526" $? ${SETLANG}
  366. ################
  367. ##RHEL-06-000089
  368. ##The system must not accept IPv4 source-routed packets by default.
  369. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.default.accept_source_route ne 0 >/dev/null 2>&1 &
  370. stig_spinner $!
  371. output "V-38529" $? ${SETLANG}
  372. ################
  373. ##RHEL-06-000090
  374. ##The system must not accept ICMPv4 secure redirect packets by default.
  375. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.default.secure_redirects ne 0 >/dev/null 2>&1 &
  376. stig_spinner $!
  377. output "V-38532" $? ${SETLANG}
  378. ################
  379. ##RHEL-06-000091
  380. ##The system must ignore ICMPv4 redirect messages by default.
  381. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.default.accept_redirects ne 0 >/dev/null 2>&1 &
  382. stig_spinner $!
  383. output "V-38533" $? ${SETLANG}
  384. ################
  385. ##RHEL-06-000092
  386. ##The system must not respond to ICMPv4 sent to a broadcast address.
  387. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.icmp_echo_ignore_broadcasts ne 1 >/dev/null 2>&1 &
  388. stig_spinner $!
  389. output "V-38535" $? ${SETLANG}
  390. ################
  391. ##RHEL-06-000093
  392. ##The system must ignore ICMPv4 bogus error responses.
  393. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.icmp_ignore_bogus_error_responses ne 1 >/dev/null 2>&1 &
  394. stig_spinner $!
  395. output "V-38537" $? ${SETLANG}
  396. ################
  397. ##RHEL-06-000095
  398. ##The system must be configured to use TCP syncookies when experiencing a TCP SYN flood.
  399. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.tcp_syncookies ne 1 >/dev/null 2>&1 &
  400. stig_spinner $!
  401. output "V-38539" $? ${SETLANG}
  402. ################
  403. ##RHEL-06-000096
  404. ##The system must use a reverse-path filter for IPv4 network traffic when possible on all interfaces.
  405. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.all.rp_filter ne 1 >/dev/null 2>&1 &
  406. stig_spinner $!
  407. output "V-38542" $? ${SETLANG}
  408. ################
  409. ##RHEL-06-000097
  410. ##The system must use a reverse-path filter for IPv4 network traffic when possible by default.
  411. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv4.conf.default.rp_filter ne 1 >/dev/null 2>&1 &
  412. stig_spinner $!
  413. output "V-38544" $? ${SETLANG}
  414. ################
  415. ##RHEL-06-000099
  416. ##The system must ignore ICMPv6 redirects by default.
  417. ##If IPv6 is disabled, this is not applicable.
  418. if [ -a /proc/net/if_inet6 ];then
  419. bash $STIG_TESTS_DIR/check-sysctl.sh net.ipv6.conf.default.accept_redirects ne 1 >/dev/null 2>&1 &
  420. stig_spinner $!
  421. output "V-38548" $? ${SETLANG}
  422. fi
  423. ################
  424. ##RHEL-06-000120
  425. ##The systems local IPv4 firewall must implement a deny-all, allow-by-exception policy for inbound
  426. iptables -L INPUT | head -n1 | grep "INPUT.*DROP" >/dev/null 2>&1 &
  427. stig_spinner $!
  428. output "V-38513" $? ${SETLANG}
  429. ################
  430. ##RHEL-06-000138
  431. ##System logs must be rotated daily.
  432. bash $STIG_TESTS_DIR/check-logrotate.sh >/dev/null 2>&1 &
  433. stig_spinner $!
  434. output "V-38624" $? ${SETLANG}
  435. ################
  436. ##RHEL-06-000203
  437. ##The xinetd service must be disabled if no network services utilizing it are enabled.
  438. bash $STIG_TESTS_DIR/check-services.sh xinetd >/dev/null 2>&1 &
  439. stig_spinner $!
  440. output "V-38582" $? ${SETLANG}
  441. ################
  442. ##RHEL-06-000204
  443. ##The xinetd service must be uninstalled if no network services utilizing it are enabled.
  444. bash $STIG_TESTS_DIR/check-packages.sh xinetd >/dev/null 2>&1 &
  445. stig_spinner $!
  446. output "V-38584" $? ${SETLANG}
  447. ################
  448. ##RHEL-06-000206
  449. ##The telnet-server package must not be installed.
  450. bash $STIG_TESTS_DIR/check-packages.sh telnetd >/dev/null 2>&1 &
  451. stig_spinner $!
  452. output "V-38587" $? ${SETLANG}
  453. ################
  454. ##RHEL-06-000211
  455. ##The telnet daemon must not be running.
  456. bash $STIG_TESTS_DIR/check-services.sh telnetd >/dev/null 2>&1 &
  457. stig_spinner $!
  458. output "V-38589" $? ${SETLANG}
  459. ################
  460. ##RHEL-06-000213
  461. ##The rsh-server package must not be installed.
  462. bash $STIG_TESTS_DIR/check-packages.sh rsh-server >/dev/null 2>&1 &
  463. stig_spinner $!
  464. output "V-38591" $? ${SETLANG}
  465. ################
  466. ##RHEL-06-000214
  467. ##The rshd service must not be running.
  468. bash $STIG_TESTS_DIR/check-services.sh rshd >/dev/null 2>&1 &
  469. stig_spinner $!
  470. output "V-38594" $? ${SETLANG}
  471. ################
  472. ##RHEL-06-000216
  473. ##The rexecd service must not be running.
  474. bash $STIG_TESTS_DIR/check-services.sh rexecd >/dev/null 2>&1 &
  475. stig_spinner $!
  476. output "V-38598" $? ${SETLANG}
  477. ################
  478. ##RHEL-06-000218
  479. ##The rlogind service must not be running.
  480. bash $STIG_TESTS_DIR/check-services.sh rlogind >/dev/null 2>&1 &
  481. stig_spinner $!
  482. output "V-38602" $? ${SETLANG}
  483. ################
  484. ##RHEL-06-000220
  485. ##The NIS(ypserv) package must not be installed.
  486. bash $STIG_TESTS_DIR/check-packages.sh nis >/dev/null 2>&1 &
  487. stig_spinner $!
  488. output "V-38603" $? ${SETLANG}
  489. ################
  490. ##RHEL-06-000221
  491. ##The nis(ypbind) service must not be running.
  492. bash $STIG_TESTS_DIR/check-services.sh nis >/dev/null 2>&1 &
  493. stig_spinner $!
  494. output "V-38604" $? ${SETLANG}
  495. ################
  496. ##RHEL-06-000224
  497. ##The cron service must be running.
  498. bash $STIG_TESTS_DIR/check-services.sh cron >/dev/null 2>&1 &
  499. stig_spinner $!
  500. output "V-38605" $? ${SETLANG}
  501. ################
  502. ##RHEL-06-000227
  503. ##The SSH daemon must be configured to use only the SSHv2 protocol.
  504. bash $STIG_TESTS_DIR/check-ssh.sh Protocol >/dev/null 2>&1 &
  505. stig_spinner $!
  506. output "V-38607" $? ${SETLANG}
  507. ################
  508. ##RHEL-06-000230
  509. ##The SSH daemon must set a timeout interval on idle sessions.
  510. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep "ClientAliveInterval" >/dev/null 2>&1 &
  511. stig_spinner $!
  512. output "V-38608" $? ${SETLANG}
  513. ################
  514. ##RHEL-06-000231
  515. ##The SSH daemon must set a timeout count on idle sessions.
  516. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep "ClientAliveCountMax" >/dev/null 2>&1 &
  517. stig_spinner $!
  518. output "V-38610" $? ${SETLANG}
  519. ################
  520. ##RHEL-06-000234
  521. ##The SSH daemon must ignore .rhosts files.
  522. bash $STIG_TESTS_DIR/check-ssh.sh rhosts >/dev/null 2>&1 &
  523. stig_spinner $!
  524. output "V-38611" $? ${SETLANG}
  525. ################
  526. ##RHEL-06-000236
  527. ##The SSH daemon must not allow host-based authentication.
  528. bash $STIG_TESTS_DIR/check-ssh.sh hostauth >/dev/null 2>&1 &
  529. stig_spinner $!
  530. output "V-38612" $? ${SETLANG}
  531. ################
  532. ##RHEL-06-000237
  533. ##The system must not permit root logins using remote access programs such as ssh.
  534. bash $STIG_TESTS_DIR/check-ssh.sh permitroot >/dev/null 2>&1 &
  535. stig_spinner $!
  536. output "V-38613" $? ${SETLANG}
  537. ################
  538. ##RHEL-06-000239
  539. ##The SSH daemon must not allow authentication using an empty password.
  540. bash $STIG_TESTS_DIR/check-ssh.sh emptypassword >/dev/null 2>&1 &
  541. stig_spinner $!
  542. output "V-38615" $? ${SETLANG}
  543. ################
  544. ##RHEL-06-000241
  545. ##The SSH daemon must not permit user environment settings.
  546. bash $STIG_TESTS_DIR/check-ssh.sh emptypasswordenvironment >/dev/null 2>&1 &
  547. stig_spinner $!
  548. output "V-38616" $? ${SETLANG}
  549. ################
  550. ##A FIPS 140-2 approved cryptographic algorithm must be used for SSH communications.
  551. bash $STIG_TESTS_DIR/check-ssh.sh ciphers >/dev/null 2>&1 &
  552. stig_spinner $!
  553. output "SV-86845r2_rule" $? ${SETLANG}
  554. ################
  555. ##The Standard Notice must be displayed immediately prior to, or as part of, remote access logon prompts.
  556. bash $STIG_TESTS_DIR/check-ssh.sh banner >/dev/null 2>&1 &
  557. stig_spinner $!
  558. output "SV-86849r2_rule" $? ${SETLANG}
  559. ################
  560. ##All networked systems must use SSH for confidentiality and integrity of transmitted and received information as well as information during preparation for transmission.
  561. bash $STIG_TESTS_DIR/check-ssh.sh sshd_status >/dev/null 2>&1 &
  562. stig_spinner $!
  563. output "SV-86859r2_rule" $? ${SETLANG}
  564. ################
  565. ##All network connections associated with SSH traffic must terminate at the end of the session or after 10 minutes of inactivity, except to fulfill documented and validated mission requirements.
  566. bash $STIG_TESTS_DIR/check-ssh.sh ClientAliveInterval >/dev/null 2>&1 &
  567. stig_spinner $!
  568. output "SV-86861r2_rule" $? ${SETLANG}
  569. ################
  570. ##The SSH daemon must not allow authentication using RSA rhosts authentication.
  571. bash $STIG_TESTS_DIR/check-ssh.sh RhostsRSAAuthentication >/dev/null 2>&1 &
  572. stig_spinner $!
  573. output "SV-86863r2_rule" $? ${SETLANG}
  574. ################
  575. ##All network connections associated with SSH traffic must terminate after a period of inactivity.
  576. bash $STIG_TESTS_DIR/check-ssh.sh ClientAliveCountMax >/dev/null 2>&1 &
  577. stig_spinner $!
  578. output "SV-86865r2_rule" $? ${SETLANG}
  579. ################
  580. ##The SSH daemon must not allow authentication using rhosts authentication.
  581. bash $STIG_TESTS_DIR/check-ssh.sh IgnoreRhosts >/dev/null 2>&1 &
  582. stig_spinner $!
  583. output "SV-86867r2_rule" $? ${SETLANG}
  584. ################
  585. ##The system must display the date and time of the last successful account logon upon an SSH logon.
  586. bash $STIG_TESTS_DIR/check-ssh.sh PrintLastLog >/dev/null 2>&1 &
  587. stig_spinner $!
  588. output "SV-86869r2_rule" $? ${SETLANG}
  589. ################
  590. ##The system must not permit direct logons to the root account using remote access via SSH.
  591. bash $STIG_TESTS_DIR/check-ssh.sh permitroot >/dev/null 2>&1 &
  592. stig_spinner $!
  593. output "SV-86871r2_rule" $? ${SETLANG}
  594. ################
  595. ##The SSH daemon must not allow authentication using known hosts authentication.
  596. bash $STIG_TESTS_DIR/check-ssh.sh IgnoreUserKnownHosts >/dev/null 2>&1 &
  597. stig_spinner $!
  598. output "SV-86873r2_rule" $? ${SETLANG}
  599. ################
  600. ##The SSH daemon must be configured to only use the SSHv2 protocol.
  601. bash $STIG_TESTS_DIR/check-ssh.sh Protocol >/dev/null 2>&1 &
  602. stig_spinner $!
  603. output "SV-86875r2_rule" $? ${SETLANG}
  604. ################
  605. ##The SSH daemon must be configured to only use Message Authentication Codes (MACs) employing FIPS 140-2 approved cryptographic hash algorithms.
  606. bash $STIG_TESTS_DIR/check-ssh.sh macs >/dev/null 2>&1 &
  607. stig_spinner $!
  608. output "SV-86877r2_rule" $? ${SETLANG}
  609. ################
  610. ##The SSH public host key files must have mode 0644 or less permissive.
  611. bash $STIG_TESTS_DIR/check-ssh.sh pubkeypermissive >/dev/null 2>&1 &
  612. stig_spinner $!
  613. output "SV-86879r1_rule" $? ${SETLANG}
  614. ################
  615. ##The SSH private host key files must have mode 0600 or less permissive.
  616. bash $STIG_TESTS_DIR/check-ssh.sh hostkeypermissive >/dev/null 2>&1 &
  617. stig_spinner $!
  618. output "SV-86881r1_rule" $? ${SETLANG}
  619. ################
  620. ##The SSH daemon must not permit Generic Security Service Application Program Interface (GSSAPI) authentication unless needed.
  621. bash $STIG_TESTS_DIR/check-ssh.sh GSSAPIAuthentication >/dev/null 2>&1 &
  622. stig_spinner $!
  623. output "SV-86883r2_rule" $? ${SETLANG}
  624. ################
  625. ##The SSH daemon must not permit Kerberos authentication unless needed.
  626. bash $STIG_TESTS_DIR/check-ssh.sh KerberosAuthentication >/dev/null 2>&1 &
  627. stig_spinner $!
  628. output "SV-86885r2_rule" $? ${SETLANG}
  629. ################
  630. ##The SSH daemon must perform strict mode checking of home directory configuration files.
  631. bash $STIG_TESTS_DIR/check-ssh.sh StrictModes >/dev/null 2>&1 &
  632. stig_spinner $!
  633. output "SV-86887r2_rule" $? ${SETLANG}
  634. ################
  635. ##The SSH daemon must use privilege separation.
  636. bash $STIG_TESTS_DIR/check-ssh.sh UsePrivilegeSeparation >/dev/null 2>&1 &
  637. stig_spinner $!
  638. output "SV-86889r2_rule" $? ${SETLANG}
  639. ################
  640. ##The SSH daemon must not allow compression or must only allow compression after successful authentication.
  641. bash $STIG_TESTS_DIR/check-ssh.sh Compression >/dev/null 2>&1 &
  642. stig_spinner $!
  643. output "SV-86891r2_rule" $? ${SETLANG}
  644. ################
  645. ##Dont allow remote X connections.
  646. bash $STIG_TESTS_DIR/check-ssh.sh X11Forwarding >/dev/null 2>&1 &
  647. stig_spinner $!
  648. output "SV-86927r2_rule" $? ${SETLANG}
  649. ################
  650. ##Check that pam_python is not installed
  651. bash $STIG_TESTS_DIR/check-ssh.sh pam_python >/dev/null 2>&1 &
  652. stig_spinner $!
  653. output "SV-86724r2_rule" $? ${SETLANG}
  654. ################
  655. ##RHEL-06-000247
  656. ##The system clock must be synchronized continuously, or at least daily.
  657. bash $STIG_TESTS_DIR/check-services.sh ntp >/dev/null 2>&1 &
  658. stig_spinner $!
  659. output "V-38620" $? ${SETLANG}
  660. ################
  661. ##RHEL-06-000248
  662. ##The system clock must be synchronized to an authoritative time source.
  663. bash $STIG_TESTS_DIR/check-ntp-sources.sh >/dev/null 2>&1 &
  664. stig_spinner $!
  665. output "V-38621" $? ${SETLANG}
  666. ################
  667. ##RHEL-06-000252
  668. ##If the system is using LDAP for authentication or account information, the system must use a TLS connection using FIPS 140-2 approved cryptographic algorithms.
  669. #Waiting to figure out
  670. #stig_spinner $!
  671. #output "V-38625" $? ${SETLANG}
  672. ################
  673. ##RHEL-06-000253
  674. ##The LDAP client must use a TLS connection using trust certificates signed by the site CA.
  675. #Waiting to figure out
  676. #stig_spinner $!
  677. #output "V-38626" $? ${SETLANG}
  678. ################
  679. ##RHEL-06-000256
  680. ##The openldap-servers package must not be installed unless required.
  681. bash $STIG_TESTS_DIR/check-packages.sh sldap>/dev/null 2>&1 &
  682. stig_spinner $!
  683. output "V-38627" $? ${SETLANG}
  684. ################
  685. ##RHEL-06-000257
  686. ##The graphical desktop environment must set the idle timeout to no more than 15 minutes.
  687. #stig_spinner $!
  688. #output "V-38629" $? ${SETLANG}
  689. ################
  690. ##RHEL-06-000258
  691. ##The graphical desktop environment must automatically lock after 15 minutes of inactivity and the system must require user reauthentication to unlock the environment.
  692. #stig_spinner $!
  693. #output "V-38630" $? ${SETLANG}
  694. ################
  695. ##RHEL-06-000259
  696. ##The graphical desktop environment must have automatic lock enabled.
  697. #stig_spinner $!
  698. #output "V-38638" $? ${SETLANG}
  699. ################
  700. ##RHEL-06-000260
  701. ##The system must display a publicly-viewable pattern during a graphical desktop environment session lock.
  702. #stig_spinner $!
  703. #output "V-38639" $? ${SETLANG}
  704. ################
  705. ##RHEL-06-000262
  706. ##The atd service must be disabled.
  707. bash $STIG_TESTS_DIR/check-services.sh atd >/dev/null 2>&1 &
  708. stig_spinner $!
  709. output "V-38641" $? ${SETLANG}
  710. ################
  711. ##RHEL-06-000271
  712. ##The noexec option must be added to removable media partitions.
  713. if [ "$(grep -Hv ^0$ /sys/block/*/removable | sed s/removable:.*$/device\\/uevent/ | xargs grep -H ^DRIVER=sd | sed s/device.uevent.*$/size/ | xargs grep -Hv ^0$ | cut -d / -f 4 | wc -l)" -gt 0 ];then
  714. bash $STIG_TESTS_DIR/check-removable.sh >/dev/null 2>&1 &
  715. stig_spinner $!
  716. output "V-38655" $? ${SETLANG}
  717. fi
  718. ################
  719. ##RHEL-06-000272
  720. ##The system must use SMB client signing for connecting to samba servers using smbclient.
  721. bash $STIG_TESTS_DIR/check-depends.sh smb-signing >/dev/null 2>&1 &
  722. stig_spinner $!
  723. output "V-38656" $? ${SETLANG}
  724. ################
  725. ##RHEL-06-000273
  726. ##The system must use SMB client signing for connecting to samba servers using mount.cifs.
  727. bash $STIG_TESTS_DIR/check-depends.sh smb-sec >/dev/null 2>&1 &
  728. stig_spinner $!
  729. output "V-38657" $? ${SETLANG}
  730. ################
  731. ##RHEL-06-000282
  732. ##There must be no world-writable files on the system.
  733. bash $STIG_TESTS_DIR/check-world-writable.sh >/dev/null 2>&1 &
  734. stig_spinner $!
  735. output "V-38643" $? ${SETLANG}
  736. ################
  737. ##RHEL-06-000286
  738. ##The x86 Ctrl-Alt-Delete key sequence must be disabled.
  739. bash $STIG_TESTS_DIR/check-ctrl-alt-del.sh >/dev/null 2>&1 &
  740. stig_spinner $!
  741. output "V-38668" $? ${SETLANG}
  742. ################
  743. ##RHEL-06-000288
  744. ##The sendmail package must be removed.
  745. bash $STIG_TESTS_DIR/check-packages.sh sendmail >/dev/null 2>&1 &
  746. stig_spinner $!
  747. output "V-38671" $? ${SETLANG}
  748. ################
  749. ##RHEL-06-000290
  750. ##X Windows must not be enabled unless required.
  751. bash $STIG_TESTS_DIR/check-services.sh x11-common >/dev/null 2>&1 &
  752. stig_spinner $!
  753. output "V-38674" $? ${SETLANG}
  754. ################
  755. ##RHEL-06-000302
  756. ##A file integrity tool must be used at least weekly to check for unauthorized file changes, particularly the addition of unauthorized system libraries or binaries, or for unauthorized modification to authorized system libraries or binaries.
  757. bash $STIG_TESTS_DIR/check-tripwire-cron.sh > /dev/null 2>&1 &
  758. stig_spinner $!
  759. output "V-38695" $? ${SETLANG}
  760. ################
  761. ##RHEL-06-000018
  762. #For tripwire to be effective, an initial database of "known-good" information about files must be captured and it should be able to be verified against the installed files.
  763. bash $STIG_TESTS_DIR/check-tripwire-baseline.sh > /dev/null 2>&1 &
  764. stig_spinner $!
  765. output "V-51391" $? ${SETLANG}
  766. ################
  767. ##RHEL-06-000308
  768. ##Process core dumps must be disabled unless needed.
  769. bash $STIG_TESTS_DIR/check-limits.sh core-dumps > /dev/null 2>&1 &
  770. stig_spinner $!
  771. output "V-38675" $? ${SETLANG}
  772. ################
  773. ##RHEL-06-000319
  774. ##The system must limit users to 10 simultaneous system logins, or a site-defined number, in accordance with operational requirements.
  775. bash $STIG_TESTS_DIR/check-limits.sh maxlogins > /dev/null 2>&1 &
  776. stig_spinner $!
  777. output "V-38684" $? ${SETLANG}
  778. ################
  779. ##RHEL-06-000320
  780. ##The systems local firewall must implement a deny-all, allow-by-exception policy for forwarded packets.
  781. iptables -L FORWARD | head -n1 | grep "FORWARD.*DROP" >/dev/null 2>&1 &
  782. stig_spinner $!
  783. output "V-38686" $? ${SETLANG}
  784. ################
  785. ##RHEL-06-000331
  786. ##The Bluetooth service must be disabled.
  787. bash $STIG_TESTS_DIR/check-services.sh bluetooth >/dev/null 2>&1 &
  788. stig_spinner $!
  789. output "V-38691" $? ${SETLANG}
  790. ################
  791. ##RHEL-06-000336
  792. ##The sticky bit must be set on all public directories.
  793. bash $STIG_TESTS_DIR/check-sticky-bit.sh >/dev/null 2>&1 &
  794. stig_spinner $!
  795. output "V-38697" $? ${SETLANG}
  796. ################
  797. ##RHEL-06-000337
  798. ##All public directories must be owned by a system account.
  799. bash $STIG_TESTS_DIR/check-public-dir-owned.sh >/dev/null 2>&1 &
  800. stig_spinner $!
  801. output "V-38699" $? ${SETLANG}
  802. ################
  803. ##RHEL-06-000345
  804. ##The system default umask in /etc/login.defs must be 077.
  805. ##For more detial :http://stackoverflow.com/questions/10220531/how-to-set-system-wide-umask
  806. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/login.defs | grep -i "umask.*077" >/dev/null 2>&1 &
  807. stig_spinner $!
  808. output "V-38645" $? ${SETLANG}
  809. ################
  810. ##RHEL-06-000347
  811. ##There must be no .netrc files on the system.
  812. bash $STIG_TESTS_DIR/check-netrc.sh >/dev/null 2>&1 &
  813. stig_spinner $!
  814. output "V-38619" $? ${SETLANG}
  815. ################
  816. ##RHEL-06-000372
  817. ##The operating system, upon successful logon/access, must display to the user the number of unsuccessful logon/access attempts since the last successful logon/access.
  818. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/pam.d/common-session | grep -i "pam_lastlog.so.*showfailed" > /dev/null 2>&1 &
  819. stig_spinner $!
  820. output "V-38501" $? ${SETLANG}
  821. ################
  822. ##RHEL-06-000507
  823. ##The operating system, upon successful logon, must display to the user the date and time of the last logon or access via ssh.
  824. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/ssh/sshd_config | grep -i "^PrintLastLog.*yes" > /dev/null 2>&1 &
  825. stig_spinner $!
  826. output "V-38484" $? ${SETLANG}
  827. ################
  828. ##RHEL-06-000514
  829. ##The package management tool must cryptographically verify the authenticity of all software packages during installation.
  830. bash $STIG_TESTS_DIR/check-apt-gpg.sh > /dev/null 2>&1 &
  831. stig_spinner $!
  832. output "V-38462" $? ${SETLANG}
  833. ################
  834. ##RHEL-06-000523
  835. ##The systems local IPv6 firewall must implement a deny-all, allow-by-exception policy for inbound packets.
  836. ip6tables -L INPUT | head -n1 | grep "INPUT.*DROP" > /dev/null 2>&1 &
  837. stig_spinner $!
  838. output "V-38444" $? ${SETLANG}
  839. ################
  840. ##RHEL-06-000526
  841. ##Automated file system mounting tools must not be enabled unless needed.
  842. bash $STIG_TESTS_DIR/check-services.sh autofs >/dev/null 2>&1 &
  843. stig_spinner $!
  844. output "V-38437" $? ${SETLANG}
  845. ################
  846. ##RHEL-06-000528
  847. ##The noexec option must be added to the /tmp partition.
  848. sed -e '/^#/d' -e '/^[ \t][ \t]*#/d' -e 's/#.*$//' -e '/^$/d' /etc/fstab | grep "/tmp.*noexec" >/dev/null 2>&1 &
  849. stig_spinner $!
  850. output "V-57569" $? ${SETLANG}
  851. ################
  852. ##RHEL-06-000529
  853. ##The sudo command must require authentication.
  854. bash $STIG_TESTS_DIR/check-sudo.sh >/dev/null 2>&1 &
  855. stig_spinner $!
  856. output "V-58901" $? ${SETLANG}
  857. ################
  858. show_passes_fails=
  859. if [ $SHOW_ALL_TESTS ]; then
  860. show_passes_fails=1
  861. else
  862. if [ $FAILS -gt 0 ]; then
  863. show_passes_fails=1
  864. fi
  865. fi
  866. if [ $show_passes_fails ]; then
  867. echo ''
  868. echo $"Passes: $PASSES"
  869. echo $"Fails: $FAILS"
  870. if [ $FAILS -gt 0 ]; then
  871. exit 792353
  872. fi
  873. fi
  874. }
  875. while [[ $# > 1 ]]
  876. do
  877. key="$1"
  878. case $key in
  879. -h|--help)
  880. show_help
  881. ;;
  882. -s|--stig)
  883. shift
  884. if [[ "$1" == 'showall' ]]; then
  885. SHOW_ALL_TESTS=1
  886. fi
  887. RUN_STIG="$1"
  888. ;;
  889. *)
  890. # unknown option
  891. ;;
  892. esac
  893. shift
  894. done
  895. if [ ! $RUN_STIG ]; then
  896. echo $'Running tests'
  897. fi
  898. test_app_functions
  899. test_unique_onion_ports
  900. remove_management_engine_interface
  901. freedombone-pass --test yes
  902. fix_stig
  903. test_stig
  904. if [ ! $RUN_STIG ]; then
  905. echo $'All tests passed'
  906. fi
  907. exit 0