2016/05/18

CentOS 安裝 rpcapd

在CentOS上安裝rpcapd順序

1. 下載winpacp source (官方載點)
2. 解開壓縮檔 並參考 https://www.winpcap.org/pipermail/winpcap-users/2011-November/004540.html
    修正daemon.c檔案的錯誤

3. 依據http://www.winpcap.org/docs/docs_40_2/html/group__remote.html 的說明編譯並啟用 

參考來源:
http://www.winpcap.org/docs/docs_40_2/html/group__remote.html
https://www.winpcap.org/pipermail/winpcap-users/2011-November/004540.html

2016/05/14

Cacti Plugin Realtime 安裝方法

個人筆記:Cacti 0.8.7e插件成功安裝之:realtime
源自:楊志剛博客 (
http://yangzhigang.cublog.cn
)

前言:
繼《個人筆記:Cacti 0.8.7e插件成功安裝之:monitor、thold、settings》
http://blog.chinaunix.net/u2/71257/showart_2093517.html
一文之後,本文來記錄我成功安裝基本的插件(realtime)的步驟步驟.

小介紹:
Realtime,provides a method to view cacti graphs with a resolution of upto 5 seconds.

//下載、解壓realtime插件包
(在
http://docs.cacti.net/plugins
中下載最新的插件包)
[root@centos53 ~]# cd /usr/local/src
[root@centos53 src]# wget
http://docs.cacti.net/_media/plugin:realtime-0.4.0-1.tar.gz
[/url]
[root@centos53 src]# tar zxvf realtime-0.4.0-1.tar.gz

[url=http://docs.cacti.net/_media/plugin:settings-latest.tgz]

//MV 插件包到 cacti/plugins/下
[root@centos53 src]# mv realtime /var/www/cacti/plugins/

//install、enable plugins:realtime
登錄Cacti,進入[Console]-[configuration]-[Plugin Management],對plugin:realtime進行Install 和 Enable。

//給admin用戶授權
登錄Cacti,進行[Console]-[Utilities]-[User Management],點admin用戶,在[Realm Permissions]中我,勾選“Plugin->Realtime”。

//第一次驗證
此時,到[Graphs]中,找一個圖,可以發現在其右側已經出現“Realtime”的一個小Logo,但當點此logo進行realtime查看時,會發現彈出的窗口中顯示“The Image Cache Directory directory does not exist. Please first create it and set permissions and then attempt to open another realtime graph.”,提示出沒有Cache目錄以及權限等。

//設置Cache目錄及權限
在realtime插件包中的README中寫到:Create a folder somewhere on your system that is accessible to the apache user for writing.
在官網的文檔中對於Installation中也寫到:You need to also create a folder somewhere on you system that is accessible to the apache user for writing.This folder should bo different than other transient folders used by plugins as it will b periodically pruned by this plugin.
所以,還要做如下操作。
-----------原文修正後------------------
# mkdir /var/www/cacti/cache
# chmod 755 -R /var/www/cacti/cache/
# chcon -u system_u -t usr_t /var/www/cacti/cache
# chown apache:apache /var/www/cacti/cache

PS:權限控管要注意
---------------------------------------------

之後,還要login cacti,進入[console]-[configuration]-[settings]-[Misc],設置“Cache Diredtiory”為“​​/var/www/cacti/cache/”

//最終驗證
按上面“第一次驗證”的方法,驗證一下,我成功了,你呢?


2015/11/28

Linux Expect 語法

參考來源:https://devcentral.f5.com/articles/example-expect-script
參考來源:http://inguza.com/document/expect-and-tcl-mini-reference-manual

先裝好epxect後 就可以用下列語法透過ssh去控制遠端主機或設備
--------------
#!/usr/bin/expect -f
set HOST "目標IP"
set USER "帳號"
set PASS "密碼"
set SERVER [lindex $argv 0]    // 參數一  字串
set TARGET [lindex $argv 1]  // 參數二 以空格分隔得字串
append SERVER "_WHITE_LIST"  // 在參數一後面加字串

spawn ssh -o StrictHostKeyChecking=no $USER@$HOST    // ssh連線到目標主機
expect  "password:" { send "$PASS\r";}   //  密碼
expect  " #" { send "config firewall addrgrp \r"; }  // 指令
expect  "(addrgrp) #" { send "edit $SERVER \r"; }  // 指令
expect  "($SERVER) #" {
        foreach target [split $TARGET " "] {       // foreach 迴圈    變數來源是用以空格分隔得字串
                send "unselect member [lindex $target 0] \r";   // 指令
                continue;  
        };
}
expect  "($SERVER) #" { send "end \r"; }   // 指令
expect  " #"  {  send "config firewall address \r"; }
expect  "(address) #" {
        foreach target [split $TARGET " "] {
                send "delete [lindex $target 0] \r";
                continue;
        };
}
expect  "(address) #" { send "end \r"; }
expect  " #" { send "exit \r"; }   // 登出主機

----------------

2015/10/26

CentOS 7 Bridge跟Traffic Control

Bridge 設定  http://www.ichiayi.com/wiki/tech/linux_bridge
Traffic Control 設定 http://chunchaichang.blogspot.tw/2010/08/qos.html

這裡有一個重點Bridge預設是不會受iptables的控制,找了一下有下列文章
http://stackoverflow.com/questions/653812/why-doesnt-my-iptables-entries-block-pinging-a-xen-virtual-machine
重點就是要把Bridge的nf功能打開http://ebtables.netfilter.org/documentation/bridge-nf.html
nf功能可以在sysctl.conf裡面設定。

開機要自動做好TC的話,請記得把rc.local改成可執行。

2015/10/06

Visual Studio 2013 如何建立C++ windows form

參考來源:http://stackoverflow.com/questions/21411926/how-to-create-a-new-windows-forms-application-project-in-visual-c-2013-ultimat


The following are the steps to make such a project:
  1. Go in the menu bar: File => New => Project, to get a list of project templates.
  2. Select in the tree to the left go: Templates => Visual C++. Select on the right of the of the window of the templates list : Empty Project (Visual C++) .
  3. There will be in the "Solution Explorer" a new tree of files which belong to your new project. Expand it. Let's say you got a new project named "Project1". You'll get on the top of the tree "Solution Project1 (1 project)" . After expanding the tree, You should get on the top of the expansion something called "Project1" right under "Solution Project1 (1 project)" . Right-click "Project1". Select "Add New Item" from the right-click menu.
  4. In "Add New Item" from, in the tree to the left , go : Visual C++ => UI => Windows Forms. click save. You'll get the question "You are adding a CLR component to a native project. The project will be converted to have Common Language Runtime support. Do you want to continue?" . Click "Yes" . Again, one more time, right-click "Project1" and go "Properties".
  5. On the tree to left, go : Configuration Properties => Linker => System. And to the right of the properties window set "SubSystem" as "Windows (/SUBSYSTEM:WINDOWS)" .
  6. Also go: Configuration Properties => Linker => Advanced . And to the right of the properties window, set "Entry Point" to "main". If you cannot not see "Entry Point", just re-open the properties window again. This is the function "main" given below. this is where you're application will start running from.
  7. Finally, Double-click the form designer and move the cursor to the bottom of the code just right before the closing brace of "namespace Project1". Paste the following code. Please remember to rename the variables of this code according to your project needs to get it working with the empty form.
    [STAThread]
    void main(array<String^>^ arg) {
        Application::EnableVisualStyles();
        Application::SetCompatibleTextRenderingDefault(false);
    
        MyForm form;
        Application::Run(%form);
    }
    PS:7的部份是指要放在namespace的{}裡面喔。放外面會爆炸的。


怎麼搞的這麼難用,阿明明就在為啥不直接秀出來就好XD


2015/05/05

windows 2008 r2 安裝 Inter I218-V 驅動方式

到Intel官網抓最新的CD包 https://downloadcenter.intel.com/download/22283/Intel-Ethernet-Connections-CD

抓完後解壓縮檔案後,到pro1000\Winx64\NDIS62\e1d64x64.inf修改
把[Intel NTamd64.6.1.1]裡面有關DEV_15A1的兩行增加到[Intel NTamd64.6.1]裡面 重新安裝即可

[Intel.NTamd64.6.1.1]
;DisplayName Section DeviceID
; ----------- ------- --------
%E153ANC.DeviceDesc% = E153A.6.1.1, PCI\VEN_8086&DEV_153A
%E153ANC.DeviceDesc% = E153A.6.1.1, PCI\VEN_8086&DEV_153A&SUBSYS_00008086
%E153ANC.DeviceDesc% = E153A.6.1.1, PCI\VEN_8086&DEV_153A&SUBSYS_00011179
%E153BNC.DeviceDesc% = E153B.6.1.1, PCI\VEN_8086&DEV_153B
%E153BNC.DeviceDesc% = E153B.6.1.1, PCI\VEN_8086&DEV_153B&SUBSYS_00008086
%E153BNC.DeviceDesc% = E153B.6.1.1, PCI\VEN_8086&DEV_153B&SUBSYS_00011179
%E155ANC.DeviceDesc% = E155A.6.1.1, PCI\VEN_8086&DEV_155A
%E155ANC.DeviceDesc% = E155A.6.1.1, PCI\VEN_8086&DEV_155A&SUBSYS_00008086
%E155ANC.DeviceDesc% = E155A.6.1.1, PCI\VEN_8086&DEV_155A&SUBSYS_00011179
%E1559NC.DeviceDesc% = E1559.6.1.1, PCI\VEN_8086&DEV_1559
%E1559NC.DeviceDesc% = E1559.6.1.1, PCI\VEN_8086&DEV_1559&SUBSYS_00008086
%E1559NC.DeviceDesc% = E1559.6.1.1, PCI\VEN_8086&DEV_1559&SUBSYS_00011179
%E15A0NC.DeviceDesc% = E15A0.6.1.1, PCI\VEN_8086&DEV_15A0
%E15A0NC.DeviceDesc% = E15A0.6.1.1, PCI\VEN_8086&DEV_15A0&SUBSYS_00008086
%E15A1NC.DeviceDesc% = E15A1.6.1.1, PCI\VEN_8086&DEV_15A1
%E15A1NC.DeviceDesc% = E15A1.6.1.1, PCI\VEN_8086&DEV_15A1&SUBSYS_00008086
%E15A2NC.DeviceDesc% = E15A2.6.1.1, PCI\VEN_8086&DEV_15A2
%E15A2NC.DeviceDesc% = E15A2.6.1.1, PCI\VEN_8086&DEV_15A2&SUBSYS_00008086
%E15A2NC.DeviceDesc% = E15A2.6.1.1, PCI\VEN_8086&DEV_15A2&SUBSYS_00011179
%E15A3NC.DeviceDesc% = E15A3.6.1.1, PCI\VEN_8086&DEV_15A3
%E15A3NC.DeviceDesc% = E15A3.6.1.1, PCI\VEN_8086&DEV_15A3&SUBSYS_00008086
%E15A3NC.DeviceDesc% = E15A3.6.1.1, PCI\VEN_8086&DEV_15A3&SUBSYS_00011179

[Intel.NTamd64.6.1]
; DisplayName Section DeviceID
; ----------- ------- --------
%E153ANC.DeviceDesc% = E153A, PCI\VEN_8086&DEV_153A
%E153ANC.DeviceDesc% = E153A, PCI\VEN_8086&DEV_153A&SUBSYS_00008086
%E153ANC.DeviceDesc% = E153A, PCI\VEN_8086&DEV_153A&SUBSYS_00011179
%E155ANC.DeviceDesc% = E155A, PCI\VEN_8086&DEV_155A
%E155ANC.DeviceDesc% = E155A, PCI\VEN_8086&DEV_155A&SUBSYS_00008086
%E155ANC.DeviceDesc% = E155A, PCI\VEN_8086&DEV_155A&SUBSYS_00011179
%E15A0NC.DeviceDesc% = E15A0, PCI\VEN_8086&DEV_15A0
%E15A0NC.DeviceDesc% = E15A0, PCI\VEN_8086&DEV_15A0&SUBSYS_00008086
%E15A1NC.DeviceDesc% = E15A1.6.1.1, PCI\VEN_8086&DEV_15A1
%E15A1NC.DeviceDesc% = E15A1.6.1.1, PCI\VEN_8086&DEV_15A1&SUBSYS_00008086
%E15A2NC.DeviceDesc% = E15A2, PCI\VEN_8086&DEV_15A2
%E15A2NC.DeviceDesc% = E15A2, PCI\VEN_8086&DEV_15A2&SUBSYS_00008086
%E15A2NC.DeviceDesc% = E15A2, PCI\VEN_8086&DEV_15A2&SUBSYS_00011179

2015/01/05

和運 IRent 有夠爛 part2

話說,1/1號跟客服反應後,客服也拿了我的卡號說會去跟銀行講來處理。結果 1/2號中午去問客服,結果還是沒處理,而且根本狀況外,似乎客服系統根本沒有任何紀錄一樣,等我講完了才說有留言,阿是留言在客服系統裡面,還是留個小紙條給接班的人?

1/3號更誇張,早上9:42分發個簡訊來說,帳戶需要1680+1938元金額才能過卡,請把錢存夠後通知客服協助處理。那我前兩天是在聯繫個心酸的嗎?這表示IRENT的客服系統、租用系統有很大的問題。

1. 租用系統無法把帳務跟租車部份完全切割。也就是說如果發生像我這樣的狀況,該車完全會被卡住,都無法出租,所以才會需要我去完成還車的動作後才能繼續出租給別人。這根本是天大的笑話,你要全自動也要留備案阿。這樣搞到客戶跟自己不是很好笑?

2. 客服人員素質跟系統問題,1/3號的客服講了很多他不該透漏的東西。
    2-1. 很多VISA簽帳卡的客戶都有發生過
            這表示你們知道有這個問題,卻沒有處理這個問題的流程,也可能其他客戶就很單純的把錢存入就解決了。但我個人基本上錢是算好的,你這樣等於卡了我一週的生活費,那沒拿到薪水前,誰要幫我解決生活費問題?
    2-2. 銀行不會對個案做處理
            或許不會對個案做處理,但基本上人工處理絕對辦得到,只是你們要不要去做而已。


    我為何可以講得這麼多,因為我也寫過跟信用卡使用的相關程序,我知道信用卡在網路交易上的流程,各家銀行或多或少都有不一樣的地方,但總流程是不變得。還有我相信和運的系統絕對是外包給廠商,而跟銀行介接這段是和運自己跟銀行接洽後轉給廠商,還是直接用廠商的系統去借接銀行,這就不得而之。但不論是哪一種,都一定會有可以取消的機制在。
    再來是客服系統,客服系統到底有沒有詳細的紀錄客戶問題?1/1號就反應了,1/2號的客服好像完全不清楚狀況,當然如果不是從0800進線,客服系統就無法抓到單號?這表示電話流程上跟電信實體介接方式有問題。不然為何1/3號打去,也是一問三不知,而且還轉到第二個客服人員才有比較好得應對。問題是我早就被你們搞毛了,而且三天講得處理方式都不一樣,阿我之前都是講心酸的嗎?
    最後是租用系統,為何無法手動處理訂單?不能強制還車?第二次還車,app還一定要拍照,為何不能用第一次拍得?有爭議訂單為何不能轉入爭議狀態,解除車輛被系統鎖定問題?

    反正不論如何,這次本以為依據和運以往的服務狀況,應該會是每好得經驗,但完全被這次的狀況整個洗白了,真心對想租車的朋友說,沒事還是請找據點租用會比較保險。

 

2015/01/01

和運 IRent 有夠爛

今天租用和運的IRent感覺非常爛。
1.車子沒整理過 有前任租用戶留下的垃圾
   這個還可以接受,因為本來就據點的每次還車後都會送去整理,IRENT本來就全自助的,會有這種問題是很正常的。
2.車子的行照跟車號不符
    這算是最誇張的部份,詢問和運還說可能是前任車主租用兩台把兩台資料搞混的關係。這啥鳥答案,這表示和運根本沒有每天去檢查車輛的資料是否正確。

3.信用卡要扣兩次款項(取車時會預扣額度,該預扣額度會被佔用,所以如果用VISA簽帳卡,你帳戶要預留兩次費用+油費)
 
外加跟和運人員通電話,一整個爛到爆,啥都要我們自己處理。搞的我們不能用加油卡加油(要自己用現金付),然後加完了才說要打統編跟車號,希望我們回去加油站更正。還車還因為取車時已經預扣款項,導致無法扣款完成還車手續,所以完全無法還車。

客服還沒有主管可以授權處理。 本來想說以往和運據點的經驗來看,應該會是很方便且愉快的服務。結果壓根就不是這麼回事,啥都爛到炸。其中最誇張的是行照資料不正確,理由盡然是跟我說可能是前任客戶租兩台所以搞錯兩台的資料,這是不是表示你們在給下一位用戶使用前沒有檢查??就算沒辦法每次都檢查,好歹一天檢查一次吧?看來是以前美好的經驗,搞成了今天超級不愉快的經驗。
    最後還要去問我的發卡行,發卡行說取車的預扣款,要由和運的網來銀行收單單位跟我的發卡行的商店服務科聯繫,才能去把預扣款佔用的額度扣除。
     換句話說,除非你像我這樣錢都卡的死死的人,否則你根本不會碰到這種問題。
     還有,還車一定要上傳照片,第二次還車還必須要重照,不能用地一次還車時照的照片。所以一整個完全不方便。

     現在就要看和運跟銀行那邊誰可以處理好。

2012/09/20

架站是否需要租用虛擬主機、vps或實體主機等

其實很多人玩網站或是論壇玩到後面,都會考慮到租用各類主機的需求。 通常會考慮到租用各類主機的最大原因就是,用戶已經成長到超過免費資源能承受的程度。但租用主機前其實也要考慮到,自己是否有能力管理這些主機,同時是否有足夠的技術能力,能解決相關技術問題。 其實不論是虛擬主機、vps或實體主機等,最大的差異在於,虛擬主機是跟所有人共用所有的設定檔,如iis或apache的設定檔,ftp,資料庫(mysql或mssql)等。而vps則是大家共用cpu、ram跟hdd的資源,但設定檔全都是自己的。實體主機則是全部都是你個人獨享。這樣看起來vps跟實體主機的差異好像只有共用cpu、ram跟hdd的資源部份。 但不論哪一類的主機,最怕的就是被ddos攻擊,而ddos攻擊分為1.流量型2.資源消耗型。碰到流量型的話,不論哪類的主機統統都會出事,因為影響的是服務提供商的整條線路,通常會採用把你的網站停用或是把流向給你使用的ip在路由上導向null,藉以避免影響到其他用戶。 而資源消耗型對虛擬及vps主機來說,通常就會設定一個上限,避免影響到其他用戶,雖說不似流量型會影響到全部客戶,但仍然會造成一定影響。而實體主機的話,因為沒有任何人跟你共用,所以就只能靠自己利用防火牆或服務提供商所提供的防火牆來進行一些阻擋。 因此是否要租用各類主機,就要看自己願意花費多少(這裡不單指金錢、還包括時間)來穩定自己的服務。有興趣的人,可以來信跟我討論,信中請註明大名及聯絡方式。

2012/06/13

賺一塊錢不是賺,省一塊錢才是賺一塊錢

標題的用法應該要改成,「賺一塊錢不是賺,不浪費一塊錢才是賺一塊錢」。

省要省對地方,省錯地方,出事才知道已經來不及了。

網路上看到,應該是王永慶說過的話。

MySQL 的安全漏洞

http://thehackernews.com/2012/06/cve-2012-2122-serious-mysql.html


看起來是 5.1.61, 5.2.11, 5.3.5, 5.5.22 以前的版本都有漏洞

輸入網頁中的那個指令 有一定的機率能拿到root

2012/05/30

Windows Media Player Toolbar on Chrome

如果用chrome開啟頁面發現,chrome說缺少Windows Media Player外掛程式的話。

安裝這個chrome用的外掛即可
https://support.google.com/chrome/bin/answer.py?hl=zh-Hant&answer=95697&p=plugin_wmp

不要直接點 chrome給的連結,那個裝了沒效果。

2012/02/06

webmin及openwebmail安裝

以下都是透過yum方式安裝,rpm及tarball方式請自行google。
一、安裝webmin
        參考:http://webmin.com/rpm.html

Using the Webmin YUM repository

If you like to install and update Webmin via RPM, create the/etc/yum.repos.d/webmin.repo file containing :[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1
You should also fetch and install my GPG key with which the packages are signed, with the commands :wget http://www.webmin.com/jcameron-key.asc
rpm --import jcameron-key.asc
You will now be able to install with the command :yum install webminAll dependencies should be resolved automatically.


二、安裝openwebmail


How to install openwebmail from yum repository
==============================================
Thomas Chung <tchung@openwebmail.org>
2008.05.29
UPDATE 2010.05.24
Install perl-Text-Iconv from rpmforge for your arch if you're running RHEL or CentOS:
http://dag.wieers.com/rpm/packages/perl-Text-Iconv/
$ su -
# cd /etc/yum.repos.d
# lftpget http://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo
# yum install openwebmail
fedora 100% |=========================| 2.1 kB 00:00
openwebmail 100% |=========================| 951 B 00:00
updates 100% |=========================| 2.3 kB 00:00
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package openwebmail.i386 0:2.53-1 set to be updated
--> Processing Dependency: openwebmail-data = 2.53-1 for package: openwebmail
--> Processing Dependency: perl-suidperl for package: openwebmail
--> Processing Dependency: perl-Text-Iconv for package: openwebmail
--> Running transaction check
---> Package openwebmail-data.i386 0:2.53-1 set to be updated
---> Package perl-suidperl.i386 4:5.8.8-32.fc8 set to be updated
---> Package perl-Text-Iconv.i386 0:1.5-1.fc8 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing for dependencies:
openwebmail i386 2.53-1 openwebmail 2.3 M
openwebmail-data i386 2.53-1 openwebmail 7.0 M
perl-Text-Iconv i386 1.5-1.fc8 fedora 20 k
perl-suidperl i386 4:5.8.8-32.fc8 updates 60 k
Transaction Summary
=============================================================================
Install 4 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 9.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-Text-Iconv-1. 100% |=========================| 20 kB 00:00
(2/4): openwebmail-2.53-1 100% |=========================| 2.3 MB 00:03
(3/4): perl-suidperl-5.8. 100% |=========================| 60 kB 00:00
(4/4): openwebmail-data-2 100% |=========================| 7.0 MB 00:10
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID cfb164d8
Importing GPG key 0xCFB164D8 "Thomas Chung <tchung@openwebmail.org>" from http://openwebmail.org/.../RPM-GPG-KEY-openwebmail
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: perl-Text-Iconv ######################### [1/4]
Installing: perl-suidperl ######################### [2/4]
Installing: openwebmail ######################### [3/4]
Permission and Ownership for openwebmail files have been fixed!
Please execute following tool first as a root:
/var/www/cgi-bin/openwebmail/openwebmail-tool.pl --init
After restarting httpd service, login with non-root account from
http://localhost.localdomain/cgi-bin/openwebmail/openwebmail.pl
or http://localhost.localdomain/webmail
If SELinux enabled, you may need to set it 'permissive' in
/etc/sysconfig/selinux or system-config-selinux
Installing: openwebmail-data ######################### [4/4]
Dependency Installed: openwebmail.i386 0:2.53-1 openwebmail-data.i386 0:2.53-1 perl-Text-Iconv.i386 0:1.5-1.fc8 perl-suidperl.i386 4:5.8.8-32.fc8
Complete!
三、 openwebmail安裝好後的設定
        修改/var/log/openwebmail.log的 selinux設定
參考:http://j796160836.pixnet.net/blog/post/21882397-%5B%E7%AD%86%E8%A8%98%5D%5B%E6%A5%B5%E9%87%8D%E8%A6%81%5Dopenwebmail%E7%9A%84%E9%97%9C%E9%8D%B5%E8%A8%AD%E5%AE%9A%EF%BC%8C%E8%A8%AD%E5%AE%9Aselinu



2011/10/31

取得檔案的版本資訊 file version information


int   iVerInfoSize;
char   *pBuf;
AnsiString   asVer;
VS_FIXEDFILEINFO   *pVsInfo;
unsigned   int   iFileInfoSize   =   sizeof(   VS_FIXEDFILEINFO   );

iVerInfoSize   =   GetFileVersionInfoSize(Application->ExeName.c_str(), NULL);
if(iVerInfoSize!=   0)
{
pBuf   =   new   char[iVerInfoSize];
if(GetFileVersionInfo(Application->ExeName.c_str(),0, iVerInfoSize, pBuf   )   )
{
if(VerQueryValue(pBuf, L"\\",(void **)&pVsInfo,&iFileInfoSize))
{
asVer = IntToStr( HIWORD(pVsInfo-> dwFileVersionMS) ) + ".";
asVer+= IntToStr( LOWORD(pVsInfo-> dwFileVersionMS) ) + ".";
asVer+= IntToStr( HIWORD(pVsInfo-> dwFileVersionLS) ) + ".";
asVer+= IntToStr( LOWORD(pVsInfo-> dwFileVersionLS) );
}
}
delete   []pBuf;
}

2011/10/28

TMemo AutoScroll

參考來源:
http://www.programmer-club.com.tw/showSameTitleN/cb/7076.html

MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/bb787577(v=vs.85).aspx

Memo1->Perform(WM_VSCROLL,SB_BOTTOM ,0);
直接用SB_BOTTOM就好。

2011/10/06

Fedora 讓gnome可以用root登入

參考來源:http://fedoraproject.org/wiki/Enabling_Root_User_For_GNOME_Display_Manager

要先有root權限或是用sudo方式處理。

1. 修改 /etc/pam.d/gdm
   將
   auth required pam_succeed_if.so user != root quiet
   這行改成
   #auth required pam_succeed_if.so user != root quiet
2. 修改 /etc/pam.d/gdm-password
  同1的方式修改

  不過一般不建議這樣作,畢竟安全至上。除非你自己有相當的管理經驗。

2011/09/05

專案管理工具

最近在找專案管理工具,找到這個open source的 phprojekt
預設只有英文、德文及西班牙文,現在正在努力得翻譯中,到時候拿來做專案管理就會比較方便了。

2011/08/10

Windows XP 更新 會跑到這一個網頁 http://support.microsoft.com/kb/2497281/

今天在灌XP的時候發生了問題,查了老半天後才知道有東西要更新。
發生的原因是這個 Windows XP 更新 會跑到這一個網頁 http://support.microsoft.com/kb/2497281/
解決方式就如連結內所敘述,直接找一台正常的XP的wuweb.dll,然後複製到新主機上覆蓋過去就好。

2011/08/04

Install snort 2.9.0.5 on CentOS 5.5

今天裝Snort 2.9.0.5到CentOS 5.5上,遭遇很多問題。
所以寫這篇紀錄如何安裝。這篇完全用tarball方式安裝,RPM部份請參考(http://forum.icst.org.tw/phpbb/viewtopic.php?f=11&t=20365)。
這邊是安裝好CentOS 5.5並且將全部套件更新到最新版後的安裝方式。

1.事前準備
  1.1 從snort官網下載snort-2.9.0.5.tar.gz, dag-0.5.tar.gz
  1.2 下載snort的rule,免費的即可,前提是你要先註冊一個帳號。將來有想要升級的話也可以升級上去。
        snortrules-snapshot-2904.tar.gz, snortrules-snapshot-2905.tar.gz
  1.3 到http://www.tcpdump.org 下載libpcap-1.1.1.tar.gz
  1.4 到http://libdnet.sourceforge.net 下載libdnet-1.11.tar.gz
  1.5 將snort,dag,libdnet及libpcap解開(請自行到鳥哥那瞭解如何解壓縮),到各自目錄夾。
        通常解開的目錄就是檔案去掉tar.gz的部份。
        例:snort-2.9.0.5.tar.gz解開後目錄名稱為snort-2.9.0.5。
2.開始安裝
  2.1 用瀏覽器打開 Install_Snort_2.8.6_on_CentOS_5.5.pdf
       請依照裡面的 Snort Installation and Setup章節安裝。裡面會要你用yum安裝很多套件。
       安裝完後會到 Making directories and building/installing Snort: 章節。
       接下來的請依順序安裝,不然會有錯誤訊息。
  2.2 安裝libdnet
cd libdnet-1.11
./configure --prefix=/usr
make
make install

  2.3 安裝libpcap
cd libpcap-1.1.1
./configure --prefix=/usr
make
make install

  2.4 安裝dag
cd dag-0.5
./configure --prefix=/usr
make
make install

  2.5 安裝snort
cd snort-2.9.0.5
./configure --with-mysql --enable-dynamicplugin --enable-ipv6 --enable-gre --enable-mpls --enable-targetbased --enable-decoder-preprocessor-rules --enable-ppm --enable-perfprofiling --enable-zlib --enable-active-response --enable-normalizer --enable-reload --enable-react --enable-flexresp3
make
make install

  2.6 接著就接續Making directories and building/installing Snort:後面章節的部份繼續安裝下去。

3. PHP Pear部份
   3.1 安裝php pear

yum -y install php-pear
pear upgrade --force http://download.pear.php.net/package/PEAR-1.9.1.tgz
pear install Numbers_Roman
pear install channel://pear.php.net/Numbers_Words-0.16.2
pear install Image_Color
pear install channel://pear.php.net/Image_Canvas-0.3.2
pear install channel://pear.php.net/Image_Graph-0.7.2


4. adodb
wget http://sourceforge.net/projects/adodb/files/adodb-php5-only/adodb-511-for-php5/adodb511.tgz/download


5. secureideas
wget http://sourceforge.net/projects/secureideas/files/BASE/base-1.4.5/base-1.4.5.tar.gz/download


6. Barnyard2
安裝裡面的網站已經不存在了,現在換到這個https://nodeload.github.com/firnsy/barnyard2/tarball/master。
  6.1 請參閱doc裡面的INSTALL文件
        如果發生 AM_PATH_LIBPRELUDE 錯誤的話,依下面方式處理。

cp snort-2.9.0.5/m4/libprelude.m4 /usr/share/aclocal

snort-2.9.0.5可以改成你實際解開的目錄。
  6.2 之後就./configure --with-mysql --prefix=/usr沒問題的話就可以安裝了

7. 修改snort.conf
     把ipvar部份全部改成var。

全部做完後就可以開始使用Snort了。