亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12345下一頁
最近訪問板塊 發(fā)新帖
查看: 10658 | 回復(fù): 47
打印 上一主題 下一主題

如何過濾secure日志的IP字段 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2009-07-13 09:29 |只看該作者 |倒序瀏覽
最近服務(wù)器secure日志里面可以看到大量的ssh掃描登陸,有什么好的方法過濾出里面的IP信息呢?如下:
要求結(jié)果為
61.152.95.172
222.73.173.143

Jul 13 08:13:09 localhost sshd[14678]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:09 localhost sshd[14679]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=222.73.173.143 user=root
Jul 13 08:13:11 localhost sshd[14691]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172 user=admin
Jul 13 08:13:11 localhost sshd[14692]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=222.73.173.143
Jul 13 08:13:14 localhost sshd[14707]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:14 localhost sshd[14711]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=222.73.173.143 user=root
Jul 13 08:13:17 localhost sshd[14722]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:17 localhost sshd[14724]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=222.73.173.143
Jul 13 08:13:20 localhost sshd[14739]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172 user=root
Jul 13 08:13:23 localhost sshd[14753]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172 user=root
Jul 13 08:13:26 localhost sshd[14767]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:29 localhost sshd[14781]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:32 localhost sshd[14795]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:35 localhost sshd[14809]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:38 localhost sshd[14823]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:41 localhost sshd[14837]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172 user=apache
Jul 13 08:13:44 localhost sshd[14851]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:47 localhost sshd[14865]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:49 localhost sshd[14876]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
Jul 13 08:13:53 localhost sshd[14895]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.152.95.172
J

[ 本帖最后由 jacson007 于 2009-7-14 21:20 編輯 ]

論壇徽章:
5
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亞洲杯之朝鮮
日期:2015-03-13 22:47:33IT運維版塊每日發(fā)帖之星
日期:2016-01-09 06:20:00IT運維版塊每周發(fā)帖之星
日期:2016-03-07 16:27:44
2 [報告]
發(fā)表于 2009-07-13 09:39 |只看該作者

回復(fù) #1 jacson007 的帖子

awk -F = '!a[$NF]++{print $NF}' urfile

[ 本帖最后由 blackold 于 2009-7-13 09:43 編輯 ]

論壇徽章:
0
3 [報告]
發(fā)表于 2009-07-13 09:50 |只看該作者
sed -n 's/\(.*rhost\)=\(.*\)/\2/p' secure | sort -u

論壇徽章:
0
4 [報告]
發(fā)表于 2009-07-13 09:55 |只看該作者
樓上的方法沒成功啊

論壇徽章:
0
5 [報告]
發(fā)表于 2009-07-13 10:00 |只看該作者
原帖由 gyp334a 于 2009-7-13 09:50 發(fā)表
sed -n 's/\(.*rhost\)=\(.*\)/\2/p' secure | sort -u


這個執(zhí)行得到的結(jié)果
125.141.231.168  user=sshd
125.141.231.168  user=sync
125.141.231.168  user=uucp
187.141.100.236
187.141.100.236  user=root
222.73.173.143
222.73.173.143  user=games
222.73.173.143  user=root
61.152.95.172
61.152.95.172  user=adm
61.152.95.172  user=apache
61.152.95.172  user=bin
61.152.95.172  user=daemon
61.152.95.172  user=ftp
61.152.95.172  user=games
。。。。。。。

如果能把后面的用戶字段去掉,然后再過濾掉重復(fù)就完美了。

論壇徽章:
0
6 [報告]
發(fā)表于 2009-07-13 10:02 |只看該作者
原帖由 blackold 于 2009-7-13 09:39 發(fā)表
awk -F = '!a[$NF]++{print $NF}' urfile


這個命令執(zhí)行的結(jié)果和日志差不多啊

論壇徽章:
5
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亞洲杯之朝鮮
日期:2015-03-13 22:47:33IT運維版塊每日發(fā)帖之星
日期:2016-01-09 06:20:00IT運維版塊每周發(fā)帖之星
日期:2016-03-07 16:27:44
7 [報告]
發(fā)表于 2009-07-13 10:03 |只看該作者
“user=games"數(shù)據(jù)又變化了?

論壇徽章:
0
8 [報告]
發(fā)表于 2009-07-13 10:05 |只看該作者
grep -P -o "(?<=rhost=)\d+.+"

論壇徽章:
0
9 [報告]
發(fā)表于 2009-07-13 10:06 |只看該作者
實際上應(yīng)該是日志文件不止這些數(shù)據(jù),所以匹配時容易出錯。

論壇徽章:
5
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亞洲杯之朝鮮
日期:2015-03-13 22:47:33IT運維版塊每日發(fā)帖之星
日期:2016-01-09 06:20:00IT運維版塊每周發(fā)帖之星
日期:2016-03-07 16:27:44
10 [報告]
發(fā)表于 2009-07-13 10:15 |只看該作者
猜一猜:
  1. sed -n 's/.*rhost=\([0-9.]\+\).*/\1/p' urfile|sort -u
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP