ลักษณะการทำงานขั้นพื้นฐานของ code เป้าหมาย
If HTTP_USER_AGENT = Player_XXX Then
print "Send Data."
Else
print "Don't Send Data."
End If
ผลลัพธ์จากการใช้คำสั่ง : $_SERVER['HTTP_USER_AGENT'];
บราวเซอร์ตัวที่ 1
Browser : Chrome
Data : Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.125 Safari/533.4
บราวเซอร์ตัวที่ 2
Browser : Player_XXX
Data :
NSPlayer/11.00.6000.6351 WMFSDK/11.00.6000.6351
NSPlayer/11.0.6000.6351 WMFSDK/11.0
Windows-Media-Player/11.0.6000.6353
NSPlayer/11.00.6000.6351 WMFSDK/11.00.6000.6351
จากข้อมูลเบื้องต้นทำให้รู้ว่า เราสามารถหยุดคำสั่งได้
เครื่องมือที่ใช้ : php (codeigniter)
การเก็บข้อมูล :
$data['data1'] = $_SERVER['HTTP_USER_AGENT'];
$data['data2'] = date('d m Y H:i:s');
$this->db->insert('tbl_b',$data);
การหยุดคำสั่ง :
$userAgent = "Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_VERBOSE, false);
$html= curl_exec($ch);
Code ต้นแบบ อ้างอิงจาก : http://www.phpdeveloping.co.za/curl/faking-your-user-agent-with-curl.html
Code ที่แก้ไขแล้ว :
$url = 'xxx://xxx.xxx.xxx.xxx/xxx/xxx.xxx';
$userAgent = "Windows-Media-Player/11.0.6000.6353";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_VERBOSE, false);
$html= curl_exec($ch);
$this->db->insert('tbl_b',array('data1'=>$html,'data2'=>date('d m Y H:i:s')));
ผลลัพธ์ที่ได้จาก Code ที่แก้ไขแล้ว
<asx version="3">
<title>xxx xxx</title>
<entry><Duration value = "xx:xx:xx" />
<ref href="xxx://xxx.xxx.xxx.xxx/xxx/xxx.xxx" />
<title>xxx</title>
</entry>
<entry><Duration value = "xx:xx:xx" />
<ref href="xxx://xxx.xxx.xxx.xxx/xxx/xxx.xxx" />
<title>xxx</title>
</entry>
...
...
...
</asx>
การนำผลลัพธ์ไปใช้ :
มีคนแนะนำให้ใช้ flashget, idm, orbit แต่ผมใช้ real player
การเพิ่มระดับการป้องกันของโค้ดเป้าหมาย : ไม่มีความเห็น
เรื่องนี้สอนให้รู้ว่า :
1. ระดับการป้องกัน 1 หลักการ 1 ชั้น
2. เพิ่มเติมส่วน Controller และ View เข้าไป จะได้เครื่องมือถอดรหัสอีกชุดหนึ่ง
3. สามารถนำโค้ดต้นแบบไปปรับปรุง แล้วลอบใช้ resource ได้