freedombone-tests 35KB

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