Skip to content

Commit

Permalink
Added: New alias pw for New-Password and allow multiple output types …
Browse files Browse the repository at this point in the history
…(New-Password)
  • Loading branch information
claudiospizzi committed Feb 16, 2024
1 parent 22f438a commit a955023
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

* Added: New alias pw for New-Password and allow multiple output types (New-Password)
* Changed: System audit optimization: Better sort and output formatting (Get-SystemAudit)

## 3.0.0 - 2023-07-25
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@

# SecurityFever PowerShell Module

PowerShell Module with custom functions and cmdlets related to Windows and
application security.
PowerShell Module with custom functions and cmdlets related to Windows and application security.

## Introduction

This is a PowerShell Module with functions and cmdlets related to Windows and
application security. It unites multiple handy tools into one module.

You can invoke PowerShell scripts or script blocks in an elevated context with
**sudo** or test your credentials against the local system or an Active
Directory domain with **Test-Credential**.
Directory domain with **Test-Credential**. A new password can be generated with
**New-Password** using cryptographically secure random numbers. Time-based
one-time password can be generated with **Get-TimeBasedOneTimePassword**. The
**Convert-Certificate** cmdlet can convert certificate files between various
formats and the **New-DomainSignedCertificate** cmdlet can create a new
certificate signed by the domain CA.

With the security activity and audit policy cmdlets, you can get the security
related configuration of security audit events in the **Audit Policy** and check
Expand Down
21 changes: 1 addition & 20 deletions SecurityFever/Functions/Certificate/Convert-Certificate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- X.509/DER
- X.509/PEM
IDeas but not yet implemented certificate formats:
Ideas but not yet implemented certificate formats:
- .PKCS#7 (.p7b)
- .pfx Files
- PKCS#1 private key
Expand Down Expand Up @@ -125,22 +125,3 @@ function Convert-Certificate
}
}
}


# openssl x509 -inform der -outform pem -in ca.cer -out ca.pem


# -----BEGIN RSA PRIVATE KEY-----
# MIIDBjCCAm8CAQAwcTERMA8GA1UEAxMIcXV1eC5jb20xDzANBgNVBAsTBkJyYWlu
# czEWMBQGA1UEChMNRGV2ZWxvcE1lbnRvcjERMA8GA1UEBxMIVG9ycmFuY2UxEzAR
# BgNVBAgTCkNhbGlmb3JuaWExCzAJBgNVBAYTAlVTMIGfMA0GCSqGSIb3DQEBAQUA
# <...>
# -----END RSA PRIVATE KEY-----


# -----BEGIN PRIVATE KEY-----
# MIIDBjCCAm8CAQAwcTERMA8GA1UEAxMIcXV1eC5jb20xDzANBgNVBAsTBkJyYWlu
# czEWMBQGA1UEChMNRGV2ZWxvcE1lbnRvcjERMA8GA1UEBxMIVG9ycmFuY2UxEzAR
# BgNVBAgTCkNhbGlmb3JuaWExCzAJBgNVBAYTAlVTMIGfMA0GCSqGSIb3DQEBAQUA
# <...>
# -----END PRIVATE KEY-----
28 changes: 16 additions & 12 deletions SecurityFever/Functions/Credential/New-Password.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
function New-Password
{
[CmdletBinding()]
[Alias('pw')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
param
(
Expand All @@ -47,7 +48,7 @@ function New-Password
[Parameter(Mandatory = $false)]
[Alias('As')]
[ValidateSet('SecureString', 'String', 'Clipboard')]
[System.String]
[System.String[]]
$OutputType = 'SecureString'
)

Expand Down Expand Up @@ -98,19 +99,22 @@ function New-Password
}
while (-not ($isComplexLower -and $isComplexUpper -and $isComplexNumber))

switch ($OutputType)
foreach ($currentOutputType in $OutputType)
{
'SecureString'
{
Write-Output $password
}
'String'
switch ($OutputType)
{
Unprotect-SecureString -SecureString $password | Write-Output
}
'Clipboard'
{
Unprotect-SecureString -SecureString $password | Set-Clipboard
'SecureString'
{
Write-Output $password
}
'String'
{
Unprotect-SecureString -SecureString $password | Write-Output
}
'Clipboard'
{
Unprotect-SecureString -SecureString $password | Set-Clipboard
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions SecurityFever/SecurityFever.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @(
'pw'
'sudo'
'cred'
'Get-TOTP'
Expand Down

0 comments on commit a955023

Please sign in to comment.