Exemplo n.º 1
0
        protected override ProgramBase.StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _bcdFile = new CommandLineParameter("bcd_file", "Path to the BCD file to inspect.", false);

            parser.AddParameter(_bcdFile);
            return StandardSwitches.Default;
        }
Exemplo n.º 2
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _portalAddress = new CommandLineParameter("portal", "Address of the iSCSI server (aka Portal) in the form <host>[:<port>], for example 192.168.1.2:3260 or 192.168.1.2", false);
            parser.AddParameter(_portalAddress);

            return StandardSwitches.UserAndPassword | StandardSwitches.Verbose;
        }
Exemplo n.º 3
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _host = new CommandLineParameter("host", "The name of a Mac / PC sharing its optical disk(s).  For example \"My Computer\".", true);
            parser.AddParameter(_host);

            return StandardSwitches.Default;
        }
Exemplo n.º 4
0
        protected override ProgramBase.StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _inFiles = FileOrUriMultiParameter("disk", "Paths to the disks to inspect.", false);

            parser.AddMultiParameter(_inFiles);

            return StandardSwitches.UserAndPassword;
        }
Exemplo n.º 5
0
        protected override ProgramBase.StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _vhdFile = new CommandLineParameter("vhd_file", "Path to the VHD file to inspect.", false);
            _dontCheck = new CommandLineSwitch("nc", "noCheck", null, "Don't check the VHD file format for corruption");

            parser.AddParameter(_vhdFile);
            parser.AddSwitch(_dontCheck);

            return StandardSwitches.Default;
        }
Exemplo n.º 6
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _sourceFile = FileOrUriParameter("in_file", "The disk image containing the Operating System image to be cloned.", false);
            _destFile = FileOrUriParameter("out_file", "The path to the output disk image.", false);
            _labelSwitch = new CommandLineSwitch("l", "label", "name", "The volume label for the NTFS file system created.");

            parser.AddParameter(_sourceFile);
            parser.AddParameter(_destFile);
            parser.AddSwitch(_labelSwitch);

            return StandardSwitches.OutputFormatAndAdapterType | StandardSwitches.UserAndPassword | StandardSwitches.DiskSize;
        }
Exemplo n.º 7
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _dmg = new CommandLineParameter("dmg", "Path to the .dmg file from which to extract the files", isOptional: false);
            _folder = new CommandLineParameter("folder", "Paths to the folders from which to extract the files.", isOptional: false);
            _recursive = new CommandLineSwitch("r", "recursive", null, "Include all subfolders of the folder specified");

            parser.AddParameter(_dmg);
            parser.AddParameter(_folder);
            parser.AddSwitch(_recursive);

            return StandardSwitches.Default;
        }
Exemplo n.º 8
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _isoFileParam = new CommandLineParameter("iso_file", "The ISO file to create.", false);
            _srcDir = new CommandLineParameter("sourcedir", "The directory to be added to the ISO", false);
            _bootImage = new CommandLineParameter("bootimage", "The bootable disk image, to create a bootable ISO", true);
            _volLabelSwitch = new CommandLineSwitch("vl", "vollabel", "label", "Volume Label for the ISO file.");

            parser.AddParameter(_isoFileParam);
            parser.AddParameter(_srcDir);
            parser.AddParameter(_bootImage);
            parser.AddSwitch(_volLabelSwitch);

            return StandardSwitches.Default;
        }
Exemplo n.º 9
0
        protected override ProgramBase.StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _diskFiles = FileOrUriMultiParameter("disk", "The disks to inspect.", false);
            _recoverFile = new CommandLineSwitch("r", "recover", "file_index", "Tries to recover the file at MFT index file_index from the disk.");
            _showMeta = new CommandLineSwitch("M", "meta", null, "Don't hide files and directories that are part of the file system itself.");
            _showZeroSize = new CommandLineSwitch("Z", "empty", null, "Don't hide files shown as zero size.");

            parser.AddMultiParameter(_diskFiles);
            parser.AddSwitch(_recoverFile);
            parser.AddSwitch(_showMeta);
            parser.AddSwitch(_showZeroSize);

            return StandardSwitches.UserAndPassword | StandardSwitches.PartitionOrVolume;
        }
Exemplo n.º 10
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _destFile = new CommandLineParameter("new.vhd", "Path to the VHD file to create.", false);
            _sourceFile = new CommandLineParameter("base.vhd", "For differencing disks, the path to the base disk.", true);
            _typeSwitch = new CommandLineSwitch("t", "type", "type", "The type of disk to create, one of: fixed, dynamic, diff.  The default is dynamic.");
            _blockSizeSwitch = new CommandLineSwitch("bs", "blocksize", "size", "For dynamic disks, the allocation uint size for new disk regions in bytes.  The default is 2MB.    Use B, KB, MB, GB to specify units (units default to bytes if not specified).");

            parser.AddParameter(_destFile);
            parser.AddParameter(_sourceFile);
            parser.AddSwitch(_typeSwitch);
            parser.AddSwitch(_blockSizeSwitch);

            return StandardSwitches.DiskSize;
        }
Exemplo n.º 11
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _inFile = FileOrUriParameter("in_file", "Path to the source disk.", false);
            _outFile = FileOrUriParameter("out_file", "Path to the output disk.", false);
            _translation = new CommandLineEnumSwitch<GeometryTranslation>("t", "translation", "mode", GeometryTranslation.None, "Indicates the geometry adjustment to apply for bootable disks.  Set this parameter to match the translation configured in the BIOS of the machine that will boot from the disk - auto should work in most cases for modern BIOS.");
            _wipe = new CommandLineSwitch("w", "wipe", null, "Write zero's to all unused parts of the disk.  This option only makes sense when converting to an iSCSI LUN which may be dirty.");

            parser.AddParameter(_inFile);
            parser.AddParameter(_outFile);
            parser.AddSwitch(_translation);
            parser.AddSwitch(_wipe);

            return StandardSwitches.OutputFormatAndAdapterType | StandardSwitches.UserAndPassword;
        }
Exemplo n.º 12
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _diskFiles = FileOrUriMultiParameter("disk", "Paths to the disks to inspect.", false);
            _showHidden = new CommandLineSwitch("H", "hidden", null, "Don't hide files and directories with the hidden attribute set in the directory listing.");
            _showSystem = new CommandLineSwitch("S", "system", null, "Don't hide files and directories with the system attribute set in the directory listing.");
            _showMeta = new CommandLineSwitch("M", "meta", null, "Don't hide files and directories that are part of the file system itself in the directory listing.");

            parser.AddMultiParameter(_diskFiles);
            parser.AddSwitch(_showHidden);
            parser.AddSwitch(_showSystem);
            parser.AddSwitch(_showMeta);

            return StandardSwitches.UserAndPassword | StandardSwitches.PartitionOrVolume;
        }
Exemplo n.º 13
0
        protected override ProgramBase.StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _diskFiles = FileOrUriMultiParameter("disk", "The disks to inspect.", false);
            _inFilePath = new CommandLineParameter("file_path", "The path of the file to extract.", false);
            _outFilePath = new CommandLineParameter("out_file", "The output file to be written.", false);
            _diskType = new CommandLineSwitch("dt", "disktype", "type", "Force the type of disk - use a file extension (one of " + string.Join(", ", VirtualDisk.SupportedDiskTypes) + ")");
            _hexDump = new CommandLineSwitch("hd", "hexdump", null, "Output a HexDump of the NTFS stream to the console, in addition to writing it to the output file.");

            parser.AddMultiParameter(_diskFiles);
            parser.AddParameter(_inFilePath);
            parser.AddParameter(_outFilePath);
            parser.AddSwitch(_diskType);
            parser.AddSwitch(_hexDump);

            return StandardSwitches.UserAndPassword | StandardSwitches.PartitionOrVolume;
        }
Exemplo n.º 14
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _inFiles = FileOrUriMultiParameter("disk", "Paths to the disks to inspect.  Where a volume manager is used to span volumes across multiple virtual disks, specify all disks in the set.", false);
            _showContent = new CommandLineSwitch("db", "diskbytes", null, "Includes a hexdump of all disk content in the output");
            _showVolContent = new CommandLineSwitch("vb", "volbytes", null, "Includes a hexdump of all volumes content in the output");
            _showFiles = new CommandLineSwitch("sf", "showfiles", null, "Includes a list of all files found in volumes");
            _showBootCode = new CommandLineSwitch("bc", "bootcode", null, "Includes a hexdump of the MBR and OS boot code in the output");
            _hideExtents = new CommandLineSwitch("he", "hideextents", null, "Suppresses display of the stored extents, which can be slow for large disk images");
            _diskType = new CommandLineSwitch("dt", "disktype", "type", "Force the type of disk - use a file extension (one of " + string.Join(", ", VirtualDisk.SupportedDiskTypes) + ")");

            parser.AddMultiParameter(_inFiles);
            parser.AddSwitch(_showContent);
            parser.AddSwitch(_showVolContent);
            parser.AddSwitch(_showFiles);
            parser.AddSwitch(_showBootCode);
            parser.AddSwitch(_hideExtents);
            parser.AddSwitch(_diskType);

            return StandardSwitches.UserAndPassword | StandardSwitches.FileNameEncoding;
        }
Exemplo n.º 15
0
        protected void Run(string[] args)
        {
            _parser = new CommandLineParser(ExeName);

            StandardSwitches stdSwitches = DefineCommandLine(_parser);

            if ((stdSwitches & StandardSwitches.OutputFormatAndAdapterType) != 0)
            {
                _outFormatSwitch = OutputFormatSwitch();
                _adapterTypeSwitch = new CommandLineEnumSwitch<GenericDiskAdapterType>("a", "adaptortype", "type", GenericDiskAdapterType.Ide, "Some disk formats encode the disk type (IDE or SCSI) into the disk image, this parameter specifies the type of adaptor to encode.");

                _parser.AddSwitch(_outFormatSwitch);
                _parser.AddSwitch(_adapterTypeSwitch);
            }

            if ((stdSwitches & StandardSwitches.DiskSize) != 0)
            {
                _diskSizeSwitch = new CommandLineSwitch("sz", "size", "size", "The size of the output disk.  Use B, KB, MB, GB to specify units (units default to bytes if not specified).");
                _parser.AddSwitch(_diskSizeSwitch);
            }

            if ((stdSwitches & StandardSwitches.FileNameEncoding) != 0)
            {
                _filenameEncodingSwitch = new CommandLineSwitch(new string[]{"ne"}, "nameencoding", "encoding", "The encoding used for filenames in the file system (aka the codepage), e.g. UTF-8 or IBM437.  This is ignored for file systems have fixed/defined encodings.");
                _parser.AddSwitch(_filenameEncodingSwitch);
            }

            if ((stdSwitches & StandardSwitches.PartitionOrVolume) != 0)
            {
                _partitionSwitch = new CommandLineSwitch("p", "partition", "num", "The number of the partition to inspect, in the range 0-n.  If not specified, 0 (the first partition) is the default.");
                _volumeIdSwitch = new CommandLineSwitch("v", "volume", "id", "The volume id of the volume to access, use the VolInfo tool to discover this id.  If specified, the partition parameter is ignored.");

                _parser.AddSwitch(_partitionSwitch);
                _parser.AddSwitch(_volumeIdSwitch);
            }

            if ((stdSwitches & StandardSwitches.UserAndPassword) != 0)
            {
                _userNameSwitch = new CommandLineSwitch("u", "user", "user_name", "If using an iSCSI source or target, optionally use this parameter to specify the user name to authenticate with.  If this parameter is specified without a password, you will be prompted to supply the password.");
                _parser.AddSwitch(_userNameSwitch);
                _passwordSwitch = new CommandLineSwitch("pw", "password", "secret", "If using an iSCSI source or target, optionally use this parameter to specify the password to authenticate with.");
                _parser.AddSwitch(_passwordSwitch);
            }

            if ((stdSwitches & StandardSwitches.Verbose) != 0)
            {
                _verboseSwitch = new CommandLineSwitch("v", "verbose", null, "Show detailed information.");
                _parser.AddSwitch(_verboseSwitch);
            }

            _helpSwitch = new CommandLineSwitch(new string[] { "h", "?" }, "help", null, "Show this help.");
            _parser.AddSwitch(_helpSwitch);
            _quietSwitch = new CommandLineSwitch("q", "quiet", null, "Run quietly.");
            _parser.AddSwitch(_quietSwitch);
            _timeSwitch = new CommandLineSwitch("time", null, "Times how long this program takes to execute.");
            _parser.AddSwitch(_timeSwitch);

            bool parseResult = _parser.Parse(args);

            if (!_quietSwitch.IsPresent)
            {
                DisplayHeader();
            }

            if (_helpSwitch.IsPresent || !parseResult)
            {
                DisplayHelp();
                return;
            }

            if ((stdSwitches & StandardSwitches.OutputFormatAndAdapterType) != 0)
            {
                if (_outFormatSwitch.IsPresent)
                {
                    string[] typeAndVariant = _outFormatSwitch.Value.Split(new char[] { '-' }, 2);
                    _outputDiskType = typeAndVariant[0];
                    _outputDiskVariant = (typeAndVariant.Length > 1) ? typeAndVariant[1] : "";
                }
                else
                {
                    DisplayHelp();
                    return;
                }

                if (_adapterTypeSwitch.IsPresent)
                {
                    _adapterType = _adapterTypeSwitch.EnumValue;
                }
                else
                {
                    _adapterType = GenericDiskAdapterType.Ide;
                }
            }

            if ((stdSwitches & StandardSwitches.DiskSize) != 0)
            {
                if (_diskSizeSwitch.IsPresent && !Utilities.TryParseDiskSize(_diskSizeSwitch.Value, out _diskSize))
                {
                    DisplayHelp();
                    return;
                }
            }

            if ((stdSwitches & StandardSwitches.PartitionOrVolume) != 0)
            {
                _partition = -1;
                if (_partitionSwitch.IsPresent && !int.TryParse(_partitionSwitch.Value, out _partition))
                {
                    DisplayHelp();
                    return;
                }

                _volumeId = _volumeIdSwitch.IsPresent ? _volumeIdSwitch.Value : null;
            }

            if ((stdSwitches & StandardSwitches.UserAndPassword) != 0)
            {
                _userName = null;

                if (_userNameSwitch.IsPresent)
                {
                    _userName = _userNameSwitch.Value;

                    if (_passwordSwitch.IsPresent)
                    {
                        _password = _passwordSwitch.Value;
                    }
                    else
                    {
                        _password = Utilities.PromptForPassword();
                    }
                }
            }

            if (_timeSwitch.IsPresent)
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                DoRun();
                stopWatch.Stop();

                Console.WriteLine();
                Console.WriteLine("Time taken: {0}", stopWatch.Elapsed);
            }
            else
            {
                DoRun();
            }
        }
Exemplo n.º 16
0
 protected abstract StandardSwitches DefineCommandLine(CommandLineParser parser);
Exemplo n.º 17
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _translation = new CommandLineEnumSwitch<GeometryTranslation>("t", "translation", "mode", GeometryTranslation.Auto,"Indicates the geometry adjustment to apply.  Set this parameter to match the translation configured in the BIOS of the machine that will boot from the disk - auto should work in most cases for modern BIOS.");
            _volumes = new CommandLineMultiParameter("volume", "Volumes to clone.  The volumes should all be on the same disk.", false);
            _destDisk = new CommandLineParameter("out_file", "Path to the output disk image.", false);

            parser.AddSwitch(_translation);
            parser.AddMultiParameter(_volumes);
            parser.AddParameter(_destDisk);

            return StandardSwitches.OutputFormatAndAdapterType;
        }