Advertisement
xosski

Untitled

Apr 20th, 2025
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. Full release can be found here : https://github.com/xosski/Wraith-Halo
  2. // RedactedRedTeamToolkit.js
  3. // A limited-scope red team simulation module for conversation state, response testing, and object resolution.
  4. // All dangerous automation and payload mechanisms have been removed for ethical and controlled evaluation.
  5.  
  6. const RedactedToolkit = (() => {
  7. const log = (...args) => console.log("%c[RedactedToolkit]", "color: crimson; font-weight: bold;", ...args);
  8.  
  9. // --- Messaging State Detection ---
  10. function getConversationIdFromPath(path) {
  11. const match = path.match(/conversation\/(new|trigger-screen|\w+)/);
  12. if (!match) return null;
  13. const id = match[1];
  14. return (id === "new" || id === "trigger-screen") ? null : id;
  15. }
  16.  
  17. function isActiveConversation(path) {
  18. return !!getConversationIdFromPath(path);
  19. }
  20.  
  21. function getScreenState(path) {
  22. if (/conversation\/new/.test(path)) return "new-conversation";
  23. if (isActiveConversation(path)) return "conversation";
  24. if (/\/conversations$/.test(path)) return "conversations";
  25. return "home-screen";
  26. }
  27.  
  28. // --- URL Param Extraction ---
  29. function extractParamFromString(input, key) {
  30. if (!input) return null;
  31. const match = input.toString().match(new RegExp(`${key}=(\\d+)`, "i"));
  32. return match ? match[1] : null;
  33. }
  34.  
  35. // --- Storage Sandbox ---
  36. const StorageSandbox = {
  37. getLocal: key => localStorage.getItem(`intercom.${key}`) || null,
  38. setLocal: (key, value) => localStorage.setItem(`intercom.${key}`, value.toString()),
  39. getSession: key => sessionStorage.getItem(`intercom.${key}`) || null,
  40. setSession: (key, value) => sessionStorage.setItem(`intercom.${key}`, value.toString()),
  41. };
  42.  
  43. // --- Response Validator (Neutralized) ---
  44. function validateSurveyInput(value, fieldConfig) {
  45. const { required, validation } = fieldConfig;
  46. const trimmed = typeof value === 'string' ? value.trim() : value;
  47.  
  48. if (required && !trimmed) return { failedValidation: true, validationError: "required" };
  49.  
  50. if (trimmed && validation?.type) {
  51. switch (validation.type) {
  52. case "email": return /\S+@\S+\.\S+/.test(trimmed);
  53. case "number": return !isNaN(trimmed);
  54. case "phone": return /\d{7,}/.test(trimmed);
  55. default: return true;
  56. }
  57. }
  58. return { failedValidation: false };
  59. }
  60.  
  61. // --- Object Label & Navigation Helper ---
  62. function resolveObjectLabel(obj) {
  63. if (!obj) return null;
  64. if (typeof obj === "object" && obj.label) return obj.label.toString();
  65. if (Array.isArray(obj)) return obj.join(", ");
  66. return obj.toString();
  67. }
  68.  
  69. function getTicketURL(id, submitted = false) {
  70. return `/tickets/${id}` + (submitted ? `?submitted=true` : "");
  71. }
  72.  
  73. function getTicketCreationURL(objId, conversationId) {
  74. return `/tickets/create/${objId}` + (conversationId ? `?conversationId=${conversationId}` : "");
  75. }
  76.  
  77. return {
  78. getConversationIdFromPath,
  79. getScreenState,
  80. extractParamFromString,
  81. validateSurveyInput,
  82. StorageSandbox,
  83. resolveObjectLabel,
  84. getTicketURL,
  85. getTicketCreationURL
  86. };
  87. })();
  88.  
  89. // Example Use (non-invasive)
  90. console.log(RedactedToolkit.getScreenState("/org123/conversation/new"));
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement