I am trying to make a script that checks warranty status on my company's monitors using this URL: http://143.101.250.86/scripts/wgate/zsvz3/!
I understand that looks shady, it's a re-direct from http://warrantycheck.necdisplay.com and it appears to be running a query against their SAP instance when you submit the form.
I frequently gets lists of monitor models and serials (Sometimes 100's of them) and would like to be able to run them through a script, rather than typing all manually.
When I run this code:
$url = "http://143.101.250.86/scripts/wgate/zsvz3/!"
$r = Invoke-WebRequest -Uri $url -SessionVariable sv
$Fields = @{"G_MATNR" = "P462";"G_SERNR" = "2X207961NW"}
$formSubmit = Invoke-WebRequest -Uri "http://143.101.250.86/scripts/wgate/zsvz3/!/scripts/wgate/zsvz32e6f78bc/~flN0YXRlPTMyNzUxLjAwMi4wMi4wMg==" -WebSession $sv -Method POST -Body $fields
Write-Host $formSubmit.ParsedHtml.body.innerHTML
The response page tells me
Your request did not contain a service name. Please provide a service name as part of the URL.
Example URL: http://.../scripts/wgate/CreateSO!
I can recognize that my POST Uri includes some kind of session ID, which I can find in the javascript for this page, but I'm not sure how to extract that and use it on my POST command.
I have tried finding it in my session variable
$sv.Cookies.GetCookies($url)
With no luck. I can't find it in the $r.ParsedHtml since it isn't parsed as HTML.
I've tried the boilerplate help code with
$form = $r.Forms[0]
$form.Fields["G_MATNR"] = "P462"
$form.Fields["G_SERNR"] = "2X207961NW"
$formSubmit = Invoke-WebRequest -Uri ($url + $form.Action) -WebSession $sv -Method POST
But this doesn't use forms and it's encapsulated inside of an iFrame, which I think might be playing into my problems with this method.
Any ideas on how to do this or how I might be able to generate the correct 'Service Name' in my POST method?
EDIT: Update The javaScript code does contain a form:
<form id="inputForm" name="inputForm" action="/scripts/wgate/zsvz32e6f3fcc/~flN0YXRlPTI4NjY4LjAwMS4wMi4wMg==" method="post">
But it's contained inside of an iFrame, perhaps that's why powershell isn't returning it in $r.Forms[0] Any insight there?
UPDATE 2 Request Headers from Fiddler:
POST /scripts/wgate/zsvz32e6f5490/~flN0YXRlPTE4NTgzLjAwMS4wMi4wMg== HTTP/1.1
Host: 143.101.250.86
Connection: keep-alive
Content-Length: 110
Cache-Control: max-age=0
Origin: http://143.101.250.86
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://143.101.250.86/scripts/wgate/zsvz32e6f5490/~flN0YXRlPTMxNjI0LjAwMS4wMi4wMg==?~subframe=1&~use_session_protocol=1&~keeprfccontext=1&~webguidynprometric=1&~webguiuserareawidth=1900&~webguiuserareaheight=803
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: ~session=PNMITS2:DLSITS02:0000.010b.00cd16f9.dcba; ~http_content_charset=iso-8859-1