หน้าเว็บ

วันอังคารที่ 28 สิงหาคม พ.ศ. 2555

แนะนำโครงสร้างไดเรกเทอรี่ของ Linux



/

/ เรียกว่า root partition ไฟล์และไดเรกเทอรี่ทั้งหมดจะเริ่มต้นจาก root partition สิทธิ์ในการเขียนภายในไดเรกเทอรี่นี้ใช้ได้กับผู้ใช้ root เท่านั้น

/bin

ไดเรกเทอรี่นี้มีไฟล์ไบนารี่อยู่ คำสั่ง linux ที่ใช้ใน user เพียงคนเดียวจะเจอในไดเรกเทอรี่นี้ นอกจากนี้ยังมีคำสั่งที่ผู้ใช้ทั้งหมดใช้ด้วยเช่นคำสั่ง ls, ping, cp

/sbin

คล้ายกับ /bin นอกจากนี้จะมีไฟล์ไบนารี่อยุู่เช่นเดียวกับ /bin แต่คำสั่งในไดเรกเทอรี่นี้ จะถูกใช้โดยผู้ดูแลระบบ มีวัตถุประสงค์เพื่อบำรังรักษาระบบเช่นคำสั่ง iptables, reboot, fdisk

/etc

เป็นไดเรกเทอรี่ที่เก็บไฟล์ที่ไว้กำหนดค่า ตั้งค่าโปรแกรมทั้งหมด โดยที่ Shell scripts จำเป็นต้องมีโปรแกรมที่จะเริ่มหรือหยุด scripts นั้นๆ ตัวอย่างเช่น /etc/resolv.conf, /etc/logrotate.conf

/dev

ประกอบด้วยแฟ้มอุปกรณ์ใน linux รวมถึงอุปกรณ์ USB หรืออุปกรณ์อื่นๆที่มีการเชื่อมต่อกับเครื่องคอมพิวเตอร์ ตัวอย่างเช่น /dev/usbmon0

/proc

ข้อมูลทั้งหมดที่ process ของระบบจะเกิดขึ้นภายใน /proc เป็นแฟ้มที่มีข้อมูลเกี่ยวกับ process การทำงาน ยกตัวอย่างเช่น /proc เป็นไดเรกเทอรี่ที่เก็บข้อมูลของ process มีข้อมูลเกี่ยวกับทรัพยากรของระบบ /proc/uptime เป็นหนึ่งในไดเรกเทอรี่ในนี้

/var

var หมายถึงไฟล์ที่เปลี่ยนแปลงค่าได้ ไฟล์เหล่านั้นจะถูกเก็บไว้ในไดเรกทอรีนี้ที่มีการปรับเปลี่ยนตลอด บางไฟล์ที่อยู่ในที่นี่เป็น /var/log (log ไฟล์ระบบ) /var/lib (แฟ้มแพคเกจ), /var/mail (อีเมล), /var/spool (คิวการพิมพ์), / var/tmp (แฟ้มชั่วคราว)

/tmp

ตัวระบบเองจะสร้างไฟล์ชั่วคราวที่ผู้ใช้ใช้งานเก็บไว้ในนี้ ไฟล์ที่สำคัญไม่ควรเก็บไว้ในนี้เพราะไฟล์ใน /tmp จะถูกลบออกทุกครั้งหลังปิดเครื่อง

/usr

/usr ไฟล์ต่างๆของผู้ใช้จะถูกเก็บไว้ในนี้ หรือโปรแกรมที่ผู้ใช้ลงก็จะถูกเก็บไว้ในนี้เช่นกัน

/home

ไฟล์ส่วนตัวของผู้ใช้ทุกคนจะถูกเก็บไว้ใน home ไดเรกเทอรี่ภายใต้ชื่อของผู้ใช้

/boot

ไดเรกเทอรี่นี้เก็บไฟล์ที่จำเป็นและสำคัญใช้ในการ boot ระบบ ในขณะที่ boot ระบบจะเข้าไปหาไฟล์ใน /boot ซึ้งมีไม่กี่ไฟล์ที่จะอยู่ในไดเรกเทอรี่นี้

/lib

ไฟล์ไบนารี่ที่อยู่ใน /bin และ /sbin จะได้รับการสนับสนุนโดยไฟล์ที่อยู่ใน /lib เป็นที่เก็บแพคเกจไฟล์

/opt

เป็นไดเรกเทอรี่ที่ใช้เก็บ add-on ที่ใช้งาน จะถูกติดตั้งใน /opt หรือไดเรกเทอรี่ย่อย

/mnt

เป็นไดเรกเทอรี่ mount มันเป็นที่เก็บไฟล์ mount ชั่วคราว เป็นที่ที่ admin สามารถ mount ไฟล์ได้ชั่วคราว

/media

/media ทำหน้าที่เป็นจุดเชื่อมต่อชั่วคราวสำหรับอุปกรณ์ที่เชื่อมต่อประเภท Removable Drive ไดร์ฟที่ถอดออกได้ ไดร์ฟที่ถอดออกได้ทั้งหมดจะอยู่ในไดเรกเทอรี่นี้ ตัวอย่างเช่น /media/cdrom หรือ /media/floppy

/srv

srv หมายถึงบริการ ข้อมูลทั้งหมดที่เกี่ยวข้องกับการใช้บริการสำหรับเซิฟเวอร์จะถูกบันทึกไว้ที่ไดเรกเทอรี่นี้

วันอาทิตย์ที่ 26 สิงหาคม พ.ศ. 2555

Safely remove hardware on Ubuntu with Ejecter.



          เนื่องจากผมมีปัญหากับการถอดไดร์ฟ External HDD ออกบน Ubuntu แล้วทำให้เครื่องค้าง เลยหาโปรแกรมที่ช่วยถอดไดร์ฟ วันนี้เลยจะมาแนะนำโปรแกรมสำหรับถอดไดร์ฟออกอย่างปลอดภัยคือ Ejecter (application to unmount easily and safely external devices) นั่นเอง ถ้ามีโปรแกรมที่รันอยู่บน external devices แล้วเราต้องการถอดออกมันจะเตือนดังรูป..



          วิธีติดตั้งก็ง่ายมากๆ เข้า Ubuntu Software Center แล้วพิมพ์ ejecter แล้วเลือกเลยครับ จากนั้นกด Install เลยครับ พอลงเสร็จก็ restart เครื่องซักครั้ง เท่านั้นก็เสร็จครับ...

Source : https://launchpad.net/ejecter/

วันศุกร์ที่ 17 สิงหาคม พ.ศ. 2555

Search String in Files on Directory and Subdirectory [ Perl ]



use File::Find;

print "\n\n\t### Search String in Files on Directory and Subdirectory By ICheer_No0M ###\n\n";
print 'Path File : ';
chomp($path=<stdin>);
print 'Search Keyword : ';
chomp($string=<stdin>);
$keyword  = AddSlashes($string);
find(\&file_names, $path);
sub file_names {
 if($_ =~ /\.php$/){
  $file = $File::Find::name;
  open (MYFILE, $file);
  $line = 1;
   while (<MYFILE>) {
   $content .= $_;
   if($content=~/$keyword/){
     print "\nFound : $string\n";
    print "On Line : $line\n";
    print "On File : $file\n";
   }
  $line += 1;
  $content = "";
  }
  close (MYFILE);
 }
}
print "\n\n\t### Finding $string on $path Complete... ###\n\n";

sub AddSlashes {
    $text = $_[0];
    $text =~ s/\\/\\\\/g;
    $text =~ s/\$/\\\$/g;
    $text =~ s/\'/\\'/g;
    $text =~ s/\"/\\\"/g;
    $text =~ s/\[/\\[/g;
    $text =~ s/\]/\\\]/g;
    $text =~ s/\(/\\(/g;
    $text =~ s/\)/\\\)/g;
    $text =~ s/\\0/\\\\0/g;
    return $text;
}

เจอบักก็แก้เอานะครับ ตอนแรกจะไม่ปล่อย เขียนลวกๆ เอาไว้ใช้เอง เก๋ๆ เลียนแบบ grep #กะไว้ใช้ใน windows ด้วย
$ find /var/www/exploit -name "*.php" -exec grep -l "base64" {} \;

วันพฤหัสบดีที่ 16 สิงหาคม พ.ศ. 2555

MobileCartly 1.0 Remote File Upload Vulnerability


ไฟล์ logo-upload-process.php น่าจะเขียนผิดตรง $_SERVER['DOCUMENT_ROOT'] . "/appcode/ <-- ต้องแก้จาก 
$_SERVER['DOCUMENT_ROOT'] . "/appcode/images/logo/" . $_FILES["logo-upload"]["name"]);
ไปเป็น
"../images/logo/" . $_FILES["logo-upload"]["name"]);
ถึงจะใช้งานไฟล์ logo-upload.php ได้ #MobileCartly


# Exploit Title: MobileCartly 1.0 Remote File Upload Vulnerability
# Google Dork: -
# Date: 14/08/2012
# Exploit Author: ICheer_No0M
# Vendor Homepage: http://icheernoom.blogspot.com/
# Software Link: http://mobilecartly.com/mobilecartly.zip
# Version: 1.0
# Tested on: Ubuntu 10.10 + PHP 5.3.3
#
#
# 1. Vuln Code : /images/uploadprocess.php
#
#   /*$zip = new ZipArchive; 
#   $zip->open($_FILES['uploadedfile']['tmp_name']); 
#   $zip->extractTo('productimages/'); 
#   $zip->close(); */
#
#  You can upload shell.php on /images/upload.php 
#  Find your shell on /images/productimages/shell.php
#
#
# 2. Vuln Code : /includes/logo-upload-process.php
#
# /*if (($_FILES["logo-upload"]["type"] == "image/gif") 
# || ($_FILES["logo-upload"]["type"] == "image/jpeg") 
# || ($_FILES["logo-upload"]["type"] == "image/pjpeg")
# && ($_FILES["logo-upload"]["size"] < 20000))*/
#
# You can upload shell on /includes/upload-logo.php and edit header values.
# Find your shell on /images/logo/shell.php
#
#

http://www.exploit-db.com/exploits/20539/