96 lines
3.3 KiB
EmacsLisp
96 lines
3.3 KiB
EmacsLisp
;;; Linux+ Quiz 120: Firewall review
|
|
;;;
|
|
;;; Review firewall ACLs, stateful behavior, firewalld, UFW, and IDS.
|
|
;;;
|
|
;;; This file is part of the Linux+ Learning project.
|
|
;;;
|
|
;;; Copyright (c) 2026, Scott C. MacCallum (scm@sdf.org).
|
|
;;;
|
|
;;; This program is free software: you can redistribute it and/or modify
|
|
;;; it under the terms of the GNU Affero General Public License as
|
|
;;; published by the Free Software Foundation, either version 3 of the
|
|
;;; License, or (at your option) any later version.
|
|
;;;
|
|
;;; This program is distributed in the hope that it will be useful,
|
|
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;;; GNU Affero General Public License for more details.
|
|
;;;
|
|
;;; You should have received a copy of the GNU Affero General
|
|
;;; Public License along with this program. If not, see
|
|
;;; <https://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
|
|
;; Run with:
|
|
;;
|
|
;; M-x linuxplus-quiz-120
|
|
;;
|
|
;; Questions are true/false, yes/no, or single-choice only.
|
|
|
|
;;; Code:
|
|
|
|
(require 'subr-x)
|
|
|
|
(defvar linuxplus-quiz-120-score-file
|
|
(expand-file-name "linuxplus-quiz-120-score.txt"
|
|
user-emacs-directory)
|
|
"File used to save the Linux+ quiz 120 score.")
|
|
|
|
(defun linuxplus-quiz-120--ask (prompt answer)
|
|
"Ask PROMPT and compare the response to ANSWER."
|
|
(string= (downcase (string-trim (read-string prompt)))
|
|
answer))
|
|
|
|
(defun linuxplus-quiz-120 ()
|
|
"Run Linux+ quiz 120 and save the score."
|
|
(interactive)
|
|
(let ((score 0)
|
|
(total 8))
|
|
(when (linuxplus-quiz-120--ask
|
|
"True or false: Firewalls use ACLs. "
|
|
"true")
|
|
(setq score (1+ score)))
|
|
(when (linuxplus-quiz-120--ask
|
|
"Yes or no: Do firewalls inspect network packets? "
|
|
"yes")
|
|
(setq score (1+ score)))
|
|
(when (linuxplus-quiz-120--ask
|
|
"Which helps firewall rules persist? A) config files B) pwd "
|
|
"a")
|
|
(setq score (1+ score)))
|
|
(when (linuxplus-quiz-120--ask
|
|
"True or false: Stateful firewalls track connections. "
|
|
"true")
|
|
(setq score (1+ score)))
|
|
(when (linuxplus-quiz-120--ask
|
|
(concat "Which can be faster after a connection exists? "
|
|
"A) stateful B) stateless ")
|
|
"a")
|
|
(setq score (1+ score)))
|
|
(when (linuxplus-quiz-120--ask
|
|
(concat "Which saves tested firewalld runtime rules? "
|
|
"A) firewall-cmd --runtime-to-permanent "
|
|
"B) ufw numbered ")
|
|
"a")
|
|
(setq score (1+ score)))
|
|
(when (linuxplus-quiz-120--ask
|
|
(concat "Which command views numbered UFW rules? "
|
|
"A) sudo ufw status numbered "
|
|
"B) sudo ufw list ")
|
|
"a")
|
|
(setq score (1+ score)))
|
|
(when (linuxplus-quiz-120--ask
|
|
(concat "Which simple command blocks SSH by port? "
|
|
"A) sudo ufw deny 22/tcp "
|
|
"B) sudo ufw allow 22/tcp ")
|
|
"a")
|
|
(setq score (1+ score)))
|
|
(with-temp-file linuxplus-quiz-120-score-file
|
|
(insert (format "Linux+ quiz 120 score: %d/%d\n" score total)))
|
|
(message "Linux+ quiz 120 score: %d/%d" score total)))
|
|
|
|
(provide 'linuxplus-quiz-120)
|
|
|
|
;;; linuxplus-quiz-120.el ends here
|