




已阅读5页,还剩15页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
系系 统统 加加 固固 目目 录录 1 BIOS 2 2 SSH 安全 2 3 禁用 telnet 3 4 禁用代码编译 3 5 ProFTP 4 6 TCP wrappers 5 7 创建 SU 用户组 5 8 root 通知 6 9 history 安全 6 10 使用欢迎信息 6 11 禁用所有特殊账户 6 12 chmod 危险文件 7 13 指定允许 root 登陆的 TTY 设备 7 14 选择一个安全的密码 8 15 检测 Rootkit 8 16 安装补丁 9 17 隐藏 Apache 信息 9 18 隐藏 php 信息 10 19 关闭不用的服务 10 20 检测监听的端口 10 21 关闭端口和服务 10 22 删除不用的 rpm 包 11 23 禁用危险的 php 函数 11 24 安装配置防火墙 11 25 安装配置 BFD 暴力破解检测 13 26 内核加固 sysctl conf 14 27 更改 SSH 端口 19 28 tmp var tmp dev shm 分区的安全 19 1 BIOS 你应该总是在系统启动的时候设置一个 BIOS 密码和禁用从 CD ROM 和软盘引导 这将防 止一些人未经允许访问你的系统和更改 BIOS 设置 2 SSH 安全安全 SSH 是一个协议 利用它可以登录到一个远程系统或远程执行系统命令 默认允许 root 登 录 并且 sshv1 存在缺陷 我们应该在 sshd config 禁止 root 访问和使用 sshv2 来让 ssh 更加安全 方法 vi etc ssh sshd config 复制代码 把协议改为 2 PermitRootLogin no 复制代码 重启 sshd etc rc d init d sshd restart 复制代码 3 禁用禁用 telnet 早期的 Linux 默认开启 telnet 服务 telnet ftp rlogin 都是明文传输的协议 是容易被嗅探到 的 这就是为什么推荐使用安全的版本 sftp scp ssh 的原因 如果你必须要使用 telnet 那么至少应该隐藏 banner 信息 方法 修改 etc xinetd d telnet disable yes 复制代码 4 禁用代码编译禁用代码编译 你可以禁用代码编译并且只把编译的权限分配给一个用户组 方法 添加编译用户组 usr sbin groupadd compiler cd usr bin 复制代码 把常见的编译器所属组赋给编译用户组 chgrp compiler cc chgrp compiler chgrp compiler ld chgrp compiler as 复制代码 设置 mysqlaccess 的访问 chgrp root mysqlaccess 复制代码 设置权限 chmod 750 cc chmod 750 chmod 750 ld chmod 750 as chmod 755 mysqlaccess 复制代码 把用户添加到组里 修改 etc group compiler x 520 user1 user2 复制代码 5 ProFTP 你可以通过修改 proftpd conf 来禁止 root 登陆 方法 修改 etc proftpd conf Add RootLogin off 复制代码 重启 proftpd sbin service proftpd stop sbin service proftpd start 复制代码 6 TCP wrappers 编辑 hosts allow 和 hosts deny 可以限制或允许访问 inet 服务 方法 限制访问 inet 服务 修改 etc hosts allow 建议格式 Approved IP addresses ALL 192 168 0 1 ALL 192 168 5 2 CSV uploader machine proftpd 10 0 0 5 pop3 from antwhere ipop3 ALL 复制代码 修改 etc hosts deny ALL ALL EXCEPT localhostENY 复制代码 7 创建创建 SU 用户组用户组 因为我们在 SSH 禁止了 root 用户访问并且禁用了 telnet 所有我们应该 分配给一些用户 su 权限来获取 root 特权 方法 vi etc group 添加一行 wheel x 10 root user1 user2 chgrp wheel bin su chmod o rwx bin su 复制代码 8 root 通知通知 当一个具有 root 权限的用户登录的时候发 mail 方法 编辑 root 下的 bashrc 当有 root 权限的用户登录时发生 email 通知 echo ALERT Root Shell Access Server Name on date who mail s Alert Root Access from who cut d f2 cut d f1 your 复制代码 9 history 安全安全 这是一个避免删除 bash history 或重定向到 dev null 的好主意 因此他不能清除或删除他最 后执行的命令 方法 chattr a bash history chattr i bash history 复制代码 获取用户的人会知道他的历史命令锁定并且要同意才可以使用服务 10 使用欢迎信息使用欢迎信息 你必须提供一些信息让攻击者知道该系统不对公众开放 在国外有类似案件 攻击者入侵一个系统并且系统没有这些信息 这种情况下法院不能做 任何裁决 因为系统说 welcome 方法 删除 etc redhat release 编辑 etc issue etc motd 并显示警告信息 11 禁用所有特殊账户禁用所有特殊账户 你应该从系统中删除所有默认用户和组 例如 news lp sync shutdown uucp games halt 等 方法 删除账户 userdel name 删除组 groupdel name 锁定特定账户 usr sbin usermod L s bin false user 复制代码 12 chmod 危险文件危险文件 这可能是限制不具有 root 权限的用户执行下面这些命令的好主意 方法 chmod 700 bin ping chmod 700 usr bin finger chmod 700 usr bin who chmod 700 usr bin w chmod 700 usr bin locate chmod 700 usr bin whereis chmod 700 sbin ifconfig chmod 700 usr bin pico chmod 700 usr bin vi chmod 700 usr bin which chmod 700 usr bin gcc chmod 700 usr bin make chmod 700 bin rpm 复制代码 13 指定允许指定允许 root 登陆的登陆的 TTY 设备设备 etc securetty 文件允许你指定 root 可以从哪个 TTY 设备登录 方法 vi etc securetty 复制代码 只留 2 个连接 tty1 tty2 复制代码 14 选择一个安全的密码选择一个安全的密码 在 etc login defs 文件中定义了 shadow 密码的具体配置 默认密码长度最短为 5 字符 你应该至少设置为 8 方法 vi etc login defs PASS MIN LEN 8 复制代码 15 检测检测 Rootkit 用 chkrootkit 或 rkhunter 以 chkrootkit 为例 方法 wget ftp br pub seg pac chkrootkit tar gz wget ftp br pub seg pac chkrootkit md5 复制代码 首先检查 md5 校验值 md5sum chkrootkit tar gz 然后解压安装 tar zxvf chkrootkit tar gz cd chkrootkit configure make sense 复制代码 然后运行 chkrootkit 我们可以将其添加到 contrab 使其每天自动扫描 vi etc cron daily chkrootkit sh 复制代码 bin bash 输入 chkrootkit 的安装目录 cd root chkrootkit 复制代码 输入你想收到检测报告的 email chkrootkit mail s Daily chkrootkit from Server Name your 复制代码 16 安装补丁安装补丁 你要经常检查更新以修复某些缺陷或系统稳定性的改进 否则你存在漏洞的系统将会不时的遭受新的攻击 方法 列出可用更新 up2date l 安装未排除的更新 up2date u 安装包括排除的更新 up2date uf 复制代码 17 隐藏隐藏 Apache 信息信息 你应该隐藏 Apache 的 banner 信息使攻击者不知道 Apache 的版本 从而使他们难以利用漏 洞 方法 修改 etc httpd conf httpd conf 改变服务器签名 ServerSignature Off 复制代码 重启 Apache sbin service httpd restart 18 隐藏隐藏 php 信息信息 你应该隐藏 php 的 banner 信息 原因同上 方法 修改 php ini 改变 expose php Off 复制代码 重启 Apache 19 关闭不用的服务关闭不用的服务 你应该把任何未使用的服务关闭 可以在 etc xinetd d 文件夹里找到 方法 cd etc xinetd d grep disable 复制代码 这将显示所有服务开启或关闭的状态 然后根据需要来开启或关闭服务 20 检测监听的端口检测监听的端口 检测是否有必要开放端口是非常重要的 方法 netstat tulp 或 lsof i n egrep COMMAND LISTEN UDP 或 nmap 复制代码 21 关闭端口和服务关闭端口和服务 重点是关闭在系统启动时打开的不需要的端口 方法 对于正在运行的服务 可以执行 chkconfig list grep on 禁用服务可以执行 chkconfig servicename off 然后停止正在运行的服务 etc init d service stop 22 删除不用的删除不用的 rpm 包包 首先应该清楚你的系统的作用 它是 web mail file 服务器或其他 然后觉得哪些包是必要的 之后删除不需要的软件包 方法 首先列出安装列表 rpm qa 更详细的信息 rpm qi rpmname 还可以检测删除包可能出现的冲突 rpm e test rpmname 23 禁用危险的禁用危险的 php 函数函数 你应该禁用 php 的危险函数防止在网站上执行系统命令 方法 whereis php ini vi usr local lib php ini 复制代码 编辑 disable functions symlink shell exec exec proc close proc open popen system dl passthru escapeshellarg escapeshellcmd 复制代码 24 安装配置防火墙安装配置防火墙 高级策略防火墙 APF 是一种 IP 表 网络过滤 它是基于当今互联网部署服务器防火墙系 统的基本需要和客户部署 LINUX 安装的唯一需要而设计的 它是最好的开源防火墙之一 配置 APF 防火墙方法 下载 APF wget http www r fx ca downloads apf current tar gz 解压安装 tar zxvf apf current tar gz cd apf 0 9 7 1 install sh 复制代码 然后我们配置它 vi etc apf conf apf 一般配置 启用防火墙使用 DShield org 块列表 USE DS 1 然后我将列出常规的配置和 CPanel 配置方式 因为 CPanel 是应该最广泛的虚拟主机管理 软件 1 常规配置 DNS Mail Web FTP Common ingress inbound Common ingress inbound TCP ports 3000 3500 passive port range for Pure FTPD IG TCP CPORTS 21 22 25 53 80 110 143 443 995 Common ingress inbound UDP ports IG UDP CPORTS 53 Egress filtering 0 Disabled 1 Enabled EGF 1 Common egress outbound TCP ports EG TCP CPORTS 21 25 80 443 43 Common egress outbound UDP ports EG UDP CPORTS 20 21 53 2 CPanel 配置 Common ingress inbound ports Common ingress inbound TCP ports 3000 3500 passive port range for Pure FTPD IG TCP CPORTS 21 22 25 53 80 110 143 443 2082 2083 2086 2087 2095 2096 3000 3500 Common ingress inbound UDP ports IG UDP CPORTS 53 Common egress outbound ports Egress filtering 0 Disabled 1 Enabled EGF 1 Common egress outbound TCP ports EG TCP CPORTS 21 25 80 443 43 2089 Common egress outbound UDP ports EG UDP CPORTS 20 21 53 复制代码 之后启动防火墙 etc apf apf s 如果运行良好我在回去修改配置文件 使 DEVM 0 然后我们配置 APF 的 AntiDos vi etc apf ad conf antidos 找到下面的内容并替换成你的资料 Organization name to display on outgoing alert emails CONAME Your Company Send out user defined attack alerts 0 off 1 on USR ALERT 0 User for alerts to be mailed to USR you 复制代码 你应把 USR ALERT 改为 1 保存后重启 APF etc apf apf r To make the firewall start with the Operating System chkconfig level 2345 apf on 复制代码 APF 开机自启动 chkconfig level 2345 apf on 禁止一个 IP 用 etc apf apf d ip 或 vi etc apf deny hosts rules 允许一个 IP 用 etc apf apf a ip 或 vi etc apf deny hosts rules 25 安装配置安装配置 BFD 暴力破解检测暴力破解检测 BFD 是一个用于分析应用日志和检测验证失败的模块化 shell 脚本 而且安装配置和用法都是非常容易的 使用 BFD 的原因很简单 其实在 LINUX 领域几乎没有结合防火墙或实时设备来监控不验证和暴力攻击审计的程序 在用 BFD 之前你必须安装 APF 防火墙 方法 wget http www r fx ca downloads bfd current tar gz tar zxvf bfd current tar gz cd bfd 0 9 复制代码 然后我们来配置它 vi usr local bfd conf bfd 把以下内容改为你的资料 Enable disable user alerts 0 off 1 on ALERT USR 1 User alert email address EMAIL USR your User alert email subject SUBJ USR Brute Force Warning for HOSTNAME 复制代码 然后 vi usr local bfd ignore hosts 把你的 IP 设置成允许主机 避免意外的锁定自己 之后重启 BFD usr local sbin bfd s 26 内核加固内核加固 sysctl conf sysctl conf 用来加固内核 目的是避免 DOS 和欺骗攻击 方法 到 proc sys 目录或 sysctl a 命令了解下当前配置的大概情况 然后 vi etc sysctl conf 添加如下内容 Kernel sysctl configuration file for Red Hat Linux For binary values 0 is disabled 1 is enabled See sysctl 8 and sysctl conf 5 for more details Controls IP packet forwarding net ipv4 ip forward 0 Controls source route verification net ipv4 conf default rp filter 1 Controls the System Request debugging functionality of the kernel kernel sysrq 0 Controls whether core dumps will append the PID to the core filename Useful for debugging multi threaded applications kernel core uses pid 1 Prevent SYN attack net ipv4 tcp syncookies 1 net ipv4 tcp max syn backlog 2048 net ipv4 tcp synack retries 2 Disables packet forwarding net ipv4 ip forward 0 Disables IP source routing net ipv4 conf all accept source route 0 net ipv4 conf lo accept source route 0 net ipv4 conf eth0 accept source route 0 net ipv4 conf default accept source route 0 Enable IP spoofing protection turn on source route verification net ipv4 conf all rp filter 1 net ipv4 conf lo rp filter 1 net ipv4 conf eth0 rp filter 1 net ipv4 conf default rp filter 1 Disable ICMP Redirect Acceptance net ipv4 conf all accept redirects 0 net ipv4 conf lo accept redirects 0 net ipv4 conf eth0 accept redirects 0 net ipv4 conf default accept redirects 0 Enable Log Spoofed Packets Source Routed Packets Redirect Packets net ipv4 conf all log martians 1 net ipv4 conf lo log martians 1 net ipv4 conf eth0 log martians 1 Disables IP source routing net ipv4 conf all accept source route 0 net ipv4 conf lo accept source route 0 net ipv4 conf eth0 accept source route 0 net ipv4 conf default accept source route 0 Enable IP spoofing protection turn on source route verification net ipv4 conf all rp filter 1 net ipv4 conf lo rp filter 1 net ipv4 conf eth0 rp filter 1 14 net ipv4 conf default rp filter 1 Disable ICMP Redirect Acceptance net ipv4 conf all accept redirects 0 net ipv4 conf lo accept redirects 0 net ipv4 conf eth0 accept redirects 0 net ipv4 conf default accept redirects 0 Disables the magic sysrq key kernel sysrq 0 Modify system limits for Ensim WEBppliance fs file max 65000 Decrease the time default value for tcp fin timeout connection net ipv4 tcp fin timeout 15 Decrease the time default value for tcp keepalive time connection net ipv4 tcp keepalive time 1800 Turn off the tcp window scaling net ipv4 tcp window scaling 0 Turn off the tcp sack net ipv4 tcp sack 0 Turn off the tcp timestamps net ipv4 tcp timestamps 0 Enable TCP SYN Cookie Protection net ipv4 tcp syncookies 1 Enable ignoring broadcasts request net ipv4 icmp echo ignore broadcasts 1 Enable bad error message Protection net ipv4 icmp ignore bogus error responses 1 Log Spoofed Packets Source Routed Packets Redirect Packets net ipv4 conf all log martians 1 Set maximum amount of memory allocated to shm to 256MB kernel shmmax 268435456 Improve file system performance vm bdflush 100 1200 128 512 15 5000 500 1884 2 Improve virtual memory performance vm buffermem 90 10 60 Increases the size of the socket queue effectively q0 net ipv4 tcp max syn backlog 1024 Increase the maximum total TCP buffer space allocatable net ipv4 tcp mem 57344 57344 65536 Increase the maximum TCP write buffer space allocatable net ipv4 tcp wmem 32768 65536 524288 15 Increase the maximum TCP read buffer space allocatable net ipv4 tcp rmem 98304 196608 1572864 Increase the maximum and default receive socket buffer size net core rmem max 524280 net core rmem default 524280 Increase the maximum and default send socket buffer size net core wmem max 524280 net core wmem default 524280 Increase the tcp time wait buckets pool size net ipv4 tcp max tw buckets 1440000 Allowed local port range net ipv4 ip local port range 16384 65536 Increase the maximum memory used to reassemble IP fragments net ipv4 ipfrag high thresh 512000 net ipv4 ipfra
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 初中政治课程资源开发与法治教育融合研究论文
- 高中语文阅读:校园经典文学作品分析与人文素养提升论文
- 中国医用超声仪行业市场占有率及投资前景预测分析报告
- 艾炙养生馆管理制度
- 苗圃维护与管理制度
- 调直机行业相关投资计划提议
- 财务制度体系
- 艾伦心理咨询案例分析步骤
- 连锁超市安全培训教材
- 解析汇编化学-专题11化学实验基础(原卷版)
- 山东省威海市实验中学2025届七下英语期末达标检测试题含答案
- 2025年河北省中考麒麟卷地理(三)及答案
- 2025年北京市水务局所属事业单位招聘工作人员101人笔试高频重点提升(共500题)附带答案详解
- 【MOOC】新媒体文化十二讲-暨南大学 中国大学慕课MOOC答案
- 国家开放大学《Python语言基础》实验2:基本数据类型和表达式计算参考答案
- 福建省普通公路建设项目施工单位管理标准化指南(共119页)
- 《心电监护》ppt课件
- 土地整治项目管理PPT
- GB∕T 40754-2021 商场公共设施服务规范
- 会计工作证明模板
- 中国核电标准化组织方式及工作方案
评论
0/150
提交评论