經過MacUknow網友的提醒,原來想要達到"將.srt字幕與avi影片檔合併",只需要透過QuickTime Pro和Perian就可以輕鬆做到,並且如果你之前已經有買過QuickTime Pro版,就可以省下再去購買Submerge之類軟體的錢了,以下將教你如何利用QuickTime Pro和Perian來做到將srt字幕檔與avi影片檔合併輸出成mov檔,其實非常簡單:
一、確認QuickTime Pro和Perian
    首先要先確認你的QuickTime播放器是Pro版本的,你可以進入"系統偏好設定"中的"QuickTime"項目中去註冊

    至於註冊的方法,則是要上Apple的網站去購買註冊碼。當然,你也可以輕易地Google到快樂碼

    再來,你的電腦要裝上Perian這套免費好用的外掛程式,並且確認在"系統偏好設定">>"Perian"中有勾選下圖紅框中的選項。

二、開啟avi影片

   將你要開啟的avi影片和srt字幕檔放在同一個資料夾下,並且使用相同的檔名

   接下來使用QuickTime來播放avi影片檔,你可以對著avi檔按右鍵,然後選擇用QuickTime Player來播放

   開啟影片之後,就可以看到影片中會自動掛上字幕檔囉

三、輸出成單一個掛載好字幕的mov檔 

   在接下來跳出的視窗中,一定要選紅框中的選項,另存為獨立式影片,就可以合併起來了

   接下來就要輸出成單一個影片了,在QuickTime Player的選當列中點選"檔案">>"儲存為..."

   存成單一個mov檔的速度也相當快,大約幾分鐘上下

   這樣以後在電腦裡就可以只留下一個mov檔,avi和srt檔就可以丟掉囉

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

安裝 Cacti 在Unix or Linux


  1. 基本需求

    您的Server基本上需要有下面這些套件,安裝方式網路上搜尋應該會有很多了在此就不多做說明


    Apache + PHP + MySQL


    基本上您的php必須有開啟snmp、sockets、gd這三個函式庫



  2. 安裝Snmp


    基本上現在的Linux都會有Snmp的套件,如果您知道怎麼啟動它請自行啟動即可,下面只介紹使用 Tarball 的安裝方式


    建議您參加鳥哥的私房菜下面這一篇來安裝ucd-snmp


    http://linux.vbird.org/linux_security/old/04mrtg.php#4



  3. 安裝RRDTool.

    注意:由於rrdtool1.2版本已經不再自帶外部的lib庫,所以需要從

    http://oss.oetiker.ch/rrdtool/pub/libs/

    下載安裝,建議還是使用1.0.x的版本比較方便



    目前1.0.x最新版本為1.0.50 (2006/01/10)

    http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.0.x/rrdtool-1.0.50.tar.gz


    shell> tar zxvf rrdtool-1.0.50.tar.gz 


    shell> cd rrdtool-1.0.50



    shell> ./configure --prefix=/usr/local/rrdtool 


    shell> make 


    shell> make install 



  4. 開使安裝 Cacti 解壓縮檔案.

    shell> tar xzvf cacti-version.tar.gz



  5. 建立 Cacti 用的 MySQL 資料庫:

    shell> mysqladmin --user=root create cacti



  6. 匯入預設的cacti資料庫:

    shell>mysql cacti < cacti.sql



  7. 非必要的 : 建立一個 MySQL使用者及密碼供Cacti使用.

    shell>mysql --user=root mysql
    mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
    mysql> flush privileges;



  8. 修改檔案 include/config.php 連接 MySQL 的使用者、密碼及資料庫名稱.

    $database_default = "cacti";

    $database_hostname = "localhost";

    $database_username = "cactiuser";

    $database_password = "cacti";



  9. 新增Unix使用者.

    shell> useradd -r -M cactiuser



  10. 設定log及rra資料夾權限.

    shell> chown -R cactiuser rra/ log/



  11. 新增自動執行到您的 /etc/crontab 檔案裡:

    */5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1


    注意:請勿使用root執行上面命令,不然還要在執行上一步驟(設定log及rra資料夾權限)。


    如果需要立即測試請先切換成cactiuser的身份再去執行上述動作


    修改 /var/www/html/cacti/ 到您的 Cacti 安裝目錄.



  12. 打開您的瀏覽器輸入下面網址:

    http://your-server/cacti/



  13. 登入的帳號密碼

    登入的帳號密碼預設都是 admin. 登入後需立即更改您的密碼。之後這裡需輸入一些資訊,如rrdtool、php、snmpwalk、snmpget的位置,使用ucd-snmp還是net-snmp等等。預設都是 admin. 登入後需立即更改您的密碼。之後這裡需輸入一寫資訊,如rrdtool、php、snmpwalk、snmpget的位置,使用ucd-snmp還是net-snmp等等。


    注意:paths裡的路徑是檔案的路徑不是目錄,請直接輸入此檔案的絕對路徑



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

◎ 軟體基本需求

 


1.(非必要) Apache> - 這個軟體是非必要的如果您的 Windows 已經有 Windows Internet Information Server.


2.Cacti> - 安裝它從 *.zip 的檔案,並將它解壓縮,然後將程式檔案複製到在您的網頁目錄裡 "Cacti" 的資料夾裡.


3.Cactid - 安裝它從 *. zip 的檔案 ,並將它解壓縮到 c:\cacti 資料夾. 確定您的 cactid.conf 檔案裡的 MySQL 資訊都正確.


4.RRDTool - 安裝它並從 Cacti 網站下載. 安裝到 c:\cacti 資料夾.


5.PHP 4.3.6+ or 5.x - 安裝它在 c:\php 資料夾或者其他資料夾.


6.MySQL 4.x or MySQL 5.x - 安裝在預設的資料夾.


7.(非必要) Cygwin - 下載它從 Cygwin website. 執行 setup.exe 檔案,之後就可以使用它.


8.Net-SNMP - 安裝它在 c:\net-snmp 資料夾.


9.(非必要)ActivePerl - 如果您要執行perl檔的話,請安裝它.


 

◎ 設定PHP

 


假如您使用PHP 4 建議將安裝目錄選在 c:\php 下面


增加系統變數 PATH c:\php 系統變數的設定在 控制台 → 系統 → 進階 → 環境變數 → 系統變數


新增一個新的系統變數 PHPRC c:\php


新增一個新的系統變數 MIBDIRS 假如使用PHP4 設定如下 c:\php\mibs  ,假如使用PHP5 設定如下 c:\php\extras\mibs


假如您使用 PHP 4.3.5 或者更少,請建立下面資料夾 c:\tmp


將您的 php.ini 移到 c:\php下面


假如使用 PHP4 請將 php.ini修改如下



extension_dir = c:\php\extensions 

extension=php_snmp.dll 

extension=php_sockets.dll 

cgi.force_redirect = 0



假如使用 PHP5 請將 php.ini 修改如下



extension_dir = c:\php\ext

extension=php_mysql.dll

extension=php_snmp.dll

extension=php_sockets.dll

cgi.force_redirect = 0



假如您使用 PHP 4.3.5或者更少 請修改 php.ini 如下


session.save_path=c:\tmp


假如您想上傳檔案請將 php.ini 修改如下


file_uploads = On


 

◎ 安裝 RRDTool

 


下載 RRDTool zip 檔案從下面網站


http://www.cacti.net/downloads/rrdtool/win32/


並將它解壓縮,複製資料夾裡的資料到 c:\cacti .


 

◎ 安裝 Net-Snmp

 


從網站 http://net-snmp.sourceforge.net/ 下載最新版本的Win32檔案


並將它安裝在 c:\net-snmp 下面


 

◎ 啟動本機 SNMP

 


如果您也要偵測本機的snmp狀態請啟用它


開啟控制台 → 新增移除程式 → 新增移除Windows元件 → Management and Monitoring Tools → Simple Network Management Protocol


將它打勾後點選確定並啟動它.


 

◎ 安裝 Cactid

 


下載 最新版本的 Cactid 從下面網站


http://www.cacti.net/downloads/cactid/packages/Windows/


解壓縮 Cactid zip 檔案,複製資料夾裡的資料到 c:\cacti,並確定 cactid.conf 檔案裡的下面資料符合您的MySQL資訊.


DB_Host        127.0.0.1 or hostname (請勿輸入 localhost)

DB_Database     cacti

DB_User         cactiuser

DB_Password     cacti

DB_Port         3306
 


 

◎ 安裝ActivePerl

 


請到下面網站下載最新版本的ActivePerl for Windows




http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl


請下載5.6.x.xxx版本


 

◎ 設定 Cacti

 


下載最新版本的 Cacti 從下面網站


http://www.cacti.net/downloads/


解壓縮檔案後將檔案複製到您的網頁目錄


MySQL 裡新增一個 cacti 的資料庫 然後匯入 cacti_web_root/cacti/cacti.sql 這一個檔案


修改 cacti_web_root/cacti/include/config.php 這一個檔案,並符合您的 MySQL 資訊.


$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "cacti";

$database_port = "3306";


 

◎ 打開您的瀏覽器輸入下面網址:

 


http://your-server/cacti/install


並依照指示選擇 New Install 然後點選下一步


之後這裡需輸入一寫資訊,如rrdtool、php、snmpwalk、snmpget的位置,請依照您上面安裝路徑輸入正確的路徑


所有路徑都是此檔案的絕對路徑而不是所在目錄


如果事後無法顯示出圖形請到Configuration → Settings → General 
→ RRDTool Utility Version 將它改成RRDTool 1.2x


如果有圖確沒文字的話,請到paths裡的RRDTool Default Font Path - c:/windows/fonts/arial.ttf


如果系統是Windows 2003 Server請將C:\WINDOWS\system32\cmd.exe及rrdTool跟netsnmp的*.exe加入IIS的使用者讀取權限,此舉對系統有一定的危險性,如果無相關對策請更改作業系統。


如果系統是是Windows 2003 Server 請到系統管理工具→服務→SNMP Service→安全性,將cacti後台裡的public新增到此群體裡,並將下面的可接受主機輸入進去,這樣才能存取Windows 2003 Server的SNMP資料


 

◎ 登入的帳號密碼

 


登入的帳號密碼預設都是 admin. 登入後需立即更改您的密碼。


 

◎ 定時執行命令 

 


請打開您的命令提示自元


輸入下面


c:/php/php.exe c:/cacti_web_root/cacti/poller.php 


測試是否有輸出下面類似資訊


C:\>c:/php/php.exe c:/cacti_web_root/cacti/poller.php

OK u:0.00 s:0.06 r:1.32

OK u:0.00 s:0.06 r:1.32

OK u:0.00 s:0.16 r:2.59

OK u:0.00 s:0.17 r:2.62

10/28/2005 04:57:12 PM - SYSTEM STATS: Time:4.7272 Method:cmd.php Processes:1 Threads:N/A Hosts:1 HostsPerProcess:2 DataSources:4 RRDsProcessed:2


之後您應該確認 cacti.log 檔案有在 /cacti/log/出現跟 *.rrd 檔案有在  /cacti/rra/ 出現.


點選開始 → 設定 → 控制台 → 排定的工作


點新增排定工作 → 下一步 → 點選瀏覽 → 並選擇 C:\PHP\php.exe


輸入排程名稱 選擇每日執行 →  下一步


這邊不要變更 → 下一步


輸入執行者的名稱及密碼 → 下一步


完成 → 勾起按下[完成]後開啟這項工作的進階內容


選擇上方選項裡的 → 工作 將執行裡的指令改成(請注意您的poller.php檔案的位置)


c:/php/php.exe c:/cacti_web_root/cacti/poller.php


選擇上方選項裡的 → 排程 點選進階


勾選 重覆執行 → 每隔改成5分鐘 → 直到:改成期間 24小時 0 分鐘


 

◎ 開始設定

 


現在您可以立即連線到cacti去設定了

 

 

 

以下是原廠英文說明

Chapter 3. Installing Under Windows

 

Software Components Required

  1. (Optional) Apache> - This software is optional if running Windows Internet Information Server.

  2. Cacti> - Install from the zip distribution and install in the web root or your choice. Many choose to install into a "Cacti" sub folder.

  3. Spine - Install from the zip distribution into the c:\cacti directory. Make sure your spine.conf.dist is located in that directory as well.

  4. RRDTool - Install from the Cacti website. Install it into the c:\cacti directory.

  5. PHP 4.3.6+ or 5.x - Install into the c:\php folder. If you choose to install into c:\Program Files\php, you will have to use 8.3 filenames to reference it's binaries in Cacti.

  6. MySQL 4.x or MySQL 5.x - Install into the default location. This is typically c:\Program Files\MySQL\MySQL Server X.XX.

  7. (Optional) Cygwin - Download and execute setup.exe from the Cygwin website. Keep the setup.exe file for later use.

  8. (Optional) Net-SNMP - Install to the c:\net-snmp directory. If you choose to use c:\Program Files\net-snmp you will have tu use 8.3 filenames to reference it's binaries in Cacti.

 

Configure PHP

  1. If using PHP 4, move the files in c:\php\dlls to c:\php

  2. Add the following directory to the existing Windows System PATH environment variable: c:\php. The Windows path can be accessed via the Control Panel at: System | Advanced | Environment Variables | System Variables.

  3. Add the following directory to a new Windows System environment variable called PHPRCc:\php.

  4. Add a new Windows System environment variable called MIBDIRS. If using PHP 4, set it to c:\php\mibs. If using PHP 5, set it to c:\php\extras\mibs

  5. If using PHP 4.3.5 or less, create the following directory c:\tmp.

  6. Rename the file c:\php\php.ini.dist to php.ini, and make the following changes to it:

    If using PHP 4 add/uncomment the following lines.

    extension_dir = c:\php\extensions
    extension=php_snmp.dll
    extension=php_sockets.dll
    cgi.force_redirect = 0

    If using PHP 5 uncomment the following lines.

    extension_dir = c:\php\ext
    extension=php_mysql.dll
    extension=php_snmp.dll
    extension=php_sockets.dll
    cgi.force_redirect = 0

    If using PHP 4.3.5 or less include the following line. If using 4.3.6 or greater, you should remove this line if present.

    session.save_path=c:\tmp
  7. In earlier installation guides to PHP, they recommended moving certain DLL's to the c:\winnt\system32 directory. If so, you will have to remove those files. Please review the PHP installation documentation for instructions on removing those files.

  8. If you want to allow template importing, uncomment the following line:

    file_uploads = On
  9. Give the user who will be running the scheduled task, modify rights to the .index file in the location pointed to by the MIBDIRS Windows System environment variable.

 

Configure the Webserver (Apache)

  1. Make sure you have stopped any IIS web servers before you proceed with Apache installation, or make sure Apache is configured on an alternate port.

  2. If you are using Apache 1.3.x, installation of PHP 5 is not recommended. If using PHP 4, add the following lines to your httpd.conf file. You can edit that file by selecting Start | All Programs | Apache HTTP Server X.XX | Configure Server | Edit the httpd.conf file pick from the Taskbar.

    If using Apache 1.3.x and PHP 4, then add the following lines:

    LoadModule php4_module c:\php\sapi\php4apache.dll
    AddModule mod_php4.c
    AddType application/x-httpd-php .php
    DirectoryIndex index.html index.htm index.php

    If using Apache 2.x and PHP 4, then add the following lines:

    LoadModule php4_module c:\php\sapi\php4apache2.dll
    AddType application/x-httpd-php .php
    DirectoryIndex index.html index.htm index.php

    If using Apache 2.x and PHP 5, then add the following lines.

    LoadModule php5_module c:\php\php5apache2.dll
    AddType application/x-httpd-php .php
    DirectoryIndex index.html index.htm index.php

 

Configure the Webserver (IIS)

  1. Start the Internet Information Services (IIS) Manager, right click on the Default Web Site (in most cases) and select Properties.

  2. Under the Home Directory tab, select Configuration and click Add. Browse to the path of php4isapi.dll or php5isapi.dll, and type in .php as the extension. Note: if using IIS6, Enable All Verbs and Script Engine.

  3. Under the ISAPI Filters tab, click Add and browse to the php4isapi.dll or php5isapi.dll file. Name the filter "php" and click OK.

  4. Under the Documents tab, add index.php to the list.

  5. If using IIS6, goto Web Service Extensions and add a new Web Service Extension. Name the extension "php", and click Add and browse to the php4isapi.dll orphp5isapi.dll file, enable Set Extension status to Enable, and click OK.

  6. Give the IUSR_XXXX and IIS_WPG users read & execute permissions to the file %windir%\system32\cmd.exe. They will also need read permissions on cacti_web_root/cactiand it's subfolders.

  7. If using IIS6, give the IIS_WPG user modify permissions to the folders cacti_web_root/cacti/log and cacti_web_root/cacti/rrd.

  8. Completely stop and start the IIS service using the following commands:

    net stop iisadmin
    net start w3svc

 

Install Cygwin (optional)

  1. Installing a single instance of Cygwin, and using it for all applications that require it is recommended so you do not have different versions of the Cygwin dlls laying around on your system, which can cause conflicts.

  2. Run setup.exe you previously download.

  3. Once you reach the portion of setup entitled Select Packages, install the following:

    Base (include all items)
    Libs
            libart_lgpl
            libfreetype26
            libpng12
            zlib
            openssl
    Utils
            patch
    Web
            wget
  4. Add c:\cygwin\bin to your Windows System PATH environment variable.

  5. Move setup.exe to c:\cygwin for future use.

 

Install RRDTool

  1. Extract the RRDTool zip file from the Cacti web site to c:\cacti\rrdtool.exe.

 

Install MySQL

  1. Extract the MySQL zip file to a temp directory and run setup.exe.

  2. Install MySQL to the default directory, or for the purposes of this manual to the c:\mysql directory.

  3. If running an older version of MySQL, start it by running c:\mysql\bin\winmysqladmin.exe. In more recent versions, this is not required.

  4. Set a password for the root user

    shell> cd mysql\bin
    shell> mysqladmin --user=root password somepassword
    shell> mysqladmin --user=root --password reload
  5. Create the MySQL database:

    shell> mysqladmin --user=root --password create cacti
  6. Import the default Cacti database:

    shell> mysql --user=root --password cacti < c:\apache2\htdocs\cacti\cacti.sql
  7. Create a MySQL username and password for Cacti.

    shell> mysql --user=root --password mysql
    mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
    mysql> flush privileges;
  8. If you are running MySQl 4.1 and above, you will need to apply the old password setting in order to authenticate with Cacti. To make this change, stop the MySQL service and add the following to the Start Parameter field. Start it again once it has been added.

    --old-password

    You will also need to update the cactiuser account with the old password style.

    shell> UPDATE mysql.user SET Password = OLD_PASSWORD('cactipwd') 
                                    WHERE Host = 'localhost' AND User = 'cactiuser';
    mysql> FLUSH PRIVILEGES;

 

Install Net-SNMP

  1. If you plan to use any hosts with SNMP v2c support, and are using early versions of PHP, you must download and install the Net-SNMP libraries. Net-SNMP provides installers to install their product. However, caution must be taken if you choose to use long file names as Cacti does not them as long file names. You will have to user 8.3 notation. For example c:\Program Files\Net-SNMP\bin becomes c:\progra~1\net-snmp\bin.

 

Install Spine

  1. Extract the Spine zip file to c:\cacti and modify the spine.conf.dist file to include the following statements.

    DB_Host       127.0.0.1 or hostname (not localhost)
    DB_Database     cacti
    DB_User         cactiuser
    DB_Password     cacti
    DB_Port         3306

    All other pre 0.8.6 settings are obsolete.

  2. Spine now comes with a binary distribution. However, we strongly suggest that you install Cygwin and then remove all the DLL files and sh.exe from the c:\cacti directory.

 

Configure Cacti

  1. Edit cacti_web_root/cacti/include/config.php and specify the MySQL user, password, database, and database port for your Cacti configuration.

    $database_default = "cacti";
    $database_hostname = "localhost";
    $database_username = "cactiuser";
    $database_password = "cacti";
    $database_port = "3306";
  2. Point your web browser to:

    http://your-server/cacti/

    Log in using the username and password of admin/admin. You will be required to change this password immediately.

  3. From Cacti, go to Settings->Paths and verify/udate your paths to point to the correct locations. Recommended examples are posted below. If you plan on using Spine, then it is very important that all paths include forward slashes instead of backslashes.

    PHP Binary Path:

    c:/php/php.exe

    RRDTool Binary Path:

    c:/cacti/rrdtool.exe

    SNMPGET, SNMPWALK, SNMPBULKWALK, SNMPGETNEXT Paths:

    c:/progra~1/net-snmp/bin/snmpget.exe
    c:/progra~1/net-snmp/bin/snmpwalk.exe
    c:/progra~1/net-snmp/bin/snmpbulkwalk.exe
    c:/progra~1/net-snmp/bin/snmpgetnext.exe

    Cacti Logfile Path:

    c:/mycacti/website/cacti/log/cacti.log

    Spine Path:

    c:/cacti/Spine.exe
  4. Click on Devices. Delete the Localhost devices as it intended for Linux environments In the upper right corner, click Add. Fill in the following information and then click Add.

    Description: My Windows localhost
    Hostname: localhost
    Host Template: Windows 2000/XP
  5. You should now be looking at the localhost device screen. Right under it's name, there should be some SNMP information listed, if not you should double check the SNMP settings on the server and firewall settings. In the upper right-hand corner, click on Create Graphs for this Host. On the following screen, select a disk partition and network interface. At the bottom of the page, click on Create.

  6. Log into the user account you'll be using for the scheduled task and verify starting a Cacti polling cycle works. Do this by running the following from the command prompt:

    php c:/cacti_web_root/cacti/poller.php

    The output should look something like the following:

    C:\>php c:\inetpub\wwwroot\cacti\poller.php
    OK u:0.00 s:0.06 r:1.32
    OK u:0.00 s:0.06 r:1.32
    OK u:0.00 s:0.16 r:2.59
    OK u:0.00 s:0.17 r:2.62
    10/28/2005 04:57:12 PM - SYSTEM STATS: Time:4.7272 Method:cmd.php Processes:1 Threads:N/A Hosts:1 HostsPerProcess:2 DataSources:4 RRDsProcessed:2

    After this has ran once, you should have cacti.log in /cacti/log/ and rrd files in /cacti/rra/.

  7. You are going to need to schedule a task while logged on as an Administrator. This task is required to you can run poller.php every 5 minutes. Make sure the Task Scheduler service is started and follow the steps below to begin.

    Note: The following instructions are based on Windows XP and Windows Server 2003. You should be able to follow these instructions close enough for Windows 2000 as well.

     

    1. Select Start --> Settings --> Control Panel and double click on Scheduled Tasks.

    2. Double click on Add Scheduled Task.

    3. Click Next and Browse on the following screen. Find c:\php and select php.exe. Choose Daily on and click Next.

    4. Click Next again without changing the time or date settings.

    5. When entering a username and password make sure the user has read and write access to the following directories:

      cacti_web_root/cacti/rra
      cacti_web_root/log

      Make sure the user has read, write, and execute access to the following directories:

      c:\php
      c:\php\sapi
    6. Click Next and Finish to close the wizard.

    7. Right click on the task you just created, and select Properties.

    8. Select the Schedule tab.

    9. Make sure Daily is selected and click the Advanced button.

    10. Check the Repeat checkbox, set it for 5 minutes and set the duration for 24 hours.

    11. Click Ok

    12. In the Run textbox enter the following text making sure to use the appropriate paths.

      c:\php\php.exe c:\mycacti\website\cacti\poller.php

      The start in box should say c:\mycacti\website\cacti.

 

Apply Patches

  1. There are two methods of applying patches to Cacti:

     

    1. If you have Cygwin installed, then the patch instructions which use wget and patch, will work.

    2. The other method requires you to visit http://www.cacti.net/downloads/patches/0.8.6h/pre-patched/ and manually download and replace the patched files.

  2. You might need to reapply file/folder security on the files patched. Double check they are correct.



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

把 data.mdb 文件改名為 data.asp 文件後放在wwwroot目錄裏。然後在IE中輸入 data.asp 路徑後,發現 IE 顯示一片空白,右鍵->察看原始碼,跳出記事本,將內容另存為.mdb文件,用ACCESS打開,發現需要密碼, 也就是說至少文件檔頭被破壞。

然後用 Flashget 試驗下載 data.asp 文件,並另存為data.mdb 文件,發現用ACCESS 打開完好無損!看來,一些程式設計人員在開發的時候都認為,改了mdb 副檔名為 asp 就能防下載的概念,是錯的!後臺資料庫被下載對於一個asp+access 的網站來說無疑是一場慘絕人寰的災難。今天找了各方的文章,歸納一下有以下9種辦法防止資料庫被下載(歡迎補充)。

1.發揮你的想像力修改資料庫檔案名稱

不用說,這是最最偷懶的方法,但是若攻擊者通過第三方途徑獲得了資料庫的路徑,就玩完了。比如說攻擊者本來只能拿到 list 權限,結果意外看到了資料庫路徑,就可以冠冕堂皇地把資料庫下載回去研究了。另外,資料文件通常大小都比較大,所以再隱蔽的文件檔案名撐都瞞不了人。故保密性為最低。

2.資料庫名稱副檔名改為ASA、ASP等

此法須配合一些要進行一些設置,否則就會出現本文開頭的那種情況。

(1)二進制字段添加。

(2)在這個文件中加入,IIS就會按ASP語法來解析,然後就會報告500錯誤,自然不能下載了。可是如果只是簡單的在資料庫的文本或者備注字段加入<%是沒用的,因為ACCESS會對其中的內容進行處理,在資料庫裏他會以<%的形式存在,無效!正確的方法是將<%存入 OLE 對象字段裏,這樣我們的目的就能達到了。

操作方法:

首先,用notepad新建一個內容為<%的文本文件,隨便起個名字存檔。

接著,用Access打開您的資料庫文件,新建一個表,隨便起個名字,在表中添加一個OLE對象的字段,然後添加一個記錄,插入之前建立的文本文件,如果操作正確的話,應該可以看到一個新的名為”資料包”的記錄。即可。

3.資料庫檔案名稱前加"#"

只需要把資料庫文件前名加上#、然後修改資料庫連接文件(如conn.asp)中的資料庫地址。原理是下載的時候只能識別# 號前名的部分,對於後面的自動去掉,比如你要下載:http://www.pcdigest.com/date/#123.mdb(假設存在的話)。無論是 IE 還是 FLASHGET 等下到的都是http://www.test.com/date/index.htm (或 index.asp、default.jsp 等你原本在IIS設置的首頁檔名)。

另外在資料庫檔案名稱中保留一些空格也起到類似作用,由於HTTP協議對地址解析的特殊性,空格會被編碼為"%",如 http://www.test.com/date/123;456.mdb,下載的時http://www.test.com/date /123%456.mdb。而我們的目錄就根本沒有123%456.mdb 這個文件,所以下載也是無效的這樣的修改後,即使你暴露了資料庫地址,一般情況下別人也是無法下載!

4.加密資料庫

首先在選取"工具->安全->加密/解密資料庫,選取資料庫(如:employer.mdb),然後接確定,接著會出現 "資料庫加 密後另存為" 的窗口,存為:employer1.mdb。接著employer.mdb就會被編碼,然後存為employer1.mdb..要注意的是,以上的動作並不是對資料庫設置密碼,而只是對資料庫文件加以編碼,目的是為了防止他人使用別的工具來查看資料庫文件的內容。

接下來我們為資料庫加密,首先以打開經過編碼了的 employer1.mdb,在打開時,選擇 "獨佔" 方式。然後選取功能表的 "工具-> 安全->設定資料庫密碼",接著輸入密碼即可。這樣即使他人得到了 employer1.mdb 文件,沒有密碼他是無法看到 employer1.mdb的。

加密後要修改資料庫連接頁,如:

conn.open "driver={ microsoft access driver&nb sp; 
(*.mdb) };uid=admin;pwd=資料庫密碼;dbq=資料庫路徑"

這樣修改後,資料庫即使被人下載了,別人也無法打開(前提是你的資料庫連接頁中的密碼沒有被泄露)。 
但值得注意的是,由於Access資料庫的加密機制比較簡單,即使設置了密碼,解密也很容易。該資料庫係統通過將用戶輸入的密碼與某一固定密鑰進行"異 或"來形成一個加密串,並將其存儲在 *.mdb 文件從地址 "&H42" 開始的區域內。所以一個好的程序員可以輕松制作一個幾十行的小程序就可以輕鬆地獲得任何Access資料庫的密碼。因此,只要資料庫被下載,其資訊安全依然是個未知數。

5.資料庫放在WEB目錄外或將資料庫連接文件放到其他虛擬目錄下

如你的WEB目錄是e:\webroot,可以把資料庫放到e:\data這個文件夾裏,在e:\webroot裏的資料庫連接頁中修改資料庫連接地址為:"../data/資料庫名"的形式,這樣資料庫可以正常調用,但是無法下載的,因為它不在WEB目錄裏!這個方法一般也不適合購買虛擬空間的用戶。

6.使用ODBC資料源

在ASP等程序設計中,如果有條件,應盡量使用ODBC資料源,不要把資料庫名寫在程序中,否則,資料庫名稱將隨ASP原始碼的失竊而一同失竊,例如:

DBPath = Server.MapPath("../123/ abc/asfadf.mdb ") 
conn.open "driver={ Microsoft Access Driver&nb sp;(*.mdb) };dbq="& DBPath

可見,即使資料庫名字起得再怪異,隱藏的目錄再深,ASP原始碼失密後,也很容易被下載下來。如果使用ODBC資料源,就不會存在這樣的問題 了:

conn.open "ODBC-DSN名"

,不過這樣是比較煩的,目錄移動的話又要重新設置資料源了,更方便的方法請看第7,8法!

7.添加資料庫名的如MDB的延伸副檔名對應

這個方法就是通過修改 IIS 設定來實現,適合有 IIS 控制權的朋友,但不適合購買虛擬主機用戶(除非管理員已經設定了)。這個方法我認為是目前最好的,只要修改一處,整個網站的資料庫都可以防止被下載,且無須修改原始碼即使是暴露目標地址也可以防止被下載。

我們在 IIS 屬性-->主目錄-->應用程式設定-->應用程式對應-->新增 那裏添加.mdb文件的應用解析。注意這裏所選擇的DLL(或EXE等) 似乎也不是任意的,選擇不當,這個MDB文件還是可以被下載的,注意最好不要選擇選擇 asp.dll 等。你可以自己多測試下,修改後下載資料庫,就出現 (404或500等錯誤)。

例如在執行檔輸入:c:\windows\system32\inetsrv\ism.dll

        副檔名輸入:.mdb

        限制於:GET,POST

8.使用.net的優越性

動網的木鳥就寫過一個防非法下載文件的"WBAL防盜鏈工具"。

不過那個只實現了防止非本地下載的,沒有起到真正的防下載資料庫的功能。不過這個方法已經跟5法差不多可以通過修改.NET文件,實現本地也不能下載!

這幾個方法中,只有第7和8個是統一性改的,一次修改設定後,整個網站的資料庫都可以防止下載,其他幾個就要分別修改資料庫名稱和連接文件,比較麻煩,不過對於虛擬主機的朋友也只能這樣了!

其實第6個方法應該是第5個方法的延伸,可以實現特殊的功能,但對於不支持.net的主機或者怕設定麻煩的話,還是直接用第5個方法了,而且預設情況下第6個方法,依然可以通過復制連接到同主機的論壇或留言本發表,然後就可以點擊下載了。(因為這樣的引用頁是來自同主機的)

9.利用NTFS磁區的文件權限設置

我們已經知道,ASP.NET中使用ADO.NET訪問資料庫,通過OleDb的連接可以訪問Access資料庫,我們非常常用的低端資料庫 之一。本文討論了ASP.NET中可能看到的若幹錯誤提示,從中看到Access2000和AccessXP創建的資料庫文件,在訪問出現錯誤時會出現不太相同的錯誤提示。希望對大家有所幫助。另一個要點是,希望通過此文,使大家對ASP.NET中Access資料庫文件的NTFS權限設置有所新的認識。

(一)實驗過程

為了敘述方便,舉個具體例子做個實驗:應用程序為/test,資料庫存放在D:\wwwroot\test\data\db1.mdb,我們已 經知道在ASP.NET中是以一個叫做ASPNET虛擬用戶的身份訪問資料庫的,我們需要給這個賬戶以特定的NTFS權限才能使ASP.NET程序正常運 行。

為了得到最嚴格的NTFS權限設置,實驗開始時我們給程序最低的NTFS權限:

a)D:\wwwroot\test\data\文件夾的給用戶ASPNET以如下權限:

允許 
拒絕

完全控制

修改

讀取及運行 
V

列出文件夾目錄 
V

讀取 
V

寫入

b) D:\wwwroot\test\data\db1.mdb文件本身給用戶ASPNET以如下權限:

√允許將來自父係的可繼承權限傳播給該對象

1.1:對於某個只包含有"SELECT"命令的aspx程序,上述權限設置運行時無障礙,即:上述權限已經滿足這類程序的運行了。

1.2:對於包含有"UPDATE""INSERT""UPDATE"等命令的aspx程序。

(a)如果db1.mdb是Access2000創建的資料庫,出現如下錯誤:

"/test"應用程序中的服務器錯誤。

MicrosoftJet資料庫引擎打不開文件'D:\wwwroot\test\data\'。它已經被別的用戶以獨佔方式打開,或沒有查看資料的權限。

說明:執行當前Web請求期間,出現未處理的異常。請檢查堆棧跟蹤資訊,以了解有關該錯誤以及原始碼中導致錯誤的出處的詳細資訊。

異常詳細資訊:System.Data.OleDb.OleDbException:MicrosoftJet資料庫引擎打不開文件'D:\wwwroot\test\data\'。它已經被別的用戶以獨佔方式打開,或沒有查看資料的權限。

(b)如果db1.mdb是AccessXP創建的資料庫,出現如下錯誤: "/test"應用程序中的服務器錯誤。

操作必須使用一個可更新的查詢。

說明:執行當前Web請求期間,出現未處理的異常。請檢查堆棧跟蹤資訊,以了解有關該錯誤以及原始碼中導致錯誤的出處的詳細資訊。

異常詳細資訊:System.Data.OleDb.OleDbException:操作必須使用一個可更新的查詢。

(c)原因初步分析:因為包含有"UPDATE""INSERT""UPDATE"等命令,需要對資料庫文件本身進行寫入操作,所以上述權限不能滿足此需求,我們需要進一步放開權限。

我們放開一些權限,

a) D:\wwwroot\test\data\ 文件夾不變;

b) D:\wwwroot\test\data\db1.mdb 文件本身給用戶ASPNET以如下權限;

允許 
拒絕

完全控制

修改

讀取及運行 
V

列出文件夾目錄 
V

讀取 
V

寫入 
V

1.3:放開權限後繼續實驗

(a)如果db1.mdb是Access2000創建的資料庫,出現如下錯誤: "/test"應用程序中的服務器錯誤。

不能鎖定文件。

說明:執行當前Web請求期間,出現未處理的異常。請檢查堆棧跟蹤資訊,以了解有關該錯誤以及原始碼中導致錯誤的出處的詳細資訊。

異常詳細資訊:System.Data.OleDb.OleDbException:不能鎖定文件。

(b)如果db1.mdb是AccessXP創建的資料庫,沒有出現錯誤。

(c)原因初步分析:我們發現在打開Access資料庫時,同時會在所在目錄生成一個同名的*.ldb文件,這是一個Access的鎖定標記。 鑒於此,我們猜測,用戶ASPNET訪問Access資料庫時,也需要生成一個鎖定標記,而該目錄沒有允許其寫入,因此出錯。至於AccessXP創建的 資料庫為什么沒有這個錯誤,原因還不得而知。

我們進一步放開權限,

a)D:\wwwroot\test\data\文件夾  給用戶ASPNET以如下權限:

允許 
拒絕

完全控制

修改

讀取及運行 
V

列出文件夾目錄 
V

讀取 
V

寫入 
V

b) D:\wwwroot\test\data\db1.mdb文件本身給用戶ASPNET以如下權限:

√允許將來自父係的可繼承權限傳播給該對象

1.4:繼續實驗,發現錯誤已解決,那么上面這個權限就是我們需要放開的"最低權限"。

(a)如果db1.mdb是Access2000創建的資料庫,我們會發現一個小問題:生成的*.ldb文件不會自己刪除,訪問後該文件依然存在,但這個問題不會影響ASP.NET的正常運行。

(b)如果db1.mdb是AccessXP創建的資料庫,沒有出現上面類似問題。

(c)原因初步分析:我們僅僅是給了ASPNET以寫入文件夾的權限,沒有給它修改的權限,所以文件一旦寫入,便無法修改其內容,*.ldb也就刪除不掉了。

如果非要解決這個問題,進一步放開權限為:

a)D:\wwwroot\test\data\文件夾給用戶ASPNET以如下權限:

允許 
拒絕

完全控制

修改 
V

讀取及運行 
V

列出文件夾目錄 
V

讀取 
V

寫入 
V

b) D:\wwwroot\test\data\db1.mdb 文件本身給用戶ASPNET以如下權限:

√允許將來自父係的可繼承權限傳播給該對象

1.5:附帶著,實驗另一種情形:我們把db1.mdb在Access打開編輯,同時訪問ASP.NET。

(a)如果db1.mdb是Access2000創建的資料庫,我們發現並沒有出現什麼問題。

(b)如果db1.mdb是AccessXP創建的資料庫,出現如下錯誤:&nb。

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

[MySQL] 使用 mysqldump備份 DB

用 mysqldump 做備份,如果要儘可能把完整的資料匯出,可以加上 --single-transaction,備份前 mysqldump 會先執行 BEGIN ,取得 READ LOCK 後,便能確定資料在執行 mysqldump 的過程中不會受到其它連線存取的干擾,也能 Dump 出較完整的資料。(使用此參數需有 READ LOCK 權限)

mysqldump --single-transaction --all-databases > all_db.sql

注意: 
1.表單較大時可以加上 --quick 
2.MySQL Cluster 不支援 --single-transaction

然而使用 --single-transaction 時最好搭配 --flush-logs 及 --master-data來維持 Binary Log 的完整性。(使用這二個參數皆需有 RELOAD 權限)

mysqldump --single-transaction --flush-logs --master-data --all-databases > all_db.sql

Binary Log 採用的是遞增備份,--flush-logs 便是把目前的 Binary Log 給 flush 出來 (若目前 MASTER_LOG_FILE 已經到 mysql-bin.000005,產生出來的檔案便是 mysql-bin.000006),完成之後才進行 Dump 的作業。

而 --master-data (預設值為1) 則是在 Dump 出來的 SQL 語法中加入下面這一行,以記錄目前 Dump 的時間點。

CHANGE MASTER TO MASTER_LOG_FILE=mysql-bin.000006',MASTER_LOG_POS=4;

如果在未來執行匯入時 SQL 語法時, MySQL 便能很清楚的知道這次 Dump 出來的 SQL 在 Binary Log 中是屬於哪個位置。

註: 若不需理會 Binary Log 的位置時 (例如進行完整備份作業),只要將 --master-data 設為 2 便會將 CHANGE MASTER 給註解起來純供參考用。

 

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