protected void AddItemToUserInv_Click(object sender, EventArgs e) { int userid = int.Parse(Cache["UserId"].ToString()); InventoryItem invItem; using (DataContext db = new DataContext()) { if (ItemLogic.CheckInventoryItem(db, userid, int.Parse(AllItemsList.SelectedValue), out invItem)) { invItem.Quantity = invItem.Quantity + 1; db.SaveChanges(); } else { invItem = new InventoryItem(); invItem.UserId = userid; invItem.Quantity = 1; db.InventoryItem.Add(invItem); db.SaveChanges(); } Response.Redirect("UserInventory.aspx", true); } }
protected void StealLinkBtn_Command(object sender, CommandEventArgs e) { MissionData mis = (MissionData)Session["MissionData"]; string stolenFile = e.CommandArgument.ToString(); if (mis.MissionType == 0) { if (MissionLogic.CheckStolenFile(stolenFile)) { // Title SummaryTitle.Text = "Congratulations, Mission Completed!"; SummaryTitle.ForeColor = System.Drawing.Color.Green; // Summary MisNameLbl.Text = mis.MissionName; MisIPLbl.Text = mis.MissionIP; MisSumLbl.Text = "Some perpetrators uses these methods to gain access to companies to actually steal theri client information. As such, this could be prevented if firewall rules and other configurations were set up correctly."; MisExpLbl.Text = mis.MissionExp.ToString(); MisCoinLbl.Text = mis.MissionCoin.ToString(); Step5Lbl.ForeColor = System.Drawing.Color.Green; using (DataContext db = new DataContext()) { Users u = CurrentUser.Entity(false, db); u.TotalExp = u.TotalExp + mis.MissionExp; Items i = ItemLogic.GetRewardForMis(mis.RecommendLevel, Machines.GetUserMachine(CurrentUser.Entity().UserID, db)); ItemNameLbl.Text = i.ItemName; ItemBonusLbl.Text = i.ItemBonus.ToString(); ItemImage.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(i.ItemPic, 0, i.ItemPic.Length); InventoryItem invItem; if (ItemLogic.CheckInventoryItem(db, u.UserID, i.ItemId, out invItem)) { invItem.Quantity += 1; db.SaveChanges(); } else { invItem = new InventoryItem(); invItem.UserId = u.UserID; invItem.ItemId = i.ItemId; invItem.Quantity = 1; db.InventoryItem.Add(invItem); } List <string> RewardList = new List <string>(); RewardList.Add("Mission Exp: " + mis.MissionExp.ToString()); RewardList.Add("Mission Coin: " + mis.MissionCoin.ToString()); RewardList.Add("Item: " + i.ItemName); MissionLogLogic.Store(CurrentUser.Entity().UserID, mis.MissionName, true, RewardList); } ScriptManager.RegisterStartupScript(this, this.GetType(), "missionSumModel", "showFinishPrompt();", true); } else { // Title SummaryTitle.Text = "Mission Failed!"; SummaryTitle.ForeColor = System.Drawing.Color.Red; MisNameLbl.Text = mis.MissionName; MisIPLbl.Text = mis.MissionIP; MisSumLbl.Text = "Mission Failed due to incorrect file choosen."; MisExpLbl.Text = "0"; MisCoinLbl.Text = "0"; Step5Lbl.ForeColor = System.Drawing.Color.Red; ItemImage.Visible = false; List <string> rewardList = new List <string>(); rewardList.Add("Failed Mission no reward"); MissionLogLogic.Store(CurrentUser.Entity().UserID, mis.MissionName, false, rewardList); ScriptManager.RegisterStartupScript(this, this.GetType(), "missionSumModel", "showFinishPrompt();", true); } } else { // Title SummaryTitle.Text = "Mission Failed!"; SummaryTitle.ForeColor = System.Drawing.Color.Red; MisNameLbl.Text = mis.MissionName; MisIPLbl.Text = mis.MissionIP; MisSumLbl.Text = "Mission Failed due to incorrect type of attack choosen"; MisExpLbl.Text = "0"; MisCoinLbl.Text = "0"; Step5Lbl.ForeColor = System.Drawing.Color.Red; ItemImage.Visible = false; List <string> rewardList = new List <string>(); rewardList.Add("Failed Mission no reward"); MissionLogLogic.Store(CurrentUser.Entity().UserID, mis.MissionName, false, rewardList); ScriptManager.RegisterStartupScript(this, this.GetType(), "missionSumModel", "showFinishPrompt();", true); } }
protected void LoginBtn_Click(object sender, EventArgs e) { MissionData mis = Session["MissionData"] as MissionData; if (mis.MissionType == (MissionType)3) { if (UsrName.Text.Equals("adminbypass-'*/--") && Password.Text.Equals("' DROP ALL TABLES;--")) { // Title SummaryTitle.Text = "Congratulations, Mission Completed!"; SummaryTitle.ForeColor = System.Drawing.Color.Green; // Summary MisNameLbl.Text = mis.MissionName; MisIPLbl.Text = mis.MissionIP; MisSumLbl.Text = "Congrats on compleeting the mission."; MisExpLbl.Text = mis.MissionExp.ToString(); MisCoinLbl.Text = mis.MissionCoin.ToString(); using (DataContext db = new DataContext()) { Users u = CurrentUser.Entity(false, db); u.TotalExp = u.TotalExp + mis.MissionExp; Items i = ItemLogic.GetRewardForMis(mis.RecommendLevel, Machines.GetUserMachine(CurrentUser.Entity().UserID, db)); ItemNameLbl.Text = i.ItemName; ItemBonusLbl.Text = i.ItemBonus.ToString(); ItemImage.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(i.ItemPic, 0, i.ItemPic.Length); Step4lbl.ForeColor = System.Drawing.Color.Green; InventoryItem invItem; if (ItemLogic.CheckInventoryItem(db, u.UserID, i.ItemId, out invItem)) { invItem.Quantity += 1; db.SaveChanges(); } else { invItem = new InventoryItem(); invItem.UserId = u.UserID; invItem.ItemId = i.ItemId; invItem.Quantity = 1; db.InventoryItem.Add(invItem); } db.SaveChanges(); List <string> RewardList = new List <string>(); RewardList.Add("Mission Exp: " + mis.MissionExp.ToString()); RewardList.Add("Mission Coin: " + mis.MissionCoin.ToString()); RewardList.Add("Item: " + i.ItemName); MissionLogLogic.Store(CurrentUser.Entity().UserID, mis.MissionName, true, RewardList); } ScriptManager.RegisterStartupScript(this, this.GetType(), "missionSumModel", "showFinishPrompt();", true); } else { // Title SummaryTitle.Text = "Mission Failed!"; SummaryTitle.ForeColor = System.Drawing.Color.Red; // Summary MisNameLbl.Text = mis.MissionName; MisIPLbl.Text = mis.MissionIP; MisSumLbl.Text = "Mission Failed due to incorrect SQL Inection code choosen"; MisExpLbl.Text = "0"; MisCoinLbl.Text = "0"; ItemImage.Visible = false; List <string> rewardList = new List <string>(); rewardList.Add("Failed Mission no reward"); MissionLogLogic.Store(CurrentUser.Entity().UserID, mis.MissionName, false, rewardList); } } else { // Title SummaryTitle.Text = "Mission Failed!"; SummaryTitle.ForeColor = System.Drawing.Color.Red; MisNameLbl.Text = mis.MissionName; MisIPLbl.Text = mis.MissionIP; MisSumLbl.Text = "Mission Failed due to incorrect type of attack choosen"; MisExpLbl.Text = "0"; MisCoinLbl.Text = "0"; ItemImage.Visible = false; List <string> rewardList = new List <string>(); rewardList.Add("Failed Mission no reward"); MissionLogLogic.Store(CurrentUser.Entity().UserID, mis.MissionName, false, rewardList); } }