This commit is contained in:
Flatlogic Bot 2026-01-25 14:39:18 +00:00
parent 387a1d8276
commit 6628329bbd
9 changed files with 398 additions and 605 deletions

View File

@ -1,4 +1,3 @@
const express = require('express');
const cors = require('cors');
const app = express();
@ -109,7 +108,8 @@ app.use('/api/projects', passport.authenticate('jwt', {session: false}), project
app.use('/api/scripts', passport.authenticate('jwt', {session: false}), scriptsRoutes);
app.use('/api/builds', passport.authenticate('jwt', {session: false}), buildsRoutes);
// Build routes are now public-facing for the playground
app.use('/api/builds', buildsRoutes);
app.use('/api/vm_configs', passport.authenticate('jwt', {session: false}), vm_configsRoutes);
@ -163,4 +163,4 @@ db.sequelize.sync().then(function () {
});
});
module.exports = app;
module.exports = app;

View File

@ -1,8 +1,8 @@
const express = require('express');
const passport = require('passport');
const BuildsService = require('../services/builds');
const BuildsDBApi = require('../db/api/builds');
const ObfuscatorService = require('../services/obfuscator');
const wrapAsync = require('../helpers').wrapAsync;
@ -15,8 +15,54 @@ const {
checkCrudPermissions,
} = require('../middlewares/check-permissions');
router.use(checkCrudPermissions('builds'));
/**
* @swagger
* /api/builds/protect:
* post:
* tags: [Builds]
* summary: Obfuscate Luau code
* requestBody:
* required: true
* content:
* application/json:
* schema:
* properties:
* source:
* type: string
* config:
* type: object
* responses:
* 200:
* description: Obfuscated code
* content:
* application/json:
* schema:
* properties:
* protectedCode:
* type: string
*/
router.post('/protect', wrapAsync(async (req, res) => {
const { source, config } = req.body;
const protectedCode = ObfuscatorService.obfuscate(source, config);
// Log the build if possible, but don't fail if no user
try {
await BuildsService.create({
version: '1.0.0',
notes: `Playground build: ${source.substring(0, 20)}...`,
success: true
}, req.currentUser);
} catch (e) {
console.error('Failed to log playground build:', e.message);
}
res.status(200).send({ protectedCode });
}));
// Apply authentication and permission checks to all other routes
router.use(passport.authenticate('jwt', { session: false }));
router.use(checkCrudPermissions('builds'));
/**
* @swagger
@ -429,4 +475,4 @@ router.get('/:id', wrapAsync(async (req, res) => {
router.use('/', require('../helpers').commonErrorHandler);
module.exports = router;
module.exports = router;

View File

@ -0,0 +1,216 @@
const crypto = require('crypto');
class ObfuscatorService {
static obfuscate(sourceCode, config = {}) {
const seed = crypto.randomBytes(4).readUInt32BE(0);
const opcodeMap = this.generateRandomOpcodeMap(seed);
const { bytecode, constants } = this.compile(sourceCode, opcodeMap);
return this.generateVMRunner(bytecode, constants, opcodeMap, seed, config);
}
static generateRandomOpcodeMap(seed) {
const baseOpcodes = [
'LOADK', 'GETGLOBAL', 'SETGLOBAL', 'CALL', 'RETURN',
'MOVE', 'ADD', 'SUB', 'MUL', 'DIV', 'MOD', 'POW',
'UNM', 'NOT', 'LEN', 'CONCAT', 'JMP', 'EQ', 'LT', 'LE',
'FORLOOP', 'FORPREP', 'TFORCALL', 'TFORLOOP', 'SETLIST',
'CLOSE', 'CLOSURE', 'VARARG', 'FAKE'
];
// Add many fake opcodes for "noise"
for (let i = 0; i < 30; i++) {
baseOpcodes.push(`NOISE_${i}`);
}
const shuffled = [...baseOpcodes].sort(() => this.seededRandom(seed++) - 0.5);
const map = {};
shuffled.forEach((op, index) => {
map[op] = index + 5; // Offset by 5
});
return map;
}
static seededRandom(seed) {
const x = Math.sin(seed) * 10000;
return x - Math.floor(x);
}
static compile(code, opcodeMap) {
const constants = [];
const bytecode = [];
const getConstant = (val) => {
let idx = constants.indexOf(val);
if (idx === -1) {
idx = constants.length;
constants.push(val);
}
return idx;
};
const lines = code.split('\n').map(l => l.trim()).filter(l => l.length > 0 && !l.startsWith('--'));
lines.forEach(line => {
// Basic call: print("hello")
const callMatch = line.match(/^(\w+)\s*\(.*\)$/);
if (callMatch) {
const funcName = callMatch[1];
const argsStr = line.match(/\((.*)\)/)?.[1] || "";
const args = argsStr ? this.splitArgs(argsStr) : [];
bytecode.push(opcodeMap['GETGLOBAL'], 0, getConstant(funcName));
args.forEach((arg, i) => {
const reg = i + 1;
this.pushValueToReg(arg, reg, bytecode, opcodeMap, getConstant);
});
bytecode.push(opcodeMap['CALL'], 0, args.length + 1, 1);
return;
}
// Basic assignment: x = 10
const assignMatch = line.match(/^(\w+)\s*=\s*(.*)$/);
if (assignMatch) {
const varName = assignMatch[1];
const val = assignMatch[2].trim();
this.pushValueToReg(val, 0, bytecode, opcodeMap, getConstant);
bytecode.push(opcodeMap['SETGLOBAL'], 0, getConstant(varName));
return;
}
// Add "opaque predicates" simulation
if (Math.random() > 0.8) {
bytecode.push(opcodeMap['JMP'], 1);
bytecode.push(opcodeMap[`NOISE_${Math.floor(Math.random() * 10)}`], 0xFF);
}
});
bytecode.push(opcodeMap['RETURN'], 0, 1);
return { bytecode, constants };
}
static splitArgs(argsStr) {
const args = [];
let current = "";
let inString = false;
for (let i = 0; i < argsStr.length; i++) {
const c = argsStr[i];
if (c === '"' || c === "'") inString = !inString;
if (c === ',' && !inString) {
args.push(current.trim());
current = "";
} else {
current += c;
}
}
args.push(current.trim());
return args.filter(a => a.length > 0);
}
static pushValueToReg(val, reg, bytecode, opcodeMap, getConstant) {
if (val.startsWith('"') || val.startsWith("'")) {
bytecode.push(opcodeMap['LOADK'], reg, getConstant(val.substring(1, val.length - 1)));
} else if (!isNaN(val)) {
bytecode.push(opcodeMap['LOADK'], reg, getConstant(Number(val)));
} else if (val === "true") {
bytecode.push(opcodeMap['LOADK'], reg, getConstant(true));
} else if (val === "false") {
bytecode.push(opcodeMap['LOADK'], reg, getConstant(false));
} else {
bytecode.push(opcodeMap['GETGLOBAL'], reg, getConstant(val));
}
}
static generateVMRunner(bytecode, constants, opcodeMap, seed, config) {
const k1 = (seed % 250) + 1;
const k2 = ((seed >> 8) % 250) + 1;
const encBytecode = [];
let rolling = k1;
bytecode.forEach((b) => {
const enc = (b ^ rolling) ^ k2;
encBytecode.push(enc);
rolling = (rolling + enc) % 256;
});
const encConstants = constants.map(c => {
if (typeof c === 'string') {
const chars = c.split('').map(char => {
let v = char.charCodeAt(0) ^ k1;
v = (v ^ 0xAA) ^ k2;
return v;
});
return { t: 's', d: chars };
}
if (typeof c === 'number') {
return { t: 'n', d: (c ^ k1) ^ 0x55 };
}
if (typeof c === 'boolean') {
return { t: 'b', d: c ? 1 : 0 };
}
return { t: 'z', d: 0 };
});
const opsMapping = Object.entries(opcodeMap).map(([k, v]) => `[${v}] = "${k}"`).join(',');
const varL = "L_" + crypto.randomBytes(2).toString('hex');
const varC = "C_" + crypto.randomBytes(2).toString('hex');
const varK = "K_" + crypto.randomBytes(2).toString('hex');
const varO = "O_" + crypto.randomBytes(2).toString('hex');
const varB = "B_" + crypto.randomBytes(2).toString('hex');
const constantsStr = encConstants.map(c => {
const dataStr = Array.isArray(c.d) ? `{${c.d.join(',')}}` : c.d;
return `{t="${c.t}",d=${dataStr}}`;
}).join(',');
const lua = `--[[ Luartex VM Protection ]]
local function Luartex_VM(...)
local ${varL} = {${encBytecode.join(',')}}
local ${varC} = {${constantsStr}}
local ${varK} = {${k1}, ${k2}}
local ${varO} = {${opsMapping}}
local ${varB} = bit32 or {bxor = function(a, b) local r, m = 0, 1 while a > 0 or b > 0 do if a % 2 ~= b % 2 then r = r + m end a, b, m = math.floor(a / 2), math.floor(b / 2), m * 2 end return r end}
local function _DECODE(v, k, k2) if v.t == "s" then local s = "" for i = 1, #v.d do local val = ${varB}.bxor(v.d[i], k2) s = s .. string.char(${varB}.bxor(val, k)) end return s elseif v.t == "n" then return ${varB}.bxor(${varB}.bxor(v.d, k), 0x55) elseif v.t == "b" then return v.d == 1 end return nil end
local function _EXECUTE()
local _ENV = getfenv() local _REG = {} local _PC = 1 local _RUNNING = true local _ROLLING = ${varK}[1]
while _RUNNING and _PC <= #${varL} do
local _RAW = ${varL}[_PC] local _OP = ${varB}.bxor(${varB}.bxor(_RAW, _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + _RAW) % 256 _PC = _PC + 1
local _MN = ${varO}[_OP]
if _MN == "LOADK" then
local _R = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
local _CI = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
_REG[_R] = _DECODE(${varC}[_CI + 1], ${varK}[1], ${varK}[2])
elseif _MN == "GETGLOBAL" then
local _R = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
local _CI = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
_REG[_R] = _ENV[_DECODE(${varC}[_CI + 1], ${varK}[1], ${varK}[2])]
elseif _MN == "SETGLOBAL" then
local _R = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
local _CI = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
_ENV[_DECODE(${varC}[_CI + 1], ${varK}[1], ${varK}[2])] = _REG[_R]
elseif _MN == "CALL" then
local _R = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
local _NA = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
local _NR = ${varB}.bxor(${varB}.bxor(${varL}[_PC], _ROLLING), ${varK}[2])
_ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
local _AS = {}
if _NA > 1 then for i = 1, _NA - 1 do _AS[i] = _REG[_R + i] end end
local _F = _REG[_R]
local _S, _RE = pcall(_F, unpack(_AS))
if _NR > 1 then for i = 1, _NR - 1 do _REG[_R + i - 1] = _RE end end
elseif _MN == "RETURN" then _RUNNING = false
elseif _MN and _MN:find("NOISE") then _ROLLING = (_ROLLING + ${varL}[_PC]) % 256 _PC = _PC + 1
end
end
end
pcall(_EXECUTE)
end
Luartex_VM(...);

View File

@ -1,6 +1,5 @@
import React, {useEffect, useRef} from 'react'
import React, {useEffect, useRef, useState} from 'react'
import Link from 'next/link'
import { useState } from 'react'
import { mdiChevronUp, mdiChevronDown } from '@mdi/js'
import BaseDivider from './BaseDivider'
import BaseIcon from './BaseIcon'
@ -129,4 +128,4 @@ export default function NavBarItem({ item }: Props) {
}
return <div className={componentClass} ref={excludedRef}>{NavBarItemComponentContents}</div>
}
}

View File

@ -1,5 +1,4 @@
import React, { ReactNode, useEffect } from 'react'
import { useState } from 'react'
import React, { ReactNode, useEffect, useState } from 'react'
import jwt from 'jsonwebtoken';
import { mdiForwardburger, mdiBackburger, mdiMenu } from '@mdi/js'
import menuAside from '../menuAside'
@ -126,4 +125,4 @@ export default function LayoutAuthenticated({
</div>
</div>
)
}
}

View File

@ -3,9 +3,9 @@ import { MenuAsideItem } from './interfaces'
const menuAside: MenuAsideItem[] = [
{
href: '/dashboard',
icon: icon.mdiViewDashboardOutline,
label: 'Dashboard',
href: '/',
icon: icon.mdiShieldLockOutline,
label: 'Obfuscator',
},
{
@ -104,4 +104,4 @@ const menuAside: MenuAsideItem[] = [
},
]
export default menuAside
export default menuAside

View File

@ -1,439 +0,0 @@
import * as icon from '@mdi/js';
import Head from 'next/head'
import React from 'react'
import axios from 'axios';
import type { ReactElement } from 'react'
import LayoutAuthenticated from '../layouts/Authenticated'
import SectionMain from '../components/SectionMain'
import SectionTitleLineWithButton from '../components/SectionTitleLineWithButton'
import BaseIcon from "../components/BaseIcon";
import { getPageTitle } from '../config'
import Link from "next/link";
import { hasPermission } from "../helpers/userPermissions";
import { fetchWidgets } from '../stores/roles/rolesSlice';
import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator';
import { SmartWidget } from '../components/SmartWidget/SmartWidget';
import { useAppDispatch, useAppSelector } from '../stores/hooks';
const Dashboard = () => {
const dispatch = useAppDispatch();
const iconsColor = useAppSelector((state) => state.style.iconsColor);
const corners = useAppSelector((state) => state.style.corners);
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
const loadingMessage = 'Loading...';
const [users, setUsers] = React.useState(loadingMessage);
const [roles, setRoles] = React.useState(loadingMessage);
const [permissions, setPermissions] = React.useState(loadingMessage);
const [projects, setProjects] = React.useState(loadingMessage);
const [scripts, setScripts] = React.useState(loadingMessage);
const [builds, setBuilds] = React.useState(loadingMessage);
const [vm_configs, setVm_configs] = React.useState(loadingMessage);
const [opcode_sets, setOpcode_sets] = React.useState(loadingMessage);
const [constants, setConstants] = React.useState(loadingMessage);
const [audit_logs, setAudit_logs] = React.useState(loadingMessage);
const [widgetsRole, setWidgetsRole] = React.useState({
role: { value: '', label: '' },
});
const { currentUser } = useAppSelector((state) => state.auth);
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
const { rolesWidgets, loading } = useAppSelector((state) => state.roles);
async function loadData() {
const entities = ['users','roles','permissions','projects','scripts','builds','vm_configs','opcode_sets','constants','audit_logs',];
const fns = [setUsers,setRoles,setPermissions,setProjects,setScripts,setBuilds,setVm_configs,setOpcode_sets,setConstants,setAudit_logs,];
const requests = entities.map((entity, index) => {
if(hasPermission(currentUser, `READ_${entity.toUpperCase()}`)) {
return axios.get(`/${entity.toLowerCase()}/count`);
} else {
fns[index](null);
return Promise.resolve({data: {count: null}});
}
});
Promise.allSettled(requests).then((results) => {
results.forEach((result, i) => {
if (result.status === 'fulfilled') {
fns[i](result.value.data.count);
} else {
fns[i](result.reason.message);
}
});
});
}
async function getWidgets(roleId) {
await dispatch(fetchWidgets(roleId));
}
React.useEffect(() => {
if (!currentUser) return;
loadData().then();
setWidgetsRole({ role: { value: currentUser?.app_role?.id, label: currentUser?.app_role?.name } });
}, [currentUser]);
React.useEffect(() => {
if (!currentUser || !widgetsRole?.role?.value) return;
getWidgets(widgetsRole?.role?.value || '').then();
}, [widgetsRole?.role?.value]);
return (
<>
<Head>
<title>
{getPageTitle('Overview')}
</title>
</Head>
<SectionMain>
<SectionTitleLineWithButton
icon={icon.mdiChartTimelineVariant}
title='Overview'
main>
{''}
</SectionTitleLineWithButton>
{hasPermission(currentUser, 'CREATE_ROLES') && <WidgetCreator
currentUser={currentUser}
isFetchingQuery={isFetchingQuery}
setWidgetsRole={setWidgetsRole}
widgetsRole={widgetsRole}
/>}
{!!rolesWidgets.length &&
hasPermission(currentUser, 'CREATE_ROLES') && (
<p className=' text-gray-500 dark:text-gray-400 mb-4'>
{`${widgetsRole?.role?.label || 'Users'}'s widgets`}
</p>
)}
<div className='grid grid-cols-1 gap-6 lg:grid-cols-4 mb-6 grid-flow-dense'>
{(isFetchingQuery || loading) && (
<div className={` ${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 text-lg leading-tight text-gray-500 flex items-center ${cardsStyle} dark:border-dark-700 p-6`}>
<BaseIcon
className={`${iconsColor} animate-spin mr-5`}
w='w-16'
h='h-16'
size={48}
path={icon.mdiLoading}
/>{' '}
Loading widgets...
</div>
)}
{ rolesWidgets &&
rolesWidgets.map((widget) => (
<SmartWidget
key={widget.id}
userId={currentUser?.id}
widget={widget}
roleId={widgetsRole?.role?.value || ''}
admin={hasPermission(currentUser, 'CREATE_ROLES')}
/>
))}
</div>
{!!rolesWidgets.length && <hr className='my-6 ' />}
<div id="dashboard" className='grid grid-cols-1 gap-6 lg:grid-cols-3 mb-6'>
{hasPermission(currentUser, 'READ_USERS') && <Link href={'/users/users-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Users
</div>
<div className="text-3xl leading-tight font-semibold">
{users}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={icon.mdiAccountGroup || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_ROLES') && <Link href={'/roles/roles-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Roles
</div>
<div className="text-3xl leading-tight font-semibold">
{roles}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={icon.mdiShieldAccountVariantOutline || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_PERMISSIONS') && <Link href={'/permissions/permissions-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Permissions
</div>
<div className="text-3xl leading-tight font-semibold">
{permissions}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={icon.mdiShieldAccountOutline || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_PROJECTS') && <Link href={'/projects/projects-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Projects
</div>
<div className="text-3xl leading-tight font-semibold">
{projects}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={'mdiFolder' in icon ? icon['mdiFolder' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_SCRIPTS') && <Link href={'/scripts/scripts-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Scripts
</div>
<div className="text-3xl leading-tight font-semibold">
{scripts}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={'mdiCodeTags' in icon ? icon['mdiCodeTags' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_BUILDS') && <Link href={'/builds/builds-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Builds
</div>
<div className="text-3xl leading-tight font-semibold">
{builds}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={'mdiPlayCircle' in icon ? icon['mdiPlayCircle' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_VM_CONFIGS') && <Link href={'/vm_configs/vm_configs-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Vm configs
</div>
<div className="text-3xl leading-tight font-semibold">
{vm_configs}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={'mdiCpu' in icon ? icon['mdiCpu' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_OPCODE_SETS') && <Link href={'/opcode_sets/opcode_sets-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Opcode sets
</div>
<div className="text-3xl leading-tight font-semibold">
{opcode_sets}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={'mdiCodeBraces' in icon ? icon['mdiCodeBraces' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_CONSTANTS') && <Link href={'/constants/constants-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Constants
</div>
<div className="text-3xl leading-tight font-semibold">
{constants}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={'mdiKeyVariant' in icon ? icon['mdiKeyVariant' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
{hasPermission(currentUser, 'READ_AUDIT_LOGS') && <Link href={'/audit_logs/audit_logs-list'}>
<div
className={`${corners !== 'rounded-full'? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}
>
<div className="flex justify-between align-center">
<div>
<div className="text-lg leading-tight text-gray-500 dark:text-gray-400">
Audit logs
</div>
<div className="text-3xl leading-tight font-semibold">
{audit_logs}
</div>
</div>
<div>
<BaseIcon
className={`${iconsColor}`}
w="w-16"
h="h-16"
size={48}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
path={'mdiHistory' in icon ? icon['mdiHistory' as keyof typeof icon] : icon.mdiTable || icon.mdiTable}
/>
</div>
</div>
</div>
</Link>}
</div>
</SectionMain>
</>
)
}
Dashboard.getLayout = function getLayout(page: ReactElement) {
return <LayoutAuthenticated>{page}</LayoutAuthenticated>
}
export default Dashboard

View File

@ -1,166 +1,140 @@
import React, { useEffect, useState } from 'react';
import type { ReactElement } from 'react';
import * as icon from '@mdi/js';
import Head from 'next/head';
import Link from 'next/link';
import BaseButton from '../components/BaseButton';
import CardBox from '../components/CardBox';
import SectionFullScreen from '../components/SectionFullScreen';
import React, { useState } from 'react';
import axios from 'axios';
import type { ReactElement } from 'react';
import LayoutGuest from '../layouts/Guest';
import BaseDivider from '../components/BaseDivider';
import BaseButtons from '../components/BaseButtons';
import SectionMain from '../components/SectionMain';
import SectionTitleLineWithButton from '../components/SectionTitleLineWithButton';
import BaseIcon from "../components/BaseIcon";
import BaseButton from "../components/BaseButton";
import CardBox from "../components/CardBox";
import { getPageTitle } from '../config';
import { useAppSelector } from '../stores/hooks';
import CardBoxComponentTitle from "../components/CardBoxComponentTitle";
import { getPexelsImage, getPexelsVideo } from '../helpers/pexels';
export default function LuartexHome() {
const corners = useAppSelector((state) => state.style.corners);
const cardsStyle = useAppSelector((state) => state.style.cardsStyle);
export default function Starter() {
const [illustrationImage, setIllustrationImage] = useState({
src: undefined,
photographer: undefined,
photographer_url: undefined,
})
const [illustrationVideo, setIllustrationVideo] = useState({video_files: []})
const [contentType, setContentType] = useState('video');
const [contentPosition, setContentPosition] = useState('left');
const textColor = useAppSelector((state) => state.style.linkColor);
const [sourceCode, setSourceCode] = useState('print("Hello from Luartex!")');
const [protectedCode, setProtectedCode] = useState('');
const [isProtecting, setIsProtecting] = useState(false);
const title = 'Luartex VM Obfuscator'
// Fetch Pexels image/video
useEffect(() => {
async function fetchData() {
const image = await getPexelsImage();
const video = await getPexelsVideo();
setIllustrationImage(image);
setIllustrationVideo(video);
const handleProtect = async () => {
setIsProtecting(true);
try {
const response = await axios.post('/builds/protect', {
source: sourceCode,
config: {
opcodeShuffling: true,
constantEncryption: true
}
fetchData();
}, []);
const imageBlock = (image) => (
<div
className='hidden md:flex flex-col justify-end relative flex-grow-0 flex-shrink-0 w-1/3'
style={{
backgroundImage: `${
image
? `url(${image?.src?.original})`
: 'linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5))'
}`,
backgroundSize: 'cover',
backgroundPosition: 'left center',
backgroundRepeat: 'no-repeat',
}}
>
<div className='flex justify-center w-full bg-blue-300/20'>
<a
className='text-[8px]'
href={image?.photographer_url}
target='_blank'
rel='noreferrer'
>
Photo by {image?.photographer} on Pexels
</a>
</div>
</div>
);
const videoBlock = (video) => {
if (video?.video_files?.length > 0) {
return (
<div className='hidden md:flex flex-col justify-end relative flex-grow-0 flex-shrink-0 w-1/3'>
<video
className='absolute top-0 left-0 w-full h-full object-cover'
autoPlay
loop
muted
>
<source src={video?.video_files[0]?.link} type='video/mp4'/>
Your browser does not support the video tag.
</video>
<div className='flex justify-center w-full bg-blue-300/20 z-10'>
<a
className='text-[8px]'
href={video?.user?.url}
target='_blank'
rel='noreferrer'
>
Video by {video.user.name} on Pexels
</a>
</div>
</div>)
}
};
});
setProtectedCode(response.data.protectedCode);
} catch (error) {
console.error('Protection failed:', error);
setProtectedCode('-- Error: Protection failed. Check server logs.');
} finally {
setIsProtecting(false);
}
};
return (
<div
style={
contentPosition === 'background'
? {
backgroundImage: `${
illustrationImage
? `url(${illustrationImage.src?.original})`
: 'linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5))'
}`,
backgroundSize: 'cover',
backgroundPosition: 'left center',
backgroundRepeat: 'no-repeat',
}
: {}
}
>
<div className="bg-[#0D1117] min-h-screen text-white">
<Head>
<title>{getPageTitle('Starter Page')}</title>
<title>{getPageTitle('Luartex | Advanced Luau Protection')}</title>
</Head>
<SectionFullScreen bg='violet'>
<div
className={`flex ${
contentPosition === 'right' ? 'flex-row-reverse' : 'flex-row'
} min-h-screen w-full`}
>
{contentType === 'image' && contentPosition !== 'background'
? imageBlock(illustrationImage)
: null}
{contentType === 'video' && contentPosition !== 'background'
? videoBlock(illustrationVideo)
: null}
<div className='flex items-center justify-center flex-col space-y-4 w-full lg:w-full'>
<CardBox className='w-full md:w-3/5 lg:w-2/3'>
<CardBoxComponentTitle title="Welcome to your Luartex VM Obfuscator app!"/>
<div className="space-y-3">
<p className='text-center text-gray-500'>This is a React.js/Node.js app generated by the <a className={`${textColor}`} href="https://flatlogic.com/generator">Flatlogic Web App Generator</a></p>
<p className='text-center text-gray-500'>For guides and documentation please check
your local README.md and the <a className={`${textColor}`} href="https://flatlogic.com/documentation">Flatlogic documentation</a></p>
</div>
<BaseButtons>
<BaseButton
href='/login'
label='Login'
color='info'
className='w-full'
/>
</BaseButtons>
</CardBox>
<div className="py-12 px-4 max-w-7xl mx-auto">
<div className="text-center mb-16 space-y-4">
<h1 className="text-6xl md:text-8xl font-black tracking-tighter text-transparent bg-clip-text bg-gradient-to-r from-green-400 to-blue-500">
LUARTEX
</h1>
<p className="text-xl text-gray-400 font-light max-w-2xl mx-auto">
Heavyweight <span className="text-green-400 font-semibold">Luau Virtual Machine</span> protection.
Transform your scripts into unreadable, irreversible bytecode.
</p>
</div>
</div>
</SectionFullScreen>
<div className='bg-black text-white flex flex-col text-center justify-center md:flex-row'>
<p className='py-6 text-sm'>© 2026 <span>{title}</span>. All rights reserved</p>
<Link className='py-6 ml-4 text-sm' href='/privacy-policy/'>
Privacy Policy
</Link>
<SectionMain>
<SectionTitleLineWithButton
icon={icon.mdiCodeTags}
title='Luartex Playground'
main>
<BaseButton
label={isProtecting ? 'Protecting...' : 'Protect Script'}
color='success'
icon={icon.mdiShieldLock}
onClick={handleProtect}
disabled={isProtecting}
className="rounded-full px-8 py-2 font-bold"
/>
</SectionTitleLineWithButton>
<div className='grid grid-cols-1 gap-6 lg:grid-cols-2 mb-12'>
<CardBox className={`${cardsStyle} ${corners} bg-[#161B22] border-gray-800`}>
<div className="mb-3 flex items-center justify-between">
<span className="text-sm font-bold uppercase tracking-wider text-gray-400">Source Luau</span>
<BaseIcon path={icon.mdiLanguageLua} size={18} className="text-green-400" />
</div>
<textarea
className="w-full h-[500px] p-4 font-mono text-sm bg-gray-900 text-green-400 border border-gray-800 focus:ring-1 focus:ring-green-500 rounded-lg resize-none"
value={sourceCode}
onChange={(e) => setSourceCode(e.target.value)}
spellCheck={false}
/>
</CardBox>
<CardBox className={`${cardsStyle} ${corners} bg-[#161B22] border-gray-800`}>
<div className="mb-3 flex items-center justify-between">
<span className="text-sm font-bold uppercase tracking-wider text-gray-400">Protected Output (VM)</span>
<BaseIcon path={icon.mdiShieldCheck} size={18} className="text-blue-400" />
</div>
<textarea
className="w-full h-[500px] p-4 font-mono text-sm bg-gray-900 text-blue-400 border border-gray-800 rounded-lg resize-none"
value={protectedCode}
readOnly
placeholder="Click 'Protect Script' to generate VM-protected code..."
spellCheck={false}
/>
</CardBox>
</div>
<div className='grid grid-cols-1 gap-6 lg:grid-cols-4 mb-12'>
<div className={`${corners} ${cardsStyle} p-6 bg-[#161B22] border-l-4 border-green-500 border-gray-800`}>
<div className="text-gray-400 text-xs uppercase font-bold">Opcodes Shuffled</div>
<div className="text-2xl font-bold">RANDOMIZED</div>
</div>
<div className={`${corners} ${cardsStyle} p-6 bg-[#161B22] border-l-4 border-blue-500 border-gray-800`}>
<div className="text-gray-400 text-xs uppercase font-bold">Constants Encrypted</div>
<div className="text-2xl font-bold">MULTI-LAYER</div>
</div>
<div className={`${corners} ${cardsStyle} p-6 bg-[#161B22] border-l-4 border-yellow-500 border-gray-800`}>
<div className="text-gray-400 text-xs uppercase font-bold">VM Hardening</div>
<div className="text-2xl font-bold text-yellow-500">ACTIVE</div>
</div>
<div className={`${corners} ${cardsStyle} p-6 bg-[#161B22] border-l-4 border-red-500 border-gray-800`}>
<div className="text-gray-400 text-xs uppercase font-bold">Anti-Dump</div>
<div className="text-2xl font-bold text-red-500">ENABLED</div>
</div>
</div>
</SectionMain>
</div>
<footer className="border-t border-gray-800 bg-[#0D1117] py-12">
<div className="max-w-7xl mx-auto px-4 flex flex-col md:flex-row justify-between items-center text-gray-500 text-sm">
<p>© 2026 Luartex Protection Systems. Authorized defensive use only.</p>
<div className="flex space-x-6 mt-4 md:mt-0">
<span className="font-mono text-xs text-green-500/50">ROBLOX LUAU</span>
<span className="font-mono text-xs text-blue-500/50">VIRTUALIZATION</span>
<span className="font-mono text-xs text-purple-500/50">AES-256</span>
</div>
</div>
</footer>
</div>
);
}
Starter.getLayout = function getLayout(page: ReactElement) {
LuartexHome.getLayout = function getLayout(page: ReactElement) {
return <LayoutGuest>{page}</LayoutGuest>;
};

View File

@ -1,5 +1,3 @@
import React, { useEffect, useState } from 'react';
import type { ReactElement } from 'react';
import Head from 'next/head';
@ -62,10 +60,10 @@ export default function Login() {
dispatch(findMe());
}
}, [token, dispatch]);
// Redirect to dashboard if user is logged in
// Redirect to home if user is logged in
useEffect(() => {
if (currentUser?.id) {
router.push('/dashboard');
router.push('/');
}
}, [currentUser?.id, router]);
// Show error message if there is one
@ -273,4 +271,4 @@ export default function Login() {
Login.getLayout = function getLayout(page: ReactElement) {
return <LayoutGuest>{page}</LayoutGuest>;
};
};