짧게 요약하면 CryptoLocker 바이러스에 감염되었습니다. 내 "정상적인"로컬 파일은 내가 백업 한 파일이기 때문에 문제가되지 않습니다. 하지만 Google 드라이브 동기화 클라이언트를 사용하고 있으며 모든 드라이브 파일이 암호화되어 있습니다. Google 드라이브가 저장되고 내 데이터가 전 세계에 저장되었다고 생각했기 때문에 백업하지 않았습니다 (내 잘못 알고 있음).CryptoLocker - Python 스크립트로 드라이브 파일 버전을 복원하십시오.
이제 Google 드라이브에서 버전을 확인할 수 있습니다. 즉, 내 이전 업로드가 서버에 남아 있음을 의미합니다. 파일로 이전 버전의 파일을 복원 할 수 있지만 수천 개의 파일, 행운을 빌어 요. Google G Suite 지원 팀에 문의 (Google G Suite 사용) 한 번에 대량 업데이트로 최신 버전을 복원 할 수 있는지 질문했습니다. 대답은 "당신이 파일별로 파일을해야만하는 것이 아닙니다"였습니다. 따라서 인터넷에서 스크립트, 도구 등을 확인하고있었습니다.
미리보기 작업 버전을 복원 할 수있는 Python 스크립트 "bitbucket.org/snippets/cyclick/EBbEG"가 있습니다.
"python.org/ftp/python/2.7.12/python-2.7.12.msi"를 설치하십시오.
"CMD"를 실행하십시오.
"bootstrap.pypa.io/get-pip.py"pip 모듈을 다운로드하십시오.
"Scripts"폴더에 복사하십시오.
CMD "python get-pip.py"를 통해 스크립트를 실행하십시오.
드라이브 API를 켜고과 OAuth 클라이언트 ID 생성 :
developers.google.com/drive/v3/web/quickstart/python JSON 파일을 다운로드은 ".credentials"에 배치 폴더 이름을 "client_secret.json"으로 변경했습니다. (28 행에서 언급 한 것과 같습니다)
CMD "pip install --upgrade google-api-python-client"로 Google 라이브러리를 설치하십시오.
나중에 스크립트를 복사하여 "cleanup.py"로 저장했습니다.
# This script removes the file revision created by the Zepto Ransomware and # renames the file back to what it was before infection. # This file CHANGES the drive. USE IT AT YOUR OWN RISK. I'M NOT RESPONSIBLE FOR ANY LOSE. # # Requirements : # * Avoid encoding problem by setting the python encoding before running the script # $ export PYTHONIOENCODING=utf8 # * Turn on the Drive API and generate a OAuth client ID : https://developers.google.com/drive/v3/web/quickstart/python from __future__ import print_function import httplib2 import os import json from apiclient import discovery import oauth2client from oauth2client import client from oauth2client import tools try: import argparse flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() except ImportError: flags = None # If modifying these scopes, delete your previously saved credentials at ~/.credentials/drive-python-quickstart.json SCOPES = 'https://www.googleapis.com/auth/drive' CLIENT_SECRET_FILE = 'client_secret.json' APPLICATION_NAME = 'Drive API Python Quickstart' def get_credentials(): """ Gets valid user credentials from storage. If nothing has been stored, or if the stored credentials are invalid, the OAuth2 flow is completed to obtain the new credentials. Returns: Credentials, the obtained credential. """ home_dir = os.path.expanduser('~') credential_dir = os.path.join(home_dir, '.credentials') if not os.path.exists(credential_dir): os.makedirs(credential_dir) credential_path = os.path.join(credential_dir, 'drive-python-quickstart.json') store = oauth2client.file.Storage(credential_path) credentials = store.get() if not credentials or credentials.invalid: flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES) flow.user_agent = APPLICATION_NAME if flags: credentials = tools.run_flow(flow, store, flags) else: # Needed only for compatibility with Python 2.6 credentials = tools.run(flow, store) print('Storing credentials to ' + credential_path) return credentials def deleteFilesWithSuffix(suffix, service): results = service.files().list( corpus="domain", spaces="drive", pageSize=1000, orderBy="folder,modifiedTime desc,name", q="name contains '" + suffix + "'", fields="nextPageToken, files(id, name)" ).execute() items = results.get('files', []) if not items: print('No files found.') else: for item in items: if item['name'].endswith(suffix): try: deleteFile = service.files().delete(fileId=item['id']).execute() print("Deleted file : " + item['name']) except Exception as e: print("Could not delete file : " + item['name'] + ". Details : " + str(e)) def renameFile(fileId, originalFilename, service): try: print("Renaming file " + fileId + " to " + originalFilename) service.files().update(fileId=fileId, body={'name': originalFilename}, fields='name').execute() except Exception as e: print("Could not rename file " + fileId + "/Details : " + str(e)) def revertFiles(suffix, service): results = service.files().list( corpus="domain", spaces="drive", pageSize=1000, orderBy="folder,modifiedTime desc,name", #q="modifiedTime > '2016-09-04T12:00:00'", q= "name contains '" + suffix + "'", fields="nextPageToken, files(id, name)" ).execute() items = results.get('files', []) if not items: print('No files found.') else: for item in items: details = service.files().get(fileId=item['id'], fields="lastModifyingUser,name").execute() if details['name'].endswith(suffix): print("About to handle file " + details['name'] + " having id " + item['id']) revs = service.revisions().list(fileId=item['id'], fields="kind,revisions").execute() allrev = revs['revisions'] lastRev = allrev[-1] if not lastRev['originalFilename'].endswith(suffix): # there was a rename problem during previous run -> fix it originalFilename = lastRev['originalFilename'] renameFile(item['id'], originalFilename, service) elif len(allrev) > 1: origRev = allrev[-2] if lastRev['originalFilename'].endswith(suffix): try: print("Removing last revision of file " + details['name']) revDel = service.revisions().delete(fileId=item['id'], revisionId=lastRev['id']).execute() originalFilename = origRev['originalFilename'] renameFile(item['id'], originalFilename, service) except Exception as e: print("Could not process file : " + details['name'] + "/Details : " + str(e)) def main(): credentials = get_credentials() http = credentials.authorize(httplib2.Http()) service = discovery.build('drive', 'v3', http=http) deleteFilesWithSuffix('_HELP_instructions.html', service) revertFiles('zepto', service) if __name__ == '__main__': main()
-
내가 CMD "파이썬 cleanup.py"를 통해 스크립트를 실행
- 합니다.
C:\Python27\Scripts>python cleanup.py Traceback (most recent call last): File "cleanup.py", line 133, in <module> main() File "cleanup.py", line 125, in main credentials = get_credentials() File "cleanup.py", line 48, in get_credentials credentials = store.get() File "C:\Python27\lib\site-packages\oauth2client\client.py", line 407, in get return self.locked_get() File "C:\Python27\lib\site-packages\oauth2client\file.py", line 54, in locked_get credentials = client.Credentials.new_from_json(content) File "C:\Python27\lib\site-packages\oauth2client\client.py", line 302, in new_from_json module_name = data['_module'] KeyError: '_module'
나는 오류 메시지가 나타납니다? 자격 증명/jason 파일에 문제가있을 수 있습니까?
이제 저는 여러분과 도움을 청합니다. 어쩌면 우리는이 스크립트를 실행하여 최신 파일 버전을 복원 할 수 있습니다.
정말 도움을 주셔서 감사합니다.
'Google Admin SDK'와 'Google 드라이브 API'를 모두 사용할 수 있지만 여전히 같은 오류 메시지입니다. 오류가 자격 증명 (json 파일)과 관련이있을 수 있습니까? 나는 json 파일을 C : 루트에 놓았고 C :의 ".credentials"폴더와 내 사용자 폴더의 같은 단계에 배치했다. 변경 없음. 어떤 생각? – x0100