Skip to content

Commit 2b0250b

Browse files
Merge pull request #19 from StrangeRanger/dev
2 parents 3e218dc + 740df0f commit 2b0250b

File tree

7 files changed

+88
-38
lines changed

7 files changed

+88
-38
lines changed

auditing/Lynis Installer/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## v1.0.8 - 2024-12-20
8+
9+
### Changed
10+
11+
- Improved the colorization of the output text.
12+
713
## v1.0.7 - 2024-08-15
814

915
### Changed

auditing/Lynis Installer/lynis-installer.bash

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,48 @@
55
# it. Unless an error is encountered, Lynis will always be downloaded to the current
66
# user's root directory (`/home/USERNAME/`).
77
#
8-
# Version: v1.0.7
8+
# Version: v1.0.8
99
# License: MIT License
1010
# Copyright (c) 2020-2024 Hunter T. (StrangeRanger)
1111
#
1212
########################################################################################
1313

1414
C_YELLOW="$(printf '\033[1;33m')"
1515
C_GREEN="$(printf '\033[0;32m')"
16+
C_BLUE="$(printf '\033[0;34m')"
1617
C_CYAN="$(printf '\033[0;36m')"
1718
C_RED="$(printf '\033[1;31m')"
1819
C_NC="$(printf '\033[0m')"
20+
21+
C_SUCCESS="${C_GREEN}==>${C_NC} "
1922
C_ERROR="${C_RED}ERROR:${C_NC} "
20-
C_WARNING="${C_YELLOW}WARNING:${C_NC} "
23+
C_WARNING="${C_YELLOW}==>${C_NC} "
24+
C_INFO="${C_BLUE}==>${C_NC} "
25+
C_NOTE="${C_CYAN}==>${C_NC} "
2126

2227

23-
read -rp "We will now download lynis. Press [Enter] to continue."
28+
read -rp "${C_NOTE}We will now download lynis. Press [Enter] to continue."
2429

25-
[[ -d "$HOME/lynis" ]] && {
30+
if [[ -d "$HOME/lynis" ]]; then
2631
echo "${C_WARNING}Lynis is already downloaded to your system" >&2
27-
echo "Current location: '$HOME/lynis'"
28-
echo -e "\nExiting..."
32+
echo "${C_NOTE} Current location: '$HOME/lynis'"
33+
echo -e "\n${C_INFO}Exiting..."
2934
exit 0
30-
}
35+
fi
3136

32-
echo "Changing working directory to '$HOME'..."
37+
echo "${C_INFO}Changing working directory to '$HOME'..."
3338
cd "$HOME" || {
3439
echo "${C_ERROR}Failed to change working directory to '$HOME'" >&2
3540
echo "${C_CYAN}Lynis will download to '$PWD'${C_NC}"
3641
}
3742

38-
echo "Downloading lynis..."
43+
echo "${C_INFO}Downloading lynis..."
3944
git clone https://github.com/CISOfy/lynis || {
4045
echo "${C_ERROR}Failed to download lynis" >&2
41-
echo -e "\nExiting..."
46+
echo -e "\n${C_INFO}Exiting..."
4247
exit 1
4348
}
4449

45-
echo -e "\n${C_GREEN}Lynis has been downloaded to your system"
46-
echo -e "${C_CYAN}To perform a system scan with lynis, execute the following command" \
47-
"in the lynis root directory: sudo ./lynis audit system${C_NC}"
50+
echo -e "\n${C_SUCCESS}Lynis has been downloaded to your system"
51+
echo -e "${C_NOTE}To perform a system scan with lynis, execute the following command" \
52+
"in the lynis root directory: sudo ./lynis audit system"

hardening/Root Locker/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## v1.0.8 - 2024-12-20
8+
9+
### Changed
10+
11+
- Improved the colorization of the output text.
12+
713
## v1.0.7 - 2024-08-15
814

915
### Changed

hardening/Root Locker/root-locker.bash

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,43 @@
22
#
33
# This script locks the root account, preventing users from directly logging in as root.
44
#
5-
# Note:
5+
# NOTE:
66
# Locking the root account doesn't prevent users from using something like `sudo su`
77
# to gain root access.
88
#
9-
# Version: v1.0.7
9+
# Version: v1.0.8
1010
# License: MIT License
1111
# Copyright (c) 2020-2024 Hunter T. (StrangeRanger)
1212
#
1313
########################################################################################
1414

1515
C_GREEN="$(printf '\033[0;32m')"
16+
C_BLUE="$(printf '\033[0;34m')"
17+
C_CYAN="$(printf '\033[0;36m')"
1618
C_RED="$(printf '\033[1;31m')"
1719
C_NC="$(printf '\033[0m')"
1820

21+
C_SUCCESS="${C_GREEN}==>${C_NC} "
22+
C_ERROR="${C_RED}ERROR:${C_NC} "
23+
C_INFO="${C_BLUE}==>${C_NC} "
24+
C_NOTE="${C_CYAN}==>${C_NC} "
25+
1926

2027
## Check if this script was executed with root privilege.
2128
if [[ $EUID != 0 ]]; then
22-
echo "${C_RED}Please run this script as or with root privilege${C_NC}" >&2
23-
echo -e "\nExiting..."
29+
echo "${C_ERROR}Please run this script as or with root privilege" >&2
30+
echo -e "\n${C_INFO}Exiting..."
2431
exit 1
2532
fi
2633

2734

28-
read -rp "We will now disable the root account. Press [Enter] to continue."
35+
read -rp "${C_NOTE}We will now disable the root account. Press [Enter] to continue."
2936

30-
echo "Disabling root account..."
37+
echo "${C_INFO}Disabling root account..."
3138
usermod -L root || {
32-
echo -e "${C_RED}ERROR:${C_NC} Failed to lock the root account" >&2
33-
echo -e "\nExiting..."
39+
echo -e "${C_ERROR}Failed to lock the root account" >&2
40+
echo -e "\n${C_INFO}Exiting..."
3441
exit 1
3542
}
3643

37-
echo -e "\n${C_GREEN}The root account has been locked${C_NC}"
44+
echo -e "\n${C_SUCCESS}The root account has been locked"

hardening/SSHD Hardening/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## v2.0.2 - 2024-12-20
8+
9+
### Changed
10+
11+
- Remove trap for `SIGQUIT`.
12+
- Move around traps and cases.
13+
14+
## v2.0.1 - 2024-10-30
15+
16+
### Fixed
17+
18+
- Fixed trapping logic and how errors are handled.
19+
720
## v2.0.0 - 2024-08-15
821

922
Complete rewrite of the script. Below are just some of the differences in the new version.

hardening/SSHD Hardening/harden-sshd.bash

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
#
33
# This script hardens the ssh server by modifying its configuration file, 'sshd_config'.
44
#
5-
# Note:
5+
# NOTE:
66
# These configurations align with the recommendations of the security auditing tool
77
# known as Lynis (https://github.com/CISOfy/lynis).
88
#
9-
# Version: v2.0.0
9+
# TODO:
10+
# - Impliment functionality to revert changes if the script fails.
11+
#
12+
# Version: v2.0.2
1013
# License: MIT License
1114
# Copyright (c) 2020-2024 Hunter T. (StrangeRanger)
1215
#
@@ -33,7 +36,7 @@ readonly C_ERROR="${C_RED}ERROR:${C_NC} "
3336
readonly C_INFO="${C_BLUE}==>${C_NC} "
3437
readonly C_NOTE="${C_CYAN}==>${C_NC} "
3538

36-
# Associative array containing the configuration settings for sshd_config.
39+
# Associative array containing the configuration settings for 'sshd_config'.
3740
declare -A C_SSHD_CONFIG=(
3841
["LogLevel"]="VERBOSE"
3942
["LogLevelRegex"]='^#?LogLevel\s+.*$'
@@ -79,31 +82,37 @@ readonly C_SSHD_CONFIG
7982

8083

8184
####
82-
# Cleanly exit the script.
85+
# Exit the script and display a message based on the exit code.
8386
#
8487
# PARAMETERS:
8588
# - $1: exit_code (Required)
86-
# - The exit code to exit the script with.
8789
clean_exit() {
8890
local exit_code="$1"
8991

92+
# Unset the EXIT trap to prevent re-entry.
93+
trap - EXIT
94+
9095
case "$exit_code" in
91-
0) exit 0 ;;
92-
1) echo "" ;;
93-
130) echo -e "\n${C_WARNING}User interrupt detected" ;;
94-
*) echo -e "\n${C_RED}==>${C_NC} Exiting with code: $exit_code" ;;
96+
0) ;;
97+
1) echo "" ;;
98+
129) echo -e "\n${C_WARNING}Hangup signal detected (SIGHUP)" ;;
99+
130) echo -e "\n${C_WARNING}User interrupt detected (SIGINT)" ;;
100+
143) echo -e "\n${C_WARNING}Termination signal detected (SIGTERM)" ;;
101+
*) echo -e "\n${C_WARNING}Exiting with code: $exit_code" ;;
95102
esac
96103

97-
echo -e "${C_INFO}Exiting..."
104+
echo "Exiting..."
98105
exit "$exit_code"
99106
}
100107

101108

102109
####[ Trapping Logic ]##################################################################
103110

104111

105-
# Catch some of the most common signals.
106-
trap 'clean_exit $?' EXIT INT TERM HUP QUIT ERR
112+
trap 'clean_exit 129' SIGHUP
113+
trap 'clean_exit 130' SIGINT
114+
trap 'clean_exit 143' SIGTERM
115+
trap 'clean_exit $?' EXIT
107116

108117

109118
####[ Prepping ]########################################################################
@@ -129,7 +138,7 @@ fi
129138
read -rp "${C_NOTE}We will now harden sshd. Press [Enter] to continue."
130139

131140
###
132-
### [ Backup 'sshd_config' ]
141+
### [ Back up 'sshd_config' ]
133142
###
134143

135144
if [[ -f $C_CONFIG_FILE_BAK ]]; then

hardening/UFW Cloudflare/ufw-cloudflare.bash

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Sets up UFW to only allow HTTP and HTTPS traffic from Cloudflare's IP ranges.
44
#
5-
# Version: v1.0.0-beta.1
5+
# Version: v1.0.0-beta.2
66
# License: MIT License
77
# Copyright (c) 2024 Hunter T. (StrangeRanger)
88
#
@@ -139,10 +139,14 @@ cleanup() {
139139
}
140140

141141

142-
####[ Trap Logic ]######################################################################
142+
####[ Trapping Logic ]##################################################################
143143

144144

145-
trap cleanup EXIT
145+
trap 'clean_exit 130' SIGINT
146+
trap 'clean_exit 143' SIGTERM
147+
trap 'clean_exit 129' SIGHUP
148+
trap 'clean_exit 131' SIGQUIT
149+
trap 'clean_exit $?' EXIT
146150

147151

148152
####[ Main ]############################################################################

0 commit comments

Comments
 (0)