{"id":64901,"date":"2024-06-16T22:12:11","date_gmt":"2024-06-16T22:12:11","guid":{"rendered":"https:\/\/viktor.xyz\/?page_id=64901"},"modified":"2024-06-16T22:18:26","modified_gmt":"2024-06-16T22:18:26","slug":"codesys-password-library","status":"publish","type":"page","link":"https:\/\/viktor.xyz\/index.php\/codesys-password-library\/","title":{"rendered":"CoDeSys password library decoder"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This is a tool that I created for revealing the password encoded in the libraries for CodeSys V2.<\/p>\n\n\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>LIB File Hex Decoder<\/title>\n    <style>\n        body {\n            font-family: Arial, sans-serif;\n            padding: 20px;\n            background-color: #f0f0f0;\n        }\n        h1 {\n            font-size: 24px;\n            margin-bottom: 20px;\n        }\n        .container {\n            background-color: #ffffff;\n            padding: 20px;\n            border-radius: 8px;\n            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n        }\n        .file-input {\n            margin-bottom: 20px;\n        }\n        .result {\n            margin-top: 20px;\n            white-space: pre-wrap;\n            font-family: monospace;\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"container\">\n        <h1>Display password from CodeSys library<\/h1>\n        <input type=\"file\" id=\"fileInput\" class=\"file-input\" \/>\n        <div class=\"result\" id=\"result\"><\/div>\n    <\/div>\n\n    <script>\n        document.getElementById('fileInput').addEventListener('change', function(event) {\n            const file = event.target.files[0];\n            if (!file) {\n                return;\n            }\n\n            const reader = new FileReader();\n            reader.onload = function(event) {\n                const arrayBuffer = event.target.result;\n                const byteArray = new Uint8Array(arrayBuffer);\n                const searchString = new TextEncoder().encode('Visualizations');\n                const searchIndex = searchArray(byteArray, searchString);\n\n                if (searchIndex === -1) {\n                    displayResult(\"The string 'Visualizations' was not found in the .lib file.\");\n                    return;\n                }\n\n                const startIndex = searchIndex + searchString.length + 13;\n                let endIndex = startIndex;\n\n                while (endIndex < byteArray.length &#038;&#038; byteArray[endIndex] !== 0x00) {\n                    endIndex++;\n                }\n\n                const hexValues = byteArray.slice(startIndex, endIndex);\n                const hexString = Array.from(hexValues).map(byte => byte.toString(16).padStart(2, '0')).join(' ');\n                const textOutput = hexToText(hexValues);\n\n                displayResult(`HEX values found: ${hexString}\\n\\nFound and decoded password: ${textOutput}`);\n            };\n\n            reader.readAsArrayBuffer(file);\n        });\n\n        function searchArray(haystack, needle) {\n            for (let i = 0; i <= haystack.length - needle.length; i++) {\n                let found = true;\n                for (let j = 0; j < needle.length; j++) {\n                    if (haystack[i + j] !== needle[j]) {\n                        found = false;\n                        break;\n                    }\n                }\n                if (found) {\n                    return i;\n                }\n            }\n            return -1;\n        }\n\n        function hexToText(hexValues) {\n            const key = 0xA5;\n            let text = \"\";\n            for (const byte of hexValues) {\n                text += String.fromCharCode(byte ^ key);\n            }\n            return text;\n        }\n\n        function displayResult(message) {\n            document.getElementById('result').textContent = message;\n        }\n    <\/script>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>This is a tool that I created for revealing the password encoded in the libraries for CodeSys V2. LIB File Hex Decoder Display password from CodeSys library<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-64901","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/pages\/64901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=64901"}],"version-history":[{"count":1,"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/pages\/64901\/revisions"}],"predecessor-version":[{"id":64902,"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/pages\/64901\/revisions\/64902"}],"wp:attachment":[{"href":"https:\/\/viktor.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=64901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}