mojic

Obfuscate C source code into e...
Log | Files | Refs | README | LICENSE

commit f0956c387d5813e1678a0853e130c4eefc3639cc
parent ec4e8a4194db059e96dd15b04a0efaf4392041e3
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Fri, 30 Jan 2026 12:50:17 +0530

New security system

Diffstat:
M.npmrc | 2+-
Mbin/mojic.js | 6++++--
Mlib/CipherEngine.js | 151++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
Anode_modules/.bin/mojic | 16++++++++++++++++
Anode_modules/.bin/mojic.cmd | 17+++++++++++++++++
Anode_modules/.bin/mojic.ps1 | 28++++++++++++++++++++++++++++
Mnode_modules/.package-lock.json | 21+++++++++++++++++++--
Anode_modules/@notamitgamer/mojic/CODE_OF_CONDUCT.md | 34++++++++++++++++++++++++++++++++++
Anode_modules/@notamitgamer/mojic/CONTRIBUTING.md | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anode_modules/@notamitgamer/mojic/LICENSE | 202+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anode_modules/@notamitgamer/mojic/README.md | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anode_modules/@notamitgamer/mojic/SECURITY.md | 13+++++++++++++
Cbin/mojic.js -> node_modules/@notamitgamer/mojic/bin/mojic.js | 0
Clib/CipherEngine.js -> node_modules/@notamitgamer/mojic/lib/CipherEngine.js | 0
Anode_modules/@notamitgamer/mojic/package.json | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackage-lock.json | 26++++++++++++++++++++++----
Mpackage.json | 7++++---
17 files changed, 683 insertions(+), 64 deletions(-)

diff --git a/.npmrc b/.npmrc @@ -1,3 +1,3 @@ -@notamitgamer:registry=https://registry.npmjs.org/ +@notamitgamer:registry=https://npm.pkg.github.com registry=https://registry.npmjs.org/ \ No newline at end of file diff --git a/bin/mojic.js b/bin/mojic.js @@ -9,10 +9,12 @@ import { Transform } from 'stream'; import { StringDecoder } from 'string_decoder'; import { CipherEngine } from '../lib/CipherEngine.js'; +const VERSION = '2.1.1'; + program .name('mojic') .description('Obfuscate C source code into emojis') - .version('1.2.5') + .version(VERSION) .addHelpCommand('help [command]', 'Display help for command') .showHelpAfterError(); @@ -119,7 +121,7 @@ program throw new Error(`'${targetPath}' is a directory. Use -r to process recursively.`); } - console.log(chalk.blue('Initiating Mojic Encryption v1.2...')); + console.log(chalk.blue(`Initiating Mojic Encryption v${VERSION}...`)); if (options.flat) console.log(chalk.yellow(' -> Structural Flattening Enabled')); const password = await promptPassword('Create password for file(s):'); diff --git a/lib/CipherEngine.js b/lib/CipherEngine.js @@ -3,12 +3,15 @@ import { Transform } from 'stream'; import { StringDecoder } from 'string_decoder'; /** - * MOJIC v1.2.5 CIPHER ENGINE - * "Operation Polymorphic Chaos" + * MOJIC v2.1.1 CIPHER ENGINE + * "Operation Ironclad" + * * Security Upgrades: + * - KDF: Upgraded from PBKDF2 to Scrypt (Memory-Hard, GPU-Resistant) + * - PRNG: Upgraded from Xoshiro256** to AES-256-CTR (Cryptographically Secure) + * - Auth: Extended Key material for higher entropy * * Fixes: - * - Word Boundaries: Prevents splitting variables like 'secretCode' - * - Regex: correctly handles #directives vs keywords - * - Tokenization: Handles combined graphemes (skin tones/modifiers) during decryption + * - Polymorphic Data: Added XOR Whitening to raw data chunks to hide patterns (e.g., repeating whitespace). + * - RNG Buffering: Fixed potential byte loss in AES-CTR buffer refill. */ // --- EMOJI UNIVERSE GENERATION --- @@ -33,7 +36,7 @@ const generateUniverse = () => { } } } - return universe; // Expect > 1100 chars + return universe; }; const RAW_UNIVERSE = generateUniverse(); @@ -50,41 +53,50 @@ const C_KEYWORDS = [ 'include', 'define', 'main', 'printf', 'NULL', '#include', '#define' ]; -// --- PRNG: Xoshiro256** --- -class Xoshiro256 { - constructor(seedBuffer) { - if (seedBuffer.length < 32) throw new Error("Seed too short"); - this.s = [ - seedBuffer.readBigUInt64BE(0), - seedBuffer.readBigUInt64BE(8), - seedBuffer.readBigUInt64BE(16), - seedBuffer.readBigUInt64BE(24) - ]; +// --- PRNG: AES-256-CTR (CSPRNG) --- +// Replaces Xoshiro with a cryptographically secure stream +class AesCounterRNG { + constructor(key, iv) { + if (key.length !== 32 || iv.length !== 16) throw new Error("Invalid seed length for AES-RNG"); + this.cipher = crypto.createCipheriv('aes-256-ctr', key, iv); + this.buffer = Buffer.alloc(0); + + // Encrypt an initial block of zeros to start the keystream + this._refill(); } - next() { - const result = this.rotl(this.s[1] * 5n, 7n) * 9n; - const t = this.s[1] << 17n; - - this.s[2] ^= this.s[0]; - this.s[3] ^= this.s[1]; - this.s[1] ^= this.s[2]; - this.s[0] ^= this.s[3]; + _refill() { + // Generate 1KB of random keystream at a time + const zeros = Buffer.alloc(1024); + const newBytes = this.cipher.update(zeros); + // Correctly concatenate new bytes to existing buffer to prevent data loss + this.buffer = Buffer.concat([this.buffer, newBytes]); + } - this.s[2] ^= t; - this.s[3] = this.rotl(this.s[3], 45n); + next() { + if (this.buffer.length < 8) this._refill(); + + // Read 64 bits (BigInt) to match previous interface + const val = this.buffer.readBigUInt64BE(0); + this.buffer = this.buffer.subarray(8); + return val; + } - return result; + nextBytes(length) { + if (this.buffer.length < length) this._refill(); + + // Return a Buffer of requested length + const bytes = this.buffer.subarray(0, length); + this.buffer = this.buffer.subarray(length); + return bytes; } nextFloat() { + // Convert uint64 to double [0, 1) + // We take upper 53 bits for standard double precision const val = Number(this.next() >> 11n); return val * (2 ** -53); } - - rotl(x, k) { - return (x << k) | (x >> (64n - k)); - } } export class CipherEngine { @@ -96,24 +108,31 @@ export class CipherEngine { this.dataReverseMap = new Map(); this.isReady = false; this.hmac = null; - this.lineLength = 0; // For wrapping + this.lineLength = 0; } async init(existingSaltHex = null, expectedAuthCheck = null) { this.salt = existingSaltHex ? Buffer.from(existingSaltHex, 'hex') - : crypto.randomBytes(16); + : crypto.randomBytes(32); // Increased salt size to 32 bytes + // SECURITY UPGRADE: Scrypt instead of PBKDF2 + // N=16384, r=8, p=1 are standard secure defaults const derivedKey = await new Promise((resolve, reject) => { - crypto.pbkdf2(this.password, this.salt, 100000, 64, 'sha512', (err, key) => { + crypto.scrypt(this.password, this.salt, 80, { N: 16384, r: 8, p: 1 }, (err, key) => { if (err) reject(err); else resolve(key); }); }); - const seedBuffer = derivedKey.subarray(0, 32); - this.authKey = derivedKey.subarray(32, 64); + // Split 80 bytes of key material: + // 0-32: AES Key (32 bytes) + // 32-48: AES IV (16 bytes) + // 48-80: HMAC Auth Key (32 bytes) + + const rngKey = derivedKey.subarray(0, 32); + const rngIv = derivedKey.subarray(32, 48); + this.authKey = derivedKey.subarray(48, 80); - // Check password correctness immediately if Auth Check is provided if (expectedAuthCheck) { const calculatedAuthCheck = this.authKey.subarray(0, 4).toString('hex'); if (calculatedAuthCheck !== expectedAuthCheck) { @@ -121,7 +140,8 @@ export class CipherEngine { } } - this.rng = new Xoshiro256(seedBuffer); + // Initialize CSPRNG + this.rng = new AesCounterRNG(rngKey, rngIv); const shuffled = this._shuffleArray([...RAW_UNIVERSE]); @@ -146,6 +166,7 @@ export class CipherEngine { } _shuffleArray(array) { + // Fisher-Yates shuffle using CSPRNG for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(this.rng.nextFloat() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; @@ -176,9 +197,16 @@ export class CipherEngine { hexString += index.toString(16); } + // Salt is now variable length (usually 32 bytes = 64 hex chars), + // AuthCheck is always last 4 bytes (8 hex chars) + const totalLen = hexString.length; + if (totalLen < 8) throw new Error("Header too short"); + + const authStart = totalLen - 8; + return { - saltHex: hexString.substring(0, 32), - authCheckHex: hexString.length >= 40 ? hexString.substring(32, 40) : null + saltHex: hexString.substring(0, authStart), + authCheckHex: hexString.substring(authStart) }; } @@ -193,11 +221,9 @@ export class CipherEngine { transform(chunk, encoding, callback) { const str = chunk.toString('utf8'); - // Separate alpha keywords (int, void) from symbols (#include) const alphaKeywords = C_KEYWORDS.filter(k => /^\w+$/.test(k)).sort((a,b)=>b.length-a.length).join('|'); const symKeywords = C_KEYWORDS.filter(k => !/^\w+$/.test(k)).map(k => k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'); - // Match: \b(int|void)\b OR (#include) const regex = new RegExp(`(\\b(?:${alphaKeywords})\\b|(?:${symKeywords}))`, 'g'); const parts = str.split(regex); @@ -227,7 +253,12 @@ export class CipherEngine { const chunk = buffer.subarray(0, 5); buffer = buffer.subarray(5); - const enc = engine._encodeBase1024(chunk); + // XOR Whitening: Hide patterns (like spaces) by XORing with RNG stream + const mask = engine.rng.nextBytes(5); + const maskedChunk = Buffer.alloc(5); + for(let i=0; i<5; i++) maskedChunk[i] = chunk[i] ^ mask[i]; + + const enc = engine._encodeBase1024(maskedChunk); engine.hmac.update(enc); this.push(engine._wrapOutput(enc)); } @@ -240,7 +271,13 @@ export class CipherEngine { if (buffer.length > 0) { const padded = Buffer.alloc(5); buffer.copy(padded); - const enc = engine._encodeBase1024(padded); + + // XOR Whitening for final block + const mask = engine.rng.nextBytes(5); + const maskedChunk = Buffer.alloc(5); + for(let i=0; i<5; i++) maskedChunk[i] = padded[i] ^ mask[i]; + + const enc = engine._encodeBase1024(maskedChunk); engine.hmac.update(enc); this.push(engine._wrapOutput(enc)); } @@ -288,7 +325,13 @@ export class CipherEngine { if (buf.length === 0) return Buffer.alloc(0); const padded = Buffer.alloc(5); buf.copy(padded); - const enc = this._encodeBase1024(padded); + + // XOR Whitening + const mask = this.rng.nextBytes(5); + const maskedChunk = Buffer.alloc(5); + for(let i=0; i<5; i++) maskedChunk[i] = padded[i] ^ mask[i]; + + const enc = this._encodeBase1024(maskedChunk); this.hmac.update(enc); return this._wrapOutput(enc); } @@ -309,11 +352,8 @@ export class CipherEngine { const segments = [...segmenter.segment(str)]; for (const { segment } of segments) { - if (segment.match(/\s/)) continue; // Skip wraps + if (segment.match(/\s/)) continue; - // FIX: Some emojis in the universe (like skin tones 0x1F3FB) are modifiers. - // If they appear next to another emoji, Intl.Segmenter merges them. - // We must split them back into atomic code points to preserve token count. const atoms = [...segment]; for (const atom of atoms) { @@ -322,7 +362,6 @@ export class CipherEngine { if (emojiBuffer.length > FOOTER_LEN) { const emo = emojiBuffer.shift(); engine._processDecryptToken(emo, this); - // Feed actual atomic tokens to HMAC to match encryption engine.hmac.update(Buffer.from(emo)); } } @@ -373,7 +412,6 @@ export class CipherEngine { const originalEmo = this.keywordEmojis[baseIdx]; const keyword = this.keywordReverseMap.get(originalEmo); - // Safety: This buffer should be empty if the stream is synced. if (this.decodeDataBuf.length > 0) { this.decodeDataBuf = []; } @@ -383,8 +421,17 @@ export class CipherEngine { } else if (this.dataReverseMap.has(emo)) { this.decodeDataBuf.push(this.dataReverseMap.get(emo)); if (this.decodeDataBuf.length === 4) { - const chunk = this._decodeBase1024(this.decodeDataBuf); + // We have a full encoded chunk (4 emojis) + const maskedChunk = this._decodeBase1024(this.decodeDataBuf); this.decodeDataBuf = []; + + // Get mask from RNG (Synchronized with encryption) + const mask = this.rng.nextBytes(5); + const chunk = Buffer.alloc(5); + + // XOR Back to get plaintext + for(let i=0; i<5; i++) chunk[i] = maskedChunk[i] ^ mask[i]; + const cleanChunk = chunk.filter(b => b !== 0x00); stream.push(cleanChunk); } diff --git a/node_modules/.bin/mojic b/node_modules/.bin/mojic @@ -0,0 +1,16 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) + if command -v cygpath > /dev/null 2>&1; then + basedir=`cygpath -w "$basedir"` + fi + ;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../@notamitgamer/mojic/bin/mojic.js" "$@" +else + exec node "$basedir/../@notamitgamer/mojic/bin/mojic.js" "$@" +fi diff --git a/node_modules/.bin/mojic.cmd b/node_modules/.bin/mojic.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\@notamitgamer\mojic\bin\mojic.js" %* diff --git a/node_modules/.bin/mojic.ps1 b/node_modules/.bin/mojic.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../@notamitgamer/mojic/bin/mojic.js" $args + } else { + & "$basedir/node$exe" "$basedir/../@notamitgamer/mojic/bin/mojic.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../@notamitgamer/mojic/bin/mojic.js" $args + } else { + & "node$exe" "$basedir/../@notamitgamer/mojic/bin/mojic.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { - "name": "mojic", - "version": "1.2.4", + "name": "@notamitgamer/mojic", + "version": "1.2.5", "lockfileVersion": 3, "requires": true, "packages": { @@ -174,6 +174,23 @@ "node": ">= 8" } }, + "node_modules/@notamitgamer/mojic": { + "version": "1.2.5", + "resolved": "https://npm.pkg.github.com/download/@notamitgamer/mojic/1.2.5/405b6c82e0160b914c3eef4c687905cd8b69d2cb", + "integrity": "sha512-Ipfu2hBS0iqIvI554lWH5gXyIgm1dg8NPnu67UB4x08kO+kS50VrJe4XvDvU1Nv9ZWDDSO8N/Q3y5Zr4VpgJ7g==", + "license": "Apache-2.0", + "dependencies": { + "chalk": "^5.3.0", + "commander": "^11.1.0", + "inquirer": "^9.2.12" + }, + "bin": { + "mojic": "bin/mojic.js" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", diff --git a/node_modules/@notamitgamer/mojic/CODE_OF_CONDUCT.md b/node_modules/@notamitgamer/mojic/CODE_OF_CONDUCT.md @@ -0,0 +1,34 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at **amitdutta4255@gmail.com** or **mail@amit.is-a.dev**. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/node_modules/@notamitgamer/mojic/CONTRIBUTING.md b/node_modules/@notamitgamer/mojic/CONTRIBUTING.md @@ -0,0 +1,70 @@ +# Contributing to Mojic + +First off, thanks for taking the time to contribute! + +The following is a set of guidelines for contributing to Mojic. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. + +## Development Workflow + +We use the standard GitHub Pull Request workflow. + +1. **Fork** the repository on GitHub: + [https://github.com/notamitgamer/mojic](https://github.com/notamitgamer/mojic) + +2. **Clone** your fork locally: + ```bash + git clone [https://github.com/YOUR_USERNAME/mojic.git](https://github.com/YOUR_USERNAME/mojic.git) + cd mojic + ``` + +3. **Create a Branch** for your feature or bugfix: + ```bash + git checkout -b feature/amazing-feature + ``` + +4. **Install Dependencies**: + ```bash + npm install + ``` + +5. **Test your changes**: + You can run the CLI locally using `npm start` or linking the package. + ```bash + # Run directly + npm start -- encode test.c + ``` + +6. **Commit** your changes (see the style guide below). + +7. **Push** to your fork: + ```bash + git push origin feature/amazing-feature + ``` + +8. **Open a Pull Request** on the main repository (`notamitgamer/mojic`). + +## How Can I Contribute? + +### Reporting Bugs +* **Use a clear and descriptive title** for the issue to identify the problem. +* **Describe the exact steps which reproduce the problem** in as many details as possible. +* **Provide specific examples** to demonstrate the steps. + +### Suggesting Enhancements +* **Use a clear and descriptive title** for the issue to identify the suggestion. +* **Provide a step-by-step description of the suggested enhancement** in as many details as possible. +* **Explain why this enhancement would be useful** to most Mojic users. + +## Styleguides + +### Git Commit Messages +* Use the present tense ("Add feature" not "Added feature") +* Use the imperative mood ("Move cursor to..." not "Moves cursor to...") +* Limit the first line to 72 characters or less + +### Mojic Code Style +* **Cipher Logic:** Changes to `CipherEngine.js` must ensure backward compatibility with the header format if possible. +* **Streams:** Always use `StringDecoder` when handling text streams to prevent multi-byte emoji corruption. +* **Linting:** Ensure your code is clean and readable. + +Happy Hacking! diff --git a/node_modules/@notamitgamer/mojic/LICENSE b/node_modules/@notamitgamer/mojic/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.+ \ No newline at end of file diff --git a/node_modules/@notamitgamer/mojic/README.md b/node_modules/@notamitgamer/mojic/README.md @@ -0,0 +1,97 @@ +# Mojic v1.2.5 + +> **Operation Polymorphic Chaos: Obfuscate C source code into a randomized, password-seeded stream of emojis.** + +**Mojic** (Magic + Emoji + Logic) is a sophisticated CLI tool designed to transform readable C code into an unrecognizable chaotic stream of emojis. Unlike simple substitution ciphers, Mojic uses your password to seed a cryptographically strong Pseudo-Random Number Generator (PRNG), creating a unique "Emoji Universe" and rolling cipher for every single session. + +## Key Features + +* ** Xoshiro256** PRNG:** Uses a high-quality 256-bit state PRNG (seeded via PBKDF2-SHA512) to handle shuffling and polymorphism. +* ** Polymorphic Keywords:** Common C keywords (`int`, `void`, `return`) are mapped to emojis that *change* every time they appear based on the PRNG state. Frequency analysis is impossible. +* ** Base-1024 Compression:** Non-keyword code is compressed using a custom Base-1024 scheme (5 bytes → 4 emojis), keeping file size manageable. +* ** Integrity Sealed:** Every file ends with an HMAC-SHA256 signature. Any tampering with the emoji stream results in an immediate `FILE_TAMPERED` error. +* ** Moon Header Protocol:** Metadata (Salt + Auth Check) is encoded using a specific alphabet of Moon and Clock phases (`🌑🌒🕐`), allowing instant password verification before decryption starts. +* ** Stream Architecture:** Built on Node.js `Transform` streams to handle large files efficiently with minimal memory footprint. + +## Installation + +Since Mojic is available on npm, you can install it globally with a single command: + +```bash +npm install -g mojic +``` + +Or run it directly using `npx` without installing: + +```bash +npx mojic encode main.c +``` + +## Usage + +### 1. Encrypting Code (`encode`) +Transforms a `.c` file into a `.mojic` file. + +```bash +# Encrypt a single file +mojic encode main.c + +# Encrypt an entire directory recursively +mojic encode ./src -r + +# Flatten/Minify code structure before encryption (Removes newlines/indentation) +mojic encode main.c --flat +``` +*You will be prompted to create a password. This password is required to decrypt.* + +### 2. Decrypting Code (`decode`) +Restores the original C code from a `.mojic` file. + +```bash +# Decrypt a single file +mojic decode main.mojic + +# Decrypt an entire directory recursively +mojic decode ./src -r +``` + +### 3. Security & Rotation Tools (`srt`) +Manage encrypted files without ever revealing their plaintext contents. + +```bash +# Rotate Password: Changes the password of an encrypted file +mojic srt --pass secret.mojic + +# Re-Encrypt: Re-shuffles the entropy (New Salt) with the SAME password +# (Useful to change the visual emoji pattern without changing the password) +mojic srt --re secret.mojic +``` + +## Under the Hood (Algorithm) + +Mojic v1.1.0 implements a custom crypto-system dubbed **"Operation Polymorphic Chaos"**. + +1. **Derivation Phase:** + * **Input:** User Password + 16-byte Random Salt. + * **KDF:** `PBKDF2-SHA512` (100,000 iterations). + * **Output:** 64 bytes (32 bytes for PRNG Seed, 32 bytes for HMAC Auth Key). + +2. **The Emoji Universe:** + * The engine generates a universe of ~1,100 valid emojis (Emoticons, Transport, Symbols). + * This universe is **shuffled** using the `Xoshiro256**` PRNG initialized with the derived seed. + +3. **Polymorphic Encryption:** + * **C Keywords:** The engine detects C keywords (e.g., `while`). It assigns them a "Base Emoji" from the shuffled universe. + * **The Twist:** It doesn't just print the Base Emoji. It calculates a random offset using the PRNG to pick a *different* emoji that maps back to the keyword. This means `int` might look like `🚀` on line 1 and `🌮` on line 5. + +4. **Base-1024 Encoding:** + * Non-keyword data is buffered into 5-byte chunks. + * These chunks are treated as a single large integer and converted into 4 base-1024 digits (mapped to emojis), effectively compressing the stream density. + +5. **The Header:** + * The Salt and a 4-byte Auth Check are written to the file header using the **Moon/Clock Alphabet** (`🌑🌒🌓🌔...`). + * **Benefit:** This allows `mojic` to tell you "Incorrect Password" instantly, rather than churning out garbage data first. + +## License + +This project is licensed under the Apache License 2.0. diff --git a/node_modules/@notamitgamer/mojic/SECURITY.md b/node_modules/@notamitgamer/mojic/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Reporting a Vulnerability + +We take security seriously. + +If you discover a security vulnerability within Mojic (e.g., in the `CipherEngine` logic or the PRNG implementation), please send an e-mail to **amitdutta4255@gmail.com** or **mail@amit.is-a.dev**. All security vulnerabilities will be promptly addressed. + +**Please do not open public issues for security vulnerabilities.** + +### Scope +* **Supported:** Issues regarding key derivation, salt collisions, HMAC integrity failures, or stream buffer overflows. +* **Not Supported:** Brute-forcing weak passwords (users are responsible for password strength). diff --git a/bin/mojic.js b/node_modules/@notamitgamer/mojic/bin/mojic.js diff --git a/lib/CipherEngine.js b/node_modules/@notamitgamer/mojic/lib/CipherEngine.js diff --git a/node_modules/@notamitgamer/mojic/package.json b/node_modules/@notamitgamer/mojic/package.json @@ -0,0 +1,57 @@ +{ + "name": "@notamitgamer/mojic", + "version": "1.2.5", + "description": "Obfuscate C source code into encrypted, password-seeded emoji streams.", + "main": "bin/mojic.js", + "bin": { + "mojic": "bin/mojic.js" + }, + "type": "module", + "scripts": { + "start": "node bin/mojic.js", + "build-binaries": "pkg . --out-path dist --public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/notamitgamer/mojic.git" + }, + "publishConfig": { + "registry": "https://npm.pkg.github.com", + "access": "public" + }, + "dependencies": { + "chalk": "^5.3.0", + "commander": "^11.1.0", + "inquirer": "^9.2.12" + }, + "devDependencies": { + "pkg": "^5.8.1" + }, + "engines": { + "node": ">=18.0.0" + }, + "keywords": [ + "cli", + "encryption", + "emoji", + "obfuscation", + "c", + "security", + "polymorphic" + ], + "author": "notamitgamer", + "license": "Apache-2.0", + "pkg": { + "scripts": "bin/mojic.js", + "assets": [ + "lib/**/*", + "package.json" + ], + "targets": [ + "node18-win-x64", + "node18-linux-x64", + "node18-macos-x64" + ], + "outputPath": "dist" + } +} diff --git a/package-lock.json b/package-lock.json @@ -1,14 +1,15 @@ { - "name": "mojic", - "version": "1.2.4", + "name": "@notamitgamer/mojic", + "version": "1.2.5", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "mojic", - "version": "1.2.4", + "name": "@notamitgamer/mojic", + "version": "1.2.5", "license": "Apache-2.0", "dependencies": { + "@notamitgamer/mojic": "^1.2.5", "chalk": "^5.3.0", "commander": "^11.1.0", "inquirer": "^9.2.12" @@ -193,6 +194,23 @@ "node": ">= 8" } }, + "node_modules/@notamitgamer/mojic": { + "version": "1.2.5", + "resolved": "https://npm.pkg.github.com/download/@notamitgamer/mojic/1.2.5/405b6c82e0160b914c3eef4c687905cd8b69d2cb", + "integrity": "sha512-Ipfu2hBS0iqIvI554lWH5gXyIgm1dg8NPnu67UB4x08kO+kS50VrJe4XvDvU1Nv9ZWDDSO8N/Q3y5Zr4VpgJ7g==", + "license": "Apache-2.0", + "dependencies": { + "chalk": "^5.3.0", + "commander": "^11.1.0", + "inquirer": "^9.2.12" + }, + "bin": { + "mojic": "bin/mojic.js" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", diff --git a/package.json b/package.json @@ -1,6 +1,6 @@ { - "name": "mojic", - "version": "1.2.5", + "name": "@notamitgamer/mojic", + "version": "2.1.1", "description": "Obfuscate C source code into encrypted, password-seeded emoji streams.", "main": "bin/mojic.js", "bin": { @@ -16,10 +16,11 @@ "url": "git+https://github.com/notamitgamer/mojic.git" }, "publishConfig": { - "registry": "https://registry.npmjs.org/", + "registry": "https://npm.pkg.github.com/", "access": "public" }, "dependencies": { + "@notamitgamer/mojic": "^1.2.5", "chalk": "^5.3.0", "commander": "^11.1.0", "inquirer": "^9.2.12"
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror