CentOS基线脚本,三级等保服务器系统安全配置脚本_centos 日志 等保三

服务器 0

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新网络安全全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上网络安全知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip204888 (备注网络安全)
img

正文

Log_Backup_Time=cat /etc/logrotate.conf |head -n 10|grep "rotate "| grep -v ^# | head -n 1|awk '{print $2}'
if [ $Log_Backup_Time -ge 26 ];then
echo “…[Y] Log backup Time: $Log_Backup_Time weeks”
else
echo “…[N] Log backup Time,Reset failed”
fi
fi
}

#检查会话超时时间
function CheckConnectionTimeout() {
Connection_Timeout=cat /etc/profile | grep 'export TMOUT' | grep -v ^# | cut -d= -f2
if [ -z C o n n e c t i o n _ T i m e o u t ] ; t h e n s e d − i ′ Connection/_Timeout ];then sed -i ' Connection_Timeout];thensedia export TMOUT=1800’ /etc/profile
elif [ $Connection_Timeout -gt 1800 -o C o n n e c t i o n _ T i m e o u t − l t 600 ] ; t h e n s e d − i ′ / T M O U T / s / ′ " Connection/_Timeout -lt 600 ];then sed -i '/TMOUT/s/'" Connection_Timeoutlt600];thensedi/TMOUT/s/"{Connection_Timeout}"‘/1800/g’ /etc/profile
fi
source /etc/profile
Connection_Timeout=cat /etc/profile | grep 'export TMOUT' | grep -v ^# | cut -d= -f2
if [ $Connection_Timeout -le 1800 -a $Connection_Timeout -ge 600 ];then
echo “…[Y] Connection timeout: $Connection_Timeout seconds”
else
echo “…[N] Connection timeout: Reset failed”
fi

}

#检查共享账户
function CheckSharedUser() {
usermod -L shutdown 2>/dev/null
usermod -L halt 2>/dev/null
echo “…[Y] Shared user: Locked”
}

#检查审计策略
function CheckAuditLogs() {
Audit_Logs=auditctl -s | grep enabled | awk '{print $2}'
if [ $Audit_Logs -ne 1 ];then
systemctl start auditd
systemctl enable auditd
fi
Audit_Logs=auditctl -s | grep enabled | awk '{print $2}'
if [ $Audit_Logs -eq 1 ];then
echo “…[Y] Audit Policy: $Audit_Logs Enable”
else
echo “…[N] Audit Policy: $Audit_Logs Disabled”
fi
}

#检查分权账户
function CheckAuthorizedUser() {
shenji=cat /etc/passwd |grep shenji | grep -v ^# | cut -d: -f 1
anquan=cat /etc/passwd |grep anquan | grep -v ^# | cut -d: -f 1
sysadmin=cat /etc/passwd |grep sysadmin | grep -v ^# | cut -d: -f 1
if [ -z KaTeX parse error: Expected 'EOF', got '#' at position 51: … shenji:In123!@#̲123|chpasswd s…a shenji ALL = (root) NOPASSWD: /usr/bin/cat , /usr/bin/less , /usr/bin/more , /usr/bin/tail , /usr/bin/head’ /etc/sudoers
fi
if [ -z $anquan ];then
useradd anquan
echo anquan:In123!@#123|chpasswd
fi
if [ -z $sysadmin ];then
useradd sysadmin
echo sysadmin:In123!@#123|chpasswd
fi
shenji=cat /etc/passwd |grep shenji | grep -v ^# | cut -d: -f 1
anquan=cat /etc/passwd |grep anquan | grep -v ^# | cut -d: -f 1
sysadmin=cat /etc/passwd |grep sysadmin | grep -v ^# | cut -d: -f 1
if [ -z $shenji -o -z $anquan -o -z $sysadmin ];then
echo “…[N] Authorized user: $shenji, $anquan, $sysadmin”
else
echo “…[Y] Authorized user: $shenji, $anquan, $sysadmin”
fi
}

#检查登录失败锁定配置CentOS
function CheckLoginFailureLock_CentOS() {
Login_Failure_Lock=grep "pam/_tally2.so" /etc/pam.d/system-auth| grep -v ^#|head -n 1|awk '{print $7}'
if [ -z $Login_Failure_Lock ];then
sed -i ‘/pam_tally2.so/s/#auth/auth/g’ /etc/pam.d/system-auth
Login_Failure_Lock=grep "pam/_tally2.so" /etc/pam.d/system-auth| grep -v ^#|head -n 1|awk '{print $7}'
fi
if [ -z L o g i n _ F a i l u r e _ L o c k ] ; t h e n s e d − i ′ Login/_Failure/_Lock ];then sed -i ' Login_Failure_Lock];thensedia auth required pam_tally2.so onerr=fail audit silent dent=5 unlock_time=600 even_deny_root root_unlock_time=600’ /etc/pam.d/system-auth
else
Login_Failure_Lock=grep "pam/_tally2.so onerr=fail audit silent dent=5 unlock/_time=600" /etc/pam.d/system-auth| grep -v ^#|awk '{print $7}'
if [ -z KaTeX parse error: Expected 'EOF', got '#' at position 63: …lly2.so/s/auth/#̲auth/g' /etc/pa…a auth required pam_tally2.so onerr=fail audit silent dent=5 unlock_time=600 even_deny_root root_unlock_time=600’ /etc/pam.d/system-auth
fi
fi
Login_Failure_Lock=grep "pam/_tally2.so onerr=fail audit silent dent=5 unlock/_time=600" /etc/pam.d/system-auth| grep -v ^#|awk '{print $7","$8","$10}'
if [ -z $Login_Failure_Lock ];then
echo “…[N] Login Failure Lock: Reset failed”
else
echo “…[Y] Login Failure Lock: $Login_Failure_Lock”
fi

}

#检查登录失败锁定配置SUSE
function CheckLoginFailureLock_SUSE() {
Login_Failure_Number=cat /etc/login.defs | grep LOGIN/_RETRIES | grep -v ^# | awk '{print $2}'
if [ -z $Login_Failure_Number ];then
sed -i ‘s/#LOGIN_RETRIES/LOGIN_RETRIES/’ /etc/login.defs
Login_Failure_Number=cat /etc/login.defs | grep LOGIN/_RETRIES | grep -v ^# | awk '{print $2}'
fi
if [ -z $Login_Failure_Number ];then
echo “…[N] Number of login failures: No configuration”
elif [ $Login_Failure_Number -le 8 -a $Login_Failure_Number -ge 3 ];then
echo “…[Y] Number of login failures: L o g i n _ F a i l u r e _ N u m b e r " e l s e s e d − i ′ / L O G I N _ R E T R I E S / s / ′ " Login/_Failure/_Number" else sed -i '/LOGIN/_RETRIES/s/'" Login_Failure_Number"elsesedi/LOGIN_RETRIES/s/"{Login_Failure_Number}”‘/5/g’ /etc/login.defs
Login_Failure_Number=cat /etc/login.defs | grep LOGIN/_RETRIES | grep -v ^# | awk '{print $2}'
if [ $Login_Failure_Number -le 8 -a $Login_Failure_Number -ge 3 ];then
echo “…[Y] Number of login failures: $Login_Failure_Number”
else
echo “…[N] Number of login failures: No configuration”
fi
fi

Login_Failure_Time=cat /etc/login.defs | grep LOGIN/_TIMEOUT | grep -v ^# | awk '{print $2}'
if [ -z $Login_Failure_Time ];then
sed -i ‘s/#LOGIN_TIMEOUT/LOGIN_TIMEOUT/’ /etc/login.defs
Login_Failure_Time=cat /etc/login.defs | grep LOGIN/_TIMEOUT | grep -v ^# | awk '{print $2}'
fi
if [ -z $Login_Failure_Time ];then
echo “…[N] Login failure lock time: Reset failed”
elif [ $Login_Failure_Time -le 1800 -a $Login_Failure_Time -ge 300 ];then
echo “…[Y] Login failure lock time: L o g i n _ F a i l u r e _ T i m e s e c o n d s " e l s e s e d − i ′ / L O G I N _ T I M E O U T / s / ′ " Login/_Failure/_Time seconds" else sed -i '/LOGIN/_TIMEOUT/s/'" Login_Failure_Timeseconds"elsesedi/LOGIN_TIMEOUT/s/"{Login_Failure_Time}”‘/300/g’ /etc/login.defs
Login_Failure_Time=cat /etc/login.defs | grep LOGIN/_TIMEOUT | grep -v ^# | awk '{print $2}'
if [ $Login_Failure_Time -le 1800 -a $Login_Failure_Time -ge 300 ];then
echo “…[Y] Login failure lock time: $Login_Failure_Time seconds”
else
echo “…[N] Login failure lock time: Reset failed”
fi
fi

}

#检查密码策略CentOS
function CheckPasswordPolicy_CentOS() {
Password_Policy=grep "pam/_cracklib.so" /etc/pam.d/system-auth| grep -v ^#|awk '{print $4}'
if [ -z $Password_Policy ];then
sed -i ‘/pam_cracklib.so/s/#password/password/g’ /etc/pam.d/system-auth
Password_Policy=grep "pam/_cracklib.so" /etc/pam.d/system-auth| grep -v ^#|awk '{print $4}'
fi
if [ -z P a s s w o r d _ P o l i c y ] ; t h e n s e d − i ′ Password/_Policy ];then sed -i ' Password_Policy];thensedia password requisite pam_cracklib.so minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1’ /etc/pam.d/system-auth
else
Password_Policy=grep "pam/_cracklib.so minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1" /etc/pam.d/system-auth| grep -v ^#|awk '{print $4}'
if [ -z KaTeX parse error: Expected 'EOF', got '#' at position 65: ….so/s/password/#̲password/g' /et…a password requisite pam_cracklib.so minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1’ /etc/pam.d/system-auth
fi
fi
Password_Policy=grep "pam/_cracklib.so minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1" /etc/pam.d/system-auth| grep -v ^#|awk '{print $4","$5","$6","$7","$8}'
if [ -z $Password_Policy ];then
echo “…[N] Password Policy: Reset failed”
else
echo “…[Y] Password Policy: $Password_Policy”
fi
}

#检查密码策略SUSE
function CheckPasswordPolicy_SUSE() {
Password_Policy=grep "pam/_cracklib.so" /etc/pam.d/common-password| grep -v ^#|awk '{print $4}'
if [ -z $Password_Policy ];then
sed -i ‘/pam_cracklib.so/s/#password/password/g’ /etc/pam.d/common-password
Password_Policy=grep "pam/_cracklib.so" /etc/pam.d/common-password| grep -v ^#|awk '{print $4}'
fi
if [ -z P a s s w o r d _ P o l i c y ] ; t h e n s e d − i ′ Password/_Policy ];then sed -i ' Password_Policy];thensedia password requisite pam_cracklib.so retry=3 difok=3 minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1’ /etc/pam.d/common-password
else
Password_Policy=grep "minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1" /etc/pam.d/common-password| grep -v ^#|awk '{print $4}'
if [ -z KaTeX parse error: Expected 'EOF', got '#' at position 65: ….so/s/password/#̲password/g' /et…a password requisite pam_cracklib.so retry=3 difok=3 minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1’ /etc/pam.d/common-password
fi
fi
Password_Policy=grep "minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1" /etc/pam.d/common-password| grep -v ^#|awk '{print $4","$5","$6","$7","$8}'
if [ -z $Password_Policy ];then
echo “…[N] Password Policy: Reset failed”
else
echo “…[Y] Password Policy: $Password_Policy”
fi
}

#检查日志服务CentOS
function CheckLogService_CentOS() {
Log_Service=systemctl status rsyslog | grep active | awk '{print $3}'
if [ $Log_Service != “(running)” ];then
systemctl start rsyslog
systemctl enable rsyslog
fi
Log_Service=systemctl status rsyslog | grep active | awk '{print $3}'
if [ $Log_Service = “(running)” ];then
echo “…[Y] Log Service: $Log_Service”
else
echo “…[N] Log Service: $Log_Service”
fi
}

#检查日志服务SUSE
function CheckLogService_SUSE() {
Log_Service=systemctl status syslog-ng | grep active | awk '{print $3}'
if [ $Log_Service != “(running)” ];then
systemctl start syslog-ng
systemctl enable syslog-ng
fi
Log_Service=systemctl status syslog-ng | grep active | awk '{print $3}'
if [ $Log_Service = “(running)” ];then
echo “…[Y] Log Service: $Log_Service”
else
zypper install syslog-ng -y 2>/dev/null
systemctl start syslog-ng
systemctl enable syslog-ng
Log_Service=systemctl status syslog-ng | grep active | awk '{print $3}'
if [ $Log_Service = “(running)” ];then
echo “…[Y] Log Service: $Log_Service”
else
echo “…[N] Log Service: Reset failed”
fi
fi
}

如何自学黑客&网络安全

黑客零基础入门学习路线&规划

初级黑客
1、网络安全理论知识(2天)
①了解行业相关背景,前景,确定发展方向。
②学习网络安全相关法律法规。
③网络安全运营的概念。
④等保简介、等保规定、流程和规范。(非常重要)

2、渗透测试基础(一周)
①渗透测试的流程、分类、标准
②信息收集技术:主动/被动信息搜集、Nmap工具、Google Hacking
③漏洞扫描、漏洞利用、原理,利用方法、工具(MSF)、绕过IDS和反病毒侦察
④主机攻防演练:MS17-010、MS08-067、MS10-046、MS12-20等

3、操作系统基础(一周)
①Windows系统常见功能和命令
②Kali Linux系统常见功能和命令
③操作系统安全(系统入侵排查/系统加固基础)

4、计算机网络基础(一周)
①计算机网络基础、协议和架构
②网络通信原理、OSI模型、数据转发流程
③常见协议解析(HTTP、TCP/IP、ARP等)
④网络攻击技术与网络安全防御技术
⑤Web漏洞原理与防御:主动/被动攻击、DDOS攻击、CVE漏洞复现

5、数据库基础操作(2天)
①数据库基础
②SQL语言基础
③数据库安全加固

6、Web渗透(1周)
①HTML、CSS和JavaScript简介
②OWASP Top10
③Web漏洞扫描工具
④Web渗透工具:Nmap、BurpSuite、SQLMap、其他(菜刀、漏扫等)
恭喜你,如果学到这里,你基本可以从事一份网络安全相关的工作,比如渗透测试、Web 渗透、安全服务、安全分析等岗位;如果等保模块学的好,还可以从事等保工程师。薪资区间6k-15k

到此为止,大概1个月的时间。你已经成为了一名“脚本小子”。那么你还想往下探索吗?

如果你想要入坑黑客&网络安全,笔者给大家准备了一份:282G全网最全的网络安全资料包评论区留言即可领取!

7、脚本编程(初级/中级/高级)
在网络安全领域。是否具备编程能力是“脚本小子”和真正黑客的本质区别。在实际的渗透测试过程中,面对复杂多变的网络环境,当常用工具不能满足实际需求的时候,往往需要对现有工具进行扩展,或者编写符合我们要求的工具、自动化脚本,这个时候就需要具备一定的编程能力。在分秒必争的CTF竞赛中,想要高效地使用自制的脚本工具来实现各种目的,更是需要拥有编程能力.

如果你零基础入门,笔者建议选择脚本语言Python/PHP/Go/Java中的一种,对常用库进行编程学习;搭建开发环境和选择IDE,PHP环境推荐Wamp和XAMPP, IDE强烈推荐Sublime;·Python编程学习,学习内容包含:语法、正则、文件、 网络、多线程等常用库,推荐《Python核心编程》,不要看完;·用Python编写漏洞的exp,然后写一个简单的网络爬虫;·PHP基本语法学习并书写一个简单的博客系统;熟悉MVC架构,并试着学习一个PHP框架或者Python框架 (可选);·了解Bootstrap的布局或者CSS。

8、超级黑客
这部分内容对零基础的同学来说还比较遥远,就不展开细说了,附上学习路线。
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

convert/32eb4b22aa740233c5198d3c161b37e8.webp?x-oss-process=image/format,png)

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注网络安全)
[外链图片转存中…(img-3ptsm9xE-1713307490999)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

也许您对下面的内容还感兴趣: