public PartialViewResult MountShadowCopy(string computerName, string timestamp)
 {
     try
     {
         PSRemoting    psr     = new PSRemoting(computerName, config.FALCON_FORENSICS_USERNAME, config.FALCON_FORENSICS_PASSWORD, config.FALCON_FORENSICS_DOMAIN);
         SystemRestore restore = new SystemRestore(psr);
         ShadowCopy    copy    = restore.GetShadowCopyByTime(Convert.ToDateTime(timestamp));
         restore.MountShadowCopyVolume(copy.DeviceObject + @"\");
         return(BrowserRefresh(computerName, @"C:\shadow", copy.DeviceObject));
     }
     catch (Exception e)
     {
         Response.StatusCode = 500;
         return(PartialView("_Error", e.Message));
     }
 }
예제 #2
0
 public static void Main(string[] args)
 {
     ShadowCopy.RunMain(main, args);
 }
예제 #3
0
        private CacheEntry <MetadataShadowCopy> CreateMetadataShadowCopy(string originalPath, MetadataImageKind kind)
        {
            int attempts = 10;

            while (true)
            {
                try
                {
                    if (ShadowCopyDirectory == null)
                    {
                        ShadowCopyDirectory = CreateUniqueDirectory(_baseDirectory);
                    }

                    // Create directory for the assembly.
                    // If the assembly has any modules they have to be copied to the same directory
                    // and have the same names as specified in metadata.
                    string assemblyDir    = CreateUniqueDirectory(ShadowCopyDirectory);
                    string shadowCopyPath = Path.Combine(assemblyDir, Path.GetFileName(originalPath));

                    ShadowCopy documentationFileCopy = null;
                    string     xmlOriginalPath;
                    if (TryFindXmlDocumentationFile(originalPath, out xmlOriginalPath))
                    {
                        // TODO (tomat): how do doc comments work for multi-module assembly?
                        var xmlCopyPath = Path.ChangeExtension(shadowCopyPath, ".xml");
                        var xmlStream   = CopyFile(xmlOriginalPath, xmlCopyPath, fileMayNotExist: true);
                        if (xmlStream != null)
                        {
                            documentationFileCopy = new ShadowCopy(xmlStream, xmlOriginalPath, xmlCopyPath);
                        }
                    }

                    var manifestModuleCopyStream = CopyFile(originalPath, shadowCopyPath);
                    var manifestModuleCopy       = new ShadowCopy(manifestModuleCopyStream, originalPath, shadowCopyPath);

                    Metadata privateMetadata;
                    if (kind == MetadataImageKind.Assembly)
                    {
                        privateMetadata = CreateAssemblyMetadata(manifestModuleCopyStream, originalPath, shadowCopyPath);
                    }
                    else
                    {
                        privateMetadata = CreateModuleMetadata(manifestModuleCopyStream);
                    }

                    var publicMetadata = privateMetadata.Copy();
                    return(new CacheEntry <MetadataShadowCopy>(new MetadataShadowCopy(manifestModuleCopy, documentationFileCopy, publicMetadata), privateMetadata));
                }
                catch (DirectoryNotFoundException)
                {
                    // the shadow copy directory has been deleted - try to copy all files again
                    if (!Directory.Exists(ShadowCopyDirectory))
                    {
                        ShadowCopyDirectory = null;
                        if (attempts-- > 0)
                        {
                            continue;
                        }
                    }

                    throw;
                }
            }
        }
예제 #4
0
 public MspecTestContainer(string location, ShadowCopy shadowCopy)
     : base(location, shadowCopy)
 {
 }