-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystem.BitConverter01.ps1
More file actions
37 lines (29 loc) · 1.73 KB
/
System.BitConverter01.ps1
File metadata and controls
37 lines (29 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$User = 'x1111'
$Pass = "Pass.23"
$Domain = "xxx.se"
$Permissions = "CONTACT:CALLS:USER:CDR_READER:COMMUNICATION_LOG:DISTRIBUTION_GROUP:PERSONAL_CONTACTS:QUEUE_STATS"
$String1 = "$($User):$($Domain):$($Pass)"
$String1MD5 = ([System.BitConverter]::ToString((New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider).ComputeHash((New-Object -TypeName System.Text.UTF8Encoding).GetBytes($String1)))).Replace("-","")
$String1MD5
$String2 = "D$([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Domain)))"
$String2Encode64 = $String2.Replace("=", "")
$String2Encode64 #Result = DYjNpdC5zZQ
$String3 = $User + ":" + $Permissions + ":" + $String1MD5.ToLower()
$String3MD5 = ([System.BitConverter]::ToString((New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider).ComputeHash((New-Object -TypeName System.Text.UTF8Encoding).GetBytes($String3)))).Replace("-","")
$String3MD5
$String4 = "P:" + $String3MD5.ToLower() + ":" + $user + ":" + $Permissions
$String4Encode = "$([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($String4)))"
$String4Encode64 = $String4Encode.Replace("=", "")
$PassToken = $String2Encode64 + "." + $String4Encode64
#With this token you can call Token API to renew API keys
#https://www.dstny.se/app/uploads/User-API-v-5.5.22336..html#tag/Tickets
###API call
$ApiKeyUserId = 'x1111'#Karol
$AlloweApis = "api=CONTACT&api=CALLS&api=USER&api=CDR_READER&api=COMMUNICATION_LOG&api=DISTRIBUTION_GROUP&api=PERSONAL_CONTACTS&api=QUEUE_STATS"
$Domain = 'xxx.se'
$headers = @{
"Accept" = "application/json"
}
(Invoke-RestMethod -Method POST `
-URI "https://bc.dstny.se/api/tickets/$Domain/$($ApiKeyUserId)?platform=other&$AlloweApis&name=token_token&t=$PassToken" `
-Headers $headers)