@shriyanss/js-recon 1.0.0 → 1.1.0-beta.2

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.
Files changed (143) hide show
  1. package/.github/workflows/build-and-prettify.yaml +65 -0
  2. package/.github/workflows/npm-publish.yml +35 -0
  3. package/.prettierignore +2 -0
  4. package/.prettierrc +4 -0
  5. package/CHANGELOG.md +50 -0
  6. package/README.md +35 -139
  7. package/build/api_gateway/checkFeasibility.js +32 -0
  8. package/build/api_gateway/checkFeasibility.js.map +1 -0
  9. package/build/api_gateway/checkFireWallBlocking.js +24 -0
  10. package/build/api_gateway/checkFireWallBlocking.js.map +1 -0
  11. package/build/api_gateway/genReq.js +199 -0
  12. package/build/api_gateway/genReq.js.map +1 -0
  13. package/build/api_gateway/index.js +275 -0
  14. package/build/api_gateway/index.js.map +1 -0
  15. package/build/endpoints/gen_report/gen_json.js +22 -0
  16. package/build/endpoints/gen_report/gen_json.js.map +1 -0
  17. package/build/endpoints/gen_report/gen_markdown.js +66 -0
  18. package/build/endpoints/gen_report/gen_markdown.js.map +1 -0
  19. package/build/endpoints/gen_report/utility/iterate_n_store.js +46 -0
  20. package/build/endpoints/gen_report/utility/iterate_n_store.js.map +1 -0
  21. package/build/endpoints/index.js +89 -0
  22. package/build/endpoints/index.js.map +1 -0
  23. package/build/endpoints/next_js/client_jsFilesHref.js +91 -0
  24. package/build/endpoints/next_js/client_jsFilesHref.js.map +1 -0
  25. package/build/endpoints/next_js/client_jsonParse.js +78 -0
  26. package/build/endpoints/next_js/client_jsonParse.js.map +1 -0
  27. package/build/endpoints/next_js/client_subsequentRequests.js +199 -0
  28. package/build/endpoints/next_js/client_subsequentRequests.js.map +1 -0
  29. package/build/endpoints/next_js/getWebpacks.js +45 -0
  30. package/build/endpoints/next_js/getWebpacks.js.map +1 -0
  31. package/build/globalConfig.js +11 -0
  32. package/build/globalConfig.js.map +1 -0
  33. package/build/index.js +166 -0
  34. package/build/index.js.map +1 -0
  35. package/build/lazyLoad/downloadFilesUtil.js +128 -0
  36. package/build/lazyLoad/downloadFilesUtil.js.map +1 -0
  37. package/build/lazyLoad/downloadLoadedJsUtil.js +51 -0
  38. package/build/lazyLoad/downloadLoadedJsUtil.js.map +1 -0
  39. package/build/lazyLoad/globals.js +22 -0
  40. package/build/lazyLoad/globals.js.map +1 -0
  41. package/build/lazyLoad/index.js +170 -0
  42. package/build/lazyLoad/index.js.map +1 -0
  43. package/build/lazyLoad/next_js/next_GetJSScript.js +94 -0
  44. package/build/lazyLoad/next_js/next_GetJSScript.js.map +1 -0
  45. package/build/lazyLoad/next_js/next_GetLazyResources.js +202 -0
  46. package/build/lazyLoad/next_js/next_GetLazyResources.js.map +1 -0
  47. package/build/lazyLoad/next_js/next_SubsequentRequests.js +120 -0
  48. package/build/lazyLoad/next_js/next_SubsequentRequests.js.map +1 -0
  49. package/build/lazyLoad/nuxt_js/nuxt_astParse.js +188 -0
  50. package/build/lazyLoad/nuxt_js/nuxt_astParse.js.map +1 -0
  51. package/build/lazyLoad/nuxt_js/nuxt_getFromPageSource.js +75 -0
  52. package/build/lazyLoad/nuxt_js/nuxt_getFromPageSource.js.map +1 -0
  53. package/build/lazyLoad/nuxt_js/nuxt_stringAnalysisJSFiles.js +94 -0
  54. package/build/lazyLoad/nuxt_js/nuxt_stringAnalysisJSFiles.js.map +1 -0
  55. package/build/lazyLoad/svelte/svelte_getFromPageSource.js +68 -0
  56. package/build/lazyLoad/svelte/svelte_getFromPageSource.js.map +1 -0
  57. package/build/lazyLoad/svelte/svelte_stringAnalysisJSFiles.js +95 -0
  58. package/build/lazyLoad/svelte/svelte_stringAnalysisJSFiles.js.map +1 -0
  59. package/build/map/index.js +58 -0
  60. package/build/map/index.js.map +1 -0
  61. package/build/map/next_js/getFetchInstances.js +108 -0
  62. package/build/map/next_js/getFetchInstances.js.map +1 -0
  63. package/build/map/next_js/getWebpackConnections.js +227 -0
  64. package/build/map/next_js/getWebpackConnections.js.map +1 -0
  65. package/build/map/next_js/interactive.js +32 -0
  66. package/build/map/next_js/interactive.js.map +1 -0
  67. package/build/map/next_js/interactive_helpers/commandHandler.js +190 -0
  68. package/build/map/next_js/interactive_helpers/commandHandler.js.map +1 -0
  69. package/build/map/next_js/interactive_helpers/commandHelpers.js +91 -0
  70. package/build/map/next_js/interactive_helpers/commandHelpers.js.map +1 -0
  71. package/build/map/next_js/interactive_helpers/helpMenu.js +11 -0
  72. package/build/map/next_js/interactive_helpers/helpMenu.js.map +1 -0
  73. package/build/map/next_js/interactive_helpers/keybindings.js +80 -0
  74. package/build/map/next_js/interactive_helpers/keybindings.js.map +1 -0
  75. package/build/map/next_js/interactive_helpers/printer.js +17 -0
  76. package/build/map/next_js/interactive_helpers/printer.js.map +1 -0
  77. package/build/map/next_js/interactive_helpers/ui.js +81 -0
  78. package/build/map/next_js/interactive_helpers/ui.js.map +1 -0
  79. package/build/map/next_js/resolveFetch.js +201 -0
  80. package/build/map/next_js/resolveFetch.js.map +1 -0
  81. package/build/run/index.js +62 -0
  82. package/build/run/index.js.map +1 -0
  83. package/build/strings/index.js +238 -0
  84. package/build/strings/index.js.map +1 -0
  85. package/build/strings/openapi.js +55 -0
  86. package/build/strings/openapi.js.map +1 -0
  87. package/build/strings/permutate.js +55 -0
  88. package/build/strings/permutate.js.map +1 -0
  89. package/build/strings/secrets.js +89 -0
  90. package/build/strings/secrets.js.map +1 -0
  91. package/build/techDetect/index.js +229 -0
  92. package/build/techDetect/index.js.map +1 -0
  93. package/build/utility/ai.js +69 -0
  94. package/build/utility/ai.js.map +1 -0
  95. package/build/utility/globals.js +84 -0
  96. package/build/utility/globals.js.map +1 -0
  97. package/build/utility/interfaces.js +2 -0
  98. package/build/utility/interfaces.js.map +1 -0
  99. package/build/utility/makeReq.js +265 -0
  100. package/build/utility/makeReq.js.map +1 -0
  101. package/build/utility/resolvePath.js +44 -0
  102. package/build/utility/resolvePath.js.map +1 -0
  103. package/{utility → build/utility}/runSandboxed.js +10 -13
  104. package/build/utility/runSandboxed.js.map +1 -0
  105. package/{utility → build/utility}/urlUtils.js +9 -11
  106. package/build/utility/urlUtils.js.map +1 -0
  107. package/docs/CNAME +1 -0
  108. package/docs/README.md +20 -0
  109. package/docs/api-gateway.md +68 -0
  110. package/docs/endpoints.md +49 -0
  111. package/docs/example-scenario.md +258 -0
  112. package/docs/interactive-mode.md +76 -0
  113. package/docs/lazyload.md +56 -0
  114. package/docs/map.md +53 -0
  115. package/docs/run.md +54 -0
  116. package/docs/strings.md +75 -0
  117. package/package.json +50 -38
  118. package/api_gateway/checkFeasibility.js +0 -25
  119. package/api_gateway/checkFireWallBlocking.js +0 -17
  120. package/api_gateway/genReq.js +0 -214
  121. package/api_gateway/index.js +0 -325
  122. package/endpoints/index.js +0 -7
  123. package/globalConfig.js +0 -12
  124. package/index.js +0 -69
  125. package/lazyLoad/downloadFilesUtil.js +0 -122
  126. package/lazyLoad/downloadLoadedJsUtil.js +0 -54
  127. package/lazyLoad/globals.js +0 -15
  128. package/lazyLoad/index.js +0 -167
  129. package/lazyLoad/next_js/next_GetJSScript.js +0 -99
  130. package/lazyLoad/next_js/next_GetLazyResources.js +0 -201
  131. package/lazyLoad/next_js/next_SubsequentRequests.js +0 -138
  132. package/lazyLoad/nuxt_js/nuxt_astParse.js +0 -194
  133. package/lazyLoad/nuxt_js/nuxt_getFromPageSource.js +0 -77
  134. package/lazyLoad/nuxt_js/nuxt_stringAnalysisJSFiles.js +0 -99
  135. package/research/firewall_bypass.md +0 -38
  136. package/research/next_js.md +0 -116
  137. package/research/nuxt_js.md +0 -125
  138. package/research/vue_js.md +0 -9
  139. package/strings/index.js +0 -145
  140. package/techDetect/index.js +0 -156
  141. package/utility/globals.js +0 -6
  142. package/utility/makeReq.js +0 -179
  143. package/utility/resolvePath.js +0 -43
@@ -0,0 +1,265 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import chalk from "chalk";
11
+ import puppeteer from "puppeteer";
12
+ import * as globals from "./globals.js";
13
+ import { get } from "../api_gateway/genReq.js";
14
+ import fs from "fs";
15
+ // random user agents
16
+ const UAs = [
17
+ "Chrome/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
18
+ "Chrome/Windows: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
19
+ "Chrome/Windows: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
20
+ "Chrome/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
21
+ "Chrome/Linux: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
22
+ "Chrome/iPhone: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1",
23
+ "Chrome/iPhone (request desktop): Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87 Version/11.1.1 Safari/605.1.15",
24
+ "Chrome/iPad: Mozilla/5.0 (iPad; CPU OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1",
25
+ "Chrome/iPod: Mozilla/5.0 (iPod; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1",
26
+ "Chrome/Android: Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36",
27
+ "Chrome/Android: Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36",
28
+ "Chrome/Android: Mozilla/5.0 (Linux; Android 10; LM-Q720) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36",
29
+ "Firefox/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0",
30
+ "Firefox/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11.1; rv:84.0) Gecko/20100101 Firefox/84.0",
31
+ "Firefox/Linux: Mozilla/5.0 (X11; Linux i686; rv:84.0) Gecko/20100101 Firefox/84.0",
32
+ "Firefox/iPhone: Mozilla/5.0 (iPhone; CPU iPhone OS 11_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/30.0 Mobile/15E148 Safari/605.1.15",
33
+ "Firefox/iPad: Mozilla/5.0 (iPad; CPU OS 11_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/30.0 Mobile/15E148 Safari/605.1.15",
34
+ "Firefox/Android: Mozilla/5.0 (Android 11; Mobile; rv:68.0) Gecko/68.0 Firefox/84.0",
35
+ "Safari/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15",
36
+ "Safari/iPhone: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1",
37
+ "Safari/iPhone (request desktop): Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15",
38
+ "Safari/iPad: Mozilla/5.0 (iPad; CPU OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1",
39
+ "IE11/Windows: Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko",
40
+ "Edge/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66",
41
+ "Edge/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66",
42
+ "Edge/Android: Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36 EdgA/45.12.4.5121",
43
+ "Edge/iOS: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.11.11 Mobile/15E148 Safari/605.1.15",
44
+ "Opera/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 OPR/73.0.3856.329",
45
+ "Opera/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 OPR/73.0.3856.329",
46
+ "Opera/Linux: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 OPR/73.0.3856.329",
47
+ "Opera/Android: Mozilla/5.0 (Linux; Android 10; VOG-L29) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36 OPR/61.1.3076.56625",
48
+ "Vivaldi/Windows: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Vivaldi/3.5",
49
+ "Vivaldi/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Vivaldi/3.5",
50
+ "Vivaldi/Linux: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Vivaldi/3.5",
51
+ "Yandex/Windows: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 YaBrowser/20.12.0 Yowser/2.5 Safari/537.36",
52
+ "Yandex/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 YaBrowser/20.12.0 Yowser/2.5 Safari/537.36",
53
+ "Yandex/iOS: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 YaBrowser/20.11.2.199 Mobile/15E148 Safari/604.1",
54
+ "Yandex/Android: Mozilla/5.0 (Linux; arm_64; Android 11; SM-G965F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 YaBrowser/20.12.29.180 Mobile Safari/537.36",
55
+ "Chrome/ChromeOS: Mozilla/5.0 (X11; CrOS x86_64 13505.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
56
+ "Safari/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15",
57
+ "Firefox/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11.1; rv:84.0) Gecko/20100101 Firefox/84.0",
58
+ "Chrome/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
59
+ "Vivaldi/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Vivaldi/3.5",
60
+ "Edge/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66",
61
+ "Safari/iOS: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1",
62
+ "Chrome/iOS: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1",
63
+ "Firefox/iOS: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/30.0 Mobile/15E148 Safari/605.1.15",
64
+ "Edge/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66",
65
+ "Internet-Explorer/Windows: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
66
+ "Chrome/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
67
+ "Firefox/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0",
68
+ "Vivaldi/Windows: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Vivaldi/3.5",
69
+ "Chrome/Android: Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36",
70
+ "Firefox/Android: Mozilla/5.0 (Android 11; Mobile; rv:68.0) Gecko/68.0 Firefox/84.0",
71
+ ];
72
+ const readCache = (url, headers) => __awaiter(void 0, void 0, void 0, function* () {
73
+ // console.log("reading cache for", url);
74
+ // open the cache file, build a Response, and return
75
+ const cache = JSON.parse(fs.readFileSync(globals.getRespCacheFile(), "utf-8"));
76
+ if (cache[url]) {
77
+ // check if the response contains the specific request headers
78
+ // iterate through cache[url] and build a Response
79
+ let headersMatch = true;
80
+ // first check if the essential headers match
81
+ const rscEnabled = headers["RSC"] ? true : false;
82
+ if (rscEnabled) {
83
+ if (cache[url].rsc) {
84
+ return new Response(atob(cache[url].rsc.body_b64), {
85
+ status: cache[url].rsc.status,
86
+ headers: cache[url].rsc.resp_headers,
87
+ });
88
+ }
89
+ }
90
+ if (!rscEnabled && cache[url] && cache[url].normal) {
91
+ return new Response(atob(cache[url].normal.body_b64), {
92
+ status: cache[url].normal.status,
93
+ headers: cache[url].normal.resp_headers,
94
+ });
95
+ }
96
+ }
97
+ // console.log("cache not found for ", url);
98
+ return null;
99
+ });
100
+ const writeCache = (url, headers, response) => __awaiter(void 0, void 0, void 0, function* () {
101
+ // clone the response
102
+ const clonedResponse = response.clone();
103
+ // if cache exists, return
104
+ if ((yield readCache(url, headers)) !== null) {
105
+ // console.log("cache already exists for ", url);
106
+ return;
107
+ }
108
+ // open the cache file, and write the response based on the special headers
109
+ const cache = JSON.parse(fs.readFileSync(globals.getRespCacheFile(), "utf-8"));
110
+ if (!cache[url]) {
111
+ cache[url] = {};
112
+ }
113
+ const body = btoa(encodeURIComponent(yield clonedResponse.text()).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(parseInt(p1, 16))));
114
+ const status = clonedResponse.status;
115
+ const resp_headers = clonedResponse.headers;
116
+ if (headers["RSC"]) {
117
+ cache[url].rsc = {
118
+ req_headers: headers,
119
+ status: status,
120
+ body_b64: body,
121
+ resp_headers: resp_headers,
122
+ };
123
+ // console.log("rsc", url);
124
+ }
125
+ else {
126
+ cache[url].normal = {
127
+ req_headers: headers,
128
+ status: status,
129
+ body_b64: body,
130
+ resp_headers: resp_headers,
131
+ };
132
+ // console.log("normal", url);
133
+ }
134
+ fs.writeFileSync(globals.getRespCacheFile(), JSON.stringify(cache));
135
+ // console.log("wrote cache for ", url);
136
+ });
137
+ const makeRequest = (url, args) => __awaiter(void 0, void 0, void 0, function* () {
138
+ // if cache is enabled, read the cache and return if cache is present. else, continue
139
+ if (!globals.getDisableCache()) {
140
+ const cachedResponse = yield readCache(url, (args === null || args === void 0 ? void 0 : args.headers) || {});
141
+ if (cachedResponse !== null) {
142
+ return cachedResponse;
143
+ }
144
+ }
145
+ if (globals.useApiGateway) {
146
+ let get_headers;
147
+ if (args && args.headers) {
148
+ get_headers = args.headers;
149
+ }
150
+ else {
151
+ get_headers = {
152
+ "User-Agent": UAs[Math.floor(Math.random() * UAs.length)],
153
+ Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
154
+ "Accept-Language": "en-US,en;q=0.9",
155
+ "Sec-Fetch-Site": "same-origin",
156
+ "Sec-Fetch-Mode": "cors",
157
+ "Sec-Fetch-Dest": "empty",
158
+ Referer: url,
159
+ Origin: url,
160
+ };
161
+ }
162
+ const body = yield get(url, get_headers);
163
+ // craft a Response, and return that
164
+ const response = new Response(body);
165
+ // if cache is enabled, write the response to the cache
166
+ if (!globals.getDisableCache()) {
167
+ yield writeCache(url, get_headers, response);
168
+ }
169
+ return response;
170
+ }
171
+ else {
172
+ if (args === undefined) {
173
+ args = {
174
+ headers: {
175
+ "User-Agent": UAs[Math.floor(Math.random() * UAs.length)],
176
+ Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
177
+ "Accept-Language": "en-US,en;q=0.9",
178
+ "Sec-Fetch-Site": "same-origin",
179
+ "Sec-Fetch-Mode": "cors",
180
+ "Sec-Fetch-Dest": "empty",
181
+ Referer: url,
182
+ Origin: url,
183
+ },
184
+ };
185
+ }
186
+ let res;
187
+ let counter = 0;
188
+ while (true) {
189
+ try {
190
+ res = yield fetch(url, args);
191
+ if (res) {
192
+ break;
193
+ }
194
+ }
195
+ catch (err) {
196
+ counter++;
197
+ if (counter > 10) {
198
+ console.log(chalk.red(`[!] Failed to fetch ${url} : ${err}`));
199
+ return null;
200
+ }
201
+ // sleep 0.5 s before retrying
202
+ yield new Promise((resolve) => setTimeout(resolve, 500));
203
+ continue;
204
+ }
205
+ }
206
+ const preservedRes = res.clone();
207
+ // check if this is a firewall
208
+ // CF first
209
+ const resp_text = yield res.text();
210
+ if (resp_text.includes("/?bm-verify=")) {
211
+ console.log(chalk.yellow(`[!] CF Firewall detected. Trying to bypass with headless browser`));
212
+ // if it is, load it in a headless browser
213
+ const browser = yield puppeteer.launch({
214
+ headless: true,
215
+ args: [
216
+ "--disable-gpu",
217
+ "--disable-dev-shm-usage",
218
+ "--disable-setuid-sandbox",
219
+ "--no-sandbox",
220
+ ],
221
+ });
222
+ const page = yield browser.newPage();
223
+ yield page.goto(url);
224
+ yield new Promise((resolve) => setTimeout(resolve, 5000));
225
+ const content = yield page.content();
226
+ yield browser.close();
227
+ // if cache is enabled, write the response to the cache
228
+ if (!globals.getDisableCache()) {
229
+ yield writeCache(url, {}, new Response(content));
230
+ }
231
+ return new Response(content);
232
+ }
233
+ else if (resp_text.includes("<title>Just a moment...</title>")) {
234
+ console.log(chalk.yellow(`[!] CF Firewall detected. Trying to bypass with headless browser`));
235
+ // if it is, load it in a headless browser
236
+ const browser = yield puppeteer.launch({
237
+ headless: true,
238
+ args: [
239
+ "--disable-gpu",
240
+ "--disable-dev-shm-usage",
241
+ "--disable-setuid-sandbox",
242
+ "--no-sandbox",
243
+ ],
244
+ });
245
+ const page = yield browser.newPage();
246
+ yield page.goto(url);
247
+ yield new Promise((resolve) => setTimeout(resolve, 5000));
248
+ const content = yield page.content();
249
+ yield browser.close();
250
+ // if cache is enabled, write the response to the cache
251
+ if (!globals.getDisableCache()) {
252
+ yield writeCache(url, {}, new Response(content));
253
+ }
254
+ return new Response(content);
255
+ }
256
+ // if cache is enabled, write the response to the cache
257
+ if (!globals.getDisableCache()) {
258
+ const resToCache = preservedRes.clone();
259
+ yield writeCache(url, (args === null || args === void 0 ? void 0 : args.headers) || {}, resToCache);
260
+ }
261
+ return preservedRes;
262
+ }
263
+ });
264
+ export default makeRequest;
265
+ //# sourceMappingURL=makeReq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeReq.js","sourceRoot":"","sources":["../../src/utility/makeReq.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,qBAAqB;AACrB,MAAM,GAAG,GAAG;IACR,oIAAoI;IACpI,+HAA+H;IAC/H,wHAAwH;IACxH,qIAAqI;IACrI,wHAAwH;IACxH,8JAA8J;IAC9J,mKAAmK;IACnK,mJAAmJ;IACnJ,0JAA0J;IAC1J,kIAAkI;IAClI,4IAA4I;IAC5I,2IAA2I;IAC3I,iGAAiG;IACjG,kGAAkG;IAClG,mFAAmF;IACnF,0JAA0J;IAC1J,+IAA+I;IAC/I,oFAAoF;IACpF,oIAAoI;IACpI,wJAAwJ;IACx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O,CAAC,CAAC,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QAED,uDAAuD;QACvD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;YAC7B,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;YACxC,MAAM,UAAU,CAAC,GAAG,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,KAAI,EAAE,EAAE,UAAU,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Resolves a given path against a base URL using the URL constructor.
3
+ *
4
+ * The function handles various cases of path resolution:
5
+ * - If the base URL does not end with a '/', its last segment is treated as a "file",
6
+ * and relative paths are resolved from its "directory".
7
+ * - Examples:
8
+ * - url='https://site.com/something', path='./main.js' => 'https://site.com/main.js'
9
+ * (Base for resolution becomes 'https://site.com/')
10
+ * - url='https://site.com/something/', path='./main.js' => 'https://site.com/something/main.js'
11
+ * (Base for resolution is 'https://site.com/something/')
12
+ * - url='https://site.com/something/other', path='../main.js' => 'https://site.com/main.js'
13
+ * (Base for resolution becomes 'https://site.com/something/', then '../' navigates up)
14
+ *
15
+ * @param {string} url - The base URL to resolve against.
16
+ * @param {string} path - The path to resolve.
17
+ * @returns {Promise<string>} - A promise that resolves to the fully resolved URL as a string.
18
+ * @throws Will throw an error if the resolution fails.
19
+ */
20
+ const resolvePath = (url, path) => {
21
+ try {
22
+ // The URL constructor handles various cases of path resolution.
23
+ // If 'url' (the base URL) does not end with a '/', its last path segment
24
+ // is typically treated as a "file", and relative paths are resolved
25
+ // from the "directory" containing that "file".
26
+ // This behavior aligns with the provided examples:
27
+ // - url='https://site.com/something', path='./main.js' => 'https://site.com/main.js'
28
+ // (Base for resolution becomes 'https://site.com/')
29
+ // - url='https://site.com/something/', path='./main.js' => 'https://site.com/something/main.js'
30
+ // (Base for resolution is 'https://site.com/something/')
31
+ // - url='https://site.com/something/other', path='../main.js' => 'https://site.com/main.js'
32
+ // (Base for resolution becomes 'https://site.com/something/', then '../' navigates up)
33
+ const resolvedUrl = new URL(path, url);
34
+ return resolvedUrl.href;
35
+ }
36
+ catch (e) {
37
+ console.error(`Error resolving path "${path}" with base URL "${url}": ${e.message}`);
38
+ // Rethrowing the error to signal failure to the caller.
39
+ // Alternative error handling (e.g., returning null) can be implemented if required.
40
+ throw e;
41
+ }
42
+ };
43
+ export default resolvePath;
44
+ //# sourceMappingURL=resolvePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvePath.js","sourceRoot":"","sources":["../../src/utility/resolvePath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,IAAY,EAAE,EAAE;IAC9C,IAAI,CAAC;QACD,gEAAgE;QAChE,yEAAyE;QACzE,oEAAoE;QACpE,+CAA+C;QAC/C,mDAAmD;QACnD,qFAAqF;QACrF,sDAAsD;QACtD,gGAAgG;QAChG,2DAA2D;QAC3D,4FAA4F;QAC5F,yFAAyF;QACzF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACvC,OAAO,WAAW,CAAC,IAAI,CAAC;IAC5B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CACT,yBAAyB,IAAI,oBAAoB,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CACxE,CAAC;QACF,wDAAwD;QACxD,oFAAoF;QACpF,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,8 +1,6 @@
1
- import 'ses';
2
-
1
+ import "ses";
3
2
  // Lock down the global environment for security
4
3
  lockdown();
5
-
6
4
  /**
7
5
  * Executes a given function in a sandboxed environment.
8
6
  * @param {string} code - The code to execute.
@@ -10,16 +8,15 @@ lockdown();
10
8
  * @returns {any} The result of the function execution.
11
9
  */
12
10
  const execFunc = (code, param) => {
13
- const c = new Compartment({
14
- console,
15
- });
16
- const wrappedCode = `
11
+ const c = new Compartment({
12
+ console,
13
+ });
14
+ const wrappedCode = `
17
15
  (${code})
18
16
  `;
19
- const func = c.evaluate(wrappedCode);
20
- const output = func(param);
21
-
22
- return output;
17
+ const func = c.evaluate(wrappedCode);
18
+ const output = func(param);
19
+ return output;
23
20
  };
24
-
25
- export default execFunc;
21
+ export default execFunc;
22
+ //# sourceMappingURL=runSandboxed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runSandboxed.js","sourceRoot":"","sources":["../../src/utility/runSandboxed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC;AAEb,gDAAgD;AAChD,QAAQ,EAAE,CAAC;AAEX;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IAC7B,MAAM,CAAC,GAAG,IAAI,WAAW,CAAC;QACtB,OAAO;KACV,CAAC,CAAC;IACH,MAAM,WAAW,GAAG;OACjB,IAAI;GACR,CAAC;IACA,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAE3B,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -7,16 +7,14 @@
7
7
  * - directory: The directory path, excluding the filename if present (e.g., "/static/js").
8
8
  */
9
9
  const getURLDirectory = (url) => {
10
- const u = new URL(url);
11
- const pathname = u.pathname;
12
-
13
- // Remove filename (last part after final /) if it ends with .js or any file extension
14
- const dir = pathname.replace(/\/[^\/?#]+\.[^\/?#]+$/, "");
15
-
16
- return {
17
- host: u.host, // e.g., "vercel.com" or "localhost:3000"
18
- directory: dir, // e.g., "/static/js"
19
- };
10
+ const u = new URL(url);
11
+ const pathname = u.pathname;
12
+ // Remove filename (last part after final /) if it ends with .js or any file extension
13
+ const dir = pathname.replace(/\/[^\/?#]+\.[^\/?#]+$/, "");
14
+ return {
15
+ host: u.host, // e.g., "vercel.com" or "localhost:3000"
16
+ directory: dir, // e.g., "/static/js"
17
+ };
20
18
  };
21
-
22
19
  export { getURLDirectory };
20
+ //# sourceMappingURL=urlUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../../src/utility/urlUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,EAAE;IAC5B,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;IAE5B,sFAAsF;IACtF,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAE1D,OAAO;QACH,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,yCAAyC;QACvD,SAAS,EAAE,GAAG,EAAE,qBAAqB;KACxC,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
package/docs/CNAME ADDED
@@ -0,0 +1 @@
1
+ js-recon.io
package/docs/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # js-recon Documentation
2
+
3
+ Welcome to the official documentation for `js-recon`, a powerful tool for JavaScript reconnaissance. This documentation provides a comprehensive overview of all available commands and their functionalities.
4
+
5
+ ## Available Commands
6
+
7
+ `js-recon` offers the following commands to help you analyze and extract valuable information from JavaScript files:
8
+
9
+ - **[Lazyload](./lazyload.md):** Download all Lazy-Loaded JavaScript files from a target URL or a list of URLs.
10
+ - **[Endpoints](./endpoints.md):** Extract client-side from JavaScript files.
11
+ - **[Strings](./strings.md):** Extract strings, URLs, and secrets from JavaScript files.
12
+ - **[API Gateway](./api-gateway.md):** Configure and manage AWS API Gateway for IP rotation.
13
+ - **[Map](./map.md):** Map and analyze functions within JavaScript files. For Next.js, an [interactive mode](./interactive-mode.md) is also available.
14
+ - **[Run](./run.md):** Run essential modules automatically.
15
+
16
+ Select a command from the list above to view its detailed documentation, including all available options and practical examples.
17
+
18
+ ## Example Scenario
19
+
20
+ An example scenario is demonstrated on [this](./example-scenario.md) page. The example assumes the app is using Next.JS.
@@ -0,0 +1,68 @@
1
+ # API Gateway Command
2
+
3
+ The `api-gateway` command is used to configure and manage AWS API Gateway for the purpose of IP address rotation. This configuration is written to `.api_gateway_config.json` by default. This allows you to make requests from a pool of different IP addresses, which can be useful for avoiding rate limiting.
4
+
5
+ Note that the only module which makes HTTP request is `lazyload`. So, the configuration generated by this module will only work there.
6
+
7
+ ## Usage
8
+
9
+ ```bash
10
+ js-recon api-gateway [options]
11
+ ```
12
+
13
+ ## Options
14
+
15
+ | Option | Alias | Description | Default | Required |
16
+ | --------------------------- | ----- | --------------------------------------------------------------------- | -------------------------- | -------- |
17
+ | `--init` | `-i` | Initialize the config file and create a new API Gateway. | `false` | No |
18
+ | `--destroy <id>` | `-d` | Destroy the API with the given ID. | | No |
19
+ | `--destroy-all` | | Destroy all APIs created by this tool in all regions. | `false` | No |
20
+ | `--region <region>` | `-r` | AWS region to create the API in. | random region | No |
21
+ | `--access-key <access-key>` | `-a` | AWS access key. Uses `AWS_ACCESS_KEY_ID` env var if not provided. | | No |
22
+ | `--secret-key <secret-key>` | `-s` | AWS secret key. Uses `AWS_SECRET_ACCESS_KEY` env var if not provided. | | No |
23
+ | `--config <config>` | `-c` | Name of the config file (if different from the default) | `.api_gateway_config.json` | No |
24
+ | `--list` | `-l` | List all APIs created by this tool. | `false` | No |
25
+ | `--feasibility` | | Check the feasibility of using API Gateway for a target. | `false` | No |
26
+ | `--feasibility-url <url>` | | URL to check the feasibility of. | | No |
27
+
28
+ ## Examples
29
+
30
+ ### Initialize API Gateway
31
+
32
+ Create a new API Gateway and save its configuration:
33
+
34
+ ```bash
35
+ js-recon api-gateway --init
36
+ ```
37
+
38
+ ### List Created APIs
39
+
40
+ List all the API Gateways that have been created by this tool:
41
+
42
+ ```bash
43
+ js-recon api-gateway --list
44
+ ```
45
+
46
+ ### Destroy an API
47
+
48
+ Destroy a specific API Gateway using its ID:
49
+
50
+ ```bash
51
+ js-recon api-gateway --destroy <api-id>
52
+ ```
53
+
54
+ ### Destroy All APIs
55
+
56
+ Destroy all APIs created by this tool in all regions:
57
+
58
+ ```bash
59
+ js-recon api-gateway --destroy-all
60
+ ```
61
+
62
+ ### Check Feasibility
63
+
64
+ Check if a target URL returns a response that contains known traces of firewall. If the result says firewall detected, then it means that the target has blocked the IP addresses originating from the AWS infrastructure.
65
+
66
+ ```bash
67
+ js-recon api-gateway --feasibility --feasibility-url https://example.com
68
+ ```
@@ -0,0 +1,49 @@
1
+ # Endpoints Command
2
+
3
+ The `endpoints` command is used to extract client-side endpoints from a directory of JavaScript files. It identifies potential client-side paths and organizes them for further analysis.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ js-recon endpoints [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ | Option | Alias | Description | Default | Required |
14
+ | --------------------------------------- | ----- | ----------------------------------------------------------------------------------- | ----------- | -------- |
15
+ | `--url <url>` | `-u` | Target Base URL (will be used to resolve relative paths). | | Yes |
16
+ | `--directory <directory>` | `-d` | Directory containing JS files. | | Yes |
17
+ | `--output <filename>` | `-o` | Output filename (without file extension). | `endpoints` | No |
18
+ | `--output-format <format>` | | Output format for the results (comma-separated; available: `md`). | `md` | No |
19
+ | `--tech <tech>` | `-t` | Technology used in the JS files (run with `-l`/`--list` to see available options). | | Yes |
20
+ | `--list` | `-l` | List available technologies. | `false` | No |
21
+ | `--subsequent-requests-dir <directory>` | | Directory containing subsequent requests. **Required for Next.JS (`--tech next`)**. | | No |
22
+
23
+ ## Examples
24
+
25
+ ### Basic Usage
26
+
27
+ Extract endpoints from a directory of JS files, specifying the technology and target URL:
28
+
29
+ ```bash
30
+ js-recon endpoints -d /path/to/js-files -t <technology> -u https://example.com
31
+ ```
32
+
33
+ ### Specify Output File
34
+
35
+ Extract endpoints and save them to a custom file named `api_paths.md`:
36
+
37
+ ```bash
38
+ js-recon endpoints -d /path/to/js-files -t <technology> -u https://example.com -o api_paths
39
+ ```
40
+
41
+ ### Next.JS Usage
42
+
43
+ When analyzing a Next.JS application, you must specify the technology as `next` and provide the directory containing subsequent requests. These requests are typically captured during the `lazyload` process. Refer to the [example scenario](./example-scenario.md#subseqent-requests) to know detailed guide on this.
44
+
45
+ ```bash
46
+ js-recon endpoints -d /path/to/js-files -t next -u https://example.com --subsequent-requests-dir /path/to/js-files/___subsequent_requests
47
+ ```
48
+
49
+ This command will analyze the JavaScript files and the subsequent requests to extract a comprehensive list of client-side paths and API endpoints specific to the Next.JS framework.