scan URL's for xmlrpclib
Thierry Parmentelat [Tue, 5 Feb 2013 09:44:21 +0000 (10:44 +0100)]
system/url_scanner.py [new file with mode: 0644]

diff --git a/system/url_scanner.py b/system/url_scanner.py
new file mode 100644 (file)
index 0000000..b744057
--- /dev/null
@@ -0,0 +1,35 @@
+# a utility for testing xmlrpclib URL's
+# should probably 
+import xmlrpclib
+auth={'AuthMethod':'password','Username':'root@test.onelab.eu','AuthString':'test++'}
+
+host='vplc21'
+
+import socket
+hostname="%s.pl.sophia.inria.fr"%host
+ip=socket.gethostbyname(hostname)
+
+import traceback
+verbose=True
+
+def try_url (url,xmlrpclib_verbose=False):
+    try:
+        xmlrpclib.ServerProxy (url, verbose=xmlrpclib_verbose, allow_none=True).GetNodes(auth)
+        print 'YES',url
+    except xmlrpclib.ProtocolError as e:
+        print '... (http error %s)'%e.errcode,url
+    except Exception as e:
+        print '---',type(e).__name__,url
+        if verbose: traceback.print_exc()
+
+def scan():
+    for protocol in ['http','https']:
+        for dest in [ hostname, ip ]:
+            for port in [ '',':80',':443']:
+#            for port in [ ':80',':443']:
+                for path in ['PLCAPI','PLCAPI/']:
+                    if protocol=='http' and port==':443': continue
+                    if protocol=='https' and port==':80': continue
+                    url="%s://%s%s/%s"%(protocol,dest,port,path)
+                    try_url (url)
+