Пример #1
0
        public async Task <IActionResult> AddMalware()
        {
            System.Console.WriteLine("Jestem");
            var file = Request.Form.Files[0];

            foreach (var t in Request.Form.Keys)
            {
                System.Console.WriteLine(t);
            }

            var dict = Request.Form.ToDictionary(x => x.Key, x => x.Value.ToString());

            System.Console.WriteLine("Win: " + file.FileName);
            MalwareDto malwareDto = new MalwareDto();

            System.Console.WriteLine("Chcą coś dodać2");
            System.Console.WriteLine(JsonConvert.SerializeObject(malwareDto));
            Malware malware = new Malware()
            {
                Name   = dict["name"],
                Author = dict["author"]
            };

            using (var ms = new MemoryStream())
            {
                file.CopyTo(ms);
                malware.Blob = ms.ToArray();
            }
            System.Console.WriteLine("Malware" + malware.ToString());


            await _repo.InsertOne(malware);

            return(StatusCode(201));
        }
Пример #2
0
 public IActionResult Delete(string id)
 {
     try
     {
         var malware = malwareManager.GetByMd5(id);
         if (malware != null)
         {
             Malware model = new Malware
             {
                 Id            = malware.Id,
                 User          = malware.User,
                 MD5           = malware.MD5,
                 SHA256        = malware.SHA256,
                 MalwareLevel  = malware.MalwareLevel,
                 MalwareStatus = malware.MalwareStatus,
                 Date          = malware.Date
             };
             return(View(model));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception e)
     {
         _log.LogError(e.Message, e);
         return(RedirectToAction("Index"));
     }
 }
Пример #3
0
        public async Task SendMalewareAsync(Malware malware)
        {
            using (var client = new HttpClient())
            {
                var response = await client.PostAsync(
                    sendingUrl,
                    new StringContent(malware.GetJson(), Encoding.UTF8, "application/json"));

                Console.WriteLine(response.ToString());
            }
        }
    public void OnCollisionEnter(Collision coolide)
    {
        Collider other = coolide.collider;

        if (other.tag == "Player")
        {
            Debug.Log("Woof");
            mal = other.GetComponentInChildren <Malware>();
            mal.Infect();
            Instantiate(death, transform.position, transform.rotation);
            this.GetComponentInParent <RoomController>().contents.Remove(this.gameObject);
            Destroy(this.gameObject);
        }
    }
Пример #5
0
        public async Task <MongoDB.Bson.ObjectId> InsertOne(Malware model)
        {
            ObjectId id = await bucket.UploadFromBytesAsync(model.Name, model.Blob);

            var collectionName   = GetCollectionName();
            var collection       = Database.GetCollection <Malware>(collectionName);
            var filterDefinition = Builders <Malware> .Filter.Where(w => w.Id == id);

            var updateDefinition = Builders <Malware> .Update
                                   .Set(d => d.Author, model.Author);

            await collection.UpdateOneAsync(filterDefinition, updateDefinition);

            return(id);
            // var collectionName = GetCollectionName();
            //var collection = Database.GetCollection<Malware>(collectionName);
            // await collection.InsertOneAsync(model);
        }
Пример #6
0
    public void OnLevelWasLoaded(int level)
    {
        if (GameObject.FindGameObjectWithTag("Player") != null)
        {
            Debug.Log("POW");
            playerObject = GameObject.FindGameObjectWithTag("Player");
            pCon         = playerObject.GetComponent <PlayerController>();
            gMan         = playerObject.GetComponent <GunManager>();
            dMal         = GameObject.FindGameObjectWithTag("Carrier").GetComponent <Malware>();
            dAd          = GameObject.FindGameObjectWithTag("Carrier").GetComponent <Adware>();
            dTro         = GameObject.FindGameObjectWithTag("Carrier").GetComponent <Trojan>();
            for (int x = 0; x < ammo.Length; x++)
            {
                gMan.m_WeaponList[x].ammo = ammo[x];
            }
            pCon.maxHp    = maxHp;
            pCon.health   = hP;
            dTro.trojan   = trojan;
            dMal.Maled    = mal;
            dAd.triggered = ad;

            game = true;
        }
    }
    public void Send(string code, EMalwareType type)
    {
        print($"Received code: '{code}' to destroy {type}");
        GameObject objFound = null;

        VirusPool.IteratePool((obj) =>
        {
            Malware malware = obj.GetComponent <Malware>();
            if (malware.Type == type && code == malware.Decode)
            {
                objFound = obj;
            }
        });

        if (objFound != null)
        {
            objFound.SetActive(false);
            print($"Got it! Destroying this annoying virus of type: {type}");
        }
        else
        {
            print($"Couldn't find any {type} with code: '{code}'");
        }
    }
Пример #8
0
 public IActionResult Status(Malware malware)
 {
     return(View(malware));
 }
Пример #9
0
 public void TestSend(Malware malware)
 {
     Upload(sendingUrl, null, null, malware.GetJson());
 }