liuhuiIris


  • 首页

  • 归档

hexo + gitment

发表于 2018-12-04

首先万分感谢踩坑小分队们!!!

陆陆续续、忐忐忑忑在工位上搞了一天gitment,终于成功搞定,完结撒花🌺 🌺 🌺

(希望领导们不会看到哈,我也是有认真完成本职工作的,认真脸_)

这里只想放大佬们的链接了

1. gitment 登录失败问题

首先大家都发现gitment 登录失败的问题,由此参考以下文章,并手动跑了原作者的Server,并替换为自己服务器地址

gitment 登录失败问题

虽然楼主注意到了文章中nginx等一系列猛如虎的操作,但还是偷懒只用了IP,结果可想而知,人家只认https…

以前楼主搞过域名解析乱七八糟的东西,也是同样的问题,到期了,于是打算偷懒找个现成的

2. gitment评论模块接入hexo

非常感谢以下文章作者,讲解很是详细,还给了解决跨域问题的例子,就是请大家留心下next版本即可,楼主今天刚升级next,版本有点对不上

gitment评论模块接入hexo

还有其中参数不是很对应,注意对应关系就好,没有对错之分

1
2
3
4
5
6
7
8
9
10
githubID:为github的用户名
repo:为博客的仓库
ClientID:为上一步获取的client ID
ClientSecret:为博客的仓库client secret
lazy:是否默认把评论框收起来

github_user:
github_repo:
client_id:
client_secret:

就在楼主满心欢喜以为大功告成的时候,发现了Error:validation failed的问题 凸(艹皿艹 )

3. 添加Gitment评论系统踩过的坑

感谢另一位踩坑小分队成员,几乎踩遍了 label 长度所有的坑,手动比心心❤️

添加Gitment评论系统踩过的坑

4. 作死的多个github账户问题

楼主当时因为入职,很作死地申请了个新的github账户,结果把浏览器这厮搞晕了,怎么都登录不上,New incognito Window 或者 登出用同一个账户登录就可以了

然后完美搞定,心累到不想放图-_-!!! 将就看吧

Clamav病毒防护软件安装

发表于 2018-12-04

参考网站:http://www.clamav.net/documents/installing-clamav#rhel

1. On CentOS:

1
2
3
# yum install -y epel-release

# yum install -y clamav

On Community Enterprise Operating System (CentOS) the clamav package requires the Extra Packages for Enterprise Linux (EPEL) repository. On RedHat Enterprise Linux (RHEL) the EPEL release package has to be installed either manually or through RHN.

2. Run command to test

1
# clamscan /tmp

3. Questions

If there are some errors like this:

1
2
3
"LibClamAV Error: cli_loaddbdir(): No supported database files found in /var/lib/clamav

ERROR: Can't open file or directory"

You need to install some package to /var/lib/clamav

1
2
3
4
5
6
7
# cd /var/lib/clamav

# wget db.local.clamav.net/main.cvd

# wget db.local.clamav.net/daily.cvd

# wget db.local.clamav.net/bytecode.cvd

And then run the command again to test

1
# clamscan /tmp

4. Done

You can see the message, then done!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@znywhost clamav]# clamscan /tmp

/tmp/cloudwiz-user-stdout---supervisor-ks4Nv4.log: OK
/tmp/mysql-stdout---supervisor-9nkIv0.log: OK
/tmp/mysql-stderr---supervisor-DPkog8.log: OK
/tmp/opentsdb-stdout---supervisor-Pe5q7f.log.1: OK
/tmp/opentsdb-stdout---supervisor-Pe5q7f.log: OK
/tmp/umanager-stderr---supervisor-mgzixe.log: OK
/tmp/permission-stdout---supervisor-Y2Bhvy.log: OK
/tmp/webfront-stderr---supervisor-IN1WLq.log: OK
/tmp/kafka-stdout---supervisor-AdqhYG.log: OK
/tmp/umanager-stdout---supervisor-cxCgc_.log: OK
/tmp/zookeeper-stdout---supervisor-bZQngQ.log: OK

----------- SCAN SUMMARY -----------
Known viruses: 6727830
Engine version: 0.100.2
Scanned directories: 1
Scanned files: 11
Infected files: 0
Data scanned: 48.80 MB
Data read: 166.54 MB (ratio 0.29:1)
Time: 34.632 sec (0 m 34 s)

rsyslog收集日志

发表于 2018-11-30

以日志服务器为10.44.85.15为例,日志源机器为10.44.85.16

1. 在10.44.85.16上修改/etc/rsyslog.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
# $ModLoad imjournal # provides access to the systemd journal

File to store the position in the journal
$IMJournalStateFile imjournal.state


#### RULES ####

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages

# The authpriv file has restricted access.
authpriv.* /var/log/secure

# Log all the mail messages in one place.
mail.* -/var/log/maillog


# Log cron stuff
cron.* /var/log/cron

# Everybody gets emergency messages
*.emerg :omusrmsg:*

# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler

# Save boot messages also to boot.log
local7.* /var/log/boot.log

# 将自定义服务日志发送至日志服务器
$ModLoad imfile
$InputFilePollInterval 10

$InputFileName /var/log/webfront/webfront.log #要监控的日志文件路径
$InputFileTag webfront-info: # 定义文件标签 ,注意最后是冒号:
$InputFileStateFile state-webfront-info #定义状态文件
$InputRunFileMonitor #激活读取,可以设置多组日志读取,每组结束时设置本参数

# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList # run asynchronously
#$ActionResumeRetryCount -1 # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
*.* @@10.44.85.15:514
# ### end of the forwarding rule ###

一般默认配置即为发送系统日志,可以不做修改,注意最后
. @@remote-host:514 修改为目标日志服务器ip

2. 重启rsyslog

方法1:

1
2
3
/etc/init.d/rsyslog restart #修改配置文件后一定要重启rsyslog服务

/etc/init.d/rsyslog status #可查看服务状态

方法2:

1
2
3
service rsyslog restart #修改配置文件后一定要重启rsyslog服务

service rsyslog status #查看服务状态

3. 在10.44.85.15上修改/etc/rsyslog.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ModLoad imuxsock
$ModLoad imjournal
$ModLoad immark
$ModLoad imudp
$UDPServerRun 514
$ModLoad imtcp
$InputTCPServerRun 514
$WorkDirectory /var/lib/rsyslog
$AllowedSender tcp, 10.44.85.0/24
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$template Remote,"/var/log/%fromhost-ip%/%fromhost-ip%_%$YEAR%-%$MONTH%-%$DAY%.log"
:fromhost-ip, !isequal, "127.0.0.1" ?Remote
$IncludeConfig /etc/rsyslog.d/*.conf
$OmitLocalLogging on
$IMJournalStateFile imjournal.state

*.info;mail.none;authpriv.none;cron.none /var/log/rsyslog
authpriv.* /var/log/secure
mail.* -/var/log/maillog
cron.* /var/log/corn
*.emerg :omusrmsg:*
uucp,news.crit /var/log/spooler
local7.* /var/log/boot.log

4. 重启rsyslog

方法1:

1
2
3
/etc/init.d/rsyslog restart #修改配置文件后一定要重启rsyslog服务

/etc/init.d/rsyslog status #可查看服务状态

方法2:

1
2
3
service rsyslog restart #修改配置文件后一定要重启rsyslog服务

service rsyslog status #查看服务状态

5. 检验日志收集

在日志服务器10.44.85.15上查看通过rsyslog收集的10.44.85.16的日志

日志路径:

1
cd /var/log/10.44.85.16/

mysql数据库密码安全策略

发表于 2018-11-30

1.安全审计要求

由于安全审计要求,建议设置数据库密码复杂策略,启用密码复杂度验证函数,至少满足锁定时间大于3分钟,最长使用天数小于180天,可重用次数小于5次);更改弱口令用户的密码,长度至少八位,由字母、数字或特殊字符混合组成,禁止用户名和口令相同

2.mysql5.6 参考文档

连接限制:

https://dev.mysql.com/doc/refman/5.6/en/connection-control.html

密码复杂度设置:

https://dev.mysql.com/doc/refman/5.6/en/validate-password.html

my.cnf文件说明:

https://dev.mysql.com/doc/refman/5.6/en/option-files.html

可通过以下命令查看部分参数内容

1
2
3
4
ps aux | grep mysql

liuhui 15695 1.2 0.0 2443044 820 s000 S+ 11:47上午 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysql
_mysql 96213 0.0 0.0 2831668 1364 ?? Ss 三02下午 0:10.16 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid

案例如下:

注意可能有些配置在用户机器上不生效,导致mysql无法正常启动

此时注释掉相关报错参数,重启mysql

改为通过官网中命令形式进行设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[liuhui@cloudwiz] $ vi /etc/my.cnf

[base]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
log_error = /usr/local/mysql/data/mysqld.local.err
pid-file = /usr/local/mysql/data/mysqld.local.pid
user = mysql

sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[client]
port = 3306
socket = /tmp/mysql.sock

[mysqld]
# localhost work, but costumer's host dosen't work, and I don't know why
default_password_lifetime = 180

# load plugin of validate_password.so
plugin-load=validate_password.so
validate_password_length = 8
validate_password_policy = 1
validate-password=FORCE_PLUS_PERMANENT

# load plugin of connetion_control.so
plugin-load-add = connection_control.so
# force enable plugin
# connection-control = FORCE_PLUS_PREMANENT
# connection-control-failed-login-attempts = FORCE_PLUS_PREMANENT
# connection_control_failed_connections_threshold = 3
# connection_control_max_connection_delay = 2147483647
# connection_control_min_connection_delay = 10000

3.mysql 5.6 与 5.7的区别

mysql5.6的不会对之前创建的用户造成影响,不改密码也OK

mysql5.7的会检测之前的用户,如果密码强度不够,会强制要求修改密码

nmap命令--基础用法

发表于 2018-11-19

文章来源: nmap命令—–基础用法

系统漏洞扫描之王-nmap

NMap,也就是Network Mapper,是Linux下的网络扫描和嗅探工具包。

其基本功能有三个:

(1)是扫描主机端口,嗅探所提供的网络服务

(2)是探测一组主机是否在线

(3)还可以推断主机所用的操作系统,到达主机经过的路由,系统已开放端口的软件版本

nmap端口状态解析
open : 应用程序在该端口接收 TCP 连接或者 UDP 报文。
closed :关闭的端口对于nmap也是可访问的, 它接收nmap探测报文并作出响应。但没有应用程序在其上监听。
filtered :由于包过滤阻止探测报文到达端口,nmap无法确定该端口是否开放。过滤可能来自专业的防火墙设备,路由规则 或者主机上的软件防火墙。
unfiltered :未被过滤状态意味着端口可访问,但是nmap无法确定它是开放还是关闭。 只有用于映射防火墙规则集的 ACK 扫描才会把端口分类到这个状态。
open | filtered :无法确定端口是开放还是被过滤, 开放的端口不响应就是一个例子。没有响应也可能意味着报文过滤器丢弃了探测报文或者它引发的任何反应。UDP,IP协议,FIN, Null 等扫描会引起。
closed|filtered:(关闭或者被过滤的):无法确定端口是关闭的还是被过滤的

nmap有windows和linux

Nmap是一款网络扫描和主机检测的非常有用的工具。Nmap是不局限于仅仅收集信息和枚举,同时可以用来作为一个漏洞探测器或安全扫描器。它可以适用于winodws,linux,mac等操作系统
从下面官网可以下载exe程序包和zip包
https://nmap.org/download.html#windows

nmap常用参数

nmap扫描速度要比nc快

面是一些基本的命令和它们的用法的例子:扫描单一的一个主机,命令如下:

前期准备

准备两台机器

主机A:ip地址 10.0.1.161

主机B:ip地址 10.0.1.162

B机器安装nmap的包(这个工具比较强大,习惯上每台机器都安装)

1
yum install nmap -y

端口扫描部分

前期准备

B机器使用nmap去扫描A机器,扫描之前,A机器先查看自己上面有哪些端口在被占用

A机器上查看本地ipv4的监听端口

netstat参数解释:
-l (listen) 仅列出 Listen (监听) 的服务
-t (tcp) 仅显示tcp相关内容
-n (numeric) 直接显示ip地址以及端口,不解析为服务名或者主机名
-p (pid) 显示出socket所属的进程PID 以及进程名字
–inet 显示ipv4相关协议的监听

查看IPV4端口上的tcp的监听

1
2
3
4
5
6
7
8
9
10
[root@A ~] netstat -lntp --inet

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2157/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1930/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2365/master
tcp 0 0 0.0.0.0:13306 0.0.0.0:* LISTEN 21699/mysqld
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2640/rsync
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 21505/rpcbind

过滤掉监控在127.0.0.1的端口

1
2
3
4
5
6
7
[root@A ~] netstat   -lntp    --inet | grep -v 127.0.0.1
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2157/sshd
tcp 0 0 0.0.0.0:13306 0.0.0.0:* LISTEN 21699/mysqld
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2640/rsync
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 21505/rpcbind

扫描tcp端口

B机器上使用nmap扫描A机器所有端口(-p后面也可以跟空格)

下面表示扫描A机器的1到65535所有在监听的tcp端口。

1
nmap 10.0.1.161  -p1-65535

指定端口范围使用-p参数,如果不指定要扫描的端口,Nmap默认扫描从1到1024再加上nmap-services列出的端口
nmap-services是一个包含大约2200个著名的服务的数据库,Nmap通过查询该数据库可以报告那些端口可能对应于什么服务器,但不一定正确。
所以正确扫描一个机器开放端口的方法是上面命令。-p1-65535
注意,nmap有自己的库,存放一些已知的服务和对应端口号,假如有的服务不在nmap-services,可能nmap就不会去扫描,这就是明明一些端口已经是处于监听状态,nmap默认没扫描出来的原因,需要加入-p参数让其扫描所有端口。
虽然直接使用nmap 10.0.1.161也可以扫描出开放的端口,但是使用-p1-65535 能显示出最多的端口
区别在于不加-p 时,显示的都是已知协议的端口,对于未知协议的端口没显示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@B ~] nmap  10.0.1.161  -p1-65535

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:11 CST
Nmap scan report for 10.0.1.161
Host is up (0.00017s latency).
Not shown: 65531 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
13306/tcp open unknown
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 2.49 seconds

如果不加-p1-65535,对于未知服务的端口(A机器的13306端口)就没法扫描到

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@B ~] nmap  10.0.1.161

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:12 CST
Nmap scan report for 10.0.1.161
Host is up (0.000089s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.43 seconds

扫描一个IP的多个端口

连续的端口可以使用横线连起来,端口之间可以使用逗号隔开

A机器上再启动两个tcp的监听,分别占用7777和8888端口,用于测试,加入&符号可以放入后台

1
2
3
4
[root@A ~] nc -l 7777&
[1] 21779
[root@A ~] nc -l 8888&
[2] 21780
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@B ~] nmap  10.0.1.161   -p20-200,7777,8888

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:32 CST
Nmap scan report for 10.0.1.161
Host is up (0.00038s latency).
Not shown: 179 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
7777/tcp open cbt
8888/tcp open sun-answerbook
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.17 seconds

扫描udp端口

先查看哪些ipv4的监听,使用grep -v排除回环接口上的监听

1
2
3
4
5
6
7
8
[root@A ~] netstat -lnup --inet |grep -v 127.0.0.1
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:111 0.0.0.0:* 21505/rpcbind
udp 0 0 0.0.0.0:631 0.0.0.0:* 1930/cupsd
udp 0 0 10.0.1.161:123 0.0.0.0:* 2261/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2261/ntpd
udp 0 0 0.0.0.0:904 0.0.0.0:* 21505/rpcbind

-sU:表示udp scan , udp端口扫描
-Pn:不对目标进行ping探测(不判断主机是否在线)(直接扫描端口)
对于udp端口扫描比较慢,扫描完6万多个端口需要20分钟左右

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@B ~] nmap  -sU  10.0.1.161  -Pn

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:16 CST
Stats: 0:12:54 elapsed; 0 hosts completed (1 up), 1 undergoing UDP Scan
UDP Scan Timing: About 75.19% done; ETC: 10:33 (0:04:16 remaining)
Stats: 0:12:55 elapsed; 0 hosts completed (1 up), 1 undergoing UDP Scan
UDP Scan Timing: About 75.29% done; ETC: 10:33 (0:04:15 remaining)
Nmap scan report for 10.0.1.161
Host is up (0.0011s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
111/udp open rpcbind
123/udp open ntp
631/udp open|filtered ipp
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 1081.27 seconds

扫描多个IP用法

中间用空格分开

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@B ~] nmap 10.0.1.161  10.0.1.162

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:18 CST
Nmap scan report for 10.0.1.161
Host is up (0.000060s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap scan report for 10.0.1.162
Host is up (0.0000070s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind

Nmap done: 2 IP addresses (2 hosts up) scanned in 0.26 seconds

也可以采用下面方式逗号隔开

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@B ~] nmap 10.0.1.161,162

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:19 CST
Nmap scan report for 10.0.1.161
Host is up (0.00025s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap scan report for 10.0.1.162
Host is up (0.0000080s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind

Nmap done: 2 IP addresses (2 hosts up) scanned in 0.81 seconds

扫描连续的ip地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@B ~] nmap 10.0.1.161-162

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:20 CST
Nmap scan report for 10.0.1.161
Host is up (0.00011s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap scan report for 10.0.1.162
Host is up (0.0000030s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind

Nmap done: 2 IP addresses (2 hosts up) scanned in 0.25 seconds

扫描一个子网网段所有IP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@B ~] nmap  10.0.3.0/24

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:21 CST
Nmap scan report for 10.0.3.1
Host is up (0.020s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
23/tcp open telnet
6666/tcp open irc
8888/tcp open sun-answerbook

Nmap scan report for 10.0.3.2
Host is up (0.012s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
21/tcp filtered ftp
22/tcp filtered ssh
23/tcp open telnet

Nmap scan report for 10.0.3.3
Host is up (0.018s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
21/tcp filtered ftp
22/tcp filtered ssh
23/tcp open telnet

Nmap done: 256 IP addresses (3 hosts up) scanned in 14.91 seconds

扫描文件里的IP

如果你有一个ip地址列表,将这个保存为一个txt文件,和namp在同一目录下,扫描这个txt内的所有主机,用法如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@B ~] cat ip.txt
10.0.1.161
10.0.1.162
[root@B ~] nmap -iL ip.txt

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:23 CST
Nmap scan report for 10.0.1.161
Host is up (0.00030s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap scan report for 10.0.1.162
Host is up (0.0000070s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind

Nmap done: 2 IP addresses (2 hosts up) scanned in 0.68 seconds

扫描地址段是排除某个IP地址

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@B ~] nmap 10.0.1.161-162  --exclude 10.0.1.162

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:24 CST
Nmap scan report for 10.0.1.161
Host is up (0.0022s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.53 seconds

扫描时排除多个IP地址

排除连续的,可以使用横线连接起来

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@B ~] nmap 10.0.1.161-163   --exclude 10.0.1.162-163

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:25 CST
Nmap scan report for 10.0.1.161
Host is up (0.00023s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
873/tcp open rsync
MAC Address: 00:0C:29:56:DE:46 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.56 seconds

  
排除分散的,使用逗号隔开

1
2
3
4
5
6
7
8
9
10
11
[root@B ~] nmap 10.0.1.161-163 --exclude 10.0.1.161,10.0.1.163

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:27 CST
Nmap scan report for 10.0.1.162
Host is up (0.0000030s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind

Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds

扫描多个地址时排除文件里的IP地址(可以用来排除不连续的IP地址)
把10.0.1.161和10.0.1.163添加到一个文件里,文件名可以随意取
下面扫描10.0.1.161到10.0.1.163 这3个IP地址,排除10.0.1.161和10.0.1.163这两个IP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@B ~] cat ex.txt
10.0.1.161
10.0.1.163
[root@B ~] nmap 10.0.1.161-163 --excludefile ex.txt

Starting Nmap 5.51 ( http://nmap.org ) at 2016-12-29 10:29 CST
Nmap scan report for 10.0.1.162
Host is up (0.0000050s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind

Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds

设置Linux用户连续N次输入错误密码进行登陆时,自动锁定X秒

发表于 2018-11-19

文章来源:设置Linux用户连续N次输入错误密码进行登陆时,自动锁定X秒

一、在字符终端下,实现某一用户连续错误登陆N次后,就锁定该用户X分钟(pam_tally2)

1
2
3
4
5
6
7
8
9
10
11
$ vim /etc/pam.d/login
# 在#%PAM-1.0 下新起一行,加入
auth required pam_tally2.so deny=3 unlock_time=5 even_deny_root root_unlock_time=10

# 如果不限制root用户,则可以写成
auth required pam_tally2.so deny=3 unlock_time=5

even_deny_root #也限制root用户;
deny # 设置普通用户和root用户连续错误登陆的最大次数,超过最大次数,则锁定该用户;
unlock_time #设定普通用户锁定后,多少时间后解锁,单位是秒;
root_unlock_time #设定root用户锁定后,多少时间后解锁,单位是秒;

备注:

1、此处使用的是 pam_tally2 模块,如果不支持 pam_tally2 模块可以使用 pam_tally 模块。另外,不同的pam版本,设置可能有所不同,具体使用方法,可以参照相关模块的使用规则。

2、也可以直接在 system-auth 文件中直接添加这些命令,修改完成后,凡是调用 system-auth 文件的服务,都会生效。因为有自动解锁时间,所以,不用担心全部限制后,会出现永远无法登陆的”尴尬”情况。

3、可以使用 pam_tally2 -r -u username 命令,手动清除某用户记录次数。

二、设置Linux用户连续N次登陆失败时,自动锁定X分钟(pam_tally)

1、如果想在所有登陆方式上,限制所有用户,可以在 /etc/pam.d/system-auth 中增加2行

1
2
auth  required  pam_tally.so  onerr=fail  no_magic_root
account required pam_tally.so deny=3 no_magic_root even_deny_root_account per_user reset

deny 设置普通用户和root用户连续错误登陆的最大次数,超过最大次数,则锁定该用户;
no_magic_root 连root用户也在限制范围,不给root特殊权限。
详细参数的含义,参见 /usr/share/doc/pam-xxxx/txts/README.pam_tally
如果不想限制root用户,可以将 even_deny_root_account 取消掉。

2、针对不同服务来限制不同登陆方式

1
2
3
4
5
6
#只在本地文本终端上做限制,可以编辑如下文件,添加的内容和上方一样。
vim /etc/pam.d/login

#只在远程telnet、ssh登陆上做限制,可以编辑如下文件,添加的内容和上方也一样。
vim /etc/pam.d/remote
vim /etc/pam.d/sshd

3、手动解除锁定:

1
2
3
4
5
6
7
8
9
10
11
#查看某一用户错误登陆次数:
pam_tally –user username
#例如,查看work用户的错误登陆次数:
pam_tally –user work

#清空某一用户错误登陆次数:
pam_tally –user username –reset
#例如,清空 work 用户的错误登陆次数,
pam_tally –user work –reset

faillog -r 命令亦可。

4、pam_tally没有自动解锁功能

因为pam_tally没有自动解锁的功能,所以,在设置限制时,要多加注意,万一全做了限制,而 root用户又被锁定了,就只能够进单用户模式解锁了,当然,也可以添加crontab任务,达到定时自动解锁的功能,但需要注意的是,如果在/etc /pam.d/system-auth 文件中添加了pam_tally的话,当root被锁定后,crontab任务会失效,所以,最好不要在system-auth 文件中添加pam_tally。

centos6添加node系统server

发表于 2017-12-14

文章来源: CentOS5.6下离线部署NodeJS环境和工程代码,并添加forever的开机自启动服务

1. centos6 启动/关闭服务

1
service server start/stop/restart

2. 添加node server

这段脚本含义有心情再补充了。。。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# sdu_server 是为自定义服务起的名字,可任意
vim /etc/init.d/sdu_server

#!/bin/bash
# chkconfig:345 99 01 这一串不知道干嘛
# description: 图书查询服务
# 启动服务的脚本路径 /opt/project/sdulibrary/library_db
# 使用node forever 管理node server
DIR='/opt/project/sdulibrary/library_db'

function start_app {
forever start -a "$DIR/getlist.js"
}
function stop_app {
forever stop "$DIR/getlist.js"
}

case $1 in
start)
start_app ;;
stop)
stop_app ;;
restart)
stop_app
start_app
;;
*)
echo "usage: clearstonecc {start|stop}" ;;
esac
exit 0

3. 启动自定义服务

1
service sdu_server start

centos7-nginx-php

发表于 2017-11-30

1.系统环境

阿里云服务器 centos7

nginx version: nginx/1.12.2

2.一键php

安装并验证

1
2
3
yum install -y php

php -v

显示以下内容则安装成功

1
2
3
PHP 5.4.16 (cli) (built: Nov 15 2017 16:33:54)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

启动php–很重要,被这个命令卡了一晚上

1
systemctl start php-fpm

验证是否成功

1
2
3
4
5
6
7
8
9
[root@liuhuiiris php_wx]# ps -ef | grep php-fpm

root 31847 1 0 23:02 ? 00:00:00 php-fpm: master process (/etc/php-fpm.conf)
apache 31849 31847 0 23:02 ? 00:00:00 php-fpm: pool www
apache 31850 31847 0 23:02 ? 00:00:00 php-fpm: pool www
apache 31851 31847 0 23:02 ? 00:00:00 php-fpm: pool www
apache 31852 31847 0 23:02 ? 00:00:00 php-fpm: pool www
apache 31853 31847 0 23:02 ? 00:00:00 php-fpm: pool www
root 31855 31234 0 23:02 pts/1 00:00:00 grep --color=auto php-fpm

3. 配置nginx

配置好相应路径即可,127.0.0.1:9000不要擅自修改

1
2
3
4
5
6
7
8
9
10
11
12
location / {
root /opt/workspace/php_wx;
index index.html index.htm index.php;
}

location ~ \.php$ {
#root /opt/workspace/php_wx;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/workspace/php_wx$fastcgi_script_name;
include fastcgi_params;
}

配置好nginx后reload

1
nginx -s reload

测试php

1
2
3
vim /opt/workspace/php_wx/info.php

<?php phpinfo(); ?>

在浏览器中打开 IP/info.php,如下图所示
php

大功告成!

linux 软链接|硬链接

发表于 2017-11-30

参考文章: Linux 系统结构详解

文章来源: 百度百科

1.软链接

软链接又叫符号链接,这个文件包含了另一个文件的路径名。可以是任意文件或目录,可以链接不同文件系统的文件。
链接文件甚至可以链接不存在的文件,这就产生一般称之为”断链”的现象,链接文件甚至可以循环链接自己。类似于编程语言中的递归。
软链接文件只是其源文件的一个标记,当删除了源文件后,链接文件不能独立存在,虽然仍保留文件名,但却不能查看软链接文件的内容了。

2.软链接使用方法

生成软链接

1
ln -s source_file softlink_file

在对符号文件进行读或写操作的时候,系统会自动把该操作转换为对源文件的操作,但删除链接文件时,系统仅仅删除链接文件,而不删除源文件本身。

删除硬/软链接用

1
rm softlink_file

或

1
unlink softlink_file

3.硬链接

硬链接(hard link, 也称链接)就是一个文件的一个或多个文件名。再说白点,所谓链接无非是把文件名和计算机文件系统使用的节点号链接起来。因此我们可以用多个文件名与同一个文件进行链接,这些文件名可以在同一目录或不同目录。

硬链接只能引用同一文件系统中的文件。它引用的是文件在文件系统中的物理索引(也称为 inode)。当您移动或删除原始文件时,硬链接不会被破坏,因为它所引用的是文件的物理数据而不是文件在文件结构中的位置。硬链接的文件不需要用户有访问原始文件的权限,也不会显示原始文件的位置,这样有助于文件的安全。如果您删除的文件有相应的硬链接,那么这个文件依然会保留,直到所有对它的引用都被删除。

4.硬链接使用方法

生成硬链接

1
ln source_file softlink_file

注意事项:

1、修改源文件或者目标文件, 对应另外一个文件也会发生相应修改.

2、删除源文件或者目标文件, 对另外一个文件没有影响.

3、硬链接文件不占用存储空间.

4、不能对目录文件进行创建硬链接操作.

5、硬链接文件不能跨文件系统.

Hello World

发表于 2017-11-29

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

123
Hui Liu

Hui Liu

22 日志
17 标签
GitHub E-Mail Twitter
© 2018 Hui Liu
由 Hexo 强力驱动
|
主题 — NexT.Muse v5.1.4