Filemanager security update.

This commit is contained in:
usmannasir
2018-04-18 15:57:49 +05:00
parent 8bcc769297
commit d282142072
12 changed files with 444 additions and 71 deletions

View File

@@ -14,10 +14,9 @@
<file leaf-file-name="fileManager.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="689">
<caret line="610" column="5" lean-forward="true" selection-start-line="610" selection-start-column="5" selection-end-line="610" selection-end-column="5" />
<state relative-caret-position="455">
<caret line="26" column="41" lean-forward="true" selection-start-line="0" selection-start-column="0" selection-end-line="652" selection-end-column="26" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
@@ -29,11 +28,22 @@
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="caller.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@@ -69,6 +79,7 @@
<option value="$PROJECT_DIR$/css/fileManager.css" />
<option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/php/fileManager.php" />
<option value="$PROJECT_DIR$/php/caller.php" />
</list>
</option>
</component>
@@ -80,10 +91,10 @@
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1402" />
<option name="y" value="4" />
<option name="width" value="1299" />
<option name="height" value="764" />
<option name="x" value="1466" />
<option name="y" value="-4" />
<option name="width" value="1287" />
<option name="height" value="696" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
@@ -100,7 +111,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<expand>
@@ -118,6 +128,7 @@
</subPane>
</pane>
<pane id="Scope" />
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
@@ -152,26 +163,27 @@
<workItem from="1512371928726" duration="717000" />
<workItem from="1512401006678" duration="9000" />
<workItem from="1512401100852" duration="2365000" />
<workItem from="1523948661253" duration="6266000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="28493000" />
<option name="totallyTimeSpent" value="34759000" />
</component>
<component name="ToolWindowManager">
<frame x="1431" y="-4" width="1301" height="772" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.21214451" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.10069177" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@@ -199,7 +211,6 @@
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
@@ -211,6 +222,28 @@
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#createNewFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#deleteFolderOrFile#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#compress#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#extract#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>
@@ -224,12 +257,19 @@
<entry file="file://$PROJECT_DIR$/js/fileManager.js" />
<entry file="file://$PROJECT_DIR$/css/fileManager.css" />
<entry file="file://$PROJECT_DIR$/index.html" />
<entry file="file://$PROJECT_DIR$/php/caller.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="31" column="23" lean-forward="false" selection-start-line="31" selection-start-column="23" selection-end-line="31" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="689">
<caret line="610" column="5" lean-forward="true" selection-start-line="610" selection-start-column="5" selection-end-line="610" selection-end-column="5" />
<state relative-caret-position="455">
<caret line="26" column="41" lean-forward="true" selection-start-line="0" selection-start-column="0" selection-end-line="652" selection-end-column="26" />
<folding>
<element signature="n#listDir#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#writeFileContents#0;n#fileManager#0;n#!!top" expanded="false" />
@@ -241,6 +281,7 @@
<element signature="n#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding>
</state>
</provider>

View File

@@ -13,6 +13,25 @@ class Caller{
{
if ($_SERVER['REQUEST_METHOD'] === 'POST' and isset($_POST['method'])) {
$pathToSeed = '/home/' . $_POST['domainName'] . '/..filemanagerkey';
$receivedSeed = $_POST['domainRandomSeed'];
$myfile = fopen($pathToSeed, "r") or die("Unable to open file!");
$seed = fread($myfile,filesize($pathToSeed));
fclose($myfile);
if ($seed != $receivedSeed){
$answer = array(
'uploadStatus' => 0,
'answer' => 'Not allowed to upload in this path.',
'error_message' => "None",
'fileName' => $_FILES['file']['name']
);
$json = json_encode($answer);
echo $json;
return;
}
switch ($_POST['method']) {
case 'upload':
$this->uploadFile();

View File

@@ -11,6 +11,25 @@ class fileManager
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$pathToSeed = '/home/' . $request->domainName . '/..filemanagerkey';
$receivedSeed = $request->domainRandomSeed;
$myfile = fopen($pathToSeed, "r") or die("Unable to open file!");
$seed = fread($myfile,filesize($pathToSeed));
fclose($myfile);
if ($seed != $receivedSeed){
$json_data = array(
"error_message" => "You can not open filemanager for this domain.",
"copied" => 1,
);
$json = json_encode($json_data);
echo $json;
return;
}
if (isset($request->method)) {
switch ($request->method) {
@@ -84,7 +103,8 @@ class fileManager
if (is_dir($completePath) == true) {
array_push($tempDir, $dirFile);
} else {
array_push($tempFiles, $dirFile);
array_push($tempFiles, $dirFile);
}
}