Python xmlrpclib.Binary() Examples
The following are 30
code examples of xmlrpclib.Binary().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xmlrpclib
, or try the search function
.
Example #1
Source File: plugin_upload.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 6 votes |
def main(options, args): address = "%s://%s:%s@%s:%s%s" % (PROTOCOL, options.username, options.password, options.server, options.port, ENDPOINT) print "Connecting to: %s" % hidepassword(address) server = xmlrpclib.ServerProxy(address, verbose=VERBOSE) try: plugin_id, version_id = server.plugin.upload(xmlrpclib.Binary(open(args[0]).read())) print "Plugin ID: %s" % plugin_id print "Version ID: %s" % version_id except xmlrpclib.ProtocolError, err: print "A protocol error occurred" print "URL: %s" % hidepassword(err.url, 0) print "HTTP/HTTPS headers: %s" % err.headers print "Error code: %d" % err.errcode print "Error message: %s" % err.errmsg
Example #2
Source File: pyratcli.py From PyRat with GNU General Public License v3.0 | 6 votes |
def terminate_proc(self, argv): try: (ptype, val) = argv.split(' ') # ptype = '/PID' if ptype == 'pid' else '/IM' # cmd = 'cmd.exe /c taskkill %s %s' % (ptype, val) # log = 'cmd.log' # p = subprocess.Popen(cmd, stdout=file(log, 'w'), stderr=subprocess.STDOUT) # p.wait() # data = self.__read_file(log) # https://www.cnblogs.com/xjh713/p/6306587.html?utm_source=itdadao&utm_medium=referral if sys.platform == 'win32': ptype = '/PID' if ptype == 'pid' else '/IM' data = os.popen('taskkill %s %s' % (ptype, val)).read() else: os.kill(val, signal.SIGKILL) return (True, xmlrpclib.Binary(data)) except Exception as e: return (False, str(e))
Example #3
Source File: test_xmlrpc.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_decode(self): d = '\x01\x02\x03abc123\xff\xfe' de = base64.encodestring(d) t1 = xmlrpclib.Binary() t1.decode(de) self.assertEqual(str(t1), d) t2 = xmlrpclib._binary(de) self.assertEqual(str(t2), d)
Example #4
Source File: guest.py From CuckooSploit with GNU General Public License v3.0 | 5 votes |
def upload_analyzer(self): """Upload analyzer to guest. @return: operation status. """ zip_data = StringIO() zip_file = ZipFile(zip_data, "w", ZIP_STORED) # Select the proper analyzer's folder according to the operating # system associated with the current machine. root = os.path.join(CUCKOO_ROOT, "analyzer", self.platform) root_len = len(os.path.abspath(root)) if not os.path.exists(root): log.error("No valid analyzer found at path: %s", root) return False # Walk through everything inside the analyzer's folder and write # them to the zip archive. for root, dirs, files in os.walk(root): archive_root = os.path.abspath(root)[root_len:] for name in files: path = os.path.join(root, name) archive_name = os.path.join(archive_root, name) zip_file.write(path, archive_name) zip_file.close() data = xmlrpclib.Binary(zip_data.getvalue()) zip_data.close() log.debug("Uploading analyzer to guest (id=%s, ip=%s)", self.id, self.ip) # Send the zip containing the analyzer to the agent running inside # the guest. try: self.server.add_analyzer(data) except socket.timeout: raise CuckooGuestError("{0}: guest communication timeout: unable " "to upload agent, check networking or try " "to increase timeout".format(self.id))
Example #5
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_default(self): t = xmlrpclib.Binary() self.assertEqual(str(t), '')
Example #6
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_string(self): d = '\x01\x02\x03abc123\xff\xfe' t = xmlrpclib.Binary(d) self.assertEqual(str(t), d)
Example #7
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_decode(self): d = '\x01\x02\x03abc123\xff\xfe' de = base64.encodestring(d) t1 = xmlrpclib.Binary() t1.decode(de) self.assertEqual(str(t1), d) t2 = xmlrpclib._binary(de) self.assertEqual(str(t2), d)
Example #8
Source File: plugin_upload.py From plugin_build_tool with GNU General Public License v2.0 | 5 votes |
def main(parameters, arguments): """Main entry point. :param parameters: Command line parameters. :param arguments: Command line arguments. """ address = "%s://%s:%s@%s:%s%s" % ( PROTOCOL, parameters.username, parameters.password, parameters.server, parameters.port, ENDPOINT) print "Connecting to: %s" % hide_password(address) server = xmlrpclib.ServerProxy(address, verbose=VERBOSE) try: plugin_id, version_id = server.plugin.upload( xmlrpclib.Binary(open(arguments[0]).read())) print "Plugin ID: %s" % plugin_id print "Version ID: %s" % version_id except xmlrpclib.ProtocolError, err: print "A protocol error occurred" print "URL: %s" % hide_password(err.url, 0) print "HTTP/HTTPS headers: %s" % err.headers print "Error code: %d" % err.errcode print "Error message: %s" % err.errmsg
Example #9
Source File: util.py From conary with Apache License 2.0 | 5 votes |
def dump_string(self, value, write, escape=xmlrpclib.escape): try: value = value.encode("ascii") except UnicodeError: sio = StringIO.StringIO() xmlrpclib.Binary(value).encode(sio) write(sio.getvalue()) return return xmlrpclib.Marshaller.dump_string(self, value, write, escape)
Example #10
Source File: util.py From conary with Apache License 2.0 | 5 votes |
def end_base64(self, data): value = xmlrpclib.Binary() value.decode(data) self.append(value.data) self._value = 0
Example #11
Source File: util.py From conary with Apache License 2.0 | 5 votes |
def _stringify(self, data): try: return data.encode("ascii") except UnicodeError: return xmlrpclib.Binary(data)
Example #12
Source File: test_xmlrpc.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_default(self): t = xmlrpclib.Binary() self.assertEqual(str(t), '')
Example #13
Source File: test_xmlrpc.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_string(self): d = '\x01\x02\x03abc123\xff\xfe' t = xmlrpclib.Binary(d) self.assertEqual(str(t), d)
Example #14
Source File: recipe-413404.py From code with MIT License | 5 votes |
def getPdf(self,aMsg): c = canvas.Canvas(None) c.drawString(100,100,aMsg) c.showPage() c.save() return xmlrpclib.Binary(c.getpdfdata())
Example #15
Source File: pyratcli.py From PyRat with GNU General Public License v3.0 | 5 votes |
def upload(self, argv): try: path = argv data = self.__read_file(path) return (True, xmlrpclib.Binary(data)) except Exception as e: return (False, str(e))
Example #16
Source File: pyratcli.py From PyRat with GNU General Public License v3.0 | 5 votes |
def cmdshell(self, cmd): try: #https://www.cnblogs.com/yangykaifa/p/7127776.html # cmd = 'cmd.exe /c %s &' % cmd # log = 'cmd.log' # p = subprocess.Popen(cmd, stdout=file(log, 'w'), stderr=subprocess.STDOUT) # p.wait() # data = self.__read_file(log) data = os.popen(cmd).read() return (True, xmlrpclib.Binary(data)) except Exception as e: return (False, str(e))
Example #17
Source File: pyratsvr.py From PyRat with GNU General Public License v3.0 | 5 votes |
def download(self, path): try: f = file(path, 'rb') b = f.read() f.close() return (True, xmlrpclib.Binary(b)) except Exception as e: return (False, str(e))
Example #18
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_default(self): t = xmlrpclib.Binary() self.assertEqual(str(t), '')
Example #19
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_string(self): d = '\x01\x02\x03abc123\xff\xfe' t = xmlrpclib.Binary(d) self.assertEqual(str(t), d)
Example #20
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_decode(self): d = '\x01\x02\x03abc123\xff\xfe' de = base64.encodestring(d) t1 = xmlrpclib.Binary() t1.decode(de) self.assertEqual(str(t1), d) t2 = xmlrpclib._binary(de) self.assertEqual(str(t2), d)
Example #21
Source File: plugin_upload.py From qgpkg with MIT License | 5 votes |
def main(parameters, arguments): """Main entry point. :param parameters: Command line parameters. :param arguments: Command line arguments. """ address = "%s://%s:%s@%s:%s%s" % ( PROTOCOL, parameters.username, parameters.password, parameters.server, parameters.port, ENDPOINT) print "Connecting to: %s" % hide_password(address) server = xmlrpclib.ServerProxy(address, verbose=VERBOSE) try: plugin_id, version_id = server.plugin.upload( xmlrpclib.Binary(open(arguments[0]).read())) print "Plugin ID: %s" % plugin_id print "Version ID: %s" % version_id except xmlrpclib.ProtocolError, err: print "A protocol error occurred" print "URL: %s" % hide_password(err.url, 0) print "HTTP/HTTPS headers: %s" % err.headers print "Error code: %d" % err.errcode print "Error message: %s" % err.errmsg
Example #22
Source File: test_xmlrpc.py From BinderFilter with MIT License | 5 votes |
def test_default(self): t = xmlrpclib.Binary() self.assertEqual(str(t), '')
Example #23
Source File: plugin_upload.py From qgis-cartodb with GNU General Public License v2.0 | 5 votes |
def main(parameters, arguments): """Main entry point. :param parameters: Command line parameters. :param arguments: Command line arguments. """ address = "%s://%s:%s@%s:%s%s" % ( PROTOCOL, parameters.username, parameters.password, parameters.server, parameters.port, ENDPOINT) print "Connecting to: %s" % hide_password(address) server = xmlrpclib.ServerProxy(address, verbose=VERBOSE) try: plugin_id, version_id = server.plugin.upload( xmlrpclib.Binary(open(arguments[0]).read())) print "Plugin ID: %s" % plugin_id print "Version ID: %s" % version_id except xmlrpclib.ProtocolError, err: print "A protocol error occurred" print "URL: %s" % hide_password(err.url, 0) print "HTTP/HTTPS headers: %s" % err.headers print "Error code: %d" % err.errcode print "Error message: %s" % err.errmsg
Example #24
Source File: aria2.py From PyOne with Mozilla Public License 2.0 | 5 votes |
def addTorrent(self, torrent, uris=None, options=None, position=None): ''' This method adds BitTorrent download by uploading ".torrent" file. torrent: string, torrent file path uris: list, list of webseed URIs options: dict, additional options position: integer, position in download queue return: This method returns GID of registered download. ''' return self.server.aria2.addTorrent(xmlrpclib.Binary(open(torrent, 'rb').read()), uris, options, position)
Example #25
Source File: aria2.py From PyOne with Mozilla Public License 2.0 | 5 votes |
def addMetalink(self, metalink, options=None, position=None): ''' This method adds Metalink download by uploading ".metalink" file. metalink: string, metalink file path options: dict, additional options position: integer, position in download queue return: This method returns list of GID of registered download. ''' return self.server.aria2.addMetalink(xmlrpclib.Binary(open(metalink, 'rb').read()), options, position)
Example #26
Source File: dokuwiki.py From python-dokuwiki with MIT License | 5 votes |
def add(self, media, filepath, overwrite=True): """Set *media* from local file *filepath*. *overwrite* parameter specify if the media must be overwrite if it exists remotely. """ with open(filepath, 'rb') as fhandler: self._dokuwiki.send('wiki.putAttachment', media, Binary(fhandler.read()), ow=overwrite)
Example #27
Source File: dokuwiki.py From python-dokuwiki with MIT License | 5 votes |
def set(self, media, _bytes, overwrite=True, b64encode=False): """Set *media* from *_bytes*. *overwrite* parameter specify if the media must be overwrite if it exists remotely. """ data = base64.b64encode(_bytes) if b64encode else Binary(_bytes) self._dokuwiki.send('wiki.putAttachment', media, data, ow=overwrite)
Example #28
Source File: test_xmlrpc.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_default(self): t = xmlrpclib.Binary() self.assertEqual(str(t), '')
Example #29
Source File: test_xmlrpc.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_string(self): d = '\x01\x02\x03abc123\xff\xfe' t = xmlrpclib.Binary(d) self.assertEqual(str(t), d)
Example #30
Source File: test_xmlrpc.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_decode(self): d = '\x01\x02\x03abc123\xff\xfe' de = base64.encodestring(d) t1 = xmlrpclib.Binary() t1.decode(de) self.assertEqual(str(t1), d) t2 = xmlrpclib._binary(de) self.assertEqual(str(t2), d)