ماهية و تعرف المجلد المراد اعلاه تعتمد على تعريفه و هيا TEMPRORY MULTI PROCCESS
و هيا الية تعدد العمليات المؤقته اي بمعنى العمليات المجملة بالسيرفر سواء كانت بالمواقع او بالسيرف و لكي يتم حمايها من اي استخدام باطل يتم من خلاله استغلال ما او تنفيد استعلامات معينه تودي بضرورة الحال الى اختراق السيرفر او المواقع ينبغي عليك معرفة بان حظر الاستعلامات الداخليه و التي تخرج عن نطاق الموقع اي بمعنى خروجها عن نطاق اللوكال هوست و الاباتشي يعني سيطرتها على مجرى الاحداث التي تحدث بالسيرفر و التي من الممكن استغلالها و هيا كما جرى في احد المواضيع التي تم نشرها مؤخرا بوجود بوفير فلوو على السيرفر تمكن المتطفل من الحصول على الروت بكل سهولة من التيمب و التي جل ما يقوم بها المتطفل للوصول الى غايته
* كيف يمكننا حماية هذا المجلد والزام المتطفل و الزائر و صاحب الموقع من استخدام اوامر اخر للوصول الى خدماته دو المساس بمقتدرات الخادم و عدم تمكينه من الوصول الى الخادم و اختراقه؟
يجب عليك اولا و لا اعتقد بوجود مشكلة بالنسبة للسيرفرات التي تعمل بالوقت الحالية و انما من الافضل تطبيق هذا الشرح اولا
بسم الله كود PHP:
[root@antg ~]# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
[root@antg ~]# pstree -p | grep tailwatchd
Find the tailwatchd process id and kill it
[root@antg ~]# kill -9 2522
2) Take a backup of /tmp as /tmp.bak
[root@localhost ~]#cp -prf /tmp /tmp.bak
3) Create a 2GB file in the avaliable freespace
[root@antg ~]# dd if=/dev/zero of=/usr/tmpDSK bs=1024k count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 73.6908 seconds, 29.1 MB/s
[root@antg ~]# du -sch /usr/tmpDSK
2.1G /usr/tmpDSK
2.1G total
4) Assign ext3 filesystem to the file
[root@antg ~]# mkfs -t ext3 /usr/tmpDSK
mke2fs 1.39 (29-May-2006)
/usr/tmpDSK is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
262144 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5) Check the file system type:-
[root@antg ~]# file /usr/tmpDSK
/usr/tmpDSK: Linux rev 1.0 ext3 filesystem data (large files)
Note:-
You may also use the following comands for making ext3 file system on a file:
[root@antg ~]# mkfs.ext3 /usr/tmpDSK
[root@antg ~]# mke2fs /usr/tmpDSK
6) Unmount /tmp partition
[root@antg ~]# umount /tmp
7) Mount the new /tmp filesystem with noexec
[root@antg ~]# mount -o loop,noexec,nosuid,rw /usr/tmpDSK /tmp
8) Set the correct permission for /tmp
[root@antg ~]# install -d –mode=1373 /tmp
[root@antg ~]# ls -ld /tmp
drwxrwxrwt 3 root root 4096 Feb 6 08:42 /tmp
( you may use the command chmod 1373 /tmp for doing the same )
[root@antg ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 28G 6.4G 20G 25% /
/dev/sda8 99M 10M 84M 11% /boot
tmpfs 500M 0 500M 0% /dev/shm
/usr/tmpDSK 2.0G 68M 1.9G 4% /tmp
7)Restore the content of old /tmp.bkp directory
[root@antg ~]# cp -rpf /tmp.bak/* /tmp
8) Restart the mysql and tailwathchd services.
[root@antg ~]# /etc/init.d/mysql start
[root@antg ~]# /scripts/restartsrv_tailwatchd
9)Edit the fstab and replace /tmp entry line with :-
/usr/tmpDSK /tmp ext3 loop,noexec,nosuid,rw 0 0
10) Mount all filesystems
[root@antg ~]# mount -a
Check it now:-
[root@antg ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 28G 6.4G 20G 25% /
/dev/sda8 99M 10M 84M 11% /boot
tmpfs 500M 0 500M 0% /dev/shm
/usr/tmpDSK 2.0G 68M 1.9G 4% /tmp
الدرس هوا عبارة عن زيادة حجم التيمب و لكن لضيق الوقت لم يتسنىلي اضافة اكواد معينه لعمل التصفيه و العمل من جدي بشكل مفصل لهذا العمل و انما يعتبر العمل متقارب بنسبة 99 بالمئة و لكن الفرق هوا بين اعادة تصفية المجلد من ملفاته و بين زيادة حجمه ... هذا هوا الفرق فقط
اما بالنسبة للغاية فهيا وحده
فبمجرد تغير التصريح و اعداده بالشكل الصحيح بشرط مسح جميع الاوامر الداخليه امجلد يعتبر المجلد محميا من الاستغلال و هوا يصبح الموقع معتمدا على مجلد يتم انشائة بشكل اوتوماتيكيا داخل حدود الموقع و يعتبر محصورآ باوامره الداخليه في مساحته و موقعه
للاستفسارات ارجو راسلتي الى
aalsaery@kau.edu.sa
دمتم بخير
مواقع النشر (المفضلة)