Donnerstag, 2. April 2015

Introduction to WS-Attacker: XML Signature Wrapping (XSW) on Web services


This post introduces WS-Attacker. We start with how to build it from source. After that we setup an example Axis2 Web service and finally we perform an XSW Attack on it.


Building WS-Attacker from Source




WS-Attacker has recently moved its sources from Sourceforge to Github. Thus, we download its source code using cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 following command:
% git clone https://github.com/RUB-NDS/WS-Attacker.git
Cloning into 'WS-Attacker'...
remote: Counting objects: 2984, done.
remote: Total 2984 (delta 0), reused 0 (delta 0), pack-reused 2984
Receiving objects: 100% (2984/2984), 90.40 MiB | 2.91 MiB/s, done.
Resolving deltas: 100% (1386/1386), done.
Checking connectivity... done.
% cd WS-Attacker

This clones cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 whole WS-Attacker repository from Github to our local storage. Next, we need maven and at least openjdk7 to build cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 tool (note that we use -DskipTests to increase cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 build speed):
% mvn clean package  -DskipTests
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] WS-Attacker
[INFO] WS-Attacker-Libraries
[INFO] SoapHttpClient
[INFO] WS-Attacker-Framework
[INFO] WS-Attacker-Plugins
[INFO] WS-Attacker-Plugin_SoapAction_Spoofing
[INFO] WS-Attacker-Plugin_WS_Addressing_Spoofing
[INFO] WS-Attacker-Plugin_Options_Tester
[INFO] WS-Attacker-Library_XML_Utilities
[INFO] WS-Attacker-Library_Schema_Analyzer
[INFO] WS-Attacker-Library_Signature_Wrapping
[INFO] WS-Attacker-Plugin_Signature_Wrapping
[INFO] WS-Attacker-Plugin_Denial_of_Service
[INFO] WS-Attacker-Library_Signature_Faking
[INFO]                                                                     
[INFO] ------------------------------------------------------------------------
[INFO] Building WS-Attacker 1.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------



Depending on your PC's power and your Internet connection's speed, this may take a while. You can find cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 runnable JAR and all cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 attack plugins in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 directory “runnable” afterwards.

Creating a sample Web Service that uses XML Signatures




% wget http://archive.apache.org/dist/axis/axis2/java/core/1.6.0/axis2-1.6.0-bin.zip
--2015-04-02 13:40:54--  http://archive.apache.org/dist/axis/axis2/java/core/1.6.0/axis2-1.6.0-bin.zip
Resolving archive.apache.org (archive.apache.org)... 140.211.11.131, 192.87.106.229, 2001:610:1:80bc:192:87:106:229
Connecting to archive.apache.org (archive.apache.org)|140.211.11.131|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20389041 (19M) [application/zip]
Saving to: 'axis2-1.6.0-bin.zip'

axis2-1.6.0-bin.zip                        100%[==========================================================================================>]  19.44M  5.40MB/s   in 4.3s

2015-04-02 13:40:59 (4.51 MB/s) - 'axis2-1.6.0-bin.zip' saved [20389041/20389041]
% unzip axis2-1.6.0-bin.zip



Next, we need to install rampart, cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 security module for axis2 which enable XML Signature processing:
% wget http://archive.apache.org/dist/axis/axis2/java/rampart/1.6.0/rampart-dist-1.6.0-bin.zip                                                      :(
--2015-04-02 13:43:53--  http://archive.apache.org/dist/axis/axis2/java/rampart/1.6.0/rampart-dist-1.6.0-bin.zip
Resolving archive.apache.org (archive.apache.org)... 140.211.11.131, 192.87.106.229, 2001:610:1:80bc:192:87:106:229
Connecting to archive.apache.org (archive.apache.org)|140.211.11.131|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6905111 (6.6M) [application/zip]
Saving to: 'rampart-dist-1.6.0-bin.zip'

rampart-dist-1.6.0-bin.zip                 100%[==========================================================================================>]   6.58M  2.25MB/s   in 2.9s

2015-04-02 13:43:56 (2.25 MB/s) - 'rampart-dist-1.6.0-bin.zip' saved [6905111/6905111]

% unzip rampart-dist-1.6.0-bin.zip

We cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365n need to “install” rampart in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 axis2 directory as follows:
% cp rampart-1.6.0/lib/* axis2-1.6.0/lib
% cp rampart-1.6.0/modules/* axis2-1.6.0/repository/modules

We will now start a rampart sample that uses XML Signatures:
% cd  rampart-1.6.0/samples/policy/
% AXIS2_HOME="/tmp/axis2-1.6.0" ant service.02   



To start cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 service, we use ant and configure cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Axis2 Home directory.

Obtaining cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 signed Message




To use WS-Attacker, we need to obtain a signed message. There are many approaches to achieve this. In this scenario, we start “Wireshark” and run cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 client sample script (from a second terminal):
% AXIS2_HOME="/tmp/axis2-1.6.0" ant client.02



Result:
xml version='1.0' encoding='UTF-8'?><> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><> xmlns:wsa="http://www.w3.org/2005/08/addressing"><> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"><> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-1">2015-04-02T12:36:45.699Z2015-04-02T12:41:45.699Z<> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="CertId-FFCBEBA22B6965E99814279782058481">MIICTzCCAbigAwIBAgIESy9O5zANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQGEwJMSzEQMA4GA1UECBMHV2VzdGVybjEQMA4GA1UEBxMHQ29sb21ibzEPMA0GA1UEChMGQXBhY2hlMRAwDgYDVQQLEwdSYW1wYXJ0MRYwFAYDVQQDEw1TYW1wbGUgQ2xpZW50MB4XDTA5MTIyMTEwMzMxMVoXDTM3MDUwNzEwMzMxMVowbDELMAkGA1UEBhMCTEsxEDAOBgNVBAgTB1dlc3Rlcm4xEDAOBgNVBAcTB0NvbG9tYm8xDzANBgNVBAoTBkFwYWNoZTEQMA4GA1UECxMHUmFtcGFydDEWMBQGA1UEAxMNU2FtcGxlIENsaWVudDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAjBQM+kgC0Wm9hk9v4pjLSg5yK0Em2ulyDmODckWv4mZJ8YwJPVgqEIzwRiOnNBH3s+wFCw297zDsnEgDKSQrsPf1smVUOK/slyDPbqZ47Ewcs07nCPfNigncmpbcaluO3bMw9Oqj9VIYjrUHu5xCp2Fe39ZPbwOzLtAmT8b6iucCAwEAATANBgkqhkiG9w0BAQUFAAOBgQAnjPanrVjFVkxnhsj83RJA2tK//v99KpPf3do9VUI2yEgvBZUzH3q2jk3widwEcsJMHgbRr3VTFL7dNVdCYBcI1KiBY9SMa1XZ4RIHmw7gkJt1JTgjKBzfrout2z614KixRf4w7qkDacGxkNspXG/PSlh03Lfm5sb0vzH1aqBl3g==<> xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-2">
<> Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<> Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<> URI="#Id-1699113578">
<> Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<> Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
FxyXQohBY+oKmQyoqCj4orZYe2Y=
<> URI="#Timestamp-1">
<> Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<> Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
FUQ5TrZnod5225pBiZX9pjWT2P8=
imGHfyo4axHLe0VnaSaTLSJey0wx3ot1algqaR1UIYo14xy5MMGb7AMNezglKCJPyOSsYDZKke6b
IXF0B9YjQrZB/jALPGjfmQL6ahJlf7aN3Xod9LNHlh+WW9GgbTBYo/FVrEW8o0tFwShdo9/WelHT
uOvaZ6AflVUYl85Te6I=
<> Id="KeyId-FFCBEBA22B6965E99814279782058532">
<> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STRId-FFCBEBA22B6965E99814279782058543"><> URI="#CertId-FFCBEBA22B6965E99814279782058481" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" />
http://localhost:8080/axis2/services/sample02urn:uuid:4732fd77-3d09-4639-ba44-41618c2c4a4aurn:echo<> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-1699113578"><> xmlns:ns1="http://sample02.policy.samples.rampart.apache.org">Hello world



Using WS-Attacker




We use again cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 second terminal to start WS-Attacker:
% cd /tmp/WS-Attacker/runnable  
% java -jar WS-Attacker-1.4-SNAPSHOT.jar



We use cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 WSDL URL http://localhost:8080/axis2/services/sample02?wsdl and feed it into WS-Attacker:

We switch to cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 “Test Request” Tab and replace cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 XML Request with cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 one that we obtained in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 previous section:


After sending cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 test request, a SOAP error message is received. Do not bocá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365r with it. We will use XSW to renew cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 timestamp. To go for it, move to cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 plugin configuration tab.



All we have to do in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 plugin configuration tab, is to select and activate cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Signature Wrapping Attack from cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 tree on cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 left. We can cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365n configure cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 payload. Payload is cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 XML content that is going to be executed instead of cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 originally signed content. In this case, cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 XML message has to signed elements: The Body Element and cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Timestamp element. For cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 first one, we just change cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 “Hello World” message to “Hello WS-ATTACKER”. For cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Timestamp, WS-Attacker automatically detected that this is a timestamp element. It will update it automatically (see lower highlighting in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 screenshot).
A common issue with cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 XSW Plugin is, that it will not go into cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 “Ready” state. This happens, when you have not configured any payload.
Next, we move to cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 “Attack Overview” tab and start cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 attack.



As we can see, Axis2 could be successfully attacked. We can also see cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 attack vector that was used.
More details can be obtained by right-clicking on cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 Signature Wrapping Plugin in cá cược thể thao bet365_cách nạp tiền vào bet365_ đăng ký bet365 upper table and selecting “Analyze XSW responses”.

Beliebte Posts