WINRM met PHP + SOAP

Pagina: 1
Acties:

Onderwerpen


  • om3ega
  • Registratie: Maart 2001
  • Laatst online: 25-09 15:04
Zijn er tweakers die mij een duw in de juiste richting kunnen geven?

Wat wil ik?

Ik weet dat de WinRM module van Windows 2008r2 met het SOAP protocol praat.

Ik heb een HTTP listener op een IIS machine gemaakt. Deze luistert op poort 5985.
Om te testen of het wertkt heb ik powershell gebruikt :

code:
1
2
3
4
PS C:\Users\adm-test> winrs -r:http://localhost:5985 hostname
WW-01

PS C:\Users\adm-testl>


Dus de listener werkt.

Nu dacht ik via NuSOAP hier tegen aan te praten..

maar dat valt vies tegen.

Voorbeeld code :

PHP:
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
<?php

//ini_set("soap.wsdl_cache_enabled", "0");
require_once('../../libs/soap/nusoap.php');

//$endpoint = "http://localhost:5985/wsman";
$endpoint = "http://localhost:5985";

$client = new nusoap_client($endpoint,true);

$command = "hostname";
$result = $client->call($command);

/* DEBUG */
// Check for a fault
if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    print_r($result);
    echo '</pre>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        // Display the result
        echo '<h2>Result</h2><pre>';
        print_r($result);
        echo '</pre>';
    }
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

?>


Result

code:
1
2
3
Error

wsdl error: Getting http://localhost:5985 - HTTP ERROR: Unsupported HTTP response status 400 Bad Request (soapclient->response has contents of the response)


Nu zit mijn probleem ergens in het aanroepen van of het endpoint, of in de call ..

Normaal gesproken krijg je met een webservice via SOAP een XML set met commands terug die je kan gebruiken. Hier is dat niet het geval. Ik heb dus ook geen idee in welke format ik het moet sturen. Is er iemand die dit wel eens werkend heeft gekregen?

Versies :

Windows Client+Server (Zelfde apparaat) : Windows 2008R2
PHP :Version 5.2.14
NuSOAP : version 0.9.5

  • MueR
  • Registratie: Januari 2004
  • Laatst online: 22:13

MueR

Admin Tweakers Discord

is niet lief

Anyone who gets in between me and my morning coffee should be insecure.


  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 20:53

Creepy

Tactical Espionage Splatterer

Je endpoint is normaal gesproken een WSDL anders kan je SOAP client niet uitzoeken wat voor soap calls e.d er zijn. En dat is dus niet dezelfde URL als waar je naar post.

[ Voor 19% gewijzigd door Creepy op 28-09-2011 20:35 ]

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney


  • om3ega
  • Registratie: Maart 2001
  • Laatst online: 25-09 15:04
Creepy schreef op woensdag 28 september 2011 @ 20:35:
Je endpoint is normaal gesproken een WSDL anders kan je SOAP client niet uitzoeken wat voor soap calls e.d er zijn. En dat is dus niet dezelfde URL als waar je naar post.
Normaal gesproken heb je gelijk ja. Echter ik ben ook tegengekomen dat de WSDL extensie er niet echt toe doet. (Bijvoorbeeld : http://something.com/service.php?wsdl ) werkt ook ..

Handmatig naar zo'n URL browsen levert je dan idd. een mooie lijst op met methods die je kunt aanroepen. Echter zou het misschien zo kunnen zijn dat Microsoft deze niet laat zien?

En wat is dan wel het juiste endpoint als mijn endpoint niet correct is. Dat is echt helemaal nergens te vinden (of ik zoek op de verkeerde zoektermen) .. Ik ben hier al dagen mee bezig zonder dat ik iets er over kan vinden.

Wellicht is mijn gedachtengang onjuist en kan het helemaal niet zoals ik wil echter ik zie dan nog niet waarom niet?

De commando uitwisseling tussen winrs en de backend gebeurd ook via SOAP en HTTP.

Ik heb nog 1 ijdele hoop door er een sniffer op los te laten maar ik wacht nog even af of een mede-tweaker een verlichting kan geven hiervoor :)

  • Voutloos
  • Registratie: Januari 2002
  • Niet online
om3ega schreef op woensdag 28 september 2011 @ 16:14:
wsdl error: Getting http://localhost:5985 - HTTP ERROR: Unsupported HTTP response status 400 Bad Request (soapclient->response has contents of the response)
[/code]
(soapclient->response has contents of the response) ==> var_dump die zooi! :P

{signature}


  • om3ega
  • Registratie: Maart 2001
  • Laatst online: 25-09 15:04
Voutloos schreef op woensdag 28 september 2011 @ 22:56:
[...]
(soapclient->response has contents of the response) ==> var_dump die zooi! :P
Gelijk heb je, maar ik had niet het idee dat er iets nuttigs in stond, maar ik ben ook maar een mens :)

code:
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Error

wsdl error: Getting http://localhost:5985 - HTTP ERROR: Unsupported HTTP response status 400 Bad Request (soapclient->response has contents of the response)

Request

Response

Debug

2011-09-29 08:08:57.820877 nusoap_client: ctor wsdl=1 timeout=0 response_timeout=30
endpoint=string(21) "http://localhost:5985"
2011-09-29 08:08:57.839093 nusoap_client: will use lazy evaluation of wsdl from http://localhost:5985
2011-09-29 08:08:57.840522 nusoap_client: call: operation=hostname, namespace=http://tempuri.org, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=wsdl
params=array(0) {
}
headers=bool(false)
2011-09-29 08:08:57.840769 nusoap_client: instantiating wsdl class with doc: http://localhost:5985
2011-09-29 08:08:57.841018 wsdl: ctor wsdl= timeout=0 response_timeout=30
2011-09-29 08:08:57.841254 wsdl: parse and process WSDL path=
2011-09-29 08:08:57.841504 wsdl: setCredentials username= authtype= certRequest=
array(0) {
}
2011-09-29 08:08:57.841732 wsdl: parse and process WSDL path=http://localhost:5985
2011-09-29 08:08:57.841951 wsdl: parse WSDL at path=http://localhost:5985
2011-09-29 08:08:57.842175 wsdl: getting WSDL http(s) URL http://localhost:5985
2011-09-29 08:08:57.842441 soap_transport_http: ctor url=http://localhost:5985 use_curl= curl_options:
array(0) {
}
2011-09-29 08:08:57.842693 soap_transport_http: parsed URL scheme = http
2011-09-29 08:08:57.842927 soap_transport_http: parsed URL host = localhost
2011-09-29 08:08:57.843156 soap_transport_http: parsed URL port = 5985
2011-09-29 08:08:57.843410 soap_transport_http: set header Host: localhost:5985
2011-09-29 08:08:57.865399 soap_transport_http: set header User-Agent: NuSOAP/0.9.5 (1.123)
2011-09-29 08:08:57.865655 soap_transport_http: set header Accept-Encoding: gzip, deflate
2011-09-29 08:08:57.865904 soap_transport_http: set header Connection: close
2011-09-29 08:08:57.866135 soap_transport_http: entered send() with data of length: 0
2011-09-29 08:08:57.866362 soap_transport_http: connect connection_timeout 0, response_timeout 30, scheme http, host localhost, port 5985
2011-09-29 08:08:57.866594 soap_transport_http: calling fsockopen with host localhost connection_timeout 0
2011-09-29 08:08:57.868645 soap_transport_http: set response timeout to 30
2011-09-29 08:08:57.868927 soap_transport_http: socket connected
2011-09-29 08:08:57.869170 soap_transport_http: HTTP request: GET  HTTP/1.1
2011-09-29 08:08:57.869388 soap_transport_http: HTTP header: Host: localhost:5985
2011-09-29 08:08:57.869602 soap_transport_http: HTTP header: User-Agent: NuSOAP/0.9.5 (1.123)
2011-09-29 08:08:57.869842 soap_transport_http: HTTP header: Accept-Encoding: gzip, deflate
2011-09-29 08:08:57.870058 soap_transport_http: HTTP header: Connection: close
2011-09-29 08:08:57.870304 soap_transport_http: wrote data to socket, length = 124
2011-09-29 08:08:57.884259 soap_transport_http: read line of 26 bytes: HTTP/1.1 400 Bad Request
2011-09-29 08:08:57.884527 soap_transport_http: read line of 43 bytes: Content-Type: text/html; charset=us-ascii
2011-09-29 08:08:57.884753 soap_transport_http: read line of 31 bytes: Server: Microsoft-HTTPAPI/2.0
2011-09-29 08:08:57.884988 soap_transport_http: read line of 37 bytes: Date: Thu, 29 Sep 2011 06:08:57 GMT
2011-09-29 08:08:57.885211 soap_transport_http: read line of 19 bytes: Connection: close
2011-09-29 08:08:57.885431 soap_transport_http: read line of 21 bytes: Content-Length: 324
2011-09-29 08:08:57.885650 soap_transport_http: read line of 2 bytes: 
2011-09-29 08:08:57.885928 soap_transport_http: found end of headers after length 179
2011-09-29 08:08:57.886191 soap_transport_http: want to read content of length 324
2011-09-29 08:08:57.886437 soap_transport_http: read buffer of 324 bytes
2011-09-29 08:08:57.886682 soap_transport_http: read body of length 324
2011-09-29 08:08:57.886916 soap_transport_http: received a total of 503 bytes of data from server
2011-09-29 08:08:57.887174 soap_transport_http: closed socket
2011-09-29 08:08:57.887424 soap_transport_http: end of send()
2011-09-29 08:08:57.887663 wsdl: Getting http://localhost:5985 - HTTP ERROR: Unsupported HTTP response status 400 Bad Request (soapclient->response has contents of the response)
2011-09-29 08:08:57.887921 nusoap_client: checkWSDL
2011-09-29 08:08:57.888148 nusoap_client: got wsdl error: Getting http://localhost:5985 - HTTP ERROR: Unsupported HTTP response status 400 Bad Request (soapclient->response has contents of the response)



PS : Mijn ijdele hoop om het verkeer te sniffen tussen de IIS Server en de request die naar dezelfe machine gaat (localhost) gaat erg lastig worden.
If you are trying to capture traffic from a machine to itself, that traffic will not be sent over a real network interface, even if it's being sent to an address on one of the machine's network adapters.

Summary: you can capture on the loopback interface on Linux, on various BSDs including Mac OS X, and on Digital/Tru64 UNIX, and you might be able to do it on Irix and AIX, but you definitely cannot do so on Solaris, HP-UX, or Windows.
Bron

[ Voor 6% gewijzigd door om3ega op 29-09-2011 08:15 . Reden: Toevoeging capture localhost ]

Pagina: 1