Archive

Archive for the ‘Users Skills’ Category

Netbean “Cannot find Java 1.5 or higher”

October 19th, 2009 Scalopus+ No comments

I had manually unpacked Netbean PHP IDE on my Windows 7 x64. My system have Java JDK 1.6 but when execute netbeans.exe, it show error message “Cannot find Java 1.5 or higher”. The solution found that netbean forum.

  • First solution, just install by installer. Not by manually unpacked.
  • Second solution, run netbeans by following command
    “C:\Program Files\Java\netbeans\netbeans-6.7.1-200907230233-ml\bin\netbeans.exe” –jdkhome “C:\Program Files\Java\jdk1.6.0_16″
Tags:

SMSGateway Exporter

October 19th, 2009 Scalopus+ No comments

สืบเนื่องจากเป็นลูกค้า SMSGateway หลายๆ ที่ และ แต่ละที่ส่วนใหญ่จะเก็บข้อมูลไว้ที่เซิร์ฟเวอร์ ไม่สามารถ Export ออกมาได้ ผมนิยมเก็บข้อมูลที่ส่งทุกประเภทไว้กับตัวเอง เลยจำเป็นต้องทำสคริปต์เพื่อ Export ข้อมูลออกมาจาก SMSGateway เจ้าต่างๆ ครับ ซึ่งใน Entry นี้ จะเป็นตัวอย่างของ SMSGateway.PacketLove.com (Oct 2009) สคริปต์นี้ ไม่รับประกันความสำเร็จในการใช้งาน และผู้ใช้รับความเสี่ยงต่อการทำงานผิดพลาดของสคริปต์ด้วยตนเอง.

<?php
class PacketLoveImportor {
var $username;
var $password;
var $rawdata;
function PacketLoveImportor(){
$this->username = "USERNAME";
$this->password = "PASSWORD";
}
function loadURL(){
define('POSTURL', 'http://smsgateway.packetlove.com/history.php');
$query = array (
"userLogin" => $data->username,
"uPasswd" => $data->password,
"page" => 0,
"page_limit" => 1000 // จำนวนข้อมูลที่แสดงในหนึ่งหน้า
);
$ch = curl_init(POSTURL);
curl_setopt($ch, CURLOPT_POST      ,1);
curl_setopt($ch, CURLOPT_POSTFIELDS    ,$query);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_HEADER      ,0);  // DO NOT RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);  // RETURN THE CONTENTS OF THE CALL
$result = curl_exec($ch);
curl_close($ch);
$this->rawdata = $result;
return $result;
}
function loadFile(){
$result = file_get_contents("import_packetlove.html");
$this->rawdata = $result;
return $result;
}
function export($encoding = "UTF-8"){
$found = false;
$offset = 0;
$html = $this->rawdata;
$result = null;
while (preg_match("/(20[0-9]{2}-[01]{0,1}[0-9]{0,1}-[0-9]{2}.[0-9]{2}:[0-9]{2}:[0-9]{2})/",$html,$match,PREG_OFFSET_CAPTURE,$offset) && !$found){
// เริ่มต้นหาจากวันที่
$date = $match[0][0];
// เสร็จแล้วเก็บ Field ที่เหลือ
$result_mobile = preg_match("/([0-9]{10})/",$html,$match,PREG_OFFSET_CAPTURE,$offset);
$mobile = $match[0][0];
$result_message = preg_match("/(<td><span class=\"link\">&nbsp;)(.[^<]{0,255})(<\/style>)/",$html,$match,PREG_OFFSET_CAPTURE,$offset);
$message = $match[2][0];
$offset = $match[0][1] +1;
$result[] = array(
"date" => trim($date),
"tel" => trim($mobile),
"message" => iconv("ISO-8859-11",$encoding,$message),
);
}
// [DATA]
return $result;
}
}
//ตัวอย่างการใช้งาน ในกรณีนี้โหลดจากไฟล์ขึ้นมาทดสอบ ถ้าหากต้องการให้ดึงข้อมูลจากเซิร์ฟเวอร์ตรงๆ ให้เปลี่ยนไปใช้ $data->loadURL();
$data = new PacketLoveImportor();
$data->loadFile();
var_dump($data->export());
?>

Thawte Free Email Digital Certificate with Windows 7

October 8th, 2009 Scalopus+ No comments

If you experience with Microsoft Outlook 2007 + Windows 7 + Thawte Free Email Digital Certificate issue. This entry will help you find the way to use your digital certificate in its.

  1. Download Thawte Root Certificate
  2. Install “Thawte Personal Freemail CA” and “Thawte Personal Freemail Issuing CA
    For me, installed to Intermediate Certification Authorities.
  3. import your Digital Certificate
  4. now, your digital certificate will be ready for use in Microsoft Outlook 2007 in Windows 7

Please note that I have Digital Certificate with Private key in its. I had exported from Windows XP when I was generated this signature.

SSH Tunnel -> SOCKS Proxy

September 30th, 2009 Scalopus+ No comments

ออกนอกบ้านบ่อยๆ ใช้ WIFI รู้สึกการรับส่งข้อมูลไม่ปลอดภัย แล้วยิ่งเราต้องใช้ส่งข้อมูลที่สำคัญบ่อยๆ บางเว็บไซต์ไม่มีช่องทาง SSL มาให้ เลยกังวล วันนี้เลยจัดการตั้งท่อ

My Laptop (A) —-> Locomotive Server (B) —–> Destination (C)

SSH Tunnel Sequence

  • A —-> B = WIFI via SSH
  • B —-> C = Normally Request
  • A = Windows 7
  • B = Ubuntu
  • C = Unknown

การเตรียมพร้อมอุปกรณ์

  • A เตรียม Putty.exe (Windows) หรือ SSH Client ใดๆ
  • B เตรียม SSH Daemon
  • C เราจัดการอะไรไม่ได้อยู่แล้ว

Node B

  • ปกติ ไม่ต้องตั้งค่าอะไรเพิ่มเติม แต่มีค่าที่เกี่ยวข้องในไฟล์ /etc/sshd_config ดังนี้
    • AllowTCPForwarding – yes (default : yes) ตั้งให้ยอมให้ส่งต่อ Packet ไปยังที่อื่น
    • UsePAM – yes (ถ้าตั้ง Authenticated ไว้ อาจจะตั้งว่ามี User อะไร สามารถใช้ Secure Shell ได้บ้าง ด้วย AllowUser)
    • AllowUsers – <username> (ตั้งให้ username นี้ๆ สามารถใช้ SSH ได้)
  • ติดตั้งค่าเสร็จ อย่าลืม Reload Configuration
  • อย่าลืมเปิด Port 22 (SSH Default Port) ถ้ามีการติดตั้ง Firewall เอาไว้
  • ดูความเสี่ยงด้านความปลอดภัยได้ที่ ThaiCERT

Node A

  • ผมใช้ SSH Client ซึ่งเป็น Opensource ชื่อว่า Putty
  • ถ้าอยากสร้าง SSH Tunnel โดยไม่ต้องใส่รหัสผ่าน ดูเอกสารเพิ่มที่ JOMYUT.NET / HowtoConfig
  • ที่โหนด A เราจะเปิด Local Port เอาไว้ อย่างเช่น ผมจะเปิด 127.0.0.1 พอร์ต 1080 ไว้ เมื่อมีการรับข้อมูลที่พอร์ตนี้ จะส่งต่อไปยัง SSH Tunnel ที่ Putty จะสร้างเอาไว้
  • ที่ Network Setting ของ Firefox / IE จะตั้ง Proxy ในรูปแบบ SOCK5 Server ชี้มาที่ localhost พอร์ต 1080
  • Firefox —–> localhost:1080 —–> Putty —–> sshserver:22 —-> Server Daemon —–> Requst Destination
  • วิธีการรูปแบบที่ 1 พิมพ์ที่ Command Line (Ref)
    putty -D <SOCK5 Port> username@ssh-server
  • วิธีการที่ 2 เปิด Putty GUI ขึ้นมา
    • ไปที่แถบ Tunnel ->
    • ตั้ง Local Port เป็น 1080 (SOCKS5 Port) เพื่อรอรับข้อมูลจากบราวซ์เซอร์
    • Destination Port ไม่ต้องใส่ แต่เปลี่ยน Default จาก Local เป็น Dynamic
    • แถบ Connection ให้ใส่ข้อมูล Server ตามปกติ
  • เมื่อ Login เสร็จ จะขึ้น Shell เหมือน Login เข้าไปที่ SSH Server
  • ทดสอบตั้งค่า Firefox แล้วลองเข้ามาดู ว่าเข้าได้หรือเปล่า
  • การปรับปรุงให้ใช้งานง่ายขึ้นเมื่อทดสอบแล้วใช้งานได้
    • Parameter ทั้งหมด ให้เก็บเป็น session ไว้ ซึ่งตั้งได้ผ่าน Putty GUI
    • เวลาเรียกใช้ เรียกใช้เป็น
      putty -load "savesession"
    • ตั้งหน้า TTY ว่า ไม่ต้องใช้ Terminal (notty) หรือ ผ่าน Command Line โดยการใช้
      putty -N -D <SOCK5 Port> username@ssh-server
  • สุดท้าย ถ้าใช้ Firefox หา Extension ชื่อ FoxyProxy มาใช้.
  • ที่เซิร์ฟเวอร์ ถ้าอยากให้ปลอดภัยมากขึ้น ก็ตั้งค่าดังนี้
    AllowTCPForwarding no
    Match group mysecureproxy
    AllowTCPForwarding yes

    กรณีนี้ จะตั้งให้เฉพาะกลุ่มที่สามารถใช้ SSH Tunnel ไปยังโหนดปลายทางได้ ซึ่งเราต้องใช้คำสั่ง
    groups -a -G mysecureproxy myusername
  • เพิ่มเติมเข้าไปอีก ก็จับ User นี้ ลง Jailed Shell ต่อไป

เสร็จแล้ว จบ. เท่านี้ เวลาอยู่ข้างนอกก็ต่อผ่านท่อก่อน ความเสี่ยงอยู่ที่ มีใคร Sniffing Data ที่เซิร์ฟเวอร์ไหมแทนที่จะเป็นจุดที่เราต่อ Wireless

Secured for spam by MLW and Associates, LLP's Super CAPTCHASecured by Super-CAPTCHA © 2009-2010 MLW & Associates, LLP. All rights reserved.