Linux system security and application - system boot and logon control, weak password detection and port scanning (IX)

System boot and logon control

In the Internet environment, most servers are managed by way of remote login, and the local guide and terminal login process tends to be neglected, leaving a security risk. Especially when a lack of server room environment where strict, safe systems of control, how to prevent other users from unauthorized intervention became necessary attention.


(A) safety control switch

Adjust the BIOS boot settings

  • The first boot device set to the current system where the hard disk

  • Other devices is prohibited from booting the system (CD-ROM, U disk, network)

  • The security level is set to setup and set the administrator password

GRUB restrictions

  • Grub2-mkpasswd-pbkdf2 using the generated secret key

  • Modify /etc/grub.d/00_header file, add password records

  • Grub.cfg generate a new configuration file

1, restart the system at this page the press "e" to enter the grub menu, you can edit anything inside

Screenshot micro-channel _20190827140416.png

Screenshot micro-channel _20190827141552.png

2, in the middle Linux system backup grub configuration file and header files to avoid losing mistakes

[root @ localhost ~] # cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak backup 
[root @ localhost ~] # cp /etc/grub.d/00_header /etc/grub.d/ 00_header.bak

Screenshot micro-channel _20190827141739.png

3, generates a ciphertext using a secret key command to copy down

[root @ localhost ~] # grub2 -mkpasswd-pbkdf2 ciphertext 
password: 
the Reenter password:

Screenshot micro-channel _20190827142442.png

4, the configuration file header information, add the contents of the ciphertext FIG added to the configuration file

[Root @ localhost ~] # vim /etc/grub.d/00_header configuration header information

Screenshot micro-channel _20190827151455.png

Screenshot micro-channel _20190827151736.png

5, rebuild grub configuration file, restart, then re-enter the grub menu, you need to enter your password

[root@localhost ~]# grub2-mkconfig -o /boot/grubs/grub.cfg   重新构建grub配置文件

Screenshot micro-channel _20190827162830.png

Screenshot micro-channel _20190827164204.png

(二)终端登录安全控制

限制root只在安全终端登录

  • 安全终端配置文件:/etc/securetty

[root@localhost ~]# vim /etc/securetty 编辑安全终端配置文件

Screenshot micro-channel _20190827170233.png

禁止普通用户登录

  • 建立/etc/nologin文件

  • 删除nologin文件或重启后即恢复正常

[root@localhost ~]# touch /etc/nologin  禁止普通用户登录

[root@localhost ~]# rm -rf /etc/nologin   恢复正常



弱口令检测,端口扫描

John the Ripper和NMAP,前者是用来检测系统账号的强度,后者是用来执行端口扫描任务

(一)弱口令检测

John the Ripper简称JR

  • 一款密码分析工具,支持字典式的暴力破解

  • 通过对shadow文件的口令分析,可以检测密码强度

  • 官方网站:http://www.openwall.com/john/

安装JR工具

  • 安装方法:make clean 系统类型

  • 主程序文件为John

检测弱口令账号

  • 获得Linux/Unix服务器的shadow文件

  • 执行john程序,将shadow文件作为参数

密码文件的暴力破解

  • 准备好密码字典文件,默认为password.lst

  • 执行john程序,结合--wordlist=字典文件

1,利用宿主机的共享将John软件包挂载到Linux的/mnt中

[root@localhost ~]# smbclient -L //192.168.100.99/  远程共享
 
[root@localhost ~]# mount.cifs //192.168.100.99/John /mnt  挂载

Screenshot micro-channel _20190827173557.png

Screenshot micro-channel _20190827173641.png

2,将挂载到/mnt下的软件包解压到/opt下

Screenshot micro-channel _20190827174023.png

3,切换到/opt/john-1.8.0/src下我们看到文件是c语言文件,所以我们要对此进行编译

Screenshot micro-channel _20190827182436.png

4,安装gcc gcc-c++软件并对此进行编译。

[root@localhost src]# yum install gcc gcc-c++ -y  安装gcc软件

[root@localhost src]# make linux-x86-64   编译

Screenshot micro-channel _20190827182506.png

Screenshot micro-channel _20190827182700.png

5,编译之后我们可以发现John变成可执行的脚本文件,我们执行对/etc/passwd /etc/shadow文件进行解析

[root@localhost run]# ./john /etc/passwd /etc/shadow  执行解析脚本

Screenshot micro-channel _20190827183419.png

6,解析成功,这个解析是通过password.lst字典进行的

Screenshot micro-channel _20190827183806.png

Screenshot micro-channel _20190827183824.png

(二)网络端口扫描(远程探测)

NMAP

  • 一款强大的网络扫描,安全检测工具

  • 可从centos7.4光盘中安装nmap-6.40-7.el7.x86_64.rpm包

NMAP的扫描语法

  • nmap [扫描类型] [选项] <扫描目标...>

常用扫描类型

  • -sT:TCP 连接扫描:这是完整的 TCP 扫描方式,用来建立一个 TCP 连接,如果成 功则认为目标端口正在监听服务,否则认为目标端口并未开放。

  • -sU:UDP 扫描:探测目标主机提供哪些 UDP 服务,UDP 扫描的速度会比较慢。

  • -sP:ICMP 扫描:类似于 ping 检测,快速判断目标主机是否存活,不做其他扫描。

1,安装nmap软件

[root@localhost run]# yum install nmap -y  安装nmap软件

Screenshot micro-channel _20190827190436.png

2,检测本机的tcp端口(127.0.0.1)

[root@localhost run]# nmap -sT 127.0.0.1   检测本机对外的tcp端口

Screenshot micro-channel _20190827190436.png

3,安装httpd服务并开启,查看本机是否有80端口httpd服务

[root@localhost run]# yum install httpd  安装httpd服务 
[root@localhost run]# systemctl start httpd.service   开启服务
[root@localhost run]# nmap -sT 127.0.0.1   检测本机tcp端口

Screenshot micro-channel _20190827190436.png

4,查看网段的主机是否开启-网段(192.168.109.0/24)  另外开启同一网段的另一台主机(192.168.109.132)

微信截图_20190827190436.png

5,查看另一台主机(192.168.109.132)上的tcp端口

Connecting to 192.168.109.132:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Tue Aug 27 19:35:45 2019
[root@localhost ~]# systemctl stop firewalld.service  将192.168.109.132上的防火墙关闭
[root@localhost ~]# setenforce 0


[root@localhost run]# nmap -sT 192.168.109.132   用原来的主机检测192.168.109.132上的tcp端口

微信截图_20190827190436.png

微信截图_20190827194047.png


本节系统安全及应用已经全部讲解好了

谢谢阅读!!!



Guess you like

Origin blog.51cto.com/14080162/2433099