94 lines
5.7 KiB
PowerShell
94 lines
5.7 KiB
PowerShell
$body = @{email="ziad.abd.elgwad2003@gmail.com"; password="2062003Mz*"} | ConvertTo-Json
|
|
$resp = Invoke-RestMethod -Uri "https://auth.ghaymah.systems/signin/email-password" -Method POST -Body $body -ContentType "application/json"
|
|
$token = $resp.session.accessToken
|
|
$headers = @{Authorization="Bearer $token"; "Content-Type"="application/json"}
|
|
|
|
Write-Host "=== 1. IDOR Test ==="
|
|
$q = '{"query":"{ ghaymah_cloud_resources_by_pk(id: \"00000000-0000-0000-0000-000000000000\") { id values status } }"}'
|
|
$r = Invoke-RestMethod -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $headers -Body $q
|
|
if ($r.data.ghaymah_cloud_resources_by_pk -eq $null) { Write-Host "SECURE - null returned for foreign resource" } else { Write-Host "VULNERABLE" }
|
|
|
|
Write-Host "`n=== 2. Unauthenticated Access Test ==="
|
|
$noAuthHeaders = @{"Content-Type"="application/json"}
|
|
$q = '{"query":"{ ghaymah_cloud_resources { id } }"}'
|
|
try {
|
|
$r = Invoke-RestMethod -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $noAuthHeaders -Body $q
|
|
if ($r.errors) { Write-Host "SECURE: $($r.errors[0].message)" } else { Write-Host "VULNERABLE: Data returned without auth" }
|
|
} catch { Write-Host "SECURE: Request blocked" }
|
|
|
|
Write-Host "`n=== 3. SQL Injection Test ==="
|
|
$sqliPayload = '{"query":"{ ghaymah_cloud_resources(where: {status: {_eq: \"test OR 1=1\"}}) { id } }"}'
|
|
$r = Invoke-RestMethod -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $headers -Body $sqliPayload
|
|
if ($r.errors) { Write-Host "FILTERED: $($r.errors[0].message)" }
|
|
elseif ($r.data.ghaymah_cloud_resources.Count -eq 0) { Write-Host "SECURE: No data returned" }
|
|
else { Write-Host "CHECK: $($r.data.ghaymah_cloud_resources.Count) results" }
|
|
|
|
Write-Host "`n=== 4. Cross-User Mutation Test ==="
|
|
$q = '{"query":"mutation { update_ghaymah_cloud_resources_by_pk(pk_columns: {id: \"00000000-0000-0000-0000-000000000000\"}, _set: {deleted: true}) { id } }"}'
|
|
$r = Invoke-RestMethod -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $headers -Body $q
|
|
if ($r.data.update_ghaymah_cloud_resources_by_pk -eq $null) { Write-Host "SECURE: Cannot modify foreign resource" } else { Write-Host "VULNERABLE" }
|
|
|
|
Write-Host "`n=== 5. JWT Token Analysis ==="
|
|
$parts = $token.Split('.')
|
|
$padding1 = $parts[0] + ("=" * ((4 - $parts[0].Length % 4) % 4))
|
|
$padding2 = $parts[1] + ("=" * ((4 - $parts[1].Length % 4) % 4))
|
|
$header = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($padding1.Replace('-','+').Replace('_','/')))
|
|
$payload = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($padding2.Replace('-','+').Replace('_','/')))
|
|
Write-Host "Algorithm: $(($header | ConvertFrom-Json).alg)"
|
|
Write-Host "Issuer: $(($payload | ConvertFrom-Json).iss)"
|
|
$claims = ($payload | ConvertFrom-Json)
|
|
Write-Host "User ID: $($claims.sub)"
|
|
Write-Host "Roles: $($claims.'https://hasura.io/jwt/claims'.'x-hasura-allowed-roles' -join ', ')"
|
|
|
|
Write-Host "`n=== 6. GraphQL Introspection ==="
|
|
$q = '{"query":"{ __schema { types { name } } }"}'
|
|
$r = Invoke-RestMethod -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $headers -Body $q
|
|
Write-Host "EXPOSED: $($r.data.__schema.types.Count) types accessible via introspection"
|
|
|
|
Write-Host "`n=== 7. Security Headers ==="
|
|
$q = '{"query":"{ __typename }"}'
|
|
$r = Invoke-WebRequest -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $headers -Body $q -ContentType "application/json" -UseBasicParsing
|
|
$headerNames = @("X-Frame-Options","X-Content-Type-Options","Strict-Transport-Security","Content-Security-Policy","X-XSS-Protection")
|
|
foreach ($h in $headerNames) {
|
|
$val = $r.Headers[$h]
|
|
if ($val) { Write-Host " PRESENT: $h = $val" } else { Write-Host " MISSING: $h" }
|
|
}
|
|
|
|
Write-Host "`n=== 8. Endpoint Probing ==="
|
|
$endpoints = @(
|
|
@{Name="Auth"; URL="https://auth.ghaymah.systems"},
|
|
@{Name="GenAI"; URL="https://genai.ghaymah.systems"},
|
|
@{Name="Status"; URL="https://status.ghaymah.systems/status/ghaymah"},
|
|
@{Name="Registry"; URL="https://registry.ghaymah.systems/v2/"},
|
|
@{Name="S3 Proxy"; URL="https://s3-nhost-proxy-83e02743fd61.hosted.ghaymah.systems"},
|
|
@{Name="CLIv2"; URL="https://cliv2.ghaymah.systems/install.sh"}
|
|
)
|
|
foreach ($ep in $endpoints) {
|
|
try {
|
|
$r = Invoke-WebRequest -Uri $ep.URL -UseBasicParsing -TimeoutSec 10 -ErrorAction Stop
|
|
Write-Host " $($ep.Name): HTTP $($r.StatusCode)"
|
|
} catch {
|
|
$code = $_.Exception.Response.StatusCode.value__
|
|
Write-Host " $($ep.Name): HTTP $code ($($_.Exception.Message.Substring(0,[Math]::Min(60,$_.Exception.Message.Length))))"
|
|
}
|
|
}
|
|
|
|
Write-Host "`n=== 9. Deploy Test App ==="
|
|
$q = '{"query":"mutation { createApp(name: \"v2-sec-test\", image: \"nginx:alpine\", port: 80, tier: \"t1\") { id name status url } }"}'
|
|
$r = Invoke-RestMethod -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $headers -Body $q
|
|
if ($r.errors) {
|
|
Write-Host "createApp errors: $($r.errors[0].message)"
|
|
# Try introspecting createApp args
|
|
$q2 = '{"query":"{ __type(name: \"mutation_root\") { fields { name args { name type { name kind ofType { name kind ofType { name } } } } } } }"}'
|
|
$r2 = Invoke-RestMethod -Uri "https://graphql.ghaymah.systems/v1/graphql" -Method POST -Headers $headers -Body $q2
|
|
$createApp = $r2.data.__type.fields | Where-Object { $_.name -eq "createApp" }
|
|
Write-Host "createApp mutation args:"
|
|
$createApp.args | ForEach-Object {
|
|
$typeName = if ($_.type.ofType.name) { $_.type.ofType.name } elseif ($_.type.ofType.ofType.name) { $_.type.ofType.ofType.name } else { $_.type.name }
|
|
$required = if ($_.type.kind -eq "NON_NULL") { " (required)" } else { "" }
|
|
Write-Host " - $($_.name): $typeName$required"
|
|
}
|
|
} else {
|
|
Write-Host "App created: $($r.data.createApp | ConvertTo-Json)"
|
|
}
|