Linux ns1.utparral.edu.mx 6.8.0-79-generic #79~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 15 16:54:53 UTC 2 x86_64
Apache/2.4.58 (Unix) OpenSSL/1.1.1w PHP/8.2.12 mod_perl/2.0.12 Perl/v5.34.1
: 10.10.1.9 | : 10.10.1.254
Cant Read [ /etc/named.conf ]
daemon
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
README
+ Create Folder
+ Create File
/
usr /
lib /
python3 /
dist-packages /
duplicity /
backends /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
pyrax_identity
[ DIR ]
drwxr-xr-x
adbackend.py
16.98
KB
-rw-r--r--
azurebackend.py
5.47
KB
-rw-r--r--
b2backend.py
8.82
KB
-rw-r--r--
_boto_multi.py
9.72
KB
-rw-r--r--
_boto_single.py
14.65
KB
-rw-r--r--
boxbackend.py
6.99
KB
-rw-r--r--
cfbackend.py
1.13
KB
-rw-r--r--
_cf_cloudfiles.py
3.85
KB
-rw-r--r--
_cf_pyrax.py
5.12
KB
-rw-r--r--
dpbxbackend.py
19.93
KB
-rw-r--r--
gdocsbackend.py
9.17
KB
-rw-r--r--
gdrivebackend.py
15.45
KB
-rw-r--r--
giobackend.py
8.05
KB
-rw-r--r--
hsibackend.py
2.67
KB
-rw-r--r--
hubicbackend.py
2.38
KB
-rw-r--r--
idrivedbackend.py
19.08
KB
-rw-r--r--
imapbackend.py
9.96
KB
-rw-r--r--
__init__.py
1.09
KB
-rw-r--r--
jottacloudbackend.py
5.54
KB
-rw-r--r--
lftpbackend.py
9.79
KB
-rw-r--r--
localbackend.py
2.96
KB
-rw-r--r--
mediafirebackend.py
4.71
KB
-rw-r--r--
megabackend.py
6.73
KB
-rw-r--r--
megav2backend.py
8.63
KB
-rw-r--r--
megav3backend.py
10.11
KB
-rw-r--r--
multibackend.py
15.49
KB
-rw-r--r--
ncftpbackend.py
5.58
KB
-rw-r--r--
onedrivebackend.py
15.03
KB
-rw-r--r--
par2backend.py
9.06
KB
-rw-r--r--
pcabackend.py
12.36
KB
-rw-r--r--
pydrivebackend.py
13.08
KB
-rw-r--r--
rclonebackend.py
4.22
KB
-rw-r--r--
README
2.52
KB
-rw-r--r--
rsyncbackend.py
6.51
KB
-rw-r--r--
s3_boto3_backend.py
9.41
KB
-rw-r--r--
s3_boto_backend.py
1.5
KB
-rw-r--r--
ssh_paramiko_backend.py
19.86
KB
-rw-r--r--
ssh_pexpect_backend.py
12.92
KB
-rw-r--r--
swiftbackend.py
10.04
KB
-rw-r--r--
sxbackend.py
2.31
KB
-rw-r--r--
tahoebackend.py
2.58
KB
-rw-r--r--
webdavbackend.py
19.77
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : megav3backend.py
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4; encoding:utf8 -*- # # Copyright 2020 Jose L. Domingo Lopez <github@24x7linux.com> # # This file is part of duplicity. # # Duplicity is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # Duplicity is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with duplicity; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from __future__ import print_function import os import re import subprocess import duplicity.backend from duplicity import util from duplicity.errors import BackendException from future import standard_library standard_library.install_aliases() class Megav3Backend(duplicity.backend.Backend): u"""Backend for MEGA.nz cloud storage, only one that works for accounts created since Nov. 2018 See https://github.com/megous/megatools/issues/411 for more details This MEGA backend resorts to official tools (MEGAcmd) as available at https://mega.nz/cmd MEGAcmd works through a single binary called "mega-cmd", which keeps state (for example, persisting a session). Multiple "mega-*" shell wrappers (ie. "mega-ls") exist as the user interface to "mega-cmd" and MEGA API The full MEGAcmd User Guide can be found in the software's GitHub page below : https://github.com/meganz/MEGAcmd/blob/master/UserGuide.md""" def __init__(self, parsed_url): duplicity.backend.Backend.__init__(self, parsed_url) # Sanity check : ensure all the necessary "MEGAcmd" binaries exist self._check_binary_exists(u'mega-cmd') self._check_binary_exists(u'mega-exec') self._check_binary_exists(u'mega-help') self._check_binary_exists(u'mega-get') self._check_binary_exists(u'mega-login') self._check_binary_exists(u'mega-logout') self._check_binary_exists(u'mega-ls') self._check_binary_exists(u'mega-mkdir') self._check_binary_exists(u'mega-put') self._check_binary_exists(u'mega-rm') self._check_binary_exists(u'mega-whoami') # "MEGAcmd" does not use a config file, however it is handy to keep one (with the old ".megarc" format) to # securely store the username and password self._hostname = parsed_url.hostname if parsed_url.username is None: self._megarc = os.getenv(u'HOME') + u'/.megav3rc' try: conf_file = open(self._megarc, u"r") except Exception as e: raise BackendException( u"No password provided in URL and MEGA configuration " u"file for duplicity does not exist as '%s'" % (self._megarc,) ) myvars = {} for line in conf_file: name, var = line.partition(u"=")[::2] myvars[name.strip()] = str(var.strip()) conf_file.close() self._username = myvars[u"Username"] self._password = myvars[u"Password"] else: self._username = parsed_url.username self._password = parsed_url.password no_logout_option = parsed_url.query_args.get(u'no_logout', []) self._no_logout = (len(no_logout_option) > 0) and ( no_logout_option[0].lower() in [u'1', u'yes', u'true'] ) self.ensure_mega_cmd_running() # Remote folder ("MEGAcmd" no longer shows "Root/" at the top of the hierarchy) self._folder = u'/' + parsed_url.path[1:] # Only create the remote folder if it doesn't exist yet self.mega_login() cmd = [u'mega-ls', self._folder] try: self.subprocess_popen(cmd) except Exception as e: self._makedir(self._folder) def _check_binary_exists(self, cmd): u'Checks that a specified command exists in the running user command path' try: # Ignore the output, as we only need the return code subprocess.check_output([u'which', cmd]) except Exception as e: raise BackendException( u"Command '%s' not found, make sure 'MEGAcmd' tools (https://mega.nz/cmd) is " u"properly installed and in the running user command path" % (cmd,) ) def ensure_mega_cmd_running(self): u'Trigger any mega command to ensure mega-cmd server is running' try: subprocess.run( u"mega-help", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ).check_returncode() except Exception: raise BackendException(u'Cannot execute mega command') def _makedir(self, path): u'Creates a remote directory (recursively if necessary)' self.mega_login() cmd = [u'mega-mkdir', u'-p', path] try: self.subprocess_popen(cmd) except Exception as e: error_str = str(e) if u"Folder already exists" in error_str: raise BackendException( u"Folder '%s' could not be created on MEGA because it already exists. " u"Use another path or remove the folder in MEGA manually" % (path,) ) else: raise BackendException( u"Folder '%s' could not be created, reason : '%s'" % (path, e) ) def _put(self, source_path, remote_filename): u"""Uploads file to the specified remote folder (tries to delete it first to make sure the new one can be uploaded)""" try: self.delete(remote_filename.decode()) except Exception: pass self.upload( local_file=source_path.get_canonical().decode(), remote_file=remote_filename.decode(), ) def _get(self, remote_filename, local_path): u'Downloads file from the specified remote path' self.download( remote_file=remote_filename.decode(), local_file=local_path.name.decode(), ) def _list(self): u'Lists files in the specified remote path' return self.folder_contents(files_only=True) def _delete(self, filename): u'Deletes file from the specified remote path' self.delete(remote_file=filename.decode()) def _close(self): u'Function called when backend is done being used' if not self._no_logout: cmd = [u'mega-logout'] self.subprocess_popen(cmd) cmd = [u'mega-exec', u'exit'] self.subprocess_popen(cmd) def mega_login(self): u"""Helper function to check existing session exists""" # Abort if command doesn't return in a reasonable time (somehow "mega-session" sometimes # doesn't return), and create session if one doesn't exist yet try: result = subprocess.run( u'mega-whoami', timeout=30, capture_output=True, ) result.check_returncode() current_username = result.stdout.decode().split(u':')[-1].strip() if current_username != self._username: raise Exception(u"Username is not match") except subprocess.TimeoutExpired: self._close() raise BackendException( u"Timed out while trying to determine if a MEGA session exists" ) except Exception as e: if self._password is None: self._password = self.get_password() cmd = [u'mega-login', self._username, self._password] try: subprocess.run( cmd, stderr=subprocess.DEVNULL, ).check_returncode() except Exception as e: self._close() raise BackendException( u"Could not log in to MEGA, error : '%s'" % (e,) ) def folder_contents(self, files_only=False): u'Lists contents of a remote MEGA path, optionally ignoring subdirectories' cmd = [u'mega-ls', u'-l', self._folder] self.mega_login() files = subprocess.check_output(cmd) files = files.decode().split(u'\n') # Optionally ignore directories if files_only: files = [f.split()[5] for f in files if re.search(u'^-', f)] return files def download(self, remote_file, local_file): u'Downloads a file from a remote MEGA path' cmd = [u'mega-get', self._folder + u'/' + remote_file, local_file] self.mega_login() self.subprocess_popen(cmd) def upload(self, local_file, remote_file): u'Uploads a file to a remote MEGA path' cmd = [u'mega-put', local_file, self._folder + u'/' + remote_file] self.mega_login() try: self.subprocess_popen(cmd) except Exception as e: error_str = str(e) if u"Reached storage quota" in error_str: raise BackendException( u"MEGA account over quota, could not write file : '%s' . " u"Upgrade your storage at https://mega.nz/pro or remove some data." % (remote_file,) ) else: raise BackendException( u"Failed writing file '%s' to MEGA, reason : '%s'" % (remote_file, e) ) def delete(self, remote_file): u'Deletes a file from a remote MEGA path' cmd = [u'mega-rm', u'-f', self._folder + u'/' + remote_file] self.mega_login() self.subprocess_popen(cmd) duplicity.backend.register_backend(u'megav3', Megav3Backend) duplicity.backend.uses_netloc.extend([u'megav3'])
Close