コード例 #1
0
 private IEnumerable <string> GetResourcesFromFiles(params byte[][] files)
 {
     foreach (byte[] fileBytes in files)
     {
         yield return(HashHelper.GetSHA256(fileBytes));
     }
 }
コード例 #2
0
 private IEnumerable <string> GetResourcesFromFiles(params Stream[] streams)
 {
     foreach (Stream stream in streams)
     {
         yield return(HashHelper.GetSHA256(stream));
     }
 }
コード例 #3
0
 private IEnumerable <string> GetResourcesFromFiles(params FileInfo[] files)
 {
     foreach (FileInfo fileInfo in files)
     {
         yield return(HashHelper.GetSHA256(fileInfo));
     }
 }
コード例 #4
0
        private IEnumerable <string> GetResourcesFromFiles(IEnumerable <FileInfo> files)
        {
            foreach (FileInfo fileInfo in files)
            {
                if (!fileInfo.Exists)
                {
                    throw new FileNotFoundException("The file " + fileInfo.FullName + " does not exist.");
                }

                yield return(HashHelper.GetSHA256(fileInfo));
            }
        }
コード例 #5
0
        /// <summary>
        /// Gets the report of the file.
        /// </summary>
        /// <param name="file">A list of files that will get hashes and scanned.</param>
        /// <returns></returns>
        public List <Report> GetFileReport(params FileInfo[] file)
        {
            string[] resources = new string[file.Length];

            for (int i = 0; i < file.Length; i++)
            {
                FileInfo fileInfo = file[i];
                if (fileInfo.Exists)
                {
                    resources[i] = HashHelper.GetSHA256(fileInfo);
                }
            }

            return(GetFileReport(resources));
        }
コード例 #6
0
        private IEnumerable <string> GetResourcesFromFiles(IEnumerable <FileInfo> files)
        {
            FileInfo[] fileInfos = files as FileInfo[] ?? files.ToArray();

            string[] hashes = new string[fileInfos.Length];

            for (int i = 0; i < fileInfos.Length; i++)
            {
                FileInfo fileInfo = fileInfos[i];

                if (!fileInfo.Exists)
                {
                    throw new FileNotFoundException("The file " + fileInfo.FullName + " does not exist.");
                }

                hashes[i] = HashHelper.GetSHA256(fileInfo);
            }

            return(hashes);
        }
コード例 #7
0
 /// <summary>
 /// Gives you a link to a URL analysis.
 /// </summary>
 /// <returns>A link to VirusTotal that contains the report</returns>
 public string GetPublicUrlScanLink(string url)
 {
     return(string.Format("{0}://www.virustotal.com/url/{1}/analysis/", UseTLS ? "https" : "http", HashHelper.GetSHA256(NormalizeUrl(url))));
 }
コード例 #8
0
 /// <summary>
 /// Gives you a link to a file analysis based on its hash.
 /// </summary>
 /// <returns>A link to VirusTotal that contains the report</returns>
 public string GetPublicFileScanLink(FileInfo file)
 {
     return(GetPublicFileScanLink(HashHelper.GetSHA256(file)));
 }
コード例 #9
0
 /// <summary>
 /// Creates a comment on a file denoted by its hash and/or scan ID.
 /// </summary>
 /// <param name="file">The file you wish to create a comment on</param>
 /// <param name="comment">The comment you wish to add.</param>
 /// <returns>A ScanResult object containing information about the resource.</returns>
 public Task <ScanResult> CreateComment(FileInfo file, string comment)
 {
     return(CreateComment(HashHelper.GetSHA256(file), comment));
 }
コード例 #10
0
 /// <summary>
 /// Gets the report of the file.
 /// Note: This does not send the files to VirusTotal. It hashes the file and sends that instead.
 /// </summary>
 /// <param name="file">The file you wish to get a report on.</param>
 public Task <FileReport> GetFileReport(FileInfo file)
 {
     return(GetFileReport(HashHelper.GetSHA256(file)));
 }
コード例 #11
0
 /// <summary>
 /// Creates a comment on a file denoted by its hash and/or scan ID.
 /// </summary>
 /// <param name="file">The file you wish to create a comment on</param>
 /// <param name="comment">The comment you wish to add.</param>
 /// <returns>A ScanResult object containing information about the resource.</returns>
 public ScanResult CreateComment(byte[] file, string comment)
 {
     return(CreateComment(HashHelper.GetSHA256(file), comment));
 }
コード例 #12
0
 /// <summary>
 /// Gets the report of the file.
 /// Note: This does not send the files to VirusTotal. It hashes the file and sends that instead.
 /// </summary>
 /// <param name="file">The file you wish to get a report on.</param>
 public FileReport GetFileReport(byte[] file)
 {
     return(GetFileReport(HashHelper.GetSHA256(file)));
 }
コード例 #13
0
 public string GetPublicScanLink(FileInfo file)
 {
     return(string.Format("{0}://www.virustotal.com/file/{1}/analysis/", UseTLS ? "https" : "http", HashHelper.GetSHA256(file)));
 }