public void RemoveVMImageProcess() { try { Uri mediaLink = null; if (this.DeleteVHD.IsPresent) { // Get the location of the underlying VHD using (new OperationContextScope(Channel.ToContextChannel())) { var image = this.RetryCall(s => this.Channel.GetOSImage(s, this.ImageName)); mediaLink = image.MediaLink; } } // Remove the image from the image repository using (new OperationContextScope(Channel.ToContextChannel())) { ExecuteClientAction(null, CommandRuntime.ToString(), s => this.Channel.DeleteOSImage(s, this.ImageName)); } if (this.DeleteVHD.IsPresent) { // Remove the underlying VHD from the blob storage Disks.RemoveVHD(this.Channel, CurrentSubscription.SubscriptionId, mediaLink); } } catch (ServiceManagementClientException ex) { this.WriteErrorDetails(ex); } }
public async Task MainTest() { string rgName = SdkContext.RandomResourceName("rgRSMA", 24); string diskName = SdkContext.RandomResourceName("disk", 24); ResourceGroups oResourceGroups = new ResourceGroups(this.credentials, this.subscriptionId); oResourceGroups.Create(rgName, this.region); var disk = new Disks(credentials, subscriptionId); disk.Create(diskName, rgName, this.region, 50); var resources = await oResourceGroups.GetResources(rgName); Assert.AreEqual(Formatter.CountPageable(resources), 1); disk.Del(diskName, rgName); var resourcesAfterDel = await oResourceGroups.GetResources(rgName); Assert.LessOrEqual(Formatter.CountPageable(resourcesAfterDel), 0); oResourceGroups.Del(rgName); }
public NandViewModel() { OpenCommand = new RelayCommand(Open); var query = new WqlObjectQuery("SELECT * FROM Win32_DiskDrive"); using (var searcher = new ManagementObjectSearcher(query)) { foreach (ManagementBaseObject drive in searcher.Get()) { if (drive.GetPropertyValue("Size") == null) { continue; } var info = new DiskInfo(); info.PhysicalName = (string)drive.GetPropertyValue("Name"); info.Name = (string)drive.GetPropertyValue("Caption"); info.Model = (string)drive.GetPropertyValue("Model"); //todo Why is Windows returning small sizes? https://stackoverflow.com/questions/15051660 info.Length = (long)((ulong)drive.GetPropertyValue("Size")); info.SectorSize = (int)((uint)drive.GetPropertyValue("BytesPerSector")); info.DisplaySize = Util.GetBytesReadable((long)((ulong)drive.GetPropertyValue("Size"))); Disks.Add(info); } } }
public void WriteToConsole() { Console.WriteLine(); Disks.ConsoleWrite((p, disk) => { if (p == Goal) { return('G'); } if (p == Point.Origin) { return('H'); } if (disk.Used == 0) { return('_'); } if (disk.Used > 100) { return('#'); } if (disk.Avail >= Disks[Goal].Used) { return('+'); } return('.'); }); // foreach (var (p,d) in Disks.AllValues()) // { // Console.WriteLine($"At {p}: [{d.Used}/{d.Size}]"); // } }
private async void Init() { IsLoading = true; var list = new[] { "System.FreeSpace", "System.Capacity" }; var folders = await Task.WhenAll(DriveInfo.GetDrives().Select(it => it.Name) .Select(async it => await StorageFolder.GetFolderFromPathAsync(it))); var treeViewItems = new ObservableCollection <TreeViewItemModel>(folders.Select(it => new TreeViewItemModel(it, true))); TreeViewItems.AddAll(treeViewItems); var properties = await Task.WhenAll(folders.Select(async it => new { size = await it.Properties.RetrievePropertiesAsync(list), folder = it })); var items = properties.Select(it => new DiskModel { StorageFolder = it.folder, FreeSpace = Convert.ToDouble(it.size["System.FreeSpace"]), Capacity = Convert.ToDouble(it.size["System.Capacity"]) }).ToList(); items.ForEach(it => Disks.Add(it)); IsLoading = false; }
private int AddDisk(float x, float y) { Vector2i index = GridIndex(x, y); Disks.Add(new Vector2f(x, y)); m_grid[index.x, index.y] = Disks.Count - 1; return(m_grid[index.x, index.y]); }
public bool EqualByMembers(Computer computer) { return(computer != null && ComputerType == computer.ComputerType && ModelEqualityByMembers <Processor> .EqualByMembers(Processor, computer.Processor) && Memories.IsEquals(computer.Memories, new ModelEqualityByMembers <Memory>()) && Disks.IsEquals(computer.Disks, new ModelEqualityByMembers <Disk>()) && ModelEqualityByMembers <MotherBoard> .EqualByMembers(MotherBoard, computer.MotherBoard) && Gpus.IsEquals(computer.Gpus, new ModelEqualityByMembers <Gpu>())); }
/// <summary> /// Returns information about drive. /// </summary> /// <param name="name">Drive name. For example: C:\\</param> public static DriveInfo GetDrive(string name) { if (Disks.ContainsKey(name)) { return(Disks[name]); } else { return(null); } }
public DiskItem this[string name] // Indexer declaration { get { var result = Disks.FirstOrDefault(item => item.Value.Equals(name)); if (ReferenceEquals(result.Value, null)) { result = Disks.FirstOrDefault(item => item.Value.Model.Equals(name)); } return(result.Value); } }
public void Clear() { Disks.Clear(); for (int y = 0; y < GridHeight; y++) { for (int x = 0; x < GridWidth; x++) { m_grid[x, y] = -1; } } }
public int GetHashCodeWithMembers() { unchecked { var hashCode = 397; hashCode = (hashCode * 397) ^ (Processor?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Memories?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Disks?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (MotherBoard?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Gpus?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ ComputerType.GetHashCode(); return(hashCode); } }
public void RemoveVMImageProcess() { Func <string, OSImage> func = null; Action <string> action = null; try { Uri mediaLink = null; SwitchParameter deleteVHD = this.DeleteVHD; if (deleteVHD.IsPresent) { using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { RemoveAzureVMImageCommand removeAzureVMImageCommand = this; if (func == null) { func = (string s) => base.Channel.GetOSImage(s, this.ImageName); } OSImage oSImage = ((CmdletBase <IServiceManagement>)removeAzureVMImageCommand).RetryCall <OSImage>(func); mediaLink = oSImage.MediaLink; } } using (OperationContextScope operationContextScope1 = new OperationContextScope((IContextChannel)base.Channel)) { RemoveAzureVMImageCommand removeAzureVMImageCommand1 = this; if (action == null) { action = (string s) => base.Channel.DeleteOSImage(s, this.ImageName); } ((CmdletBase <IServiceManagement>)removeAzureVMImageCommand1).RetryCall(action); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); managementOperationContext.set_OperationId(operation.OperationTrackingId); managementOperationContext.set_OperationStatus(operation.Status); ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } SwitchParameter switchParameter = this.DeleteVHD; if (switchParameter.IsPresent) { Disks.RemoveVHD(base.Channel, base.get_CurrentSubscription().get_SubscriptionId(), mediaLink); } } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } }
public Cluster Copy() { var copy = new Cluster(); copy.Disks = new SparseMap <Disk>(); foreach (var(p, disk) in Disks.All()) { copy.Disks[p] = new Disk { Size = disk.Size, Used = disk.Used }; } copy.Goal = Goal; return(copy); }
public HanoiTower() { for (int i = 0; i < DIMENTION_1; i++) { TowerSet[i] = new Disks[DIMENTION_2]; for (int j = 0; j < DIMENTION_2; j++) { if (i == 0) { TowerSet[i][j] = (Disks)j + 1; } } } TowerSet[0][NAME_POSITION] = Disks.TowerA; TowerSet[1][NAME_POSITION] = Disks.TowerB; TowerSet[2][NAME_POSITION] = Disks.TowerC; }
private static void RefreshDrives() { Disks.Clear(); foreach (var drive in DriveInfo.GetDrives()) { Disks.Add(drive.Name, drive); // to się przyda potem: //double freeSpace = drive.TotalFreeSpace; //double totalSpace = drive.TotalSize; //double percentFree = (freeSpace / totalSpace) * 100; //float num = (float)percentFree; //Console.WriteLine("Drive:{0} With {1} % free", drive.Name, num); //Console.WriteLine("Space Remaining:{0}", drive.AvailableFreeSpace); //Console.WriteLine("Percent Free Space:{0}", percentFree); //Console.WriteLine("Space used:{0}", drive.TotalSize); //Console.WriteLine("Type: {0}", drive.DriveType); //Console.WriteLine("\n\n"); } }
public AntdStorageModule() { Get["/storage"] = x => { var disks = new Disks(); var model = new PageStorageModel { DisksList = disks.GetList() }; return(JsonConvert.SerializeObject(model)); }; Post["/storage/print"] = x => { string disk = Request.Form.Disk; var result = _bash.Execute($"parted /dev/{disk} print 2> /dev/null").SplitBash().Grep("'Partition Table: '").First(); return(Response.AsText(result.Replace("Partition Table: ", ""))); }; Post["/storage/mklabel"] = x => { string disk = Request.Form.Disk; string type = Request.Form.Type; string yn = Request.Form.Confirm; var result = _bash.Execute($"parted -a optimal /dev/{disk} mklabel {type} {yn}"); return(Response.AsText(result)); }; }
public async Task Initialize() { //await base.Initialize(); var Memory = new AddressableRegion { SizeRows = 3, SizeColumns = 4, }; Memory.InitializeEmptyMemorySpace(); #region disk var disk0 = new AddressableRegion(); disk0.VolumeName = "Keystore"; disk0.ReadOnly = true; disk0.DriveId = 0; disk0.SizeRows = 4; disk0.SizeColumns = 4; disk0.InitializeEmptyMemorySpace(); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 0 }, "~451"); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 0, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 0, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 2, Y = 0, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 3, Y = 0, DriveId = 0 }] = true; disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 0 }, "~451"); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 1, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 1, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 2, Y = 1, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 3, Y = 1, DriveId = 0 }] = true; disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 0 }, "~451"); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 2, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 2, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 2, Y = 2, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 3, Y = 2, DriveId = 0 }] = true; disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 3 }, "/*YOU"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 1, Y = 3 }, "R KE"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 2, Y = 3 }, "Y HE"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 3, Y = 3 }, "RE*/"); disk0.SetMemoryToDefault(); Disks.Add(disk0); #endregion Memory.SetMemoryToDefault(); var ManualProgram = new CpuProgram(); ManualProgram.AllCommands = new List <CpuCommand>(); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT KBD M:0A")); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:0A @SEARCH_TEXT")); ManualProgram.AllCommands.Add(QueryCpuCommand.FromText("QUERY 0:3* FOR @SEARCH_TEXT")); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT @Index M:0B")); ManualProgram.AllCommands.Add(new AssertCpuCommand("M:0A", "XM:0B")); AddProcess("Login.exe", new Process { Memory = Memory, Source = ManualProgram, Prompt = "Please enter your password", Instruction = "^ Can't remember your password? Try 'Password'." }); this.Hints.Add(new Hint { Title = "What am I looking at?", Body = "In this scenario, some memory addresses are prefixed with X. This indicates that the value in memory at that location should be treated as a MEMORY ADDRESS to go fetch the value from." }); this.Hints.Add(new Hint { Title = "The security is too tight! There's no way for me to get in and break this thing.", Body = "Yea, it'd be better if you just had the password." }); this.Hints.Add(new Hint { Title = "The password's in encrypted memory, I can't see it.", Body = "Find a way to get the password OUT of encrypted memory." }); }
private void button17_Click(object sender, EventArgs e) { label17.Text = Disks.GetDriveName(); }
//Диски private void button16_Click(object sender, EventArgs e) { label16.Text = Disks.GetHDDSerialNo(); }
public AntdZfsModule() { Get["/zfs"] = x => { var zpool = new Zpool(); var zfsSnap = new ZfsSnap(); var zfs = new Zfs(); var disks = new Disks(); var model = new PageZfsModel { ZpoolList = zpool.List(), ZfsList = zfs.List(), ZfsSnap = zfsSnap.List(), ZpoolHistory = zpool.History(), DisksList = disks.GetList().Where(_ => _.Type == "disk" && string.IsNullOrEmpty(_.Mountpoint)) }; return(JsonConvert.SerializeObject(model)); }; //todo //Get["/zfs/cron"] = x => { // var list = _timerRepository.GetAll(); // return Response.AsJson(list); //}; Post["/zfs/snap"] = x => { string pool = Request.Form.Pool; string interval = Request.Form.Interval; if (string.IsNullOrEmpty(pool) || string.IsNullOrEmpty(interval)) { return(HttpStatusCode.InternalServerError); } _timers.Create(pool + "snap", interval, $"/sbin/zfs snap -r {pool}@${{TTDATE}}"); return(HttpStatusCode.OK); }; //Post["/zfs/snap/disable"] = x => { // string guid = Request.Form.Guid; // var tt = _timerRepository.GetByGuid(guid); // if(tt == null) // return HttpStatusCode.InternalServerError; // _timers.Disable(tt.Alias); // return HttpStatusCode.OK; //}; Post["/zpool/create"] = x => { string altroot = Request.Form.Altroot; string poolname = Request.Form.Name; string pooltype = Request.Form.Type; string disk = Request.Form.Disk; if (string.IsNullOrEmpty(altroot) || string.IsNullOrEmpty(poolname) || string.IsNullOrEmpty(pooltype) || string.IsNullOrEmpty(disk)) { return(HttpStatusCode.BadRequest); } ConsoleLogger.Log($"[zpool] create => altroot:{altroot} poolname:{poolname} pooltype:{pooltype} disk:{disk} "); _launcher.Launch("zpool-create", new Dictionary <string, string> { { "$pool_altroot", altroot }, { "$pool_name", poolname }, { "$pool_type", poolname }, { "$disk", disk } }); return(HttpStatusCode.OK); }; Post["/zfs/create"] = x => { string altroot = Request.Form.Altroot; string poolname = Request.Form.Name; string datasetname = Request.Form.Dataset; if (string.IsNullOrEmpty(altroot) || string.IsNullOrEmpty(poolname) || string.IsNullOrEmpty(datasetname)) { return(HttpStatusCode.BadRequest); } _launcher.Launch("zfs-create", new Dictionary <string, string> { { "$pool_altroot", altroot }, { "$pool_name", poolname }, { "$dataset_name", datasetname } }); return(HttpStatusCode.OK); }; }
private void button18_Click(object sender, EventArgs e) { label18.Text = Disks.GetDriveManufacturer(); }
public async Task Initialize() { //await base.Initialize(); NextScenario = "Scenario4"; var process = new Process { Prompt = "Please enter your 4 character pin number to manage the camera feed.", Instruction = "^ Note: pin number 'HOTDOG' has been disabled due to it not being 4 characters, or a number." }; var Memory = new AddressableRegion { SizeRows = 3, SizeColumns = 4, }; Memory.InitializeEmptyMemorySpace(); #region disk var disk0 = new AddressableRegion(); disk0.VolumeName = "Keystore"; disk0.DriveId = 0; disk0.SizeRows = 1; disk0.SizeColumns = 4; disk0.InitializeEmptyMemorySpace(); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 0 }, "0x1x"); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 0, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 0, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 2, Y = 0, DriveId = 0 }] = true; disk0.EncryptionState[new MemoryCoordinate { X = 3, Y = 0, DriveId = 0 }] = true; disk0.SetMemoryToDefault(); Disks.Add(disk0); #endregion //Memory.SetDefault(new MemoryCoordinate { X = 0, Y = 0}, "VALI"); //Memory.SetDefault(new MemoryCoordinate { X = 1, Y = 0 }, "DATI"); //Memory.SetDefault(new MemoryCoordinate { X = 2, Y = 0 }, "NG "); //Memory.SetDefault(new MemoryCoordinate { X = 0, Y = 1 }, "PASS"); //Memory.SetDefault(new MemoryCoordinate { X = 1, Y = 1 }, "WORD"); //Memory.SetDefault(new MemoryCoordinate { X = 2, Y = 1 }, "|"); //Memory.SetDefault(new MemoryCoordinate { X = 3, Y = 2 }, "0x51"); //Memory.EncryptionState[new MemoryCoordinate { X = 3, Y = 2 }] = true; Memory.SetMemoryToDefault(); process.Memory = Memory; //var ManualProgram = new CpuProgram(); //ManualProgram.AllCommands = new List<CpuCommand>(); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:0A PRINT")); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:1A PRINT")); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:2A PRINT")); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:0B PRINT")); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:1B PRINT")); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:2B PRINT")); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT KB M:0C")); //ManualProgram.AllCommands.Add(new AssertCpuCommand("M:0C", "0:0,0")); //process.Source = ManualProgram; this.AddProcess("Login.exe", process); }
private void button19_Click(object sender, EventArgs e) { label19.Text = Disks.GetCdRomDrive(); }
private void button20_Click(object sender, EventArgs e) { label20.Text = Disks.GetDriveFreeSize() + " " + "ГБ"; label21.Text = Disks.GetDriveSize() + " " + "ГБ"; }
public async Task Initialize() { //await base.Initialize(); var Memory = new AddressableRegion { SizeRows = 2, SizeColumns = 4, }; Memory.InitializeEmptyMemorySpace(); #region disk var disk0 = new AddressableRegion(); disk0.VolumeName = "Keystore"; disk0.ReadOnly = true; disk0.DriveId = 0; disk0.SizeRows = 5; disk0.SizeColumns = 3; disk0.InitializeEmptyMemorySpace(); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 0 }, "USR1"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 1, Y = 0 }, "0451"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 2, Y = 0 }, "HIGH"); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 0, DriveId = 0 }] = false; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 0, DriveId = 0 }] = true; disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 1 }, "USR2"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 1, Y = 1 }, "0451"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 2, Y = 1 }, "HIGH"); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 1, DriveId = 0 }] = false; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 1, DriveId = 0 }] = true; disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 2 }, "USR3"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 1, Y = 2 }, "0451"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 2, Y = 2 }, "LOW "); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 2, DriveId = 0 }] = false; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 2, DriveId = 0 }] = true; disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 3 }, "USR4"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 1, Y = 3 }, "0451"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 2, Y = 3 }, "LOW "); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 3, DriveId = 0 }] = false; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 3, DriveId = 0 }] = true; disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 0, Y = 4 }, "USR5"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 1, Y = 4 }, "0451"); disk0.SetDefault(new MemoryCoordinate { DriveId = 0, X = 2, Y = 4 }, "LOW "); disk0.EncryptionState[new MemoryCoordinate { X = 0, Y = 4, DriveId = 0 }] = false; disk0.EncryptionState[new MemoryCoordinate { X = 1, Y = 4, DriveId = 0 }] = true; disk0.SetMemoryToDefault(); Disks.Add(disk0); #endregion var disk1 = new AddressableRegion { VolumeName = "SWAP_DRIVE", ReadOnly = false, DriveId = 1, SizeRows = 2, SizeColumns = 4 }; disk1.InitializeEmptyMemorySpace(); disk1.SetDefault(MemoryCoordinate.FromText("1:0A"), "ACCE"); disk1.SetDefault(MemoryCoordinate.FromText("1:1A"), "SS G"); disk1.SetDefault(MemoryCoordinate.FromText("1:2A"), "RANT"); disk1.SetDefault(MemoryCoordinate.FromText("1:3A"), "ED "); disk1.SetDefault(MemoryCoordinate.FromText("1:0B"), "----"); disk1.SetDefault(MemoryCoordinate.FromText("1:1B"), " "); disk1.SetDefault(MemoryCoordinate.FromText("1:2B"), "SEC:"); disk1.SetDefault(MemoryCoordinate.FromText("1:3B"), "----"); disk1.SetMemoryToDefault(); Disks.Add(disk1); var disk2 = new AddressableRegion { VolumeName = "QUERY_BUILDER", ReadOnly = false, DriveId = 2, SizeRows = 2, SizeColumns = 4 }; disk2.InitializeEmptyMemorySpace(); disk2.SetDefault(MemoryCoordinate.FromText("2:0A"), "QUER"); disk2.SetDefault(MemoryCoordinate.FromText("2:1A"), "Y "); disk2.SetDefault(MemoryCoordinate.FromText("2:2A"), "0:**"); disk2.SetDefault(MemoryCoordinate.FromText("2:3A"), " FOR"); disk2.SetDefault(MemoryCoordinate.FromText("2:0B"), " @USR"); disk2.SetDefault(MemoryCoordinate.FromText("2:1B"), "/@PWD"); disk2.SetMemoryToDefault(); Disks.Add(disk2); Memory.SetMemoryToDefault(); var ManualProgram = new CpuProgram(); ManualProgram.AllCommands = new List <CpuCommand>(); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT KBD M:0A")); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:0A @USR")); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT M:1A @PWD")); ManualProgram.AllCommands.Add(ExecCpuCommand.FromText("EXEC 2:**")); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT @Index 1:0B")); ManualProgram.AllCommands.Add(new SeekCpuCommand() { Amount = new LiteralTarget { Value = "2" }, Target = new VariableTarget { Number = "Index" } }); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT @Index 1:3B")); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT X1:0B 1:0B")); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT X1:3B 1:3B")); ManualProgram.AllCommands.Add(new DumpCommand() { From = new SearchConstraints { DriveConstraint = 1 }, Target = new PrinterTarget() }); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT `| PRINT")); AddProcess("Login.exe", new Process { Memory = Memory, Source = ManualProgram, Prompt = "Please enter your password", Instruction = "^ Can't remember your password? Try 'Password'." }); }
public async Task Initialize() { //await base.Initialize(); var Memory = new AddressableRegion { SizeRows = 3, SizeColumns = 4, }; Memory.InitializeEmptyMemorySpace(); #region disk var disk0 = new AddressableRegion(); disk0.VolumeName = "SWAP_DRIVE"; disk0.ReadOnly = false; disk0.DriveId = 0; disk0.SizeRows = 1; disk0.SizeColumns = 4; disk0.InitializeEmptyMemorySpace(); disk0.SetMemoryToDefault(); Disks.Add(disk0); #endregion disk #region disk var disk1 = new AddressableRegion(); disk1.VolumeName = "Keystore"; disk1.ReadOnly = true; disk1.DriveId = 1; disk1.SizeRows = 1; disk1.SizeColumns = 4; disk1.InitializeEmptyMemorySpace(); disk1.SetDefault(new MemoryCoordinate { DriveId = 1, X = 0, Y = 0 }, "0451"); disk1.SetDefault(new MemoryCoordinate { DriveId = 1, X = 1, Y = 0 }, "0451"); disk1.SetDefault(new MemoryCoordinate { DriveId = 1, X = 2, Y = 0 }, "PASS"); disk1.SetDefault(new MemoryCoordinate { DriveId = 1, X = 3, Y = 0 }, "0451"); disk1.EncryptionState[new MemoryCoordinate { X = 0, Y = 0, DriveId = 1 }] = true; disk1.EncryptionState[new MemoryCoordinate { X = 1, Y = 0, DriveId = 1 }] = true; disk1.EncryptionState[new MemoryCoordinate { X = 2, Y = 0, DriveId = 1 }] = false; disk1.EncryptionState[new MemoryCoordinate { X = 3, Y = 0, DriveId = 1 }] = true; disk1.SetMemoryToDefault(); Disks.Add(disk1); #endregion #region disk //var disk1 = new AddressableRegion //{ // VolumeName = "SWAP_DRIVE", // ReadOnly = true, // DriveId = 1, // SizeRows = 1, // SizeColumns = 4, // IsExternalDrive = true, // IsMounted = false //}; //disk1.InitializeEmptyMemorySpace(); //disk1.SetDefault(new MemoryCoordinate { DriveId = 1, X = 0, Y = 0 }, "YOUR"); //disk1.SetDefault(new MemoryCoordinate { DriveId = 1, X = 1, Y = 0 }, "DATA"); //disk1.SetDefault(new MemoryCoordinate { DriveId = 1, X = 2, Y = 0 }, "HERE"); //disk1.SetMemoryToDefault(); //Disks.Add(disk1); #endregion Memory.SetMemoryToDefault(); // // var ManualProgram = new CpuProgram(); ManualProgram.AllCommands = new List <CpuCommand>(); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT KBD 0:0A")); ManualProgram.AllCommands.Add(QueryCpuCommand.FromText("QUERY *:** FOR `PASS")); ManualProgram.AllCommands.Add(new SeekCpuCommand { Target = new VariableTarget { Number = "Index" }, Amount = new LiteralTarget { Value = "1" } }); ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT @Index M:0B")); ManualProgram.AllCommands.Add(new AssertCpuCommand("0:0A", "XM:0B")); //ManualProgram.AllCommands.Add(ReadCpuCommand.FromText("PUT KB M:2C")); //ManualProgram.AllCommands.Add(new AssertCpuCommand //{ // CompareLeft = MediaTarget.FromText("M:2C"), // CompareRight = MediaTarget.FromText("0:0,0") //}); AddProcess("Login.exe", new Process { Memory = Memory, Source = ManualProgram, Prompt = "Please enter your password", Instruction = "^ Can't remember your password? Try 'Password'." }); this.Hints.Add(new Hint { Title = "What am I looking at?", Body = "In this scenario, some memory addresses are prefixed with X. This indicates that the value in memory at that location should be treated as a MEMORY ADDRESS to go fetch the value from." }); this.Hints.Add(new Hint { Title = "The security is too tight! There's no way for me to get in and break this thing.", Body = "Yea, it'd be better if you just had the password." }); this.Hints.Add(new Hint { Title = "The password's in encrypted memory, I can't see it.", Body = "Find a way to get the password OUT of encrypted memory." }); }