Thursday, August 6, 2015

Fast check of Cross-domain policy file that server sends to client via socket

Often the socket connection to the certain server or its ports can be restricted by the policy file. It could be also allowed only from the particular list of domains (where the client hosts). So, here the quick way to make a socket connection to the server, request & output the cross-domain policy file (it can be launched via Groovy console right from your IntelijIDEA->Tools->Groovy console):

import javax.net.ssl.SSLSocketFactory

SSLSocketFactory f =(javax.net.SocketFactory) SSLSocketFactory.getDefault();
c = f.createSocket("foo.bar.com", 4855);
c.startHandshake();
c.withStreams { input, output ->
    output << "\0"
    println input.newReader().text}
Here is the output:
@seeAlso Senocular - Cross-domain Policy File Specification

No comments:

Post a Comment