-
Notifications
You must be signed in to change notification settings - Fork 0
/
BruteApiCall.ps1
47 lines (36 loc) · 1.05 KB
/
BruteApiCall.ps1
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
38
39
40
41
42
43
44
45
46
47
$numberOfParallels = 10
$numberOfExecutions = 30
$desiredUrl = 'http://api.yoursite.com/data/ws/xxx/login'
$paramPassado = @{
usuar="[email protected]"
pswd="qwerty"
access="web"
} | ConvertTo-Json
For ($iParalelos = 0; $iParalelos -le $numberOfParallels; $iParalelos++){
Start-Job -Name $iParalelos.ToString() -ScriptBlock{
param(
[int]$iIterations,
$urlURL,
$oParams
)
For($count=0; $count -le $iIterations; $count++){
Invoke-WebRequest -Uri $urlURL -Body $oParam -Method Post -TimeoutSec 10
}
} -ArgumentList $numberOfExecutions, $desiredUrl, $paramPassado
}
$running = $true
while ($running -eq $true){
Clear-Host
Write-Output "Looking for Jobs in execution..."
$results = Get-Job | Where-Object {$_.State -eq "Running"}
if($results -eq $null){
Write-Output "Removing Jobs..."
Start-Sleep -Seconds 3
$running = $false
Get-Job | Remove-Job
Clear-Host
} else{
$results
Start-Sleep -Seconds 2
}
}