في بعض الحالات لا يتمكن مدير الموقع من تحديد ثغرة أمنية أو التعرف على البرمجيات الخبيثة malwares التي تعدّل على ملفات معينة. فيحتاج ولو بشكل مؤقت إلى تجميد بعض الملفات/المجلدات ومنعها من أي تغيير غير مصرح له فيضمن عمل الموقع بينما يتولى مواصلة فحصه، وهو ما يتم بتحويل العناصر المطلوبة إلى حالة immutable :

chattr +i -R public_html

لإلغائه:

chattr -i -R public_html

وبالإمكان استثناء مجلد معين بعد تجميد الجذر الرئيسي، مثل:

chattr -i -R public_html/uploads

أو ملف معين مثل:

chattr -i public_html/log.txt

كما بوسعه أيضا تحويل قاعدة البيانات إلى وضع القراءة وحصر الجهات والبيانات التي يتم الوصول وإليه.

An example of script to fetch for a text or file in all the cPanel accounts:

# Case of use for example: Looking for a plugin or a theme in each account with a specific path, useful in case of malwares or to estimate its impact, can be improved by looking in subfolders, subdomains and addon domains

keyword="elementor-pro"
path="public_html/wp-content/plugins"
declare -i i=0; # int

for f in /home/*; do
    if [ -d "$f/$path" ]; then
        ls "$f/$path" | grep -i "$keyword" && echo "== $f ==" && i=$i+1
    fi
done

echo "$i results found in total"

من المشاكل المسببة لتوقف المواقع بشكل متكرر أو بطئها: انحصار الموارد الحية (CPU/RAM) بحيث لا يقدر حسابكم أو خادمكم الخاص على معالجة طلبات أخرى بسبب امتلاء طابور أعماله الحالية وتحميله فوق طاقته مثل:

  • تزامن عدد كبير من الزيارات في آن واحد في حين أن خطة الاستضافة قد تتضمن ذاكرة حية بقدر 1G RAM و ربما نواة معالجة واحدة vCPU. مع موقع معقد برمجيا بحيث يتطلب توليد الصفحة الواحدة، موارد كبيرة قد تصل إلى ربع موارد كامل الحساب ما يحصر عدد الزيارات الممكنة في ذات الوقت.

وهو ما قد يترجم بأخطاء مثل HTTP 503 أو أخطاء الاتصال بقاعدة البيانات، لذلك تحتاجون لفحص على مستويات متعددة.Continue reading

صادفنا اليوم موقعا ناسخا يقوم آنيا بسحب صفحة المواقع وإعادة إرسالها عند كل طلب، اسم النطاق كان يستتر بـ Cloudflare كما أنه يعتمد عنوانا مختلفا عن سجلات DNS Records لخادمه.

الحل في هذه الحالة هو إنشاء ملف في الموقع يحوي الطلب التالي:

<?=$_SERVER['REMOTE_ADDR'];?>
وهو ما سيظهر لك عنوان آيبي الخادم الذي استدعى السكريبت. ويمكن حظره بعدها سواء من لوحة التحكم أو من خلال ملف htaccess بكتابة الأمر التالي أول الملف:
Deny from عنوان الآيبي السابق
قد يكون السبب لإجل التكسب من وراء الإعلانات بإعادة تغيير معرّفات الـ ads ونحوها. لكن الغريب في حالنا هذا أنه اسم نطاق باللاحقة .tk وهي لاحقة لا تحظى بالقبول على منصات محركات البحث ومنصات التواصل الاجتماعي ومواقع عدّة.

One of the most important functions used to debug executions and processes is strace.


However, It should be handled carefully when debugging an non trusted app.

An example of usage on a multi-tenant cPanel env is when a website is too slow as if it’s stuck at a specific stage (e.g. db connection or an external call):

/sbin/cagefs_enter_user $USERNAME strace -s 1024 -T php index.php

P.S.: We use cagefs command to isolate tenants and limit permissions

  /sbin/cagefs_enter_user $USERNAME "command"

WHM also provides a GUI strace tool on System Health > Process Manager.

Useful links:

Basic guide for using strace to diagnose software problems on Linux

How to strace cPanel or WHM processes


Specific URLs

Let’s taker as an example PHP when given parameters or when the URL is rewritten while the issue is specifically with these arguments at specific page (for example a WordPress page in which a plugin is invoked), here what I do is:

– Pass the parameters (e.g. $_GET & $_POST) manually in the index.php if I can identify the behavior.

– or Add a sleeping to the code or invoke it from another script, and then get the process ID (using for example ps) and apply the strace directly on the PID.

Enhancing strace effectiveness:

  • Filtering: Use strace filters to focus on specific system calls related to network activity, like connect, read, and write. This will reduce the output to relevant information, streamlining analysis.
  • Conditional tracing: Consider utilizing tools like stracetop or perf to capture system call data only when certain conditions are met (e.g., specific URL accessed). This further streamlines the data you need to analyze.