2008年10月22日 星期三

Xoops簡介

簡介:
XOOPS 是一個高度可擴充、具物件導向、且易於使用的動態網站內容管理系統(CMS),採用 PHP 語言來設計。XOOPS 十分適合用於發展小型至大型的動態社群網站、內部 Intranet 網站、入口網站、並且可用來做為 WEB LOG 使用。


優點:
1. 免費與完全開放原始碼
2. 完整的中文支援
3. 數量龐大的外掛功能

綜合分析:
此版本為PHPNuke所分離出來的,免除了PHPNuke的程式碼混亂的情形,是早期的CMS產品.
台灣這邊有浪游者在做中文支援,但是因為其封閉的管理作風,導致於xoop的使用者紛紛獨立成立網站作中文支援.目前因為浪游者和國外官方因為理念不合,所以將獨立出來開發XoopCube.
所以建議使用者,請自行了解其差異點後選擇.

2008年10月15日 星期三

無名小站的 XSS 安全漏洞

前言
布丁大長輩 在 Year.new(2006) 這篇幹剿無名小站的 XSS 安全漏洞,沒有講的很明白,加上我這陣子沒在實驗室遇到 wkwu (是的,我跟他是同一個指導教授),所以一直沒有跟他說這個在國外已經「開發」好一陣子的安全漏洞。

Javascript 是在使用者端 (Browser) 跑的程式,理論上來說,讓使用者輸入自己的 Javascript 並不會有什麼問題,但實際上自從 XMLHttpRequest() 被大量應用後 (一開始發展 AJAX 所使用的核心技術之一),有些人就發現 XMLHttpRequest() 是可以拿來當作攻擊的工具。

舉例說明
舉個例子說明會比較清楚。以目前最大的 無名小站 為例,「修改個人資料」的頁面是在 http://www.wretch.cc/user/modify.php?admin_user=1 這個位置,會以 POST 的方式送給 http://upload.wretch.cc/user/do_modify.php,那麼我就可以在文章裡面嵌入一段 Javascript:(修改自 Use the XMLHttpRequest Object to Post Data)

var objHTTP, strResult;
objHTTP = new ActiveXObject('Microsoft.XMLHTTP');
objHTTP.Open('POST',
"http://upload.wretch.cc/user/do_modify.php",false);
objHTTP.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
objHTTP.send("依照 form 的內容填入一些東西");
strResult=objHTTP.responseText;上面的程式碼是 IE Only 的程式碼,但是要弄 IE & Firefox 並存的程式碼其實只是加個 if 判斷句後改用 new XMLHttpRequest 而已…

原因
問題來了:為什麼這樣做有效?那我隨便用 WWW::Mechanize 丟個東西進去 server 不就炸了?

答案是:使用 XMLHttpRequest() 連線時,會送出使用者的 Cookie,於是 server 端會以這個 Cookie 的擁有人去做 Javascript 要做的事情!接下來就 !@#$%^…

再一個例子
你會說我只是隨便講講?其實這件事情在兩個月前已經在 MySpace.com 上發生過了,而且還寫成 worm 自動感染:Cross-Site Scripting Worm Floods MySpace (Slashdot)。

Google 應對的方法
回過頭來提 Google 對 XSS 的應對 這篇所提到的例子。

假設有個人在他自己的網站上 (假設是 www.example.com) 放個 Javascript,用 XMLHttpRequest() 連 mail.google.com (Gmail) 的某些 function,幫使用者刪除所有的 mail。在平常的時候,會因為 example.com != google.com 而無法產生 XMLHttpRequest Object,但是在「頁庫存檔」的時候就會在同一個 Domain 下!於是 Google 必須避免這種情況:硬把 www.google.com 換成 IP address,這樣就沒問題了。

你可以測試 http://www.google.com/search?q=cache:http://www.google.com/ 這個頁面,會發現 Google 會故意換到 IP address。

Google 的另外一個服務是 Blogger。你會發現 Blogger 可以讓你隨便修改 Template 填入各種 code,於是你就可以對 *.blogspot.com 下面的 site 進行 XSS 攻擊:但實際上 Blogger 的 Control panel 放在 blogger.com,於是根本不怕你利用 Template 惡搞。

結語
最後,Javascript 是邪惡的,平常逛網站請不要打開 Javascript:請安裝 NoScript 以避免被 ox 掉 :p

摘自:http://blog.gslin.org/archives/2006/01/06/288/

2008年10月6日 星期一

jquery radio取值,checkbox取值,select取值,radio選中,checkbox選中,select選中,及其相關

獲取一組radio被選中項的值
var item = $('input[@name=items][@checked]').val();
獲取select被選中項的文本
var item = $("select[@name=items] option[@selected]").text();
select下拉框的第二個元素為當前選中值
$('#select_id')[0].selectedIndex = 1;
radio單選組的第二個元素為當前選中值
$('input[@name=items]').get(1).checked = true;

獲取值:

文本框,文本區域:$("#txt").attr("value");
多選框checkbox:$("#checkbox_id").attr("value");
單選組radio: $("input[@type=radio][@checked]").val();
下拉框select: $('#sel').val();

控制表單元素:
文本框,文本區域:$("#txt").attr("value",'');//清空內容
$("#txt").attr("value",'11');//填充內容

多選框checkbox: $("#chk1").attr("checked",'');//不打勾
$("#chk2").attr("checked",true);//打勾
if($("#chk1").attr('checked')==undefined) //判斷是否已經打勾

單選組radio: $("input[@type=radio]").attr("checked",'2');//設置value=2的項目為當前選中項
下拉框select: $("#sel").attr("value",'-sel3');//設置value=-sel3的項目為當前選中項
$("11112222").appendTo("#sel")//添加下拉框的option
$("#sel").empty();//清空下拉框


摘自:http://www.cnblogs.com/xlfj521/archive/2008/01/29/1057375.html

2008年9月16日 星期二

[WordPress]ImageManager上傳圖失敗

SOLUTION:
在ImageManager
Options >> ImageManager
將Base image directory:改成正確的路徑

即可

2008年9月15日 星期一

Subversion - Cleanup Failed To Process The Following Paths

SOLUTION I
1) Try and determine what rev your Working Copy is checked out at -
file->properties->subversion should tell you this, but the picture may
be less clear if you have mixed revisions.

2) Check out a new Working Copy at the revision you've just determined

3) Create a patch from your broken Working Copy

4) Apply the patch to your new Working Copy

5) Continue using the new one. Delete the broken copy when you're
confident you no longer need it.

2008年9月12日 星期五

undefined / null in JavaScript

In JavaScript null is an object. undefined is used for things that don't exist. The DOM returns null for almost all cases where it fails to find some structure in the document, but in JavaScript itself undefined is the value used.

null and undefined are not strictly equivalent. If you really want to check for null, do:

if (varname == null) // with casting
if (varname === null) // without casting (i.e. same value, same type)

If you want to check if a variable exist

if (typeof(varname) != 'undefined')

The variable exists but you want to know if there's any value stored in it:

if (varname != undefined)

Check if a member variable exists (independent of whether it has been assigned a value or not) :

if ('varname' in object) // With inheritance
if (object.hasOwnProperty('varname')) // Without inheritance


摘自:http://blog.jails.fr/index.php?post/2007/08/01/undefined-/-null-in-JavaScript

2008年9月11日 星期四

[FreeBSD]如何將帳號加入到sudoers

1. 編輯 /usr/local/etc/sudoers
2. 加上 <帳號> ALL=(ALL) SETENV: ALL

wibiya widget