วิธีการเขียน Script ตรวจสอบ Server Performance สำหรับเครื่อง Windows 2008 R2

ขอนำเสนอ Powershell Script สำหรับใช้ Monitor Server Performance สำหรับเครื่อง Windows 2008 R2 ขึ้นไปดังนี้ การติดตั้ง PowerShell Editor และ วิธีใช้งานบน Windows 2008 1. ติดตั้งโดยไปที่ Server Manager -> Features -> Add Features 2. เลือกหัวข้อ Windows PowerShell Integrated Script Environment (ISE) 3. ให้เลือกใช้งาน Version X86 ซึ่งเมื่อลงแล้ว Icon จะอยู่ที่ Accessories -> Windows PowerShell -> Windows PowerShell ISE (x86) คำสั่งในการเปิด Execution Policy Set-ExecutionPolicyUnrestricted -Force การสร้าง Loop เพื่อให้สามารถรันได้ตลอดเวลา While($true){ …..[Monitor Script]….. } คำสั่งตรวจหา IP ของ Server Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.Description -eq “Intel(R) Dual Band Wireless-N 7260” } | ForEach-Object { $ipaddr = $_.IPAddress } $ip = $ipaddr[0] คำสั่งตรวจสอบ Max CPU Clock Speed Get-WmiObject-class win32_processor -Property  “maxclockspeed” | ForEach-Object {$clockspeed = $_.maxclockspeed } Get-WmiObject-class win32_computersystem -Property “NumberOfLogicalProcessors” | ForEach-Object { $lprocessor = $_.NumberOfLogicalProcessors } $sumclockspeed = $clockspeed*$lprocessor คำสั่งตรวจสอบ Current CPU (Get-Counter “\Processor(_Total)\% Processor Time”).CounterSamples | ForEach-Object {$cpuuse = $_.CookedValue}     $cpuuse = [math]::round($cpuuse,0)     $clockspeed = ($cpuuse*$sumclockspeed)/100     $clockspeed = [math]::round($clockspeed,0)     $pcpuuse = $clockspeed/$sumclockspeed     $pcpuuse = [math]::round($pcpuuse,0) คำสั่งตรวจสอบ Maximum Memory $sumram = 0 Get-WMIObject-class win32_physicalmemory -Property “Capacity”  | ForEach-Object { $sumram = $sumram + $_.Capacity} $sumram = $sumram/(1024*1024) คำสั่งตรวจสอบ Current Memory (Get-Counter “\Memory\Available MBytes”).CounterSamples | ForEach-Object {$memfree = $_.CookedValue}     $memuse = $sumram-$memfree;     $pmemuse = ($memuse/$sumram)*100     $pmemuse = [math]::round($pmemuse,0) คำสั่งตรวจสอบ Connection  $netstat = “netstat

Read More »

แนะนำ ffDiaporama โปรแกรมนำภาพถ่ายมาทำภาพยนตร์ (Movie creator)

แนะนำ ffDiaporama โปรแกรมนำภาพถ่ายมาทำภาพยนตร์ (Movie creator) Movie creator from photos and video clips with ffDiaporama ตัวอย่าง http://ftp.psu.ac.th/pub/cc/2557cop1/ccadmintour2014.mp4 (392M) โปรแกรม ffDiaporama เป็นโปรแกรมทำภาพยนตร์จากภาพถ่ายและคลิปวิดีโอ มีทั้งเวอร์ชั่นที่ใช้งานบน linux และ Windows มีเว็บไซต์อยู่ที่นี่ URL: http://ffdiaporama.tuxfamily.org/ โดยทั่วไปวิธีติดตั้งโปรแกรมเพิ่มใน linux mint คือ เลือก Menu > Software Manager แต่โปรแกรม ffDiaporama นั้นมันเป็นเวอร์ชั่น 1.5 ซึ่งยังขาดความสามารถในการแปลง (render) จัดได้ว่ามันไม่ทันสมัย (outdated!) จึงจำเป็นต้องติดตั้งด้วยวิธี command line จากเว็บไซต์ของผู้พัฒนาโปรแกรมโดยตรง (Launchpad on the ffDiaporama-stable PPA) ทำคำสั่งนี้เพื่อเพิ่มชื่อ server ต้นทางที่เก็บโปรแกรม sudo add-apt-repository ppa:ffdiaporamateam/stable จะได้ผลลัพธ์แบบนี้ mint@mint-PSU ~ $ sudo add-apt-repository ppa:ffdiaporamateam/stable You are about to add the following PPA to your system: This PPA supplies stable packages of ffDiaporama 2.1 For more information on ffDiaporama see : http://ffdiaporama.tuxfamily.org More info: https://launchpad.net/~ffdiaporamateam/+archive/stable Press [ENTER] to continue or ctrl-c to cancel adding it เมื่อกด Enter แล้วจะได้แบบนี้ Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –homedir /tmp/tmp.JiNHX5a3T2 –no-auto-check-trustdb –trust-model always –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 77296259 gpg: requesting key 77296259 from hkp server keyserver.ubuntu.com gpg: key 77296259: public key “Launchpad PPA for ffDiaporama Team” imported gpg: Total number processed: 1 gpg:               imported: 1  (RSA: 1) สั่งอัปเดตรายการซอฟต์แวร์ sudo apt-get update ติดตั้งโปรแกรม sudo apt-get install ffdiaporama จะได้ผลลัพธ์แบบนี้ mint@mint-PSU ~ $ sudo apt-get install ffdiaporama Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: ffdiaporama-data libqimageblitz4 Use ‘apt-get autoremove’

Read More »

วิธีตรวจสอบเว็บไซต์ที่โดน Hack #15

จาก วิธีตรวจสอบเว็บไซต์ที่โดน Hack #7 : การตรวจสอบ Windows Server ที่ถูก Hack ด้วย PowerShell ซึ่งเป็นกระบวนการตรวจสอบ Windows Server ซึ่งโดนเจาะด้วยช่องโหว่ JCE ของ Joomla ก็มีคนถามว่า จะมีกระบวนการแก้ไขป้องกัน เหมือนกับที่ทำกับ Apache ซึ่งแสดงใน วิธีตรวจสอบเว็บไซต์ที่โดน Hack #12 : เทคนิคการตั้งค่า Apache Web Server เพื่อให้ปลอดภัยจากช่องโหว่ ตอนนี้มีคำตอบแล้วครับ เทคนิคนี้ ใช้ผ่าน Internet Information Services (IIS) Manager โดยการแก้ไข Request Filtering ในระดับ Web Server เลย โดยดำเนินการตามวิธีการต่อไปนี้ เรียก Command ด้วย การกดปุ่ม Windows + R แล้ว พิมพ์ inetmgr แล้วกดปุ่ม Enter คลิกเว็บเซิร์ฟเวอร์ของเครื่องที่ต้องการใน Connection Tab (ตัวอย่างในภาพ คลิกที่ WUNCAWEBSEC) ต่อไป ภายใต้หัวข้อ IIS ให้ Double-Click ที่ Request Filtering คลิกที่ Rules tab เพิ่มกฏสำหรับ JCE Bot ซึ่ง ไม่ต้องการให้ PHP ทำงานภายใต้ URL ซึ่งมีข้อความว่า “images/stories” โดย ไปที่ Action ด้านขวามือ แล้ว คลิกที่ Add Filtering Rules … แล้วใส่ข้อมูลตามภาพ แล้วคลิกปุ่ม OK เพิ่มกฏสำหรับ Upload โฟลเดอร์ ซึ่ง ไม่ต้องการให้ PHP ทำงานภายใต้ URL ซึ่งมีข้อความว่า “upload” โดย ไปที่ Action ด้านขวามือ แล้ว คลิกที่ Add Filtering Rules … แล้วใส่ข้อมูลตามภาพ แล้วคลิกปุ่ม OK ผลที่ได้ใน Rules tab ทดสอบผลการทำงาน สมมุติเดิมโดนวางไฟล์ Backdoor ไว้ที่ http://localhost/corin/images/stories/backdoor.php แต่เมื่อตั้ง Rules ดังกล่าวแล้ว จะทำให้ Hacker ไม่สามารถเรียกใช้งาน PHP ที่วางไว้ใน images/stories ได้ โดยจะได้ Error เช่นนี้ วิธีนี้มีข้อดีคือ สามารถป้องกันการใช้งาน PHP ใน images/stories (และใน upload โฟลเดอร์) แต่ยังสามารถเรียกไฟล์ภาพและไฟล์อื่นๆได้ตามปรกติ เช่น http://localhost/corin/images/stories/clownspin.gif ลองใช้งานดูครับ 😉

Read More »