mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 16:26:16 -04:00
Magic operation now displays an ordered table of the most likely decodings.
This commit is contained in:
parent
28abd00d82
commit
6947d2a7f3
5 changed files with 266 additions and 31 deletions
|
@ -96,12 +96,12 @@ class Magic {
|
|||
/**
|
||||
* Speculatively executes matching operations, recording metadata of each result.
|
||||
*
|
||||
* @param {number} [depth=1] - How many levels to try to execute
|
||||
* @param {number} [depth=0] - How many levels to try to execute
|
||||
* @param {Object[]} [recipeConfig=[]] - The recipe configuration up to this point
|
||||
* @returns {Object[]} A sorted list of the recipes most likely to result in correct decoding
|
||||
*/
|
||||
async speculativeExecution(depth = 1, recipeConfig = []) {
|
||||
if (depth === 0) return [];
|
||||
async speculativeExecution(depth = 0, recipeConfig = []) {
|
||||
if (depth < 0) return [];
|
||||
|
||||
let results = [];
|
||||
|
||||
|
@ -123,12 +123,16 @@ class Magic {
|
|||
opConfig = {
|
||||
op: op.op,
|
||||
args: op.args
|
||||
},
|
||||
recipe = new Recipe([opConfig]);
|
||||
};
|
||||
|
||||
if (ENVIRONMENT_IS_WORKER()) self.loadRequiredModules([opConfig]);
|
||||
|
||||
const recipe = new Recipe([opConfig]);
|
||||
await recipe.execute(dish, 0);
|
||||
|
||||
const magic = new Magic(dish.get(Dish.ARRAY_BUFFER)),
|
||||
speculativeResults = await magic.speculativeExecution(depth-1, [...recipeConfig, opConfig]);
|
||||
|
||||
results = results.concat(speculativeResults);
|
||||
}));
|
||||
|
||||
|
@ -215,6 +219,201 @@ class Magic {
|
|||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates an ISO 639-1 code to a full language name.
|
||||
*
|
||||
* @param {string} code - The two letter ISO 639-1 code
|
||||
* @returns {string} The full name of the languge
|
||||
*/
|
||||
static codeToLanguage(code) {
|
||||
return {
|
||||
"aa": "Afar",
|
||||
"ab": "Abkhazian",
|
||||
"ae": "Avestan",
|
||||
"af": "Afrikaans",
|
||||
"ak": "Akan",
|
||||
"am": "Amharic",
|
||||
"an": "Aragonese",
|
||||
"ar": "Arabic",
|
||||
"as": "Assamese",
|
||||
"av": "Avaric",
|
||||
"ay": "Aymara",
|
||||
"az": "Azerbaijani",
|
||||
"ba": "Bashkir",
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"bh": "Bihari languages",
|
||||
"bi": "Bislama",
|
||||
"bm": "Bambara",
|
||||
"bn": "Bengali",
|
||||
"bo": "Tibetan",
|
||||
"br": "Breton",
|
||||
"bs": "Bosnian",
|
||||
"ca": "Catalan; Valencian",
|
||||
"ce": "Chechen",
|
||||
"ch": "Chamorro",
|
||||
"co": "Corsican",
|
||||
"cr": "Cree",
|
||||
"cs": "Czech",
|
||||
"cu": "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic",
|
||||
"cv": "Chuvash",
|
||||
"cy": "Welsh",
|
||||
"da": "Danish",
|
||||
"de": "German",
|
||||
"dv": "Divehi; Dhivehi; Maldivian",
|
||||
"dz": "Dzongkha",
|
||||
"ee": "Ewe",
|
||||
"el": "Greek, Modern (1453-)",
|
||||
"en": "English",
|
||||
"eo": "Esperanto",
|
||||
"es": "Spanish; Castilian",
|
||||
"et": "Estonian",
|
||||
"eu": "Basque",
|
||||
"fa": "Persian",
|
||||
"ff": "Fulah",
|
||||
"fi": "Finnish",
|
||||
"fj": "Fijian",
|
||||
"fo": "Faroese",
|
||||
"fr": "French",
|
||||
"fy": "Western Frisian",
|
||||
"ga": "Irish",
|
||||
"gd": "Gaelic; Scottish Gaelic",
|
||||
"gl": "Galician",
|
||||
"gn": "Guarani",
|
||||
"gu": "Gujarati",
|
||||
"gv": "Manx",
|
||||
"ha": "Hausa",
|
||||
"he": "Hebrew",
|
||||
"hi": "Hindi",
|
||||
"ho": "Hiri Motu",
|
||||
"hr": "Croatian",
|
||||
"ht": "Haitian; Haitian Creole",
|
||||
"hu": "Hungarian",
|
||||
"hy": "Armenian",
|
||||
"hz": "Herero",
|
||||
"ia": "Interlingua (International Auxiliary Language Association)",
|
||||
"id": "Indonesian",
|
||||
"ie": "Interlingue; Occidental",
|
||||
"ig": "Igbo",
|
||||
"ii": "Sichuan Yi; Nuosu",
|
||||
"ik": "Inupiaq",
|
||||
"io": "Ido",
|
||||
"is": "Icelandic",
|
||||
"it": "Italian",
|
||||
"iu": "Inuktitut",
|
||||
"ja": "Japanese",
|
||||
"jv": "Javanese",
|
||||
"ka": "Georgian",
|
||||
"kg": "Kongo",
|
||||
"ki": "Kikuyu; Gikuyu",
|
||||
"kj": "Kuanyama; Kwanyama",
|
||||
"kk": "Kazakh",
|
||||
"kl": "Kalaallisut; Greenlandic",
|
||||
"km": "Central Khmer",
|
||||
"kn": "Kannada",
|
||||
"ko": "Korean",
|
||||
"kr": "Kanuri",
|
||||
"ks": "Kashmiri",
|
||||
"ku": "Kurdish",
|
||||
"kv": "Komi",
|
||||
"kw": "Cornish",
|
||||
"ky": "Kirghiz; Kyrgyz",
|
||||
"la": "Latin",
|
||||
"lb": "Luxembourgish; Letzeburgesch",
|
||||
"lg": "Ganda",
|
||||
"li": "Limburgan; Limburger; Limburgish",
|
||||
"ln": "Lingala",
|
||||
"lo": "Lao",
|
||||
"lt": "Lithuanian",
|
||||
"lu": "Luba-Katanga",
|
||||
"lv": "Latvian",
|
||||
"mg": "Malagasy",
|
||||
"mh": "Marshallese",
|
||||
"mi": "Maori",
|
||||
"mk": "Macedonian",
|
||||
"ml": "Malayalam",
|
||||
"mn": "Mongolian",
|
||||
"mr": "Marathi",
|
||||
"ms": "Malay",
|
||||
"mt": "Maltese",
|
||||
"my": "Burmese",
|
||||
"na": "Nauru",
|
||||
"nb": "Bokmål, Norwegian; Norwegian Bokmål",
|
||||
"nd": "Ndebele, North; North Ndebele",
|
||||
"ne": "Nepali",
|
||||
"ng": "Ndonga",
|
||||
"nl": "Dutch; Flemish",
|
||||
"nn": "Norwegian Nynorsk; Nynorsk, Norwegian",
|
||||
"no": "Norwegian",
|
||||
"nr": "Ndebele, South; South Ndebele",
|
||||
"nv": "Navajo; Navaho",
|
||||
"ny": "Chichewa; Chewa; Nyanja",
|
||||
"oc": "Occitan (post 1500)",
|
||||
"oj": "Ojibwa",
|
||||
"om": "Oromo",
|
||||
"or": "Oriya",
|
||||
"os": "Ossetian; Ossetic",
|
||||
"pa": "Panjabi; Punjabi",
|
||||
"pi": "Pali",
|
||||
"pl": "Polish",
|
||||
"ps": "Pushto; Pashto",
|
||||
"pt": "Portuguese",
|
||||
"qu": "Quechua",
|
||||
"rm": "Romansh",
|
||||
"rn": "Rundi",
|
||||
"ro": "Romanian; Moldavian; Moldovan",
|
||||
"ru": "Russian",
|
||||
"rw": "Kinyarwanda",
|
||||
"sa": "Sanskrit",
|
||||
"sc": "Sardinian",
|
||||
"sd": "Sindhi",
|
||||
"se": "Northern Sami",
|
||||
"sg": "Sango",
|
||||
"si": "Sinhala; Sinhalese",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"sm": "Samoan",
|
||||
"sn": "Shona",
|
||||
"so": "Somali",
|
||||
"sq": "Albanian",
|
||||
"sr": "Serbian",
|
||||
"ss": "Swati",
|
||||
"st": "Sotho, Southern",
|
||||
"su": "Sundanese",
|
||||
"sv": "Swedish",
|
||||
"sw": "Swahili",
|
||||
"ta": "Tamil",
|
||||
"te": "Telugu",
|
||||
"tg": "Tajik",
|
||||
"th": "Thai",
|
||||
"ti": "Tigrinya",
|
||||
"tk": "Turkmen",
|
||||
"tl": "Tagalog",
|
||||
"tn": "Tswana",
|
||||
"to": "Tonga (Tonga Islands)",
|
||||
"tr": "Turkish",
|
||||
"ts": "Tsonga",
|
||||
"tt": "Tatar",
|
||||
"tw": "Twi",
|
||||
"ty": "Tahitian",
|
||||
"ug": "Uighur; Uyghur",
|
||||
"uk": "Ukrainian",
|
||||
"ur": "Urdu",
|
||||
"uz": "Uzbek",
|
||||
"ve": "Venda",
|
||||
"vi": "Vietnamese",
|
||||
"vo": "Volapük",
|
||||
"wa": "Walloon",
|
||||
"wo": "Wolof",
|
||||
"xh": "Xhosa",
|
||||
"yi": "Yiddish",
|
||||
"yo": "Yoruba",
|
||||
"za": "Zhuang; Chuang",
|
||||
"zh": "Chinese",
|
||||
"zu": "Zulu"
|
||||
}[code];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue