Exemple #1
0
        public static void CleanGit(Config config, TeknikEntities db)
        {
            Output(string.Format("[{0}] Started Cleaning of Orphaned Git Accounts.", DateTime.Now));
            List <string> gitAccounts = GetOrphanedGit(config, db);

            foreach (string account in gitAccounts)
            {
                // User doesn't exist, and it isn't reserved.  Let's nuke it.
                UserHelper.DeleteUserGit(config, account);
            }

            if (gitAccounts.Count > 0)
            {
                // Add to transparency report if any users were removed
                Takedown report = db.Takedowns.Create();
                report.Requester        = TAKEDOWN_REPORTER;
                report.RequesterContact = config.SupportEmail;
                report.DateRequested    = DateTime.Now;
                report.Reason           = "Orphaned Git Account";
                report.ActionTaken      = string.Format("{0} Accounts Removed", gitAccounts.Count);
                report.DateActionTaken  = DateTime.Now;
                db.Takedowns.Add(report);
                db.SaveChanges();
            }

            Output(string.Format("[{0}] Finished Cleaning of Orphaned Git Accounts.  {1} Accounts Removed.", DateTime.Now, gitAccounts.Count));
        }
Exemple #2
0
        public static void CleanAccounts(Config config, TeknikEntities db, int maxDays)
        {
            Output(string.Format("[{0}] Started Cleaning of Inactive/Invalid Users.", DateTime.Now));
            List <string> invalidAccounts  = GetInvalidAccounts(config, db);
            List <string> inactiveAccounts = GetInactiveAccounts(config, db, maxDays);

            // Delete invalid accounts
            foreach (string account in invalidAccounts)
            {
                UserHelper.DeleteAccount(db, config, UserHelper.GetUser(db, account));
            }

            if (invalidAccounts.Count > 0)
            {
                // Add to transparency report if any users were removed
                Takedown report = db.Takedowns.Create();
                report.Requester        = TAKEDOWN_REPORTER;
                report.RequesterContact = config.SupportEmail;
                report.DateRequested    = DateTime.Now;
                report.Reason           = "Username Invalid";
                report.ActionTaken      = string.Format("{0} Accounts Removed", invalidAccounts.Count);
                report.DateActionTaken  = DateTime.Now;
                db.Takedowns.Add(report);
                db.SaveChanges();
            }

            // Delete inactive accounts
            foreach (string account in inactiveAccounts)
            {
                UserHelper.DeleteAccount(db, config, UserHelper.GetUser(db, account));
            }

            if (invalidAccounts.Count > 0)
            {
                // Add to transparency report if any users were removed
                Takedown report = db.Takedowns.Create();
                report.Requester        = TAKEDOWN_REPORTER;
                report.RequesterContact = config.SupportEmail;
                report.DateRequested    = DateTime.Now;
                report.Reason           = "Account Inactive";
                report.ActionTaken      = string.Format("{0} Accounts Removed", inactiveAccounts.Count);
                report.DateActionTaken  = DateTime.Now;
                db.Takedowns.Add(report);
                db.SaveChanges();
            }

            Output(string.Format("[{0}] Finished Cleaning of Inactive/Invalid Users.  {1} Accounts Removed.", DateTime.Now, invalidAccounts.Count + inactiveAccounts.Count));
        }
Exemple #3
0
    private void Start()
    {
        Physics2D.IgnoreLayerCollision(8, 10);

        player = GameObject.FindGameObjectWithTag("Player").GetComponent <Takedown>();
        initialTakedownCooldown = player.takedownCooldown;

        if (PlayerPrefs.GetInt("Takedown", 0) == 1)
        {
            player.takedownCooldown = 0;
        }
        else if (PlayerPrefs.GetInt("Takedown", 0) == 0)
        {
            player.takedownCooldown = initialTakedownCooldown;
        }

        SetUpLevelStats();

        levelTimer = 0;
    }
Exemple #4
0
        private static async Task <bool> ScanUpload(Config config, TeknikEntities db, Upload upload, int totalCount, int currentCount)
        {
            bool   virusDetected = false;
            string subDir        = upload.FileName[0].ToString();
            string filePath      = Path.Combine(config.UploadConfig.UploadDirectory, subDir, upload.FileName);

            if (File.Exists(filePath))
            {
                // If the IV is set, and Key is set, then scan it
                if (!string.IsNullOrEmpty(upload.Key) && !string.IsNullOrEmpty(upload.IV))
                {
                    byte[] keyBytes = Encoding.UTF8.GetBytes(upload.Key);
                    byte[] ivBytes  = Encoding.UTF8.GetBytes(upload.IV);


                    long maxUploadSize = config.UploadConfig.MaxUploadSize;
                    if (upload.User != null)
                    {
                        maxUploadSize = config.UploadConfig.MaxUploadSizeBasic;
                        IdentityUserInfo userInfo = await IdentityHelper.GetIdentityUserInfo(config, upload.User.Username);

                        if (userInfo.AccountType == AccountType.Premium)
                        {
                            maxUploadSize = config.UploadConfig.MaxUploadSizePremium;
                        }
                    }

                    using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                        using (AesCounterStream aesStream = new AesCounterStream(fs, false, keyBytes, ivBytes))
                        {
                            ClamClient clam = new ClamClient(config.UploadConfig.ClamServer, config.UploadConfig.ClamPort);
                            clam.MaxStreamSize = maxUploadSize;
                            ClamScanResult scanResult = await clam.SendAndScanFileAsync(fs);

                            switch (scanResult.Result)
                            {
                            case ClamScanResults.Clean:
                                string cleanMsg = string.Format("[{0}] Clean Scan: {1}/{2} Scanned | {3} - {4}", DateTime.Now, currentCount, totalCount, upload.Url, upload.FileName);
                                Output(cleanMsg);
                                break;

                            case ClamScanResults.VirusDetected:
                                string msg = string.Format("[{0}] Virus Detected: {1} - {2} - {3}", DateTime.Now, upload.Url, upload.FileName, scanResult.InfectedFiles.First().VirusName);
                                Output(msg);
                                lock (scanStatsLock)
                                {
                                    virusDetected = true;
                                    File.AppendAllLines(virusFile, new List <string> {
                                        msg
                                    });
                                }

                                lock (dbLock)
                                {
                                    string urlName = upload.Url;
                                    // Delete from the DB
                                    db.Uploads.Remove(upload);

                                    // Delete the File
                                    if (File.Exists(filePath))
                                    {
                                        File.Delete(filePath);
                                    }

                                    // Add to transparency report if any were found
                                    Takedown report = new Takedown();
                                    report.Requester        = TAKEDOWN_REPORTER;
                                    report.RequesterContact = config.SupportEmail;
                                    report.DateRequested    = DateTime.Now;
                                    report.Reason           = "Malware Found";
                                    report.ActionTaken      = string.Format("Upload removed: {0}", urlName);
                                    report.DateActionTaken  = DateTime.Now;
                                    db.Takedowns.Add(report);

                                    // Save Changes
                                    db.SaveChanges();
                                }
                                break;

                            case ClamScanResults.Error:
                                string errorMsg = string.Format("[{0}] Scan Error: {1}", DateTime.Now, scanResult.RawResult);
                                File.AppendAllLines(errorFile, new List <string> {
                                    errorMsg
                                });
                                Output(errorMsg);
                                break;

                            case ClamScanResults.Unknown:
                                string unkMsg = string.Format("[{0}] Unknown Scan Result: {1}", DateTime.Now, scanResult.RawResult);
                                File.AppendAllLines(errorFile, new List <string> {
                                    unkMsg
                                });
                                Output(unkMsg);
                                break;
                            }
                        }
                }
            }
            return(virusDetected);
        }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <Takedown>();

        img = GetComponent <Image>();
    }