Code Monkey home page Code Monkey logo

stlcc-lmsautomation_public's Introduction

STLCC-LMSAutomation_Public

stlcc-lmsautomation_public's People

Contributors

dangioiastlcc avatar

Watchers

James Cloos avatar  avatar

stlcc-lmsautomation_public's Issues

Incorrect ssha password hash generate method

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"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.