@feardread/fear 1.0.1

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 (99) hide show
  1. package/FEAR.js +459 -0
  2. package/FEARServer.js +280 -0
  3. package/controllers/agent.js +438 -0
  4. package/controllers/auth/index.js +345 -0
  5. package/controllers/auth/token.js +50 -0
  6. package/controllers/blog.js +105 -0
  7. package/controllers/brand.js +10 -0
  8. package/controllers/cart.js +425 -0
  9. package/controllers/category.js +9 -0
  10. package/controllers/coupon.js +63 -0
  11. package/controllers/crud/crud.js +508 -0
  12. package/controllers/crud/index.js +36 -0
  13. package/controllers/email.js +34 -0
  14. package/controllers/enquiry.js +65 -0
  15. package/controllers/events.js +9 -0
  16. package/controllers/order.js +125 -0
  17. package/controllers/payment.js +31 -0
  18. package/controllers/product.js +147 -0
  19. package/controllers/review.js +247 -0
  20. package/controllers/tag.js +10 -0
  21. package/controllers/task.js +10 -0
  22. package/controllers/upload.js +41 -0
  23. package/controllers/user.js +401 -0
  24. package/index.js +7 -0
  25. package/libs/agent/index.js +561 -0
  26. package/libs/agent/modules/ai/ai.js +285 -0
  27. package/libs/agent/modules/ai/chat.js +518 -0
  28. package/libs/agent/modules/ai/config.js +688 -0
  29. package/libs/agent/modules/ai/operations.js +787 -0
  30. package/libs/agent/modules/analyze/api.js +546 -0
  31. package/libs/agent/modules/analyze/dorks.js +395 -0
  32. package/libs/agent/modules/ccard/README.md +454 -0
  33. package/libs/agent/modules/ccard/audit.js +479 -0
  34. package/libs/agent/modules/ccard/checker.js +674 -0
  35. package/libs/agent/modules/ccard/payment-processors.json +16 -0
  36. package/libs/agent/modules/ccard/validator.js +629 -0
  37. package/libs/agent/modules/code/analyzer.js +303 -0
  38. package/libs/agent/modules/code/jquery.js +1093 -0
  39. package/libs/agent/modules/code/react.js +1536 -0
  40. package/libs/agent/modules/code/refactor.js +499 -0
  41. package/libs/agent/modules/crypto/exchange.js +564 -0
  42. package/libs/agent/modules/net/proxy.js +409 -0
  43. package/libs/agent/modules/security/cve.js +442 -0
  44. package/libs/agent/modules/security/monitor.js +360 -0
  45. package/libs/agent/modules/security/scanner.js +300 -0
  46. package/libs/agent/modules/security/vulnerability.js +506 -0
  47. package/libs/agent/modules/security/web.js +465 -0
  48. package/libs/agent/modules/utils/browser.js +492 -0
  49. package/libs/agent/modules/utils/colorizer.js +285 -0
  50. package/libs/agent/modules/utils/manager.js +478 -0
  51. package/libs/cloud/index.js +228 -0
  52. package/libs/config/db.js +21 -0
  53. package/libs/config/validator.js +82 -0
  54. package/libs/db/index.js +318 -0
  55. package/libs/emailer/imap.js +126 -0
  56. package/libs/emailer/info.js +41 -0
  57. package/libs/emailer/smtp.js +77 -0
  58. package/libs/handler/async.js +3 -0
  59. package/libs/handler/error.js +66 -0
  60. package/libs/handler/index.js +161 -0
  61. package/libs/logger/index.js +49 -0
  62. package/libs/logger/morgan.js +24 -0
  63. package/libs/passport/passport.js +109 -0
  64. package/libs/search/api.js +384 -0
  65. package/libs/search/features.js +219 -0
  66. package/libs/search/service.js +64 -0
  67. package/libs/swagger/config.js +18 -0
  68. package/libs/swagger/index.js +35 -0
  69. package/libs/validator/index.js +254 -0
  70. package/models/blog.js +31 -0
  71. package/models/brand.js +12 -0
  72. package/models/cart.js +14 -0
  73. package/models/category.js +11 -0
  74. package/models/coupon.js +9 -0
  75. package/models/customer.js +0 -0
  76. package/models/enquiry.js +29 -0
  77. package/models/events.js +13 -0
  78. package/models/order.js +94 -0
  79. package/models/product.js +32 -0
  80. package/models/review.js +14 -0
  81. package/models/tag.js +10 -0
  82. package/models/task.js +11 -0
  83. package/models/user.js +68 -0
  84. package/package.json +12 -0
  85. package/routes/agent.js +615 -0
  86. package/routes/auth.js +13 -0
  87. package/routes/blog.js +19 -0
  88. package/routes/brand.js +15 -0
  89. package/routes/cart.js +105 -0
  90. package/routes/category.js +16 -0
  91. package/routes/coupon.js +15 -0
  92. package/routes/enquiry.js +14 -0
  93. package/routes/events.js +16 -0
  94. package/routes/mail.js +170 -0
  95. package/routes/order.js +19 -0
  96. package/routes/product.js +22 -0
  97. package/routes/review.js +11 -0
  98. package/routes/task.js +12 -0
  99. package/routes/user.js +17 -0
@@ -0,0 +1,479 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const colorizer = require('../utils/colorizer');
4
+
5
+ /**
6
+ * Payment Data Security Auditor
7
+ *
8
+ * PURPOSE: Security auditing and compliance testing
9
+ * - Scans JSON files for exposed payment card data
10
+ * - Validates format of card numbers and routing numbers
11
+ * - Generates security reports for PCI DSS compliance
12
+ * - Educational tool for understanding payment data structures
13
+ *
14
+ * DISCLAIMER: For legitimate security testing only.
15
+ * Do NOT use with stolen or unauthorized payment data.
16
+ */
17
+
18
+ class PaymentDataAuditor {
19
+ constructor() {
20
+ this.name = 'Payment Data Security Auditor';
21
+ this.version = '1.0.0';
22
+
23
+ // Official test card numbers for reference
24
+ this.testCards = {
25
+ visa: ['4242424242424242', '4000056655665556'],
26
+ mastercard: ['5555555555554444', '2223003122003222'],
27
+ amex: ['378282246310005', '371449635398431'],
28
+ discover: ['6011111111111117', '6011000990139424'],
29
+ dinersclub: ['3056930009020004', '36227206271667'],
30
+ jcb: ['3566002020360505', '3566111111111113']
31
+ };
32
+
33
+ // BIN ranges for card identification (first 6 digits)
34
+ this.binRanges = {
35
+ visa: /^4[0-9]{5}/,
36
+ mastercard: /^(5[1-5][0-9]{4}|222[1-9][0-9]{2}|22[3-9][0-9]{3}|2[3-6][0-9]{4}|27[01][0-9]{3}|2720[0-9]{2})/,
37
+ amex: /^3[47][0-9]{4}/,
38
+ discover: /^6(?:011|5[0-9]{2})[0-9]{2}/,
39
+ dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{3}/,
40
+ jcb: /^(?:2131|1800|35[0-9]{2})[0-9]{2}/,
41
+ unionpay: /^62[0-9]{4}/
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Luhn Algorithm - validates card number checksum
47
+ */
48
+ validateLuhn(cardNumber) {
49
+ const digits = cardNumber.replace(/\D/g, '');
50
+
51
+ if (digits.length < 13 || digits.length > 19) {
52
+ return false;
53
+ }
54
+
55
+ let sum = 0;
56
+ let isEven = false;
57
+
58
+ // Loop through digits from right to left
59
+ for (let i = digits.length - 1; i >= 0; i--) {
60
+ let digit = parseInt(digits[i], 10);
61
+
62
+ if (isEven) {
63
+ digit *= 2;
64
+ if (digit > 9) {
65
+ digit -= 9;
66
+ }
67
+ }
68
+
69
+ sum += digit;
70
+ isEven = !isEven;
71
+ }
72
+
73
+ return sum % 10 === 0;
74
+ }
75
+
76
+ /**
77
+ * Identify card type from BIN (Bank Identification Number)
78
+ */
79
+ identifyCardType(cardNumber) {
80
+ const digits = cardNumber.replace(/\D/g, '');
81
+ const bin = digits.substring(0, 6);
82
+
83
+ for (const [type, pattern] of Object.entries(this.binRanges)) {
84
+ if (pattern.test(bin)) {
85
+ return type.toUpperCase();
86
+ }
87
+ }
88
+
89
+ return 'UNKNOWN';
90
+ }
91
+
92
+ /**
93
+ * Validate ABA Routing Number (US Bank Routing)
94
+ */
95
+ validateRoutingNumber(routing) {
96
+ const digits = routing.replace(/\D/g, '');
97
+
98
+ if (digits.length !== 9) {
99
+ return false;
100
+ }
101
+
102
+ // ABA routing number checksum algorithm
103
+ const weights = [3, 7, 1, 3, 7, 1, 3, 7, 1];
104
+ let sum = 0;
105
+
106
+ for (let i = 0; i < 9; i++) {
107
+ sum += parseInt(digits[i], 10) * weights[i];
108
+ }
109
+
110
+ return sum % 10 === 0;
111
+ }
112
+
113
+ /**
114
+ * Check if a card is a known test card
115
+ */
116
+ isTestCard(cardNumber) {
117
+ const clean = cardNumber.replace(/\D/g, '');
118
+
119
+ for (const testCardList of Object.values(this.testCards)) {
120
+ if (testCardList.includes(clean)) {
121
+ return true;
122
+ }
123
+ }
124
+
125
+ return false;
126
+ }
127
+
128
+ /**
129
+ * Analyze JSON file for payment data exposure
130
+ */
131
+ async analyzeFile(args) {
132
+ if (!args || args.length === 0) {
133
+ console.log(colorizer.error('Usage: analyze-payment-data <json-file>'));
134
+ console.log(colorizer.info('Example: analyze-payment-data data.json'));
135
+ return;
136
+ }
137
+
138
+ const filePath = args[0];
139
+
140
+ if (!fs.existsSync(filePath)) {
141
+ console.log(colorizer.error('File not found: ' + filePath));
142
+ return;
143
+ }
144
+
145
+ try {
146
+ console.log(colorizer.section('Payment Data Security Audit'));
147
+ console.log(colorizer.cyan('File: ') + filePath);
148
+ console.log();
149
+
150
+ const fileContent = fs.readFileSync(filePath, 'utf8');
151
+ const data = JSON.parse(fileContent);
152
+
153
+ const results = this.scanObject(data);
154
+
155
+ this.displayResults(results);
156
+ this.displayRecommendations(results);
157
+
158
+ } catch (err) {
159
+ console.log(colorizer.error('Error analyzing file: ' + err.message));
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Recursively scan object for payment data
165
+ */
166
+ scanObject(obj, path = '', results = null) {
167
+ if (!results) {
168
+ results = {
169
+ cardsFound: [],
170
+ routingFound: [],
171
+ accountsFound: [],
172
+ exposedPaths: [],
173
+ securityIssues: []
174
+ };
175
+ }
176
+
177
+ if (Array.isArray(obj)) {
178
+ obj.forEach((item, index) => {
179
+ this.scanObject(item, `${path}[${index}]`, results);
180
+ });
181
+ } else if (typeof obj === 'object' && obj !== null) {
182
+ for (const [key, value] of Object.entries(obj)) {
183
+ const currentPath = path ? `${path}.${key}` : key;
184
+
185
+ // Check if this might be payment data based on key names
186
+ const keyLower = key.toLowerCase();
187
+ const isSensitiveKey =
188
+ keyLower.includes('card') ||
189
+ keyLower.includes('credit') ||
190
+ keyLower.includes('routing') ||
191
+ keyLower.includes('account') ||
192
+ keyLower.includes('payment') ||
193
+ keyLower.includes('bank');
194
+
195
+ if (typeof value === 'string' || typeof value === 'number') {
196
+ const stringValue = String(value).replace(/\D/g, '');
197
+
198
+ // Check for card numbers (13-19 digits)
199
+ if (stringValue.length >= 13 && stringValue.length <= 19) {
200
+ if (this.validateLuhn(stringValue)) {
201
+ const cardType = this.identifyCardType(stringValue);
202
+ const isTest = this.isTestCard(stringValue);
203
+
204
+ results.cardsFound.push({
205
+ path: currentPath,
206
+ type: cardType,
207
+ masked: this.maskCard(stringValue),
208
+ isTestCard: isTest,
209
+ length: stringValue.length
210
+ });
211
+
212
+ if (!isTest) {
213
+ results.securityIssues.push({
214
+ severity: 'CRITICAL',
215
+ type: 'EXPOSED_CARD',
216
+ path: currentPath,
217
+ message: 'Real credit card data detected'
218
+ });
219
+ }
220
+
221
+ results.exposedPaths.push(currentPath);
222
+ }
223
+ }
224
+
225
+ // Check for routing numbers (9 digits)
226
+ if (stringValue.length === 9 && this.validateRoutingNumber(stringValue)) {
227
+ results.routingFound.push({
228
+ path: currentPath,
229
+ masked: this.maskRouting(stringValue)
230
+ });
231
+
232
+ results.securityIssues.push({
233
+ severity: 'HIGH',
234
+ type: 'EXPOSED_ROUTING',
235
+ path: currentPath,
236
+ message: 'Bank routing number detected'
237
+ });
238
+
239
+ results.exposedPaths.push(currentPath);
240
+ }
241
+
242
+ // Check for bank account numbers (typically 8-17 digits)
243
+ if (isSensitiveKey && stringValue.length >= 8 && stringValue.length <= 17) {
244
+ if (!this.validateLuhn(stringValue)) { // Not a card number
245
+ results.accountsFound.push({
246
+ path: currentPath,
247
+ masked: this.maskAccount(stringValue),
248
+ length: stringValue.length
249
+ });
250
+
251
+ results.securityIssues.push({
252
+ severity: 'HIGH',
253
+ type: 'EXPOSED_ACCOUNT',
254
+ path: currentPath,
255
+ message: 'Potential bank account number detected'
256
+ });
257
+
258
+ results.exposedPaths.push(currentPath);
259
+ }
260
+ }
261
+ } else if (typeof value === 'object') {
262
+ this.scanObject(value, currentPath, results);
263
+ }
264
+ }
265
+ }
266
+
267
+ return results;
268
+ }
269
+
270
+ /**
271
+ * Display audit results
272
+ */
273
+ displayResults(results) {
274
+ console.log(colorizer.section('AUDIT RESULTS'));
275
+ console.log();
276
+
277
+ // Credit Cards
278
+ if (results.cardsFound.length > 0) {
279
+ console.log(colorizer.warning('⚠️ Credit Cards Detected: ' + results.cardsFound.length));
280
+ results.cardsFound.forEach((card, i) => {
281
+ const status = card.isTestCard ?
282
+ colorizer.green('[TEST CARD]') :
283
+ colorizer.red('[REAL CARD - SECURITY RISK]');
284
+
285
+ console.log(colorizer.dim(` ${i + 1}. ${card.path}`));
286
+ console.log(colorizer.cyan(' Type: ') + card.type + ' ' + status);
287
+ console.log(colorizer.cyan(' Number: ') + card.masked);
288
+ console.log();
289
+ });
290
+ } else {
291
+ console.log(colorizer.green('✓ No credit card numbers detected'));
292
+ console.log();
293
+ }
294
+
295
+ // Routing Numbers
296
+ if (results.routingFound.length > 0) {
297
+ console.log(colorizer.warning('⚠️ Routing Numbers Detected: ' + results.routingFound.length));
298
+ results.routingFound.forEach((routing, i) => {
299
+ console.log(colorizer.dim(` ${i + 1}. ${routing.path}`));
300
+ console.log(colorizer.cyan(' Number: ') + routing.masked);
301
+ console.log();
302
+ });
303
+ } else {
304
+ console.log(colorizer.green('✓ No routing numbers detected'));
305
+ console.log();
306
+ }
307
+
308
+ // Account Numbers
309
+ if (results.accountsFound.length > 0) {
310
+ console.log(colorizer.warning('⚠️ Account Numbers Detected: ' + results.accountsFound.length));
311
+ results.accountsFound.forEach((account, i) => {
312
+ console.log(colorizer.dim(` ${i + 1}. ${account.path}`));
313
+ console.log(colorizer.cyan(' Number: ') + account.masked);
314
+ console.log();
315
+ });
316
+ } else {
317
+ console.log(colorizer.green('✓ No account numbers detected'));
318
+ console.log();
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Display security recommendations
324
+ */
325
+ displayRecommendations(results) {
326
+ if (results.securityIssues.length === 0) {
327
+ console.log(colorizer.section('SECURITY STATUS'));
328
+ console.log(colorizer.green('✓ No sensitive payment data detected'));
329
+ console.log(colorizer.green('✓ File appears to be PCI DSS compliant'));
330
+ console.log();
331
+ return;
332
+ }
333
+
334
+ console.log(colorizer.section('SECURITY ISSUES FOUND'));
335
+ console.log();
336
+
337
+ const critical = results.securityIssues.filter(i => i.severity === 'CRITICAL');
338
+ const high = results.securityIssues.filter(i => i.severity === 'HIGH');
339
+
340
+ if (critical.length > 0) {
341
+ console.log(colorizer.red('🚨 CRITICAL ISSUES: ' + critical.length));
342
+ critical.forEach((issue, i) => {
343
+ console.log(colorizer.red(` ${i + 1}. ${issue.message}`));
344
+ console.log(colorizer.dim(` Location: ${issue.path}`));
345
+ });
346
+ console.log();
347
+ }
348
+
349
+ if (high.length > 0) {
350
+ console.log(colorizer.warning('⚠️ HIGH PRIORITY ISSUES: ' + high.length));
351
+ high.forEach((issue, i) => {
352
+ console.log(colorizer.warning(` ${i + 1}. ${issue.message}`));
353
+ console.log(colorizer.dim(` Location: ${issue.path}`));
354
+ });
355
+ console.log();
356
+ }
357
+
358
+ console.log(colorizer.section('RECOMMENDATIONS'));
359
+ console.log(colorizer.cyan(' 1. Remove all real payment data from this file immediately'));
360
+ console.log(colorizer.cyan(' 2. Use tokenization or encryption for sensitive data'));
361
+ console.log(colorizer.cyan(' 3. Replace real data with official test cards (see show-test-cards)'));
362
+ console.log(colorizer.cyan(' 4. Review PCI DSS compliance requirements'));
363
+ console.log(colorizer.cyan(' 5. Implement proper data masking in logs and databases'));
364
+ console.log();
365
+
366
+ console.log(colorizer.info('For PCI DSS compliance, visit: https://www.pcisecuritystandards.org'));
367
+ console.log();
368
+ }
369
+
370
+ /**
371
+ * Mask credit card number
372
+ */
373
+ maskCard(cardNumber) {
374
+ if (cardNumber.length <= 4) return cardNumber;
375
+ const last4 = cardNumber.slice(-4);
376
+ const masked = '*'.repeat(cardNumber.length - 4);
377
+ return masked + last4;
378
+ }
379
+
380
+ /**
381
+ * Mask routing number
382
+ */
383
+ maskRouting(routing) {
384
+ if (routing.length !== 9) return routing;
385
+ return '*****' + routing.slice(-4);
386
+ }
387
+
388
+ /**
389
+ * Mask account number
390
+ */
391
+ maskAccount(account) {
392
+ if (account.length <= 4) return account;
393
+ return '****' + account.slice(-4);
394
+ }
395
+
396
+ /**
397
+ * Show official test cards
398
+ */
399
+ showTestCards() {
400
+ console.log(colorizer.section('Official Test Card Numbers'));
401
+ console.log(colorizer.info('Use these for development and testing'));
402
+ console.log();
403
+
404
+ Object.entries(this.testCards).forEach(([type, cards]) => {
405
+ console.log(colorizer.cyan(type.toUpperCase() + ':'));
406
+ cards.forEach(card => {
407
+ const formatted = card.match(/.{1,4}/g).join(' ');
408
+ console.log(colorizer.dim(' ' + formatted));
409
+ });
410
+ console.log();
411
+ });
412
+
413
+ console.log(colorizer.info('Sources:'));
414
+ console.log(colorizer.dim(' • Stripe: https://stripe.com/docs/testing'));
415
+ console.log(colorizer.dim(' • PayPal: https://developer.paypal.com/tools/sandbox/card-testing/'));
416
+ console.log();
417
+ }
418
+
419
+ /**
420
+ * Explain Luhn algorithm
421
+ */
422
+ explainAlgorithm() {
423
+ console.log(colorizer.section('Card Validation Algorithms'));
424
+ console.log();
425
+
426
+ console.log(colorizer.cyan('LUHN ALGORITHM (Mod 10):'));
427
+ console.log(colorizer.dim('Used to validate credit card numbers'));
428
+ console.log();
429
+ console.log(colorizer.dim('Steps:'));
430
+ console.log(colorizer.dim(' 1. Start from the rightmost digit'));
431
+ console.log(colorizer.dim(' 2. Double every second digit'));
432
+ console.log(colorizer.dim(' 3. If doubled value > 9, subtract 9'));
433
+ console.log(colorizer.dim(' 4. Sum all digits'));
434
+ console.log(colorizer.dim(' 5. If sum % 10 = 0, card is valid'));
435
+ console.log();
436
+
437
+ console.log(colorizer.cyan('Example: 4242 4242 4242 4242'));
438
+ console.log(colorizer.dim(' 4 2 4 2 4 2 4 2 4 2 4 2 4 2 4 2'));
439
+ console.log(colorizer.dim(' × ✓ × ✓ × ✓ × ✓ × ✓ × ✓ × ✓ × ✓'));
440
+ console.log(colorizer.dim(' 8 2 8 2 8 2 8 2 8 2 8 2 8 2 8 2 = 80'));
441
+ console.log(colorizer.dim(' 80 % 10 = 0 ✓ VALID'));
442
+ console.log();
443
+
444
+ console.log(colorizer.cyan('ABA ROUTING NUMBER VALIDATION:'));
445
+ console.log(colorizer.dim('Used for US bank routing numbers'));
446
+ console.log();
447
+ console.log(colorizer.dim('Steps:'));
448
+ console.log(colorizer.dim(' 1. Must be exactly 9 digits'));
449
+ console.log(colorizer.dim(' 2. Multiply digits by weights [3,7,1,3,7,1,3,7,1]'));
450
+ console.log(colorizer.dim(' 3. Sum all products'));
451
+ console.log(colorizer.dim(' 4. If sum % 10 = 0, routing number is valid'));
452
+ console.log();
453
+ }
454
+
455
+ /**
456
+ * Show help
457
+ */
458
+ showHelp() {
459
+ console.log(colorizer.section('Payment Data Security Auditor - Help'));
460
+ console.log();
461
+ console.log(colorizer.cyan('Commands:'));
462
+ console.log(colorizer.bullet('analyze-payment-data <file> - Scan JSON file for payment data'));
463
+ console.log(colorizer.bullet('show-test-cards - Show official test card numbers'));
464
+ console.log(colorizer.bullet('explain-algorithm - Explain validation algorithms'));
465
+ console.log();
466
+ console.log(colorizer.cyan('Purpose:'));
467
+ console.log(colorizer.dim(' • Security auditing and PCI DSS compliance testing'));
468
+ console.log(colorizer.dim(' • Detect exposed payment data in logs/files'));
469
+ console.log(colorizer.dim(' • Educational tool for payment data structures'));
470
+ console.log();
471
+ console.log(colorizer.warning('⚠️ IMPORTANT:'));
472
+ console.log(colorizer.dim(' • For legitimate security testing only'));
473
+ console.log(colorizer.dim(' • Do NOT use with stolen or unauthorized data'));
474
+ console.log(colorizer.dim(' • Always use official test cards for development'));
475
+ console.log();
476
+ }
477
+ }
478
+
479
+ module.exports = PaymentDataAuditor;