예제 #1
0
        public bool TryGetHackable(uint address, ushort port, out int hops, out HackStartInfo startInfo)
        {
            var result = false;

            hops      = 0;
            startInfo = null;

            var node = MapAddressToNode(address, out hops);

            if (node is DeviceNode device)
            {
                var hackables = _simulation.GetHackables(device.Device);

                var matched = hackables.FirstOrDefault(x => x.Port == port);

                if (matched != null)
                {
                    startInfo = _simulation.StartHack(matched);
                    result    = true;
                }
            }
            else if (node is NetworkNode network)
            {
                var mappedHackables = _simulation.GetMappedHackables(network.Network);

                var matched = mappedHackables.FirstOrDefault(x => x.Port == port);

                if (matched != null)
                {
                    if (!matched.HackableFlags.IsFirewalled)
                    {
                        startInfo = _simulation.StartHack(matched);
                        result    = true;
                    }
                }
            }

            return(result);
        }
예제 #2
0
 public HackContext(HackStartInfo hack, Device device, NetworkInterface nic)
 {
     _hack   = hack;
     _nic    = nic;
     _device = device;
 }