Releasing mail from the quarantine - queue files For the purposes of this, I’m assuming you have set up a single (safe!) postfix instance, with messages going to the HOLD queue, before being processed by MailScanner and sent to the INCOMING queue. You also need to be saving whole messages as queue files. In MailScanner.conf ensure that you have # When you quarantine an entire message, do you want to store it as
# raw mail queue files (so you can easily send them onto users) or
# as human-readable files (header then body in 1 file)?
Quarantine Whole Messages As Queue Files = yes
Quarantined emails are by default kept in /var/spool/MailScanner/quarantine and sorted into subdirectories by date. With any luck it will be dead easy to find, as MailScanner will have sent a message including text along the lines of either:
A: If it’s a quarantined virus, or other dangerous content. “Note to Help Desk: Look on the <Your text> in /var/spool/MailScanner/quarantine/20050309 (message
6BC5E368497.3C3A6).”
MailScanner keeps such quarantined emails in their own directories, thus the directory containing the quarantined message will be (in this example): /var/spool/MailScanner/quarantine/20050309/6BC5E368497.3C3A6. In this directory, you should see the original queue file, named as a 10 digit hex number matching the name of the directory. There should also be copies of any attachments that may have been picked up by the virus scanning engine or file filtering.
B: If it’s a quarantined spam "Your system administrators will need the following information:
Server name: <Your Server>
Message id: 46EE0E18151.CE630
Date code: 20080509"
MailScanner keeps all spam on a given day in the same directory, thus the directory containing the quarantined message will be (in this example): /var/spool/MailScanner/quarantine/20080509/spam.
If you want to check the original message use: # postcat <filename>
Releasing an email from quarantine is a simple matter of replacing the queue file back into the Postfix queue, so that it gets sent. The permissions on the file are wrong, however and must be changed. # chmod 700 <filename>
The file must now be moved into /var/spool/postfix/incoming. There may be 16 directories in there (Collectively referred to as ‘hashed queue files’) each corresponding to a hexadecimal digit, depending which version of Postfix you are running. First check if you have hashed queue files by: # ls /var/spool/postfix/incoming
If no directories are listed then follow the instructions below but do not add the trailing letter/ number.
The file must be placed in the directory which corresponds to the first digit of the filename. So in the example above, it must go into /var/spool/postfix/incoming/6. We must also be sure to preserve the ownership and permissions of the file when moving it, so we use “cp -p”. If the message is a spam, we must also remove the trailing 6 characters.
Thus for the example above: # cp –p 6BC5E368497 /var/spool/postfix/incoming/6
or for the example quarantined spam # cp –p 46EE0E18151.CE630 /var/spool/postfix/incoming/4/46EE0E18151
The email will disappear from the queue and be delivered.
Thanks to Joshua Hirsh for the details and Stef Morrell for writing the document
Releasing mail from the quarantine - with a bash script
Maybe it’s too circuitous for you to do all the steps in the section above to release a mail. For this I wrote a tiny script to release very easily. To use this script you should set the MailScanner environment identically to the article above.
To use this script copy it to a file and make it executable.
The Syntax: release.sh <Message-ID> (e.g. release.sh 5B604228086.932F0) #!/bin/sh
if [ -z "$1" ]; then
echo "Syntax: release.sh <Message-ID> i.e. 5B604228086.932F0 (case sensitive)"
exit
fi
#change in the quarantine folder
folder=`find /var/spool/MailScanner/quarantine/ -name $1`
cd $folder
#set the mailfile executable
mailname=`echo $1 | cut -d . -f 1`
chmod u+x $mailname
#lets get the first character
char=`echo $1 | cut -b 1-1`
#copy the mail
cp -a $mailname /var/spool/postfix/incoming/$char/
echo Mail $mailname released
Releasing mail from the quarantine - message files
If you don’t quarantine the complete queue file, but instead have the rfc822 message file, releasing messages are actually a bit simpler (for postfix) than the above, since you can use the postfix sendmail convenience program.
In MailScanner.conf you have Quarantine Whole Messages As Queue Files = no
and in the quarantine directory you have a file called message (this is the complete human-readible message, but without the envelope info). Just do cd /path/to/quarantine/dir
sendmail -t -i < message
to send the message to the recipient(s) as found in the message file, or cd /path/to/quarantine/dir
sendmail -i alternate_recipient@example.net < message
to send the message to an alternate recipient (of course you can combine them). The -i option is to avoid terminating the message prematurely on a spurious single “.” on a line in the message file.
If you use MailWatch, this can also release the message iff you don’t quarantine the whole message file as the queue file, although this uses a different method to release messages from the GUI.
Releasing mail from the quarantine - queue files postfix (again)
In a larger environment with many hosts and thousands of quarantined emails per day, we’ve found it impractical to reply to each email released or deleted from a queue, and simply process it without fanfare. The code below is modified from the release.sh above to accomodate moving the released mail back into postfix using the original mail ID. In addition, our postfix install required us to rename the queue file to its shortname, that is, the 10 or 11 character filename before postfix would accept the email into the queue.
The Syntax: release.sh <Message-ID> (e.g. release.sh 5B604228086.932F0) #!/bin/sh
if [ -z "$1" ]; then
echo "Syntax: release.sh <Message-ID> i.e. 5B604228086.932F0 (case sensitive)"
exit
fi
#change in the quarantine folder
folder=`find /var/spool/MailScanner/quarantine/ -name $1 | sed -e "s/$1//g"`
cd $folder
#set the mailfile executable
mailname=`echo $1 | cut -d . -f1`
chmod u+x $1
#lets get the first character
char=`echo $1 | cut -b 1-1`
#copy the mail
cp -a $1 /var/spool/postfix/incoming/$char/$mailname
The following is for recent postfixes (2.3, 2.4) which seem to have a flat incoming directory: #!/bin/sh
# this is the final destination for the mail to be released:
# postfix's incoming queue
POSTFIX_DEST=/var/spool/postfix/incoming
# check for valid parameters
if [ -z "$1" ]; then
echo "Syntax: release.sh <Message-ID>"
echo "Example: release.sh 678362AC.9CFE7"
exit
fi
# find the specific mail in the quarantine folders
folder=`find /var/spool/MailScanner/quarantine/ -name $1`
mailname=`echo $1 | cut -d . -f1`
# copy the mail
if [ -e $POSTFIX_DEST/$mailname ] ; then
echo "ERROR: $mailname already in $POSTFIX_DEST! EXITING"
echo "This should not happen"
exit 255
fi
cp -avi "$folder/$mailname" "$POSTFIX_DEST/$mailname"
# make it 0700 so that the mail is deemed ready
chmod 0700 $POSTFIX_DEST/$mailname
Releasing mail from the quarantine - the one liner
sudo install -m 0700 -o postfix <source message> /var/spool/postfix/incoming
Releasing mail from the quarantine - alias with intelligenceintegrate() {
# integration: antonym of quarantine
# Pass the message ID as obtained from user's email as $1
DEST=$(postconf queue_directory | cut -d= -f2)/incoming
SOURCE=$(find /var/spool/MailScanner/quarantine -name "$1")
install --verbose --mode=0700 --owner=postfix $SOURCE $DEST
}
Updated bash script
Line 9 on initial bash script returned filename with full path and not folder, as expected. Instructions at the top also used the cp -p option, and not -a. Instead of cd’ing to quarantine folder, this will do the copy and preserve permissions. #!/bin/sh
if [ -z "$1" ]; then
echo "Syntax: release.sh <Message-ID> i.e. 5B604228086.932F0 (case sensitive)"
exit
fi
#find the quarantined file and set permissions
quarantined_file=`find /var/spool/MailScanner/quarantine/ -name $1`
chmod u+x $quarantined_file
#truncate the filename
mailname=`echo $1 | cut -d . -f 1`
#lets get the first character
char=`echo $1 | cut -b 1-1`
#copy the mail, destination is the truncated filename
cp -p $quarantined_file /var/spool/postfix/incoming/$char/$mailname
echo Mail $mailname released

NoMoney NoHoney 發表在 痞客邦 留言(1) 人氣()

印度的1919乘法(補充說明) 想到之前台灣不是叫小學生連99乘法表都不要背了嗎...? 當台灣媽媽因為小朋友會背99乘法高興的同時... 印度小孩已經在被1919乘法了! 難怪近幾年印度進步得那麼快!

印度的九九乘法表是從1背到19(→19×19乘法?)

不過您知道印度人是怎麼記11到19的數字嗎?

我是看了下面這本書之後才恍然大悟的...

「印度式計算訓練」

2007年6月10日第一版第6刷發行株式會社晉遊社發售...

介紹了加減乘除的各種快速計算方法...

不過在這裡我只介紹印度的九九乘法...

因為實在太神奇了!!

下面的數字跟說明都是引用該書P.44的例子...

請試著用心算算出下面的答案:

13×12=?
(被乘數)×(乘數)=?

印度人是這樣算的...

****************************************************************************

第一步:
先把被乘數(13)跟乘數的個位數(2)加起來
13+2=15

第二步:
然後把第一步的答案乘以10(→也就是說後面加個0)

15×10=150

第三步:
再把被乘數的個位數(3)乘以乘數的個位數(2)
2×3=6

(13+2)×10+6=156

****************************************************************************

就這樣,用心算就可以很快地算出11×11到19×19了喔!

這真是太神奇了!

我們試著演算一下...

14×13:
(1)14+3=17
(2)17×10=170
(3)4×3=12
(4)170+12=182

16×17:
(1)16+7=23
(2)23×10=230
(3)6×7=42
(4)230+42=272

真的是耶,好簡單喔!

怎不早點讓我知道呢?!

NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

DELPHI 7 使用ADO元件寫入資料庫強制四捨五入小數到第四位問題 parameters.parambyname('tmpprice').datatype:=ftFloat;   <==寫入資料前先將欄位設定成 Float 型態即可解決此問題。 參考:http://jzinfo.javaeye.com/blog/432853
  • var   
  •     adoquery1:Tadoquery;   
  • begin   
  •     adoquery1:=Tadoquery.create(nil);   
  •     try   
  •        if not DM.adonconnection1.connected then   
  •            DM.adoconnection1.connected:=true;   
  •        adoquery1.connection:=DM.adoconnection1;   
  •        adoquery1.enableBCD:=False;       //禁用bcd类型   
  •        with adoquery1 do   
  •        begin   
  •            close;   
  •            sql.clear;   
  •            sql.add('insert into materialInfo values(:tmppno,:tmpvendor,:tmpdesc,:tmpprice)');   
  •            parameters.parambyname('tmppno').value:=trim(edit1.text);   
  •            parameters.parambyname('tmpvendor').value:=trim(edit2.text);   
  •            parameters.parambyname('tmpdesc').value:=trim(edit3.text);   
  •            parameters.parambyname('tmpprice').datatype:=ftFloat;       //设置下数据类型   
  •            parameters.parambyname('tmpprice').value:=trim(edit4.text);   
  •            execsql;   
  •        end;   
  •     finally   
  •         adoquery1.free;   
  •     end;   
  • end; 
  • NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    參考:http://aesoptw.blogspot.com/2010/09/outlook-express.html 文章中有提到
    此帳號的 UUID
    uuid每台電腦不同
    以前都要逐一幫user建這個檔 所附的指令碼會自動抓到這個值 請把以下指令碼複製存成bat或cmd檔 ----------
    CLS
    @ECHO OFF
    FOR /F "skip=10 tokens=3 delims=\" %%a IN ('reg query HKCU\Identities') DO (
    REG ADD "HKCU\Identities\%%a\Software\Microsoft\Outlook Express\5.0"
    /v "Compact Check Count" /t REG_DWORD /d 0 /f
    )
    --------- 然後加入GPO中使用電腦設定加入開機SCRIPT即可。

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    參考文章:http://www.benjr.tw/?q=node/634 ESX下有很多VM機器,但是實體連USB裝置的在同一時間內只有一台可以連,那麼要怎麼指定USB裝置給那台使用呢? VM Workstation 下只要把視窗作用,然後插入usb裝置後,在該VM下就可以直接連接USB裝置,但是在ESX下要指定USB裝置給那台VM機器使用,則要做一些設定,設定方式如下: 1. 先將欲使用的USB裝置插入該台ESX SERVER實體硬體上。 2. 進 vSphere Cliet 3. 開啟要連USB裝置的硬體設定畫面,確認有USB controller裝置。 clip_image002 4. 新增USB裝置,若不確定,可先拔除實體USB然後再做到這步驟看看與接上USB裝置後的差別來判定那個USB裝置是您要的。 clip_image004 clip_image005 5. 新增完VM機器上的USB裝置,應該可以看到對應的VM機器上抓到USB裝置使用。 clip_image006

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    至台灣官網下載 Kies 連線軟體,安裝完後接上手機即有提示可升級軔體,更新完後就是 2.2版囉 注意:升級前請把SD卡拿掉,不然資料都會被清掉…………願我是唯一一個經歷此慘痛經驗的人 http://www.samsung.com/tw/consumer/mobile-phones/mobile-phones/touch-series/GT-I9000HKATWM/index.idx?pagetype=prd_detail&tab=support&subsubtype=infotainment-series 話說三爽的Kies連線軟體做的真漂亮,管理手機界面也方便,台灣人要加油了,整天藍綠,不如多下點功夫賺外國人的錢! 照步驟來,最後手機會重開機就完成升級動作。 1 2 6  3  4  5

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    這是台明學生用品社 tm.infinity.idv.tw 自行打版使用電腦繡製作而成的臂章(背部可上魔鬼沾),若喜愛收集空軍相關物品的收藏家請勿錯過。  IMG_0678  IMG_0679  IMG_0681  IMG_0682  IMG_0683

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    是的,您沒看錯標題,泡麵也可以很特別… 這是朋有去日本買給我的禮物,先來看看UNIQLO的 變態紫色襯衫 與 蜘蛛人吊飾 吧,今年的流行元素--格子衫
    (迷之音:這不是之前就流行過了嗎?)
    是阿,想看看現在年輕人把褲子改的窄窄的,10多年前我們不也流行過,現在看起來還真不好看,穿起來好看的真的不多,要瘦高腿長的才會好看,偏偏台灣的都屬腿短型,不合適也…
    (迷之音:原來是阿北(阿伯)來的…)
    靠~~北~~邊走路… IMG_0658    變態紫色稱衫,因為阿北…不不不,是哥哥長的帥,穿啥都好看 XD
    (迷之音:與曹操齊名!)
    怎?
    (迷之音:臉皮真厚!)
    ………
    IMG_0649   L號太大了,看看價格折合台幣約幾百塊吧,聽說後來來台灣開的店賣1千多塊。
    (迷之音:明明就很緊繃…)
    ……… IMG_0650 IMG_0651  IMG_0652   史努比與蜘蛛人泡麵,份量適合減肥的人吃…
    (迷之音:剛剛好適合阿北) IMG_0653  IMG_0654  IMG_0655 IMG_0656    捨不得吃呢,擺著當裝飾吧~~
    (迷之音:過期前肯定被吃…)
    您真了解我! IMG_0657

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    最近看中了三爽 i9000,朋友對於泡菜很感冒,對我說不要買韓國貨,但是人家產品設計很成功,堪稱現在的Android機王一點也不為過………對於科技產品我是沒啥民族意識,只道東西好用否? 我的門號是中華電信,但是中華電信並沒有與 三爽 i9000 有綁約活動,那坊間為何通訊行卻可以做綁約的活動,原來是用iPhone綁約的活動,幫你申請iPhone 4,然後再用i9000跟你換iPhone4,iPhone 4 16g空機價約26000,但i9000 8G約19000,這中間價差就是通訊行願意做的原因……………… 有些人想說自己辦 iPhone 4 然後賣掉再買空機 i9000,不過前題是也要賣的出去…

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    好大的Iphone!
    http://mag.udn.com/mag/digital/storypage.jsp?f_MAIN_ID=319&f_SUB_ID=2940&f_ART_ID=281563

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    最近MAIL常出現主旨為 : Problem Messages 內容為: Archive:
    Number of messages: 5
    Tries Message Last Tried
    ===== ======= ==========
    6 3553C24D80D2.A0925 Sat Oct 30 04:57:38 2010
    6 10ED024D80EC.AC79E Sat Oct 30 04:56:25 2010
    6 2FF5D24D80D7.AD62C Sat Oct 30 04:53:05 2010
    6 DC7FD24D80BD.AC95D Sat Oct 30 04:43:07 2010
    6 73A4D24D80C2.A16DF Sat Oct 30 04:42:41 2010 找著找著找到了Mailscanner 的 Archive 用法 文章出處:http://i-yow.blogspot.com/2009/07/archive-mailby-mailscanner.html ===================================================== 邪惡的Archive Mail備份郵件(By MailScanner)
    MailScanner有一個邪惡又好用的功能:『Archive Mail』
    這個比Forward還要厲害的功能,當你想要存留(備份)用戶收、發的信件時,用這就就對了~ 1.啟動Archive功能
    vim /etc/MailScanner/MailScanner.conf
    Archive Mail = /etc/MailScanner/archive.rule 2.編輯Archive規則
    vim /etc/MailScanner/archive.rule
    基本規則如下:
    FromOrTo: User@mail.com* yes forward Admin@mail.com.tw
    (收件者或寄件者) (關鍵字,可配合萬用字元) (yes,啟用規則) (forward,動作) (Forward的目標) ※Archive Mail不但可以過濾到本機網域的帳號,也可以以外部帳號作為關鍵字,只要有經過MailScanner掃描的都可以做處理。
    ※以上只是簡單的例子,Archive Mail還有許多變化跟應用 ======================================================

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    今日公司有台SERVER被入侵,修改了帳號密碼,應該也有植入木馬程式………還好前陣子把環境移植到 VM ESXi Server環境,對系統做了備份,故今日很快的恢復系統運作,但對於被入侵的Server,看不出端倪,因為系統日誌檔被刪除了,但對外防火牆的記錄看不出有任何對該台Server異常連線的記錄,故有點擔心是由內部引起的……… 已請管理的同事對該台Server做了一些安全上的設定:
    1.找時間關閉Guest,要連線請都使用帳號密碼連線(無AD就將使用者本機帳號密碼也建立一份在SERVER上),分享目錄請把Everyone權限拿掉,改特定帳號密碼。
    2.關閉奇怪的帳號 kurt$ , 這帳號既然有本機Admin權限。怎麼來的也不清楚,只知道是廠商裝完系統後出現的帳號。 找了一下怎麼備份日誌檔,雖然並不能百分百記錄到駭客入侵前所有記錄,但多一份備份就多一份機會找出問題點,當然希望以後是用不到才是。 ======================================= 文章出處:http://forum.slime.com.tw/thread65618.html 日誌對於系統安全的作用是顯而易見的,無論是網路管理員還是黑客都非常重視日誌,一個有經驗的管理員往往能夠迅速通過日誌瞭解到系統的安全效能,而一個聰明的黑客往往會在入侵成功 後迅速清除掉對自己不利的日誌。下面我們就來討論一下日誌的安全和新增問題。
    一:概述:
    Windows 2000的系統日誌文件有應用程式日誌,安全日誌、系統日誌、DNS伺服器日誌等等,應用程式日誌、安全日誌、系統日誌、DNS日誌預設位置:%systemroot%\system32\config,預設文件大小512KB。
    安全日誌文件:%systemroot%\system32\config\SecEvent.EVT
    系統日誌文件:%systemroot%\system32\config\SysEvent.EVT
    應用程式日誌文件:%systemroot%\system32\config\AppEvent.EVT
    這些LOG文件在註冊表中的:
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Eventlog有的管理員很可能將這些日誌重定位。其中EVENTLOG下面有很多的子表,裡面可查到以上日誌的定位目錄。
    二:作為網路管理員:
    1.日誌的安全配置:
    預設的條件下,日誌的大小為512KB大小,如果超出則會報錯,並且不會再記錄任何日誌。所以首要工作是更改預設大小,具體方法:註冊表中HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Eventlog對應的每個日誌如系統,安全,應用程式等均有一個maxsize子鍵,修改即可。
    下面給出一個來自微軟站點的一個指令碼,利用VMI來設定日誌最大25MB,並允許日誌自行覆蓋14天前的日誌:
    該指令碼利用的是WMI對像, WMI(Windows Management Instrumentation)技術是微軟提供的Windows下的系統系統管理工具。通過該工具可以在本機或者管理客戶端系統中幾乎一切的信息。很多專業的網路系統管理工具都是關於WMI開發的。該工具在Win2000以及WinNT下是標準工具,在Win9X下是擴展安裝選項。所以以下的程式碼在2000以上均可執行成功。
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Security)}!\\" & _
    strComputer & "\root\cimv2") \'獲得VMI對像
    Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile")
    For each objLogfile in colLogFiles
    strLogFileName = objLogfile.Name
    Set wmiSWbemObject = GetObject _
    ("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2:" _
    & "Win32_NTEventlogFile.Name=\'" & strLogFileName & "\'")
    wmiSWbemObject.MaxFileSize = 2500000000
    wmiSWbemObject.OverwriteOutdated = 14
    wmiSWbemObject.Put_
    Next
    將上述指令碼用記事本儲存碟為vbs為後面的即可使用。
    另外需要說明的是程式碼中的strComputer="."在Windows指令碼中的含義相當於localhost,如果要在遠端主機上執行程式碼,只需要把"."改動為主機名,當然首先得擁有對方主機的管理員權限並建立IPC連接.本文中的程式碼所出現的strComputer均可作如此改動。
    2. 日誌的查詢與制作備份:
    一個優秀的管理員是應該養成制作備份日誌的習慣,如果有條件的話還應該把日誌轉存到制作備份電腦上或直接轉儲到列印機上,在這裡推薦微軟的resourceKit工具箱中的dumpel.exe,他的常用方法:
    dumpel -f filename -s \\server -l log
    -f filename 輸出日誌的位置和檔案名
    -s \\server 輸出遠端電腦日誌
    -l log log 可選的為system,security,application,可能還有別的如DNS等.
    如要把目標伺服器server上的系統日誌轉存為backupsystem.log可以用以下格式:
    dumpel \\server -l system -f backupsystem.log
    再利用計劃工作可以實現定期制作備份系統日誌。
    另外利用指令碼編程的VMI對象也可以輕而易舉的實現日誌制作備份:
    下面給出制作備份application日誌的程式碼:
    backuplog.vbs
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
    strComputer & "\root\cimv2") \'獲得 VMI對像
    Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName=\'Application\'") \'獲取日誌對像中的應用程式日誌
    For Each objLogfile in colLogFiles
    errBackupLog = objLogFile.BackupEventLog("f:\application.evt") \'將日誌制作備份為f:\application.evt
    If errBackupLog <> 0 Then
    Wscript.Echo "The Application event log could not be backed up."
    else Wscript.Echo "success backup log"
    End If
    Next
    程序說明:如果制作備份成功將視窗提示:"success backup log" 否則提示:"The Application event log could not be backed up",此處制作備份的日誌為application 制作備份位置為f:\application.evt,可以自行修改,此處制作備份的格式為evt的原始格式,用記事本開啟則為亂碼,這一點他不如dumpel用得方便。
    三:作為黑客
    1、日至清除
    一個入侵系統成功後的黑客第一件事便是清除日誌,如果以圖形界面遠端控制對方機器或是從終端登入進入,刪除日誌不是一件困難的事,由於日誌雖然也是作為一種服務執行,但不同於http,ftp這樣的服務,可以在指令行下先停止,再刪除,在m指令行下用net stop eventlog是不能停止的,所以有人認為在指令行下刪除日誌是很困難的,實際上不是這樣,下面介紹幾種方法:
    (1)借助第三方工具:如小榕的elsave.exe遠端清除system,applicaton,security的軟體,使用方法很簡單,首先利用獲得的管理員帳號與對方建立ipc會話,net use \\ip pass /user: user
    然後指令行下:elsave -s \\ip -l application -C,這樣就刪除了安全日誌。
    其實利用這個軟體還可以進行制作備份日誌,只要加一個參數 -f filename就可以了,在此不再詳述。
    (2)利用指令碼編程中的VMI,也可以實現刪除日誌,首先獲得object對象,然後利用其clearEventLog()方法刪除日誌。來源碼:
    cleanevent.vbs
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
    strComputer & "\root\cimv2")
    dim mylogs(3)
    mylogs(1)="application"
    mylogs(2)="system"
    mylogs(3)="security"
    for Each logs in mylogs
    Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName=\'"&logs&"\'")
    For Each objLogfile in colLogFiles
    objLogFile.ClearEventLog()
    Next
    next
    在上面的程式碼中,建立一個陣列,為application,security,system如果還有其他日誌也可以加入陣列。
    然後用一個for 循環,刪除陣列中的每一個元素,即各個日誌.
    2、新增日誌:
    刪除日誌後,任何一個有頭腦的管理員面對空空的日誌,馬上就會反應過來被入侵了,所以一個聰明的黑客的學會如何偽造日誌:
    (1)利用指令碼編程中的eventlog方法是創造日誌變得非常簡單;下面看一個程式碼
    createlog.vbs
    set ws=wscript.createobject("Wscript.shell")
    ws.logevent 0 ,"write log success" \'新增一個成功執行日誌
    這個程式碼很容易閱讀,首先獲得wscript的一個shell對象,然後利用shell對象的logevent方法
    logevent的用法:logevent eventtype,"description" [,remote system]
    eventtype 為日誌類型,可以使用的如下:0 代表成功執行;1 執行出錯;2 警告;4 信息;8 成功審計;16 故障審計
    所以上面程式碼中,把0改為1,2,4,8,16均可,引號下的為日誌描述。
    這種方法寫的日誌有一個缺點,只能寫到應用程式日誌,而且日至來源只能為wsh,即Windows scripting host,所以不能起太多的隱蔽作用。
    (2)微軟為了方便系統管理員和程序員,在xp下有個新的指令行工具,eventcreate.exe,利用它,新增日誌更加簡單。
    eventcreate -s server -l logname -u username -p password -so source -t eventtype -id id -d description
    含義:-s 為遠端主機新增日誌: -u 遠端主機的用戶名 -p 遠端主機的用戶密碼
    -l 日誌;可以新增system和application 不能新增security日誌,
    -so 日誌來源,可以是任何日誌 -t 日誌類型 如information信息,error錯誤,warning 警告,
    -d 日誌描述,可以是任意語句 -id 自主日誌為1-1000之內
    例如,我們要本機新增一個系統日誌,日至來源為admin,日誌類型是警告,描述為"this is a test",事件ID為500
    可以用如下參數
    eventcreate -l system -so administrator -t warning -d "this is a test" -id 500
    這個工具不能新增安全日誌。至於如何新增安全日誌,希望大家能夠找到一個好方法! ================================================================= 另一篇使用Script自動備份維護LOG檔 文章出處:http://jiemelody.blog.51cto.com/405459/331906 前言:
    在管理windows平台的服務器時,常常在系統發生問題或是服務器上運行的服務發生異常時,我們第一個一定是先打開"事件檢查器" 來查看Eventlog,查看是不是有異常的訊息產生,但是windows的log產生默認下是不會以日期來自動備份的,往往要找一個問題都要在一堆 log裡翻呀找呀,好不方便,如果能夠每天在午夜12點59分整以全文字檔備份每天的eventlog,那我們就可以在問題發生時,把我們要查找的 eventlog以照日期調閱出來,方便又快速~以下小弟我就寫了一個很小但又方便的dos scripts提供給大家參考囉!
    一.實作:
    首先scripts的組成有以下三個檔案
    1.Dump_eventlog.cmd  -->這支Scripts是把eventlog Dump出來共以全文字檔 txt來存檔
    2.dumpel.exe -->這是一支工具程式,因為如果用windows內建的匯出eventlog功能,匯出來的後綴檔名是.evt,以文字編程工具打開來會是亂碼,一定要用windows的事件檢查器打來看才行,那就太煩人了,所以我們用這支程式加上上一支 scripts就可以匯出後綴檔名為.txt的log檔,要查看就方便多了!
    3.del_eventlog.vbs -->這支是用wsh編程編寫的scripts,功用是清空系統的eventlog記錄,有人要問了,我們不是要備份log嗎為什麼需要這支來刪除呀!
    還記得剛才說的嗎?我們是要備份每天的系統Log檔,所以用排程排定在每天的午夜12:59備份系統Log後,就利用這支scripts清空系統裡舊的 log,那樣我們每天備份的eventlog就會是完完整整的一整天,而不是好幾天混雜在一起的log備份!
    二.代碼說明
    接下來我就要解說代源的寫法囉
    1.Dump_eventlog.cmd 
    ---------------------------------- 源代碼 ------------------------------------------------------------
    @echo Off
    mkdir %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%
    @echo ******* start Backup Eventlog ******
    dumpel -s 127.0.0.1 -l system -f %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%/system.log
    dumpel -s 127.0.0.1 -l application -f %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%/application.log
    dumpel -s 127.0.0.1 -l security -f %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%/security.log
    @echo ******* Finish Backup Eventlog ******
    star /min del_eventlog.vbs
    ---------------------------------------------------------------------------------------------------------
    說明:
    代碼不含上下二條虛線喔!第二行是我們要建立一個以日期為名稱的資料夾
    因為windows的date抓取的日期變數會是2005/02/23 星期三"這樣的文字,其內的斜線(/)或減號(-)都是用做命令列的選項符號,這樣的組合可能會造成錯誤。
    在此最簡單的方法便是用環境變數的擴充功能了,用%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%,我們就可以抓取以 2006-10-20這種格式的日期,4~6行則是利用dumpel 這支程式把 security 、application 、system 三項log記錄匯出來以txt檔備份到以當天日期命名的資料夾裡,ip我是用本機,請依照自己的需要改成你自己主機的ip,star /min del_eventlog.vbs這行則是在備份完之後清空系統的log記錄,原因,前面我們己經說過了!把上面的源碼copy並存成.bat或.cmd 的檔名就可以了!
    2.del_eventlog.vbs
    -------------------------------------源代碼 -----------------------------------------------------------
    '刪除Evenlog
    strComputer= "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
    strComputer & "\root\cimv2")
    dim mylogs(3)
    mylogs(1)="application"
    mylogs(2)="system"
    mylogs(3)="security"
    for Each logs in mylogs
    Set colLogFiles=objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='"&logs&"'")
    For Each objLogfile in colLogFiles
    objLogFile.ClearEventLog()
    Next
    Next
    ---------------------------------------------------------------------------------------------------------
    說明:
    代碼不包含上下二條虛線喔!這支是清空系統eventlog的wsh編程 scripts,這裡就不多做介紹了,有興趣可以到微軟的腳本範例網站看看,上面有對wsh的做很多的介紹也有範例檔可下來研究!
    http://www.microsoft.com/china/technet/community/scriptcenter/default.mspx
    以上三支scripts我有提供我寫好的碼代碼在附件裡,大家可以玩看看,歡迎修改,
    eventlog的備份也許有些人覺得沒什麼重要,但以筆者我,在管理大量主機時,尤其我又是管理線上遊戲服務器,對於系統異常狀況的掌控就是非常重要的了~

    NoMoney NoHoney 發表在 痞客邦 留言(0) 人氣()

    Blog Stats
    ⚠️

    成人內容提醒

    本部落格內容僅限年滿十八歲者瀏覽。
    若您未滿十八歲,請立即離開。

    已滿十八歲者,亦請勿將內容提供給未成年人士。