dangioiastlcc / stlcc-lmsautomation_public Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The function Get-CanvasSisSshaPasswordText in Canvas-API-Lib.ps1#L81-L92 is incorrect.
Refering the LDAP SSHA salted sha1 generation method in github (e.g. https://github.com/ffquintella/lapi/blob/766b7cbe5414fc7dd41eb9b75209e9a27fdbdd03/lapi/Security/HashHelper.cs#L9-L20), the hash value should generate by the sha1 of byte vaule,
here is my powershell sciprt to generate the LDAP SSHA salted sha1 value
function Get-LDAPPasswordSSHA1 {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String]
$Password,
[Parameter()]
[int]
$saltByteLength = 5
)
# https://github.com/ffquintella/lapi/blob/766b7cbe5414fc7dd41eb9b75209e9a27fdbdd03/lapi/Security/HashHelper.cs#L25
# get the password byte value
[byte[]] $passwordBytes = [System.Text.Encoding]::ASCII.GetBytes($Password)
# generate the salt and get the salt byte value
[byte[]] $saltBytes = New-Object -TypeName 'Byte[]' -Argumentlist $saltByteLength
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rng.GetBytes($saltBytes)
$rng.Dispose()
# create the byte container to host the byte of password + byte of salt
[byte[]] $mergedBytes = New-Object -TypeName 'Byte[]' -Argumentlist ($passwordBytes.Length + $saltByteLength)
# https://stackoverflow.com/questions/415291/best-way-to-combine-two-or-more-byte-arrays-in-c-sharp#415396
# https://github.com/samratashok/nishang/blob/d87229d2112456470ad30a50edbf312463f2b09a/MITM/Invoke-Interceptor.ps1#L438
[System.Buffer]::BlockCopy( $passwordBytes, 0, $mergedBytes, 0, $passwordBytes.Length)
[System.Buffer]::BlockCopy( $saltBytes, 0, $mergedBytes, $passwordBytes.Length, $saltBytes.Length )
# hash the byte container above to sha1
$SHA1Generator = [System.Security.Cryptography.SHA1]::Create()
[byte[]] $mergedBytesSHA1 = $SHA1Generator.ComputeHash($mergedBytes)
$SHA1Generator.Dispose()
# create the final byte container to host the sha1 byte above + byte of salt
[byte[]] $finalMergedBytes = New-Object -TypeName 'Byte[]' -Argumentlist ($mergedBytesSHA1.Length + $saltByteLength)
[System.Buffer]::BlockCopy( $mergedBytesSHA1, 0, $finalMergedBytes, 0, $mergedBytesSHA1.Length)
[System.Buffer]::BlockCopy( $saltBytes, 0, $finalMergedBytes, $mergedBytesSHA1.Length, $saltBytes.Length )
# convert the final byte to base64
$result = [Convert]::ToBase64String($finalMergedBytes)
return "{SSHA}$result"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.