Ejemplo n.º 1
0
        public static string GetDrives()
        {
            var result = new SharpC2ResultList <DriveInfoResult>();
            var drives = DriveInfo.GetDrives();

            foreach (var drive in drives)
            {
                var info = new DriveInfoResult
                {
                    Name = drive.Name,
                    Type = drive.DriveType
                };

                if (drive.IsReady)
                {
                    info.Label     = drive.VolumeLabel;
                    info.Format    = drive.DriveFormat;
                    info.Capacity  = Helpers.ConvertFileLength(drive.TotalSize);
                    info.FreeSpace = Helpers.ConvertFileLength(drive.AvailableFreeSpace);
                }

                result.Add(info);
            }

            return(result.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets information about current drives.
        /// </summary>
        /// <returns>SharpSploitResultList of DriveInfoResults</returns>
        public static SharpSploitResultList <DriveInfoResult> GetDrives()
        {
            SharpSploitResultList <DriveInfoResult> results = new SharpSploitResultList <DriveInfoResult>();

            DriveInfo[] drives = DriveInfo.GetDrives();

            foreach (DriveInfo drive in drives)
            {
                DriveInfoResult info = new DriveInfoResult
                {
                    Name = drive.Name,
                    Type = drive.DriveType
                };
                if (drive.IsReady)
                {
                    info.Label     = drive.VolumeLabel;
                    info.Format    = drive.DriveFormat;
                    info.Capacity  = Utilities.ConvertFileLengthForDisplay(drive.TotalSize);
                    info.FreeSpace = Utilities.ConvertFileLengthForDisplay(drive.AvailableFreeSpace);
                }
                results.Add(info);
            }
            return(results);
        }