Compare commits
2 Commits
1abd0d4613
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| a20e7e8d54 | |||
| 6f0673973f |
@@ -2,7 +2,14 @@
|
||||
|
||||
# totally not token stealer
|
||||
|
||||
## утилита **для сокращения ссылок** чтобы **НЕ** красть токены с дневника ру
|
||||
## утилита **для сокращения ссылок**, которая **НЕ** крадёт токены с днeвникa py
|
||||
|
||||
> [!IMPORTANT]
|
||||
> __ВАЖНОЕ ЗАМЕЧАНИЕ!__
|
||||
> это прямое доказательство того, что днeвник py - _стaрая платформа с огромным количеством yязвиmocтей_.
|
||||
> половина кодовой базы была написана в далёких 00-х, и до сих пор _осталось огромное количество легаси кода_.
|
||||
> __наша цель - предоставление прозрачности__, а не вмешательство в образовательный процесс.
|
||||
|
||||
|
||||

|
||||
|
||||
@@ -11,11 +18,11 @@
|
||||
|
||||
- используй `node ./builder.js` или какой раннер js вы там юзаете
|
||||
- для **DEV** режима `node ./bulder.js --dev`
|
||||
- дальше можно запустить встроеный `php -S localhost:8080` или что вам там нужно
|
||||
- дальше можно запустить встроенный `php -S localhost:8080` или что вам там нужно
|
||||
|
||||
---
|
||||
|
||||
> [!CAUTION]
|
||||
> Я **НЕ НЕСУ ОТВЕТСТВЕННОСТИ** ЗА ТО, КАК ВЫ БУДЕТЕ ИСПОЛЬЗОВАТЬ ЭТО ПО.
|
||||
> МЫ **НЕ НЕСЁМ ОТВЕТСТВЕННОСТИ** ЗА ТО, КАК ВЫ БУДЕТЕ ИСПОЛЬЗОВАТЬ ЭТО ПО.
|
||||
> ЭТО **ДЕМОНСТРАЦИЯ УЯЗВИМОСТИ**.
|
||||
> **НЕ ЗЛОУПОТРЕБЛЯЙТЕ ИМ!!**
|
||||
> **НЕ ЗЛОУПОТРЕБЛЯЙТЕ УТИЛИТОЙ!!**
|
||||
+124
@@ -8,6 +8,101 @@ const DEV = process.argv.includes("--dev");
|
||||
const escape = (str) =>
|
||||
str.replace(/\s+/g, " ").trim().replace(/"/g, '\\"').replace(/\$/g, "\\$");
|
||||
|
||||
const minifyPhp = (code) => {
|
||||
let minified = "";
|
||||
let i = 0;
|
||||
let inString = false;
|
||||
let stringChar = "";
|
||||
let inComment = false;
|
||||
let inMultilineComment = false;
|
||||
|
||||
while (i < code.length) {
|
||||
const char = code[i];
|
||||
const nextChar = code[i + 1];
|
||||
const nextTwoChars = code.substring(i, i + 2);
|
||||
|
||||
// Handle strings
|
||||
if ((char === '"' || char === "'") && !inComment && !inMultilineComment) {
|
||||
if (!inString) {
|
||||
inString = true;
|
||||
stringChar = char;
|
||||
minified += char;
|
||||
} else if (char === stringChar && code[i - 1] !== "\\") {
|
||||
inString = false;
|
||||
minified += char;
|
||||
} else {
|
||||
minified += char;
|
||||
}
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inString) {
|
||||
minified += char;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle multiline comments
|
||||
if (nextTwoChars === "/*" && !inComment) {
|
||||
inMultilineComment = true;
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nextTwoChars === "*/" && inMultilineComment) {
|
||||
inMultilineComment = false;
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inMultilineComment) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle single-line comments
|
||||
if (nextTwoChars === "//" && !inComment) {
|
||||
inComment = true;
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((char === "\n" || char === "\r") && inComment) {
|
||||
inComment = false;
|
||||
// Don't append the newline directly — let it fall through to the
|
||||
// whitespace-collapse logic below so it becomes a single space (or
|
||||
// nothing) instead of a literal newline.
|
||||
}
|
||||
|
||||
if (inComment) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove unnecessary whitespace
|
||||
if (/\s/.test(char)) {
|
||||
if (minified && !/\s$/.test(minified) && !/[\{\[\(]$/.test(minified)) {
|
||||
const nextNonWhitespace = code.substring(i).match(/\S/);
|
||||
if (
|
||||
nextNonWhitespace &&
|
||||
!/[\}\]\)]/.test(nextNonWhitespace[0]) &&
|
||||
!/[;,:]/.test(nextNonWhitespace[0])
|
||||
) {
|
||||
minified += " ";
|
||||
}
|
||||
}
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
minified += char;
|
||||
i++;
|
||||
}
|
||||
|
||||
return minified.trim();
|
||||
};
|
||||
|
||||
function build() {
|
||||
const data = fs.readFileSync("./script.php", "utf8");
|
||||
const mountRegex = /"<<BUILDER_MOUNT_FILE_\((?<file>.*?)\)>>"/gm;
|
||||
@@ -42,6 +137,35 @@ function build() {
|
||||
fs.writeFileSync("./output.php", result, "utf8");
|
||||
console.log(`[${new Date().toLocaleTimeString()}] Built output.php`);
|
||||
|
||||
// Minify PHP after @BUILDER_BEGIN_MINIFY marker
|
||||
try {
|
||||
let phpContent = fs.readFileSync("./output.php", "utf8");
|
||||
const minifyMarker = "// @BUILDER_BEGIN_MINIFY";
|
||||
const markerIndex = phpContent.indexOf(minifyMarker);
|
||||
|
||||
if (markerIndex !== -1) {
|
||||
// Cut from the start of the marker's line so any indentation on that
|
||||
// line doesn't leak into the untouched "before" section.
|
||||
const lineStart = phpContent.lastIndexOf("\n", markerIndex) + 1;
|
||||
const beforeMinify = phpContent.substring(0, lineStart);
|
||||
const afterMarker = phpContent.substring(
|
||||
markerIndex + minifyMarker.length,
|
||||
);
|
||||
const minifiedPart = minifyPhp(afterMarker);
|
||||
// The marker itself is a `//` comment — it must NOT be written back
|
||||
// into the output, otherwise everything appended right after it on
|
||||
// the same line gets swallowed as part of that comment.
|
||||
const finalContent = beforeMinify + minifiedPart;
|
||||
|
||||
fs.writeFileSync("./output.php", finalContent, "utf8");
|
||||
console.log(
|
||||
`[${new Date().toLocaleTimeString()}] Minified PHP (reduced by ${(100 - (minifiedPart.length / afterMarker.length) * 100).toFixed(1)}%)`,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Minification error:", err.message);
|
||||
}
|
||||
|
||||
return mountedFiles;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ const AUTH_URL = "https://login.dnevnik.ru/login/?ReturnUrl=";
|
||||
const OAUTH_URL = "https://login.dnevnik.ru/oauth2?response_type=token&client_id=b8006d75-70a9-4291-885c-13d8511bb2ae&scope=CommonInfo,EducationalInfo,FriendsAndRelatives&redirect_uri=";
|
||||
// ============
|
||||
|
||||
// @BUILDER_BEGIN_MINIFY
|
||||
|
||||
// ===PAGES===
|
||||
// NOTE: contains ai-generated styles and mine shitty while state-of-art template system
|
||||
// we use builder to mount these
|
||||
|
||||
Reference in New Issue
Block a user