
UNIX 보안 감사 도구로, 여러 보안 프레임워크를 기반으로 합니다.

Lockdown UNix Auditing and Reporting
현재 버전 15.9.1
더 최신 버전 정보는 lunar.sh 및 변경 로그를 참조하세요.
CC BY-SA: https://creativecommons.org/licenses/by-sa/4.0/
여기에서 후원해 주세요: https://ko-fi.com/richardatlateralblast
이 코드는 감사 모드로만 실행하세요. 예: -a 또는 --audit 스위치 사용. 락다운은 사용자 책임 하에 실행하세요. 모든 시스템 변경과 마찬가지로 백업을 준비하세요. 복구 모드를 개선하는 중이지만, 여전히 버그가 있을 수 있습니다.
shellcheck를 사용하여 이 스크립트를 최대한 정리하려고 노력했으며, 오류를 방지하기 위해 -e (errexit) 및 -u (nounset) 셸 플래그를 사용하는 옵션을 활성화했습니다. -x (xtrace) 셸 플래그는 -Q 또는 --debug 플래그와 함께 스크립트를 사용하여 활성화할 수 있습니다.
진행 중:
이 스크립트는 Unix 호스트의 보안에 대한 점수화된 감사 보고서를 생성합니다. CIS 및 기타 프레임워크를 기반으로 합니다. 가능한 경우 코드 문서에 CIS 및 기타 벤치마크에 대한 참조가 포함되어 있습니다.
왜 셸 스크립트인가? 다른 도구를 사용할 수 없는 제한된 시스템에서 실행할 수 있는 도구를 원했습니다. 또한 모든 버전의 UNIX에서 실행되는 도구를 원했습니다. 그럼에도 sh와 bash 사이에는 약간의 차이가 있으므로, sh의 함수만 사용했습니다.
이 스크립트에는 명시적이거나 암시적인 보증이 없습니다. 권장 사항은 이 스크립트를 감사 모드에서만 사용하고, 각 경고를 정책, 문서 및 구성 관리를 통해 개별적으로 처리하는 것입니다.
저는 결코 코더가 아니므로, 이 스크립트에는 버그나 더 나은 접근 방식이 있을 수 있습니다. 코드의 버그/기능을 수정하기 위해 피드백, 업데이트 및 패치를 제공해 주신 분들께 진심으로 감사드립니다.
또한 락다운을 수행할 수 있습니다. 다른 스크립트와 달리 변경 사항을 롤백할 수 있는 기능을 추가했습니다. 파일은 날짜를 기준으로 한 디렉토리에 cpio를 사용하여 백업됩니다.
락다운을 수행할 수 있지만, 앞서 말씀드렸듯이 경고를 정책, 문서 및 구성 관리를 통해 처리하는 것을 권장합니다. 이것이 제가 이 도구를 사용하는 방식입니다. AWS 서비스 감사는 보고만 지원하며, 락다운 기능을 제공하지 않습니다.
다음 운영 체제가 지원됩니다:
Windows 지원은 추가 소프트웨어 설치가 필요하므로 고려하지 않았습니다. 그러나 향후 bash를 통해 Windows 지원이 제공될 수 있습니다.
다음 서비스가 지원됩니다:
AWS 서비스 감사는 AWS CLI를 사용하며, 적절한 권한이 있는 사용자가 필요합니다. 현재 락다운 기능을 지원하지 않으며, CIS 벤치마크에 대한 감사 보고서 생성만 지원합니다.
일부 검사는 GUI를 통해서만 수행하거나 해결할 수 있습니다. 예를 들어 청구 활성화가 있습니다. 자세한 내용은 CIS 벤치마크를 참조하세요.
가능한 경우 자세한 감사 출력에 권장 수정 명령을 넣었습니다. 다시 말하지만, 어떤 경우에는 CLI로만 수행할 수 있습니다. 자세한 내용은 CIS 벤치마크를 참조하세요.
또한 Cloud Conformity와 같은 회사의 공개 모범 사례를 기준으로 AWS를 확인하는 권장 모드를 추가했습니다.
다음 구성 관리 출력이 지원됩니다:
이 옵션은 권장 사항을 구현하기 위한 예제 Ansible 구성 관리 코드/스탠자를 출력합니다.
UNIX:
AWS:
Azure:
Usage: ./lunar.sh -switch|--switch
switch(es):
-----------
-1|--list)
List changes/backups
-2|--tests)
Print tests
-3|--printfunct)
Print function
-4|--dryrun)
Run in dryrun mode
-6|--format)
Outpt format/type
-7|--file)
Output file
-8|--usesudo)
Use sudo
-9|--shellcheck)
Run shellcheck against script
-0|--force)
Force action
-a|--audit)
Run in audit mode (for Operating Systems - no changes made to system)
-A|--fullaudit)
Run in audit mode and include filesystems (for Operating Systems - no changes made to system)
-b|--backups|--listbackups)
List backups
-B|--basedir)
Set base directory
-c|--codename|--distro)
Distro/Code name (used with docker/multipass)
-C|--shell)
Run docker-compose testing suite (drops to shell in order to do more testing)
-d|--dockeraudit)
Run in audit mode (for Docker - no changes made to system)
-D|--dockertests)
List all Docker functions available to selective mode
-e|--host)
Run in audit mode on external host (for Operating Systems - no changes made to system)
-E|--hash|--passwordhash)
Password hash
-f|--action)
Action (e.g delete - used with multipass)
-F|--tempfile)
Temporary file to use for operations
-g|--giturl)
Git URL for code to copy to container
-G|--wheelgroup)
Set wheel group
-h|--help)
Display help
-H|--usage)
Display usage
-i|--anacron)
Enable/Disable anacron
-I|--type)
Audit type
-k|--kubeaudit)
Run in audit mode (for Kubernetes - no changes made to system)
-K|--function|--test)
Do a specific function
-l|--lockdown)
Run in lockdown mode (for Operating Systems - changes made to system)
-L|--fulllockdown|fulllock)
Run in lockdown mode (for Operating Systems - changes made to system)
-m|--machine|--vm)
Set virtualisation type
-M|--workdir)
Set work directory
-n|--ansible)
Output ansible
-N|--nocat)
Do output cat in score
-o|--os|--osver)
Set OS version
-O|--osinfo|--systeminfo)
Print OS/System information
-p|--previous)
Print previous audit information
-P|--sshsandbox|--sandbox)
Enable/Disabe SSH sandbox
-q|--quiet|--nostrict)
Run in quiet mode
-Q|--debug)
Run in debug mode
-r|--awsregion|--region)
Set AWS region
-R|--moduleinfo|--testinfo)
Print information about a module
-s|--select|--check)
Run in selective mode (only run tests you want to)
-S|--unixtests|--unix)
List UNIX tests
-t|--tag|--name)
Set docker tag
-T|--tempdir)
Set temp directoru
-u|--undo)
Undo lockdown (for Operating Systems - changes made to system)
-U|--dofiles)
Include filesystems
-v|--verbose)
Run in verbose mode
-V|--version)
Print version
-w|--awsaudit)
Run in audit mode (for AWS - no changes made to system)
-W|--awstests|--aws)
List all AWS functions available to selective mode
-x|--awsrec)
Run in recommendations mode (for AWS - no changes made to system)
-X|--strict)
Run shellcheck against script
-z)
Run specified audit function in lockdown mode
-Z|--changes|--listchanges)
List changes
전체 감사 수행 (재귀적 파일 시스템 검사 제외):
./lunar.sh --audit
테스트 목록 보기:
./lunar.sh --tests
AWS 테스트 목록 보기:
./lunar.sh --tests aws
특정 테스트 실행:
./lunar.sh --audit --select remote_shell
테스트용 Ubuntu 24.04 multipass VM 생성:
./lunar.sh --action create --machine multipass --osver 24.04
자세한 내용은 위키를 참조하세요:
lunar 스크립트 자체를 디버깅하기 위한 간단한 테스트 프레임워크를 추가했습니다. 이는 docker compose를 사용하여 컨테이너를 시작하고, lunar 디렉토리를 마운트한 후 lunar를 실행합니다.