CryptoLocker-使用Google Apps脚本还原云端硬盘文件版本 [英] CryptoLocker - restore Drive file version with Google Apps Scripts

查看:59
本文介绍了CryptoLocker-使用Google Apps脚本还原云端硬盘文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

长话短说,我被CryptoLocker病毒感染了.我的普通"本地文件不是问题,因为我备份了这些文件.但是我使用的是Google Drive Sync客户端,并且我所有的云端硬盘文件都已加密.我之所以没有备份它们,是因为我认为Google云端硬盘已保存并且我的数据存储在世界各地(我知道是我的错).

现在,我可以看到Google云端硬盘提供了版本控制.这意味着我的旧上传文件仍在服务器上.我可以逐个文件还原以前的版本文件,但可以恢复数千个文件,祝您好运.我联系了Google G Suite支持团队(我正在为自己的企业使用Google G Suite),并询问他们是否可以一次批量恢复最新版本.答案是您不必逐个文件地进行处理".因此,我正在检查互联网上的脚本,工具等.

我在Google云端硬盘帮助论坛"

1)我将"Google Apps脚本"应用添加到了驱动器中.

2)我创建了一个新应用,并通过了脚本:

 函数testSmallFolder(){var smallFolder = DriveApp.getFolderById('FOLDER_ID_HERE');var files = smallFolder.getFiles();同时(files.hasNext()){file = files.next();deleteRevisions(file);}var childFolders = smallFolder.getFolders();while(childFolders.hasNext()){var childFolder = childFolders.next();Logger.log(childFolder.getName());var files = childFolder.getFiles();同时(files.hasNext()){file = files.next();deleteRevisions(file);}getSubFoldersAndDelete(childFolder);}}函数deleteRevisions(文件){var fileId = file.getId();var版本= Drive.Revisions.list(fileId);如果(revisions.items& revisions.lengths> 1){对于(var i = 0; i< versions.items.length; i ++){var版本= versions.items [i];var date = new Date(revision.modifiedDate);var startDate = new Date();var endDate =新的Date(revision.modifiedDate);var fileName = Drive.Files.get(fileId);if(revision.modifiedDate>"2017-02-16T10:00:00"&& version.modifiedDate<"2017-02-18T10:00:00"&& version.lastModifyingUserName =="ENTER_MODIFIED_USERNAME_HERE]]&& file.getName()!==" HELP_DECRYPT.URL&& file.getName()!==" HELP_DECRYPT.PNG&& file.getName()!==" HELP_DECRYPT.HTML"){Logger.log('%s,Date:%s,文件大小(字节):%s',file.getName(),date.toLocaleString(),version.fileSize);返回Drive.Revisions.remove(fileId,version.id);}}} 别的{Logger.log('未找到修订版本.');}}函数getSubFoldersAndDelete(父级){parent = parent.getId();var childFolders = DriveApp.getFolderById(parent).getFolders();while(childFolders.hasNext()){var childFolder = childFolders.next();var files = childFolder.getFiles();同时(files.hasNext()){file = files.next();deleteRevisions(file);}getSubFoldersAndDelete(childFolder);}返回;}  

3)该脚本提供3个功能"testSmallFolder"/"deleteRevisions"/"getSubFoldersAndDelete".看起来函数"festSmallFolder"可以仅在某个文件夹上使用.第2行:FOLDER_ID_HERE

4)我创建了一个文件夹,并将文件移动到该文件夹​​中.之后,我获得了文件夹ID(URL)并将其添加到脚本中.

5)在第37行中,您可以添加修改的开始日期和结束日期.我还在同一行中调整了用户名.

6)我保存了脚本并运行了"testSmallFolder"功能.

7)我收到一条错误消息:"ReferenceError:未定义驱动器".(第27行,文件代码")".第27行如下所示:"var版本= Drive.Revisions.list(fileId);".

我再次联系了Google G Suite支持人员,并要求他们提供有关此错误的帮助.他们的回答是很抱歉,我们不支持脚本."

现在我在这里,请你帮忙.也许我们可以运行该脚本,以便恢复文件的最新工作版本.

非常感谢您能提供的任何帮助.

首先,您必须确保启用Advanced Drive Service,如此处所述: https://developers.google.com/apps-script/advanced/drive进入脚本页面,单击资源->,然后单击Google Advances Services,然后启用(必须为绿色!)Drive API.可能是警报打开了一个页面,您必须在该页面上增强脚本才能访问驱动器和文件夹(我认为这只是第一次).之后,如果在脚本的第二行上放置一个断点并在istruction之后运行调试器istruction,则可以顺利通过第27行,并且可以在变量堆栈中看到第一个文件的所有字符串,然后第二等...然后停止然后这次正常运行,一切都会好的.祝你有一个美好的夜晚.

long story short I got infected by the CryptoLocker Virus. My "normal" local files are not the problem because these files I backup. But I was using the Google Drive Sync client and all my Drive files got encrypted. I didn’t back them up because I thought Google Drive is save and my data is stored all over the world (my fault I know).

Now I can see that Google Drive provides versioning. This means my old uploads are still on the server. I can restore the previous version file by file but by several thousand files, good luck. I contacted the Google G Suite support team (I’m using Google G Suite for my business) and asked them if they can restore the latest version in one bulk action. The answer was "no you have to do it file by file". Therefore I was checking the internet for scripts, tools etc.

I found a Google Apps Script in the Google Drive help forum "https://productforums.google.com/forum/#!topic/drive/p08UBFYgFs0https://productforums.google.com/forum/#!topic/drive/p08UBFYgFs0".

1) I added the "Google Apps Script" app to my drive.

2) I created a new app and past the script:

function testSmallFolder() {          
  var smallFolder = DriveApp.getFolderById('FOLDER_ID_HERE');            
  var files = smallFolder.getFiles();  
  while (files.hasNext())
  {    
    file = files.next();      
    deleteRevisions(file);  
  }     
  var childFolders = smallFolder.getFolders(); 
  while(childFolders.hasNext()) 
  {
    var childFolder = childFolders.next();   
    Logger.log(childFolder.getName());    
    var files = childFolder.getFiles();  
    while (files.hasNext())
    {    
      file = files.next();         
      deleteRevisions(file);  
    }   
    getSubFoldersAndDelete(childFolder);     
  }   
} 

function deleteRevisions(file) 
{  
  var fileId = file.getId();  
  var revisions = Drive.Revisions.list(fileId);  
  if (revisions.items && revisions.items.length > 1) 
  {    
    for (var i = 0; i < revisions.items.length; i++) 
  {      
    var revision = revisions.items[i];      
    var date = new Date(revision.modifiedDate);      
    var startDate = new Date();      
    var endDate = new Date(revision.modifiedDate);      
    var fileName = Drive.Files.get(fileId);      
    if(revision.modifiedDate > "2017-02-16T10:00:00" && revision.modifiedDate < "2017-02-18T10:00:00" && revision.lastModifyingUserName == "ENTER_MODIFIED_USERNAME_HERE]]" && file.getName() !== "HELP_DECRYPT.URL" && file.getName() !== "HELP_DECRYPT.PNG" && file.getName() !== "HELP_DECRYPT.HTML")
    {      
      Logger.log(' %s, Date: %s, File size (bytes): %s',file.getName(), 
                 date.toLocaleString(),          
                 revision.fileSize);        
      return Drive.Revisions.remove( fileId, revision.id);      
    }    
  }  
  } else 
  {    
    Logger.log('No revisions found.');  
  }
}function getSubFoldersAndDelete(parent) 
{  
  parent = parent.getId();  
  var childFolders = DriveApp.getFolderById(parent).getFolders();  
  while(childFolders.hasNext()) 
{
 var childFolder = childFolders.next();     
 var files = childFolder.getFiles();  
 while (files.hasNext())
 {    
   file = files.next();         
   deleteRevisions(file);  
 }   
 getSubFoldersAndDelete(childFolder);     
}  
  return;
} 

3) The script provides 3 functions "testSmallFolder" / "deleteRevisions" / "getSubFoldersAndDelete". Looks like the function "festSmallFolder" can just work on a certain folder. Line 2: FOLDER_ID_HERE

4) I created a folder and moved my files into this folder. Afterwards I got the folder ID (URL) and added it to the script.

5) In line 37 you can add the start and end date of the modification. I also adjusted the username in the same line.

6) I saved the script and ran the "testSmallFolder" function.

7) I get an error message: "ReferenceError: "Drive" is not defined. (line 27, file "Code")". Line 27 looks like this: „var revisions = Drive.Revisions.list(fileId);".

I contacted again the Google G Suite support and asked them for help regarding this error. Their answer was "Sorry we do not support scripts."

Now I’m here guys and asking you for help. Maybe we can get this script running so that I can restore the latest working version of my files.

I really appreciate any help you can provide.

解决方案

You first of all must be sure to enable Advance Drive Service as documented here: https://developers.google.com/apps-script/advanced/drive Go in your script page, click on Resources --> then click on Google Advances Services, then enable (must be GREEN!) Drive API. Maybe an alert open you a page where you MUST abilitate the script to access at your drive and folders (I think only the first time). After do that, if you put a breakpoint on the 2nd row of the script and run the debugger istruction after istruction, you pass the 27 line without any problem, and you can see in the variable stack all the string for the first file, then for the second etc.... Stop then and Run normally this time and all will be ok. Have a good night.

这篇关于CryptoLocker-使用Google Apps脚本还原云端硬盘文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆