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

@@ -530,15 +530,22 @@ def deleteDNSZone(request):
try: try:
val = request.session['userID'] val = request.session['userID']
val = request.session['userID']
admin = Administrator.objects.get(pk=val) admin = Administrator.objects.get(pk=val)
domainsList = [] domainsList = []
domains = Domains.objects.all() if admin.type == 1:
domains = Domains.objects.all()
for items in domains:
domainsList.append(items.name)
else:
websites = admin.websites_set.all()
for items in domains: for web in websites:
domainsList.append(items.name) try:
tempDomain = Domains.objects.get(name = web.domain)
domainsList.append(web.domain)
except:
pass
return render(request, 'dns/deleteDNSZone.html',{"domainsList":domainsList}) return render(request, 'dns/deleteDNSZone.html',{"domainsList":domainsList})

View File

@@ -15,6 +15,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var aceEditorMode = ''; var aceEditorMode = '';
var domainName = window.location.pathname.split("/")[2]; var domainName = window.location.pathname.split("/")[2];
var domainRandomSeed = "";
var homePathBack = "/home/"+domainName; var homePathBack = "/home/"+domainName;
$scope.currentPath = "/home/"+domainName; $scope.currentPath = "/home/"+domainName;
@@ -67,7 +68,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
completeStartingPath : completePath, completeStartingPath : completePath,
method : "list" method : "list",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -118,7 +121,6 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
parentNode.appendChild(prepareChildNodeLI(path,completePath,dropDown)); parentNode.appendChild(prepareChildNodeLI(path,completePath,dropDown));
} }
function prepareChildNodeLI(path,completePath,dropDown){ function prepareChildNodeLI(path,completePath,dropDown){
// text nodes are created // text nodes are created
@@ -364,6 +366,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var permissionsNode = document.createTextNode(permissions); var permissionsNode = document.createTextNode(permissions);
// //
@@ -598,6 +602,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
// table functions // table functions
$scope.fetchForTableSecondary = function(node,functionName) { $scope.fetchForTableSecondary = function(node,functionName) {
allFilesAndFolders = []; allFilesAndFolders = [];
@@ -632,7 +638,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
completeStartingPath : completePathToFile, completeStartingPath : completePathToFile,
method : "listForTable", method : "listForTable",
home: homePathBack home: homePathBack,
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
var tableBody = document.getElementById("tableBodyFiles"); var tableBody = document.getElementById("tableBodyFiles");
@@ -666,6 +674,11 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var fileSize = filesData[keys[i]][3]; var fileSize = filesData[keys[i]][3];
var permissions = filesData[keys[i]][4]; var permissions = filesData[keys[i]][4];
var dirCheck = filesData[keys[i]][5]; var dirCheck = filesData[keys[i]][5];
console.log(fileName);
if(fileName === "..filemanagerkey"){
continue;
}
tableBody.appendChild(createTR(fileName,fileSize,lastModified,permissions,dirCheck)); tableBody.appendChild(createTR(fileName,fileSize,lastModified,permissions,dirCheck));
} }
@@ -682,12 +695,51 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
} }
}; };
$scope.fetchForTableSecondary(null,"startPoint");
function findFileExtension(fileName){ function findFileExtension(fileName){
return (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName) : undefined; return (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName) : undefined;
} }
// Create entry point for domain
function createEntryPoint(){
url = "/filemanager/createTemporaryFile";
var data = {
domainName:domainName
};
var config = {};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.createTemporaryFile === 1){
domainRandomSeed = response.data.domainRandomSeed;
$scope.fetchForTableSecondary(null,"startPoint");
}
else
{
var notification = alertify.notify(response.data.error_message, 'error', 10, function(){ console.log('dismissed'); });
}
}
function cantLoadInitialDatas(response) {
var notification = alertify.notify("Could not connec to server, refresh page.", 'error', 10, function(){ console.log('dismissed'); });
}
}
createEntryPoint();
// html editor // html editor
@@ -698,7 +750,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
fileName : completePathForFile, fileName : completePathForFile,
method : "readFileContents" method : "readFileContents",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -738,7 +792,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
fileName : completePathForFile, fileName : completePathForFile,
method : "writeFileContents", method : "writeFileContents",
fileContent: editor.getValue() fileContent: editor.getValue(),
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -790,7 +846,13 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
uploader.onAfterAddingFile = function(fileItem) { uploader.onAfterAddingFile = function(fileItem) {
$scope.errorMessage = true; $scope.errorMessage = true;
fileItem.formData.push({"completePath":$scope.currentPath}); fileItem.formData.push(
{
"completePath":$scope.currentPath,
domainRandomSeed:domainRandomSeed,
domainName: domainName
});
}; };
// folder functions // folder functions
@@ -823,6 +885,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
folderName : completePathForFolder, folderName : completePathForFolder,
method : "createNewFolder", method : "createNewFolder",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -872,6 +936,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
fileName : completePathForFile, fileName : completePathForFile,
method : "createNewFile", method : "createNewFile",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -914,6 +980,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
path : $scope.currentPath, path : $scope.currentPath,
method : "deleteFolderOrFile", method : "deleteFolderOrFile",
fileAndFolders: allFilesAndFolders, fileAndFolders: allFilesAndFolders,
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -962,7 +1030,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
listOfFiles : allFilesAndFolders, listOfFiles : allFilesAndFolders,
compressedFileName: $scope.compressedFileName, compressedFileName: $scope.compressedFileName,
compressionType: $scope.compressionType, compressionType: $scope.compressionType,
method: 'compress' method: 'compress',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1017,7 +1087,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
fileToExtract: completeFileToExtract, fileToExtract: completeFileToExtract,
extractionType: extractionType, extractionType: extractionType,
extractionLocation: $scope.extractionLocation, extractionLocation: $scope.extractionLocation,
method: 'extract' method: 'extract',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1069,7 +1141,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
basePath : $scope.currentPath, basePath : $scope.currentPath,
newPath : $scope.pathToMoveTo, newPath : $scope.pathToMoveTo,
fileAndFolders:allFilesAndFolders, fileAndFolders:allFilesAndFolders,
method: 'move' method: 'move',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1120,7 +1194,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
basePath : $scope.currentPath, basePath : $scope.currentPath,
newPath : $scope.pathToCopyTo, newPath : $scope.pathToCopyTo,
fileAndFolders:allFilesAndFolders, fileAndFolders:allFilesAndFolders,
method: 'copy' method: 'copy',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1238,7 +1314,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
basePath : $scope.currentPath, basePath : $scope.currentPath,
existingName: $scope.fileToRename, existingName: $scope.fileToRename,
newFileName : $scope.newFileName, newFileName : $scope.newFileName,
method: 'rename' method: 'rename',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1274,6 +1352,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
domainName : domainName, domainName : domainName,
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1305,7 +1385,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
url = "/filemanager/downloadFile"; url = "/filemanager/downloadFile";
var data = { var data = {
fileToDownload: $scope.currentPath + "/" + allFilesAndFolders[0] fileToDownload: $scope.currentPath + "/" + allFilesAndFolders[0],
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };

View File

@@ -5,6 +5,7 @@ urlpatterns = [
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.loadFileManagerHome, name='loadFileManagerHome'), url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)$', views.loadFileManagerHome, name='loadFileManagerHome'),
url(r'^changePermissions',views.changePermissions, name='changePermissions'), url(r'^changePermissions',views.changePermissions, name='changePermissions'),
url(r'^downloadFile',views.downloadFile, name='downloadFile'), url(r'^downloadFile',views.downloadFile, name='downloadFile'),
url(r'^createTemporaryFile',views.createTemporaryFile, name='createTemporaryFile'),
] ]

View File

@@ -11,6 +11,8 @@ from websiteFunctions.models import Websites
import subprocess import subprocess
import shlex import shlex
import os import os
from plogical.virtualHostUtilities import virtualHostUtilities
# Create your views here. # Create your views here.
@@ -21,12 +23,28 @@ def loadFileManagerHome(request,domain):
admin = Administrator.objects.get(pk=val) admin = Administrator.objects.get(pk=val)
viewStatus = 1 if Websites.objects.filter(domain=domain).exists():
if admin.type == 1:
viewStatus = 1
if admin.type == 3:
viewStatus = 0
return render(request, 'filemanager/index.html', {"viewStatus": viewStatus})
else:
website = Websites.objects.get(domain=domain)
if website.admin == admin:
viewStatus = 1
if admin.type == 3:
viewStatus = 0
return render(request, 'filemanager/index.html', {"viewStatus": viewStatus})
else:
return HttpResponse("Domain ownership error.")
else:
return HttpResponse("Domain does not exists.")
if admin.type == 3:
viewStatus = 0
return render(request,'filemanager/index.html',{"viewStatus":viewStatus})
except KeyError: except KeyError:
return redirect(loadLoginPage) return redirect(loadLoginPage)
@@ -62,16 +80,80 @@ def changePermissions(request):
return redirect(loadLoginPage) return redirect(loadLoginPage)
def downloadFile(request): def downloadFile(request):
data = json.loads(request.body) try:
fileToDownload = data['fileToDownload']
response = '' data = json.loads(request.body)
if os.path.isfile(fileToDownload): fileToDownload = data['fileToDownload']
try:
with open(fileToDownload, 'rb') as f:
response = HttpResponse(f.read(), content_type="application/octet-stream")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(fileToDownload)
except Exception as e:
raise Http404
return response response = ''
if os.path.isfile(fileToDownload):
try:
with open(fileToDownload, 'rb') as f:
response = HttpResponse(f.read(), content_type="application/octet-stream")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(fileToDownload)
except Exception as e:
raise Http404
return response
except KeyError:
return redirect(loadLoginPage)
def createTemporaryFile(request):
try:
val = request.session['userID']
data = json.loads(request.body)
domainName = data['domainName']
admin = Administrator.objects.get(pk=val)
## Create file manager entry
if Websites.objects.filter(domain=domainName).exists():
if admin.type == 1:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/filemanager.py"
execPath = execPath + " createTemporaryFile --domainName " + domainName
output = subprocess.check_output(shlex.split(execPath))
if output.find("0,") > -1:
data_ret = {'createTemporaryFile': 0, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
domainRandomSeed = output.rstrip('\n')
data_ret = {'createTemporaryFile': 1, 'error_message': "None", 'domainRandomSeed':domainRandomSeed}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
website = Websites.objects.get(domain=domainName)
if website.admin == admin:
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/filemanager.py"
execPath = execPath + " createTemporaryFile --domainName " + domainName
output = subprocess.check_output(shlex.split(execPath))
if output.find("0,") > -1:
data_ret = {'createTemporaryFile': 0, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
domainRandomSeed = output.rstrip('\n')
data_ret = {'createTemporaryFile': 1, 'error_message': "None", 'domainRandomSeed': domainRandomSeed}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
else:
data_ret = {'createTemporaryFile': 0, 'error_message': "Domain ownership error."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError:
return redirect(loadLoginPage)

View File

@@ -14,10 +14,9 @@
<file leaf-file-name="fileManager.php" pinned="false" current-in-tab="true"> <file leaf-file-name="fileManager.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/php/fileManager.php"> <entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="689"> <state relative-caret-position="455">
<caret line="610" column="5" lean-forward="true" selection-start-line="610" selection-start-column="5" selection-end-line="610" selection-end-column="5" /> <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> <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#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#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#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#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#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#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </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> </leaf>
</component> </component>
<component name="FileTemplateManagerImpl"> <component name="FileTemplateManagerImpl">
@@ -69,6 +79,7 @@
<option value="$PROJECT_DIR$/css/fileManager.css" /> <option value="$PROJECT_DIR$/css/fileManager.css" />
<option value="$PROJECT_DIR$/index.html" /> <option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/php/fileManager.php" /> <option value="$PROJECT_DIR$/php/fileManager.php" />
<option value="$PROJECT_DIR$/php/caller.php" />
</list> </list>
</option> </option>
</component> </component>
@@ -80,10 +91,10 @@
</component> </component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" /> <component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="1402" /> <option name="x" value="1466" />
<option name="y" value="4" /> <option name="y" value="-4" />
<option name="width" value="1299" /> <option name="width" value="1287" />
<option name="height" value="764" /> <option name="height" value="696" />
</component> </component>
<component name="ProjectView"> <component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1"> <navigator currentView="ProjectPane" proportions="" version="1">
@@ -100,7 +111,6 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scratches" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
@@ -118,6 +128,7 @@
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" /> <pane id="Scope" />
<pane id="Scratches" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@@ -152,26 +163,27 @@
<workItem from="1512371928726" duration="717000" /> <workItem from="1512371928726" duration="717000" />
<workItem from="1512401006678" duration="9000" /> <workItem from="1512401006678" duration="9000" />
<workItem from="1512401100852" duration="2365000" /> <workItem from="1512401100852" duration="2365000" />
<workItem from="1523948661253" duration="6266000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="28493000" /> <option name="totallyTimeSpent" value="34759000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="1431" y="-4" width="1301" height="772" extended-state="6" /> <frame x="1431" y="-4" width="1301" height="772" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <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="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="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="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="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="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="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="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="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="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" /> <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"> <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" /> <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> <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#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#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#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#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#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#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> </folding>
</state> </state>
</provider> </provider>
@@ -224,12 +257,19 @@
<entry file="file://$PROJECT_DIR$/js/fileManager.js" /> <entry file="file://$PROJECT_DIR$/js/fileManager.js" />
<entry file="file://$PROJECT_DIR$/css/fileManager.css" /> <entry file="file://$PROJECT_DIR$/css/fileManager.css" />
<entry file="file://$PROJECT_DIR$/index.html" /> <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"> <entry file="file://$PROJECT_DIR$/php/fileManager.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="689"> <state relative-caret-position="455">
<caret line="610" column="5" lean-forward="true" selection-start-line="610" selection-start-column="5" selection-end-line="610" selection-end-column="5" /> <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> <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#listForTable#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#readFileContents#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#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#moveFileAndFolders#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#copyFileAndFolders#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#renameFileOrFolder#0;n#fileManager#0;n#!!top" expanded="false" />
<element signature="n#cleanInput#0;n#fileManager#0;n#!!top" expanded="false" />
</folding> </folding>
</state> </state>
</provider> </provider>

View File

@@ -13,6 +13,25 @@ class Caller{
{ {
if ($_SERVER['REQUEST_METHOD'] === 'POST' and isset($_POST['method'])) { 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']) { switch ($_POST['method']) {
case 'upload': case 'upload':
$this->uploadFile(); $this->uploadFile();

View File

@@ -11,6 +11,25 @@ class fileManager
$postdata = file_get_contents("php://input"); $postdata = file_get_contents("php://input");
$request = json_decode($postdata); $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)) { if (isset($request->method)) {
switch ($request->method) { switch ($request->method) {
@@ -84,7 +103,8 @@ class fileManager
if (is_dir($completePath) == true) { if (is_dir($completePath) == true) {
array_push($tempDir, $dirFile); array_push($tempDir, $dirFile);
} else { } else {
array_push($tempFiles, $dirFile); array_push($tempFiles, $dirFile);
} }
} }

View File

@@ -249,7 +249,7 @@ app.controller('deleteEmailAccount', function($scope,$http) {
function ListInitialDatas(response) { function ListInitialDatas(response) {
if(response.data.deleteEmailStatus == 1){ if(response.data.deleteEmailStatus === 1){
$scope.emailDetails = true; $scope.emailDetails = true;

45
plogical/filemanager.py Normal file
View File

@@ -0,0 +1,45 @@
import os.path
import shutil
import CyberCPLogFileWriter as logging
import subprocess
import argparse
import shlex
from random import randint
class filemanager:
@staticmethod
def createTemporaryFile(domainName):
try:
path = "/home/" + domainName + "/..filemanagerkey"
fileKey = str(randint(1000, 9999))
filemanager = open(path,'w')
filemanager.write(fileKey)
filemanager.close()
print fileKey
except BaseException,msg:
logging.CyberCPLogFileWriter.writeToFile(
str(msg) + " [createEmailAccount]")
print "0," + str(msg)
def main():
parser = argparse.ArgumentParser(description='CyberPanel Filemanager')
parser.add_argument('function', help='Specific a function to call!')
parser.add_argument('--domainName', help='Domain name!')
args = parser.parse_args()
if args.function == "createTemporaryFile":
filemanager.createTemporaryFile(args.domainName)
if __name__ == "__main__":
main()

View File

@@ -4,12 +4,6 @@ import CyberCPLogFileWriter as logging
import subprocess import subprocess
import argparse import argparse
import shlex import shlex
import installUtilities
from random import randint
import sslUtilities
from os.path import join
from os import listdir, rmdir
from shutil import move
class mailUtilities: class mailUtilities:

View File

@@ -15,6 +15,7 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var aceEditorMode = ''; var aceEditorMode = '';
var domainName = window.location.pathname.split("/")[2]; var domainName = window.location.pathname.split("/")[2];
var domainRandomSeed = "";
var homePathBack = "/home/"+domainName; var homePathBack = "/home/"+domainName;
$scope.currentPath = "/home/"+domainName; $scope.currentPath = "/home/"+domainName;
@@ -67,7 +68,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
completeStartingPath : completePath, completeStartingPath : completePath,
method : "list" method : "list",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -118,7 +121,6 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
parentNode.appendChild(prepareChildNodeLI(path,completePath,dropDown)); parentNode.appendChild(prepareChildNodeLI(path,completePath,dropDown));
} }
function prepareChildNodeLI(path,completePath,dropDown){ function prepareChildNodeLI(path,completePath,dropDown){
// text nodes are created // text nodes are created
@@ -364,6 +366,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var permissionsNode = document.createTextNode(permissions); var permissionsNode = document.createTextNode(permissions);
// //
@@ -598,6 +602,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
// table functions // table functions
$scope.fetchForTableSecondary = function(node,functionName) { $scope.fetchForTableSecondary = function(node,functionName) {
allFilesAndFolders = []; allFilesAndFolders = [];
@@ -632,7 +638,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
completeStartingPath : completePathToFile, completeStartingPath : completePathToFile,
method : "listForTable", method : "listForTable",
home: homePathBack home: homePathBack,
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
var tableBody = document.getElementById("tableBodyFiles"); var tableBody = document.getElementById("tableBodyFiles");
@@ -666,6 +674,11 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var fileSize = filesData[keys[i]][3]; var fileSize = filesData[keys[i]][3];
var permissions = filesData[keys[i]][4]; var permissions = filesData[keys[i]][4];
var dirCheck = filesData[keys[i]][5]; var dirCheck = filesData[keys[i]][5];
console.log(fileName);
if(fileName === "..filemanagerkey"){
continue;
}
tableBody.appendChild(createTR(fileName,fileSize,lastModified,permissions,dirCheck)); tableBody.appendChild(createTR(fileName,fileSize,lastModified,permissions,dirCheck));
} }
@@ -682,12 +695,51 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
} }
}; };
$scope.fetchForTableSecondary(null,"startPoint");
function findFileExtension(fileName){ function findFileExtension(fileName){
return (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName) : undefined; return (/[.]/.exec(fileName)) ? /[^.]+$/.exec(fileName) : undefined;
} }
// Create entry point for domain
function createEntryPoint(){
url = "/filemanager/createTemporaryFile";
var data = {
domainName:domainName
};
var config = {};
$http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if(response.data.createTemporaryFile === 1){
domainRandomSeed = response.data.domainRandomSeed;
$scope.fetchForTableSecondary(null,"startPoint");
}
else
{
var notification = alertify.notify(response.data.error_message, 'error', 10, function(){ console.log('dismissed'); });
}
}
function cantLoadInitialDatas(response) {
var notification = alertify.notify("Could not connec to server, refresh page.", 'error', 10, function(){ console.log('dismissed'); });
}
}
createEntryPoint();
// html editor // html editor
@@ -698,7 +750,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
fileName : completePathForFile, fileName : completePathForFile,
method : "readFileContents" method : "readFileContents",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -738,7 +792,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
fileName : completePathForFile, fileName : completePathForFile,
method : "writeFileContents", method : "writeFileContents",
fileContent: editor.getValue() fileContent: editor.getValue(),
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -790,7 +846,13 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
uploader.onAfterAddingFile = function(fileItem) { uploader.onAfterAddingFile = function(fileItem) {
$scope.errorMessage = true; $scope.errorMessage = true;
fileItem.formData.push({"completePath":$scope.currentPath}); fileItem.formData.push(
{
"completePath":$scope.currentPath,
domainRandomSeed:domainRandomSeed,
domainName: domainName
});
}; };
// folder functions // folder functions
@@ -823,6 +885,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
folderName : completePathForFolder, folderName : completePathForFolder,
method : "createNewFolder", method : "createNewFolder",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -872,6 +936,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
fileName : completePathForFile, fileName : completePathForFile,
method : "createNewFile", method : "createNewFile",
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -914,6 +980,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
path : $scope.currentPath, path : $scope.currentPath,
method : "deleteFolderOrFile", method : "deleteFolderOrFile",
fileAndFolders: allFilesAndFolders, fileAndFolders: allFilesAndFolders,
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -962,7 +1030,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
listOfFiles : allFilesAndFolders, listOfFiles : allFilesAndFolders,
compressedFileName: $scope.compressedFileName, compressedFileName: $scope.compressedFileName,
compressionType: $scope.compressionType, compressionType: $scope.compressionType,
method: 'compress' method: 'compress',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1017,7 +1087,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
fileToExtract: completeFileToExtract, fileToExtract: completeFileToExtract,
extractionType: extractionType, extractionType: extractionType,
extractionLocation: $scope.extractionLocation, extractionLocation: $scope.extractionLocation,
method: 'extract' method: 'extract',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1069,7 +1141,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
basePath : $scope.currentPath, basePath : $scope.currentPath,
newPath : $scope.pathToMoveTo, newPath : $scope.pathToMoveTo,
fileAndFolders:allFilesAndFolders, fileAndFolders:allFilesAndFolders,
method: 'move' method: 'move',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1120,7 +1194,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
basePath : $scope.currentPath, basePath : $scope.currentPath,
newPath : $scope.pathToCopyTo, newPath : $scope.pathToCopyTo,
fileAndFolders:allFilesAndFolders, fileAndFolders:allFilesAndFolders,
method: 'copy' method: 'copy',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1238,7 +1314,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
basePath : $scope.currentPath, basePath : $scope.currentPath,
existingName: $scope.fileToRename, existingName: $scope.fileToRename,
newFileName : $scope.newFileName, newFileName : $scope.newFileName,
method: 'rename' method: 'rename',
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1274,6 +1352,8 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
var data = { var data = {
domainName : domainName, domainName : domainName,
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };
@@ -1305,7 +1385,9 @@ fileManager.controller('fileManagerCtrl', function($scope,$http,FileUploader) {
url = "/filemanager/downloadFile"; url = "/filemanager/downloadFile";
var data = { var data = {
fileToDownload: $scope.currentPath + "/" + allFilesAndFolders[0] fileToDownload: $scope.currentPath + "/" + allFilesAndFolders[0],
domainRandomSeed:domainRandomSeed,
domainName: domainName
}; };

View File

@@ -249,7 +249,7 @@ app.controller('deleteEmailAccount', function($scope,$http) {
function ListInitialDatas(response) { function ListInitialDatas(response) {
if(response.data.deleteEmailStatus == 1){ if(response.data.deleteEmailStatus === 1){
$scope.emailDetails = true; $scope.emailDetails = true;