[align=LEFT][align=CENTER]FTP Shell[/align]
[php]
<!--
FTP Shell
Written by darkjoker
--!>
<html>
<head>
<title>
FTP Shell ~ Written by darkjoker
</title>
</head>
<body>
<style type="text/css">
body{
background: #242424;
color: #DDDDDD;
font-family: Verdana;
font-size: 11px;
}
a:link{
text-decoration: none;
color: #3366FF;
}
a:visited{
text-decoration: none;
color: #3366FF;
}
a:hover{
text-decoration: none;
Color: #CCFFFF;
}
table {
font-size: 11px;
}
i {
Color: #FF0000;
}
input{
margin: 0;
font-family: Verdana;
background: #DDDDDD;
padding: 2px 3px;
color: #242424;
border: 1px solid #DADADA;
}
</style>
<?
error_reporting (0);
set_time_limit (0);
function ftp_is_dir ($connect, $current, $file)
{
if (ftp_chdir ($connect, $current . $file))
{
ftp_chdir ($connect, "..");
return true;
}
else
{
return false;
}
}
list ($page) = explode ("?", htmlentities ($_SERVER ['PHP_SELF']));
$current = $_GET ['pwd'];
if (empty ($current))
$current = "/";
$page .= "?pwd={$current}";
$hostname = htmlentities ($_COOKIE ['_hostname']);
$username = htmlentities ($_COOKIE ['_username']);
$password = base64_decode ($_COOKIE ['_password']);
if ((empty ($hostname)) || (empty ($username)) || (empty ($password)))
{
$hostname = $_POST ['hostname'];
$username = $_POST ['username'];
$password = base64_encode ($_POST ['password']);
if ((empty ($hostname)) || (empty ($username)) || (empty ($password)))
{
echo
"<table><form method = 'POST'>\n".
"<tr><td>Hostname:</td><td><input name = 'hostname'></td></tr>\n".
"<tr><td>Username:</td><td><input name = 'username'></td></tr>\n".
"<tr><td>Password:</td><td><input name = 'password' type = 'password'></td></tr>\n".
"<tr><td><input value = 'Login' type = 'submit'></td></tr>\n".
"</form></table>";
}
else
{
setcookie ("_hostname", $hostname);
setcookie ("_username", $username);
setcookie ("_password", base64_encode ($password));
header ("Location: {$page}");
}
}
else
{
$connect = ftp_connect ($hostname);
(!$connect) ? die ("Unable to connect to {$hostname}.") : $a = 0;
$login = ftp_login ($connect, $username, $password);
(!$login) ? die ("Username/password wrong.") : $a = 0;
ftp_chdir ($connect, $current);
echo "Hostname: {$hostname}<br>\n".
"Logged as: {$username} (<a href = '{$page}&mode=logout'>logout</a>)<br>\n".
"System: " . ftp_systype ($connect) . "<br>\n".
"Current directory: " . ftp_pwd ($connect) . "<pre>\n\n</pre>\n".
"<b>Upload:</b><br>\n".
"<table>\n".
"<form action = '{$page}&mode=up' method = 'POST' ENCTYPE='multipart/form-data'>\n".
"<tr><td>Local file:</td><td><input name = 'local' type = 'file'></td></tr>\n".
"<tr><td>Remote file:</td><td><input size = 16 name = 'remote'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Upload'></td></tr>\n".
"</form></table><pre>\n\n</pre>\n".
"<b>Make new directory</b><br><table>\n".
"<form action = '{$page}&mode=mkdir' method = 'POST'>\n".
"<tr><td>New name:</td><td><input size = 17 name = 'new_dir'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Create'></td></tr>\n".
"</form></table><pre>\n\n</pre>\n".
"<b>Run command</b><br><table>\n".
"<form action = '{$page}&mode=cmd' method = 'POST'>\n".
"<tr><td>Command:</td><td><input size = 17 name = 'cmd'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Run'></td></tr>\n".
"<form></table><p>\n";
$mode = $_GET ['mode'];
switch ($mode)
{
case 'chdir':
$new = $_GET ['new'];
if (ftp_chdir ($connect, $new))
{
list ($page) = explode ("?", $page);
if ($new == '..')
{
$dirs = explode ("/", $current);
array_pop ($dirs);
array_pop ($dirs);
$dirs = "/" . join ("", $dirs);
(strlen ($dirs) > 1) ? $dirs .= "/" : $a = 0;
header ("Location: {$page}?pwd={$dirs}");
}
else
header ("Location: {$page}?pwd={$current}{$new}/");
}
else
echo "<i>Unable to change directory.</i><p>";
break;
case 'rmdir':
$dir = $_GET ['dir'];
if (ftp_rmdir ($connect, $current . $dir))
echo "<i>Directory removed successfully.</i><p>";
else
echo "<i>Unable to remove directory.</i><p>";
break;
case 'rename':
$old = htmlentities ($_GET ['old']);
$new = $_POST ['new'];
if (empty ($new))
echo
"<b>Rename</b><br>\n".
"<table><form action = '{$page}&mode=rename&old={$old}' method = 'POST'>\n".
"<tr><td>New name/location</td><td><input name = 'new'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Rename/Move'></td></tr>\n".
"</form></table>\n";
else
{
if (ftp_rename ($connect, $old, $new))
echo "<i>File/Directory renamed/moved successfully.</i><p>";
else
echo "<i>Unable to rename/move file/directory.</i><p>";
}
break;
case 'chmod':
$file = htmlentities ($_GET ['file']);
$perm = $_POST ['perm'];
if ((empty ($perm)) || (!is_numeric ($perm)))
echo
"<b>Change permissions</b><br>\n".
"<table><form action = '{$page}&mode=chmod&file={$file}' method = 'POST'>".
"<tr><td>Permission:</td><td><input name = 'perm'></td></tr>".
"<tr><td><input type = 'submit' value = 'Change permissions'</td></tr>".
"</form></table>";
else
{
if (ftp_chmod ($connect, $perm, $file))
echo "<i>File permissions changed successfully.</i><p>";
else
echo "<i>Unable to change file permissions.</i><p>";
}
break;
case 'rm':
$file = $_GET ['file'];
if (ftp_delete ($connect, $file))
echo "<i>File removed successfully.</i><p>";
else
echo "<i>Unable to remove file.</i><p>";
break;
case 'dwn':
$remote = htmlentities ($_GET ['remote']);
$local = $_POST ['local'];
if (empty ($local))
echo
"<b>Download</b><br>\n".
"<table><form action = '{$page}&mode=dwn&remote={$remote}' method = 'POST'>\n".
"<tr><td>Local file:</td><td><input name = 'local'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Download'></td></tr></form></table>";
else
{
if (ftp_get ($connect, $local, $remote, FTP_ASCII))
echo "<i>File downloaded successfully.</i><p>";
else
echo "<i>Unable to download file.</i><p>";
}
break;
case 'up':
$remote = $_POST ['remote'];
$local = $_FILES['local']['tmp_name'];
$file = basename($_FILES['local']['name']);
if(move_uploaded_file($local,$file))
{
if (ftp_put ($connect, $remote, $file, FTP_ASCII))
{
echo "<i>File uploaded successfully.</i><p>";
unlink ($file);
}
else
echo "<i>Unable to upload file.</i><p>";
unlink ($local);
}
else
echo "<i>Unable to upload file.</i><p>\n";
break;
case 'mkdir':
$new_dir = $_POST ['new_dir'];
if (ftp_mkdir ($connect, $new_dir))
echo "<i>New directory created successfully.</i><p>";
else
echo "<i>Unable to create new directory.</i><p>";
break;
case 'system':
$cmd = $_POST ['cmd'];
if (ftp_site ($connect, $cmd))
echo "<i>Command executed successfully.</i><p>";
else
echo "<i>Unable to run command.</i><p>";
break;
case 'logout':
setcookie ("_hostname");
setcookie ("_username");
setcookie ("_password");
header ("Location: {$page}");
break;
default:
break;
}
echo "<pre>\n\n\n</pre><table width = 100%>\n";
$files = ftp_nlist ($connect, $current);
echo "<tr><td><a href = '{$page}&mode=chdir&new=..'>Up</a></td></tr>\n";
foreach ($files as $file)
{
if (ftp_is_dir ($connect, $current, $file))
{
$items = count (ftp_nlist ($connect, $file));
echo "<tr><td><a href = '{$page}&mode=chdir&new={$file}'>{$file}</a></td>".
"<td>{$items} items</td>".
"<td><a href = '{$page}&mode=rmdir&dir={$file}'>Remove</a></td>".
"<td><a href = '{$page}&mode=rename&old={$file}'>Rename/Move</a></td></tr>";
}
else
{
$size = round (ftp_size ($connect, $file) / 1024, 2);
echo "<tr><td>{$file}</td>\n".
"<td>{$size} KB</td>\n".
"<td><a href = '{$page}&mode=rm&file={$file}'>Remove</a></td>\n".
"<td><a href = '{$page}&mode=rename&old={$file}'>Rename/Move</a></td>\n".
"<td><a href = '{$page}&mode=chmod&file={$file}'>Change permissions</a></td>\n".
"<td><a href = '{$page}&mode=dwn&remote={$file}'>Download</a></td></tr>\n";
}
}
ftp_close ($connect);
}
?>
[/php][/align]
[php]
<!--
FTP Shell
Written by darkjoker
--!>
<html>
<head>
<title>
FTP Shell ~ Written by darkjoker
</title>
</head>
<body>
<style type="text/css">
body{
background: #242424;
color: #DDDDDD;
font-family: Verdana;
font-size: 11px;
}
a:link{
text-decoration: none;
color: #3366FF;
}
a:visited{
text-decoration: none;
color: #3366FF;
}
a:hover{
text-decoration: none;
Color: #CCFFFF;
}
table {
font-size: 11px;
}
i {
Color: #FF0000;
}
input{
margin: 0;
font-family: Verdana;
background: #DDDDDD;
padding: 2px 3px;
color: #242424;
border: 1px solid #DADADA;
}
</style>
<?
error_reporting (0);
set_time_limit (0);
function ftp_is_dir ($connect, $current, $file)
{
if (ftp_chdir ($connect, $current . $file))
{
ftp_chdir ($connect, "..");
return true;
}
else
{
return false;
}
}
list ($page) = explode ("?", htmlentities ($_SERVER ['PHP_SELF']));
$current = $_GET ['pwd'];
if (empty ($current))
$current = "/";
$page .= "?pwd={$current}";
$hostname = htmlentities ($_COOKIE ['_hostname']);
$username = htmlentities ($_COOKIE ['_username']);
$password = base64_decode ($_COOKIE ['_password']);
if ((empty ($hostname)) || (empty ($username)) || (empty ($password)))
{
$hostname = $_POST ['hostname'];
$username = $_POST ['username'];
$password = base64_encode ($_POST ['password']);
if ((empty ($hostname)) || (empty ($username)) || (empty ($password)))
{
echo
"<table><form method = 'POST'>\n".
"<tr><td>Hostname:</td><td><input name = 'hostname'></td></tr>\n".
"<tr><td>Username:</td><td><input name = 'username'></td></tr>\n".
"<tr><td>Password:</td><td><input name = 'password' type = 'password'></td></tr>\n".
"<tr><td><input value = 'Login' type = 'submit'></td></tr>\n".
"</form></table>";
}
else
{
setcookie ("_hostname", $hostname);
setcookie ("_username", $username);
setcookie ("_password", base64_encode ($password));
header ("Location: {$page}");
}
}
else
{
$connect = ftp_connect ($hostname);
(!$connect) ? die ("Unable to connect to {$hostname}.") : $a = 0;
$login = ftp_login ($connect, $username, $password);
(!$login) ? die ("Username/password wrong.") : $a = 0;
ftp_chdir ($connect, $current);
echo "Hostname: {$hostname}<br>\n".
"Logged as: {$username} (<a href = '{$page}&mode=logout'>logout</a>)<br>\n".
"System: " . ftp_systype ($connect) . "<br>\n".
"Current directory: " . ftp_pwd ($connect) . "<pre>\n\n</pre>\n".
"<b>Upload:</b><br>\n".
"<table>\n".
"<form action = '{$page}&mode=up' method = 'POST' ENCTYPE='multipart/form-data'>\n".
"<tr><td>Local file:</td><td><input name = 'local' type = 'file'></td></tr>\n".
"<tr><td>Remote file:</td><td><input size = 16 name = 'remote'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Upload'></td></tr>\n".
"</form></table><pre>\n\n</pre>\n".
"<b>Make new directory</b><br><table>\n".
"<form action = '{$page}&mode=mkdir' method = 'POST'>\n".
"<tr><td>New name:</td><td><input size = 17 name = 'new_dir'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Create'></td></tr>\n".
"</form></table><pre>\n\n</pre>\n".
"<b>Run command</b><br><table>\n".
"<form action = '{$page}&mode=cmd' method = 'POST'>\n".
"<tr><td>Command:</td><td><input size = 17 name = 'cmd'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Run'></td></tr>\n".
"<form></table><p>\n";
$mode = $_GET ['mode'];
switch ($mode)
{
case 'chdir':
$new = $_GET ['new'];
if (ftp_chdir ($connect, $new))
{
list ($page) = explode ("?", $page);
if ($new == '..')
{
$dirs = explode ("/", $current);
array_pop ($dirs);
array_pop ($dirs);
$dirs = "/" . join ("", $dirs);
(strlen ($dirs) > 1) ? $dirs .= "/" : $a = 0;
header ("Location: {$page}?pwd={$dirs}");
}
else
header ("Location: {$page}?pwd={$current}{$new}/");
}
else
echo "<i>Unable to change directory.</i><p>";
break;
case 'rmdir':
$dir = $_GET ['dir'];
if (ftp_rmdir ($connect, $current . $dir))
echo "<i>Directory removed successfully.</i><p>";
else
echo "<i>Unable to remove directory.</i><p>";
break;
case 'rename':
$old = htmlentities ($_GET ['old']);
$new = $_POST ['new'];
if (empty ($new))
echo
"<b>Rename</b><br>\n".
"<table><form action = '{$page}&mode=rename&old={$old}' method = 'POST'>\n".
"<tr><td>New name/location</td><td><input name = 'new'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Rename/Move'></td></tr>\n".
"</form></table>\n";
else
{
if (ftp_rename ($connect, $old, $new))
echo "<i>File/Directory renamed/moved successfully.</i><p>";
else
echo "<i>Unable to rename/move file/directory.</i><p>";
}
break;
case 'chmod':
$file = htmlentities ($_GET ['file']);
$perm = $_POST ['perm'];
if ((empty ($perm)) || (!is_numeric ($perm)))
echo
"<b>Change permissions</b><br>\n".
"<table><form action = '{$page}&mode=chmod&file={$file}' method = 'POST'>".
"<tr><td>Permission:</td><td><input name = 'perm'></td></tr>".
"<tr><td><input type = 'submit' value = 'Change permissions'</td></tr>".
"</form></table>";
else
{
if (ftp_chmod ($connect, $perm, $file))
echo "<i>File permissions changed successfully.</i><p>";
else
echo "<i>Unable to change file permissions.</i><p>";
}
break;
case 'rm':
$file = $_GET ['file'];
if (ftp_delete ($connect, $file))
echo "<i>File removed successfully.</i><p>";
else
echo "<i>Unable to remove file.</i><p>";
break;
case 'dwn':
$remote = htmlentities ($_GET ['remote']);
$local = $_POST ['local'];
if (empty ($local))
echo
"<b>Download</b><br>\n".
"<table><form action = '{$page}&mode=dwn&remote={$remote}' method = 'POST'>\n".
"<tr><td>Local file:</td><td><input name = 'local'></td></tr>\n".
"<tr><td><input type = 'submit' value = 'Download'></td></tr></form></table>";
else
{
if (ftp_get ($connect, $local, $remote, FTP_ASCII))
echo "<i>File downloaded successfully.</i><p>";
else
echo "<i>Unable to download file.</i><p>";
}
break;
case 'up':
$remote = $_POST ['remote'];
$local = $_FILES['local']['tmp_name'];
$file = basename($_FILES['local']['name']);
if(move_uploaded_file($local,$file))
{
if (ftp_put ($connect, $remote, $file, FTP_ASCII))
{
echo "<i>File uploaded successfully.</i><p>";
unlink ($file);
}
else
echo "<i>Unable to upload file.</i><p>";
unlink ($local);
}
else
echo "<i>Unable to upload file.</i><p>\n";
break;
case 'mkdir':
$new_dir = $_POST ['new_dir'];
if (ftp_mkdir ($connect, $new_dir))
echo "<i>New directory created successfully.</i><p>";
else
echo "<i>Unable to create new directory.</i><p>";
break;
case 'system':
$cmd = $_POST ['cmd'];
if (ftp_site ($connect, $cmd))
echo "<i>Command executed successfully.</i><p>";
else
echo "<i>Unable to run command.</i><p>";
break;
case 'logout':
setcookie ("_hostname");
setcookie ("_username");
setcookie ("_password");
header ("Location: {$page}");
break;
default:
break;
}
echo "<pre>\n\n\n</pre><table width = 100%>\n";
$files = ftp_nlist ($connect, $current);
echo "<tr><td><a href = '{$page}&mode=chdir&new=..'>Up</a></td></tr>\n";
foreach ($files as $file)
{
if (ftp_is_dir ($connect, $current, $file))
{
$items = count (ftp_nlist ($connect, $file));
echo "<tr><td><a href = '{$page}&mode=chdir&new={$file}'>{$file}</a></td>".
"<td>{$items} items</td>".
"<td><a href = '{$page}&mode=rmdir&dir={$file}'>Remove</a></td>".
"<td><a href = '{$page}&mode=rename&old={$file}'>Rename/Move</a></td></tr>";
}
else
{
$size = round (ftp_size ($connect, $file) / 1024, 2);
echo "<tr><td>{$file}</td>\n".
"<td>{$size} KB</td>\n".
"<td><a href = '{$page}&mode=rm&file={$file}'>Remove</a></td>\n".
"<td><a href = '{$page}&mode=rename&old={$file}'>Rename/Move</a></td>\n".
"<td><a href = '{$page}&mode=chmod&file={$file}'>Change permissions</a></td>\n".
"<td><a href = '{$page}&mode=dwn&remote={$file}'>Download</a></td></tr>\n";
}
}
ftp_close ($connect);
}
?>
[/php][/align]