Bạn thường thấy trên mạng có share nhiều code đẹp và bạn tải về nghiên cứu, hoặc sử dụng. Nếu bạn sử dụng bạn băn khoăn không biết trong code đc share kia có Shell không? vậy làm sao để tìm ra nó trong 1 rừng file như vậy. Bình thường những file chứa Shell thường được mã hóa dạng: base64, có thể qua mặt được những Antivirut Ở tut này mình sẽ hướng dẫn các bạn tut tìm kiếm Shell trên host. Tut này khá đơn giản áp dụng cho tất cả code chạy php không riêng gì Joomla. Có thể Scan trên live hosting hay ở localhost đều được, miễn hỗ trợ chạy php. Đầu tiên là tải file đính kèm về giải nén và Up ngang hàng với file index.php. Hình 1 Foder: điền thư mục cần tìm, để mặc định nếu tìm kiếm hết root Keywork: Để nguyên nếu tìm Shell, hoặc điền key khác nếu muốn tìm chữ nào đó mà ko biết ở file nào Hình 2 Kết quả sau khi Scan, những file nào chứa key: base64 sẽ đc liệt kê màu đỏ Chúng ta nên kiểm tra từng file 1 bằng cách gõ trên trình duyệt. Ở đây như hình sau khi Scan tôi thấy file sukien/components/com_myblog/libraries/cgbin.php Tôi mở trình duyệt http://localhost/sukien/components/com_myblog/libraries/cgbin.php Hình 3 Sau khi chạy file : http://localhost/sukien/components/com_myblog/libraries/cgbin.php ồ hóa ra nó đây, tìm và xóa đi Các bạn nên check từng file đc liệt kê màu đỏ cho yên tâm, ko phải file nào đc liệt kê cũng là shell. Ngoài ra còn 1 số chức năng khác ở file này các bạn tự kiểm tra nhé. Chúc các bạn thành công Download
Mình không biết các bạn lỗi ntn, mình đã test = cách up lên host --> chạy tốt. Cài appserv 2.5.10 làm localhost test code --> test trên cái này chạy tốt. Trong 1 số trường hợp thì server, localhost của các bạn bật chế độ báo lỗi (Trong Joomla khuyên tắt) Bạn có thể coppy code phía dưới mình đã fix để các bạn chạy trên những server khó tính, Nhớ lưu lại dưới dạng tenfil.php nhé (Dùng notepad ++ hoặc EditPlust cho nó không có lỗi nhé) PHP: <?php /*********************************************************- Tool Scan shell vesion 1.0- Code by KID- Edit by : www.joomlaviet.vn**********************************************************/error_reporting (E_ALL); // Mở báo lỗiini_set("memory_limit","2000M");ini_set("safe_mode","off");$safe_mode = @ini_get('safe_mode');if (!$safe_mode)set_time_limit(0);if (@!isset($_POST['key'])){?><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Scan Shell v1.1</title><style>body {font-family:arial;}</style></head><body bgcolor=black text=blue size=2><center><form method='post' action=''><div style="border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px"><h1>Scan Shell - v1.1</h1> <div> Folder: <input type='text' size=70 name='folder' value='<?echo $_SERVER['DOCUMENT_ROOT']?>/'/></div> <div> KeyWord: <input type='text' size=70 name='key' value='base64_decode'/></div> <p><input type='submit' name='submit' value='Tìm kiếm' /></p> </div> <div align=left><br>Step 1: Nhập đường dẫn thư mục cần scan</div> <div align=left>Step 2: Nhập từ khóa cần tìm</div> </form> <br><br>---------------------------------------------------------------------------------<br><br><i>Power By <a href="http://joomlaviet.vn"><font color=red>Joomla Việt</font></a><br>Copyright 2012<a href="http://diendan.joomlaviet.vn"><font color=yellow>Diễn Đàn Joomla Việt</font></a><br/><br>---------------------------------------------------------------------------------</center> </body></html> <?}else{if ($_POST['folder']) $folder = $_POST['folder']; else $folder = $_SERVER['DOCUMENT_ROOT'];define('Keyword',$_POST['key']); // Tìm kiếm từ khóadefine('TAB'," "); define('IGNORE_EXTENSIONS',"jpg pdf zip psd doc gif swf xls gz txt"); // Không tìm những filedefine("MAX_SIZE",1024*1024*1024); // Size tối đadefine("IGNORE_BEFORE", strtotime('2009-08-01') ); // Tìm File trước ngày$shell = $_SERVER["PHP_SELF"]; function findexts($filename){ $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return strtolower($exts);} function check_dir($directory,$level) { global $virus_detected, $all, $detect_errors_only, $detected_Keyword_in_test_script; $indent=''; for ($count=0;$count<$level;$count++) { $indent.=TAB; } $level++; $read_dir=opendir($directory); // Mở thư mục hiện tại while ($file=readdir($read_dir)) { $filepath=$directory.'/'.$file; if ($detect_errors_only && $virus_detected) { exit; } if (is_dir($filepath)) { // Thư mục if ( ($file<>'.') && ($file<>'..') ) { check_dir($filepath,$level); } } else { if (is_file($filepath)) { // Tập if ( (is_readable($filepath) ) && (!stristr(IGNORE_EXTENSIONS, findexts($file))) ) { if ((filesize($filepath)< MAX_SIZE) && (filemtime($filepath)>IGNORE_BEFORE) ){ $fileentry=$directory.'/'.$file.' - '.date('j F Y H:i',filemtime($filepath)); $filestring=file_get_contents($filepath); $found=stripos($filestring,Keyword); // PHP 5 ONLY $found=stristr($filestring,Keyword);flush(); if ($found==false) { if ( (!$detect_errors_only) && (!$all) ) { echo($filepath.' <font color=#FFFFFF>OK</font><br/>'); } } else { if ($file=='scan_file.php'){ $detected_Keyword_in_test_script=true; } else { $virus_detected=true; if ($detect_errors_only) { echo('<b style="color:#F00">Tập tin đề nghị phát hiện</b><br/>'); } else { echo(TAB.'<b style="color:#F00">'.$fileentry.'</b> - <b style="color:#FFFFF0">Phát hiện</b><br/>'); } } } $found=''; } else { if ( (!$detect_errors_only) && (!$all) ) { echo($filepath.' <b style="color:yellow">NOT CHECKED - File quá lớn</b><br/>'); } } } else { if ( (!$detect_errors_only) && (!$all) ) { echo($filepath.' <b style="color:yellow">NOT CHECKED - Không thuộc kiểu tìm kiếm</b><br/>'); } } } else { } } } closedir($read_dir);} $virus_detected=false;$all=true;$detect_errors_only=false;$detected_Keyword_in_test_script=false;if (isset($_GET['all'])) { $all=false;}if (isset($_GET['detect_errors_only'])) { $detect_errors_only=true;} echo<<<END1<html><head><title>Scan Shell v1.1</title><style>body {font-family:arial;}</style></head><body bgcolor=black text=blue size=2>END1;?><div style="border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px"><h1>Truy xuất từ khóa "<?echo Keyword?>" trong hệ thống !</h1>Bỏ qua lỗi file : <font color=yellow><?echo IGNORE_EXTENSIONS?>.</font><br/>Bỏ qua file vượt quá : <font color=yellow><?echo MAX_SIZE?> bytes.</font><br/>Tìm kiếm file trước ngày :<font color=yellow> <?echo date('j F Y',IGNORE_BEFORE)?>.</font><br/><br></div><br/><br>[<a href="<?echo $shell?>?all">Hiển thị tất cả?</a>]<br/><br/> <br/><? if ($all) { echo('<font color=yellow>List File</font><br/>');}check_dir($folder,0); if ($virus_detected) { echo('<br/><b style="color:#f00">Tìm kiếm thành công!</b><br> <br/>');}else {echo('<br/><b style="color:#f00">Không có file chứa Key Word!</b><br> <br/>');} ?></body></html><?}?>
Tại sao vẫn không được nhỉ? Trong file download thì dòng 188 là: ?><? Mình đã sửa lại thành ?> giống như code bạn vừa up lại. Vẫn lỗi Parse error: syntax error, unexpected $end in D:\xxx\scan.php on line 188
Bạn có thể nói rõ hơn tắt như thế nào không? File scan này chạy trên host thì ok nhưng chạy trên localhost nó báo lỗi
cái này theo mình nghĩ cái server bạn đang sài ko hiểu được <?, bạn thử sửa các <? thành <?php xem sao nha
Sau khi quet phát hiện: C:\\AppServ\\www\\cobang\\templates\\zt_opis25/html/com_k2/templates/zootemplate/item.php - 4 February 2012 15:00 - Phát hiện mở file lên thấy đoạn này khong biết phải không:
Các bạn nên check từng file đc liệt kê màu đỏ cho yên tâm, ko phải file nào đc liệt kê cũng là shell. Nếu trong file có đoạn code mã hóa, bạn hãy thử bỏ đoạn mã hóa và chạy thử xem có vấn đề gì không, nhớ coppy 1 file gốc ra phòng trường hợp bị sao đó còn add lại
down về giai nén ra thì đc 1 file scan.php, mình up lên host trong folder public_html ngang hàng với file index.php rồi làm sao nữa các bạn? tks
lúc tìm xong mình copy link và vào thì lại báo: "Direct Accessssssssssss to this location is not allowed." có file thì là "Restricted access" là sao nhỉ?