Snippets Collections
View(active tab)
Version control
21people starred this project

Integrates your Drupal site with CrowdSec to keep suspicious users and cybercriminals away. No account with CrowdSec required, and no other agent software to be installed. This module brings everything required with it. Download with composer, enable the module and rest assured, that a lot of malicious traffic and many attack vectors will just be gone!
### FUNCTION: Generate New Complex Password
Function generateNewComplexPassword([int]$passwordNrChars) {
	Process {
		$iterations = 0
        Do {
			If ($iterations -ge 20) {
				Logging "  --> Complex password generation failed after '$iterations' iterations..." "ERROR"
				Logging "" "ERROR"
				EXIT
			}
			$iterations++
			$pwdBytes = @()
			$rng = New-Object System.Security.Cryptography.RNGCryptoServiceProvider
			Do {
				[byte[]]$byte = [byte]1
				$rng.GetBytes($byte)
				If ($byte[0] -lt 33 -or $byte[0] -gt 126) {
					CONTINUE
				}
                $pwdBytes += $byte[0]
			}
			While ($pwdBytes.Count -lt $passwordNrChars)
				$pwd = ([char[]]$pwdBytes) -join ''
			} 
        Until (confirmPasswordIsComplex $pwd)
        Return $pwd
	}
}
// open api
@SecurityScheme(
    name = "Basic Auth",
    type = SecuritySchemeType.HTTP,
    scheme = "basic",
    description = "Basic Auth")

// security config 2 users
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

  @Bean
  public PasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
  }

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.antMatcher("/api/**")
        .authorizeRequests()
        .anyRequest()
        .authenticated()
        .and()
        .httpBasic()
        .and()
        .sessionManagement()
        .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and()
        .exceptionHandling()
        .authenticationEntryPoint(new Http403ForbiddenEntryPoint())
        .and()
        .csrf()
        .disable();
  }

  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
        .passwordEncoder(new BCryptPasswordEncoder())
        .withUser("<username>")
        .password(passwordEncoder().encode("<password>"))
        .roles("<role>")
        .and()
        .withUser("<user2>")
        .password(passwordEncoder().encode("<password2>"))
        .roles("<role>");
  }

// controllers
@SecurityRequirement(name = "Basic Auth")
import { Component, OnInit } from '@angular/core';
import { SecurityService } from './data.service';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Component({
  selector: 'app-root',
  template: `<div [innerHtml] = "safeValue"></div>`,
  providers: [SecurityService]
})
export class AppComponent implements OnInit {
  safeValue: SafeHtml;
  constructor(private secure: SecurityService) {
    this.safeValue = this.secure.getSafeHtml("<h1>Sanitization Success</h1>");
  }
  ngOnInit() {
  }
}
#include <iostream>
using namespace std;

struct hashing
{
    int value;
    int key;
};


void put(int value, hashing hash[],int n) {
    hash[value % n].value = value;
    hash[value % n].key = (value % n);
}

int get(int key, hashing hash[]) {
    return hash[key].value;
}

int main()
{
    int n;
    
    struct hashing hash[n];
    cin >> n;
    for (int t=0;t<n;t++) {
        put(t+1,hash,n);
        cout << "Inserted : " << (t+1) << endl;
    }
    int temp;
    cin >> temp;
    cout << get(temp,hash) << endl;
}
double AttackerSuccessProbability(double q, int z)
{
    double p = 1.0 - q;
    double lambda = z * (q / p);
    double sum = 1.0;
    int i, k;
    for (k = 0; k <= z; k++)
    {
        double poisson = exp(-lambda);
        for (i = 1; i <= k; i++)
            poisson *= lambda / i;
        sum -= poisson * (1 - pow(q / p, z - k));
    }
    return sum;
}
star

Sat May 04 2024 16:07:37 GMT+0000 (Coordinated Universal Time) https://www.drupal.org/project/crowdsec

#security #crowd
star

Sat Mar 25 2023 23:47:18 GMT+0000 (Coordinated Universal Time) https://pentestkit.co.uk/howto.html

#web #development #security #pentest
star

Fri Nov 18 2022 20:07:55 GMT+0000 (Coordinated Universal Time) https://github.com/zjorz/Public-AD-Scripts/blob/master/Reset-KrbTgt-Password-For-RWDCs-And-RODCs.ps1

#powershell #security
star

Thu Sep 22 2022 02:03:37 GMT+0000 (Coordinated Universal Time) undefined

#ssh #vm #security #server
star

Mon Mar 15 2021 17:15:39 GMT+0000 (Coordinated Universal Time)

#spring #security
star

Sun Mar 07 2021 08:22:25 GMT+0000 (Coordinated Universal Time) https://www.syncfusion.com/blogs/post/top-5-best-practices-angular-app-security.aspx

#angular #security
star

Fri Jan 03 2020 19:00:00 GMT+0000 (Coordinated Universal Time) https://github.com/manosriram/Data-Structures/blob/master/Hashing/basicHash.cpp

#ios #swift #apps #hash #security

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension