{"id":473786,"date":"2025-09-03T09:01:07","date_gmt":"2025-09-03T09:01:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=473786"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=473786","title":{"rendered":"<span>\u0414\u0432\u043e\u0439\u043d\u043e\u0435 \u0434\u043d\u043e: \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f .CHA \u043d\u0430 Python \u0438 \u043f\u0440\u044f\u0447\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043e \u0437\u0430\u0449\u0438\u0442\u0435 \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0434\u0432\u0430 \u043f\u0443\u0442\u0438: <strong>\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong> \u0438 <strong>\u0441\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f<\/strong>. \u041f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445. \u0412\u0442\u043e\u0440\u043e\u0439 \u2014 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0430\u043c \u0444\u0430\u043a\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c. \u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0432 \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0448\u0435\u043c\u0443 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 &#171;\u0434\u0432\u043e\u0439\u043d\u043e\u0435 \u0434\u043d\u043e&#187; \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445?<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0442\u0435\u043e\u0440\u0438\u044e, \u0430 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e, \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c \u043a\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>.cha<\/code> (\u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 Chameleon) \u043d\u0430 Python. \u0410 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c LSB-\u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u00ab<a href=\"https:\/\/habr.com\/ru\/articles\/938684\/\" rel=\"noopener noreferrer nofollow\">ChameleonLab<\/a>\u00bb \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u0438 \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ffe\/b90\/085\/ffeb9008575a537783888e46b02cb9ab.png\" width=\"852\" height=\"677\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ffe\/b90\/085\/ffeb9008575a537783888e46b02cb9ab.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ffe\/b90\/085\/ffeb9008575a537783888e46b02cb9ab.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>\u0427\u0430\u0441\u0442\u044c 1: \u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f .CHA \u043d\u0430 Python<\/h2>\n<p>\u0426\u0435\u043b\u044c \u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0434\u0435\u0436\u043d\u043e \u0448\u0438\u0444\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u043e\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>cryptography<\/code>.<\/p>\n<h3>\u0428\u0430\u0433 1: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0438\u0437 \u043f\u0430\u0440\u043e\u043b\u044f (KDF)<\/h3>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f! \u0415\u0433\u043e \u043d\u0443\u0436\u043d\u043e &#171;\u0440\u0430\u0441\u0442\u044f\u043d\u0443\u0442\u044c&#187; \u0434\u043e \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u043e\u0439\u043a\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0435\u0440\u0438\u0432\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 (KDF). \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c PBKDF2 \u0441\u043e 100 000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<pre><code class=\"python\"># \u0418\u0437 crypto_utils.py from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC import base64 import os  def generate_key_from_password(password: str, salt: bytes) -&gt; bytes:     \"\"\"     \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 32-\u0431\u0430\u0439\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0438\u0437 \u043f\u0430\u0440\u043e\u043b\u044f \u0438 \u0441\u043e\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PBKDF2-HMAC-SHA256.     \"\"\"     kdf = PBKDF2HMAC(         algorithm=hashes.SHA256(),         length=32,  # \u0414\u043b\u0438\u043d\u0430 \u043a\u043b\u044e\u0447\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445 (256 \u0431\u0438\u0442 \u0434\u043b\u044f AES)         salt=salt,         iterations=100000, # \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439     )     # \u041a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447 \u0432 URL-safe Base64 \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 Fernet     return base64.urlsafe_b64encode(kdf.derive(password.encode())) <\/code><\/pre>\n<h3>\u0428\u0430\u0433 2: \u0423\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0430\u0448\u0435\u0433\u043e <code>.cha<\/code> \u0444\u0430\u0439\u043b\u0430: <code>[\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e] + [\u0421\u043e\u043b\u044c] + [\u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435]<\/code>.<\/p>\n<ul>\n<li>\n<p><strong>\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e (<\/strong><code><strong>b'CHAMELEON'<\/strong><\/code><strong>)<\/strong>: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u043e\u043f\u043e\u0437\u043d\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u043b\u044c<\/strong>: 16 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0431\u0430\u0439\u0442 \u0434\u043b\u044f PBKDF2.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong>: \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 <strong>Fernet<\/strong> (AES-128-CBC + HMAC-SHA256), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\"># \u0418\u0437 crypto_utils.py from cryptography.fernet import Fernet from pathlib import Path  MAGIC_NUMBER = b'CHAMELEON'  def encrypt_cha_file(input_path: str, output_path: str, password: str):     \"\"\"\u0428\u0438\u0444\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 .cha, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430.\"\"\"     input_path = Path(input_path)     with open(input_path, 'rb') as f:         plaintext = f.read()      # \u0423\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c '|'     packaged_data = input_path.name.encode('utf-8') + b'|' + plaintext     salt = os.urandom(16)     key = generate_key_from_password(password, salt)     f = Fernet(key)     encrypted_data = f.encrypt(packaged_data)      with open(output_path, 'wb') as f_out:         f_out.write(MAGIC_NUMBER)         f_out.write(salt)         f_out.write(encrypted_data) <\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 UI \u043d\u0430 \u0432\u043a\u043b\u0430\u0434\u043a\u0435 &#171;\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432&#187;.<\/p>\n<h3>\u0428\u0430\u0433 3: \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430<\/h3>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439, \u043d\u043e \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c: <code>fernet.decrypt()<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442 HMAC-\u043f\u043e\u0434\u043f\u0438\u0441\u044c. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u044b \u0438\u043b\u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0435\u0432\u0435\u0440\u0435\u043d, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>InvalidToken<\/code>, \u0437\u0430\u0449\u0438\u0449\u0430\u044f \u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"python\"># \u0418\u0437 crypto_utils.py def decrypt_cha_file(input_path: str, output_path: str, password: str) -&gt; str:     \"\"\"\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 .cha \u0444\u0430\u0439\u043b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430.\"\"\"     with open(input_path, 'rb') as f:         if f.read(len(MAGIC_NUMBER)) != MAGIC_NUMBER:             raise ValueError(\"\u042d\u0442\u043e \u043d\u0435 \u0444\u0430\u0439\u043b \u0444\u043e\u0440\u043c\u0430\u0442\u0430 .cha \u0438\u043b\u0438 \u043e\u043d \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d.\")         salt = f.read(16)         encrypted_data = f.read()      key = generate_key_from_password(password, salt)     f = Fernet(key)     decrypted_packaged_data = f.decrypt(encrypted_data)      filename_bytes, file_content = decrypted_packaged_data.split(b'|', 1)     original_filename = filename_bytes.decode('utf-8')      with open(output_path, 'wb') as f_out:         f_out.write(file_content)     return original_filename <\/code><\/pre>\n<h2>\u0427\u0430\u0441\u0442\u044c 2: \u041f\u0440\u044f\u0447\u0435\u043c \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u043e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u044b\u043c. \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438, \u0447\u0442\u043e \u0435\u0449\u0435 \u0432\u0430\u0436\u043d\u0435\u0435, \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0439\u0442\u0438 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438?<\/p>\n<h3>\u0428\u0430\u0433 2a: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 &#171;\u0421\u0442\u0435\u0433\u043e-\u041f\u0430\u043a\u0435\u0442\u0430&#187;<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043c\u043e\u0433\u043b\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043c\u044b &#171;\u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c&#187; \u043d\u0430\u0448 <code>.cha<\/code> \u0444\u0430\u0439\u043b \u0432 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441\u043e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u0435\u0433\u043e-\u043f\u0430\u043a\u0435\u0442\u0430:<\/p>\n<p><code>[\u0414\u043b\u0438\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (4\u0431)] + [\u0427\u0438\u0441\u043b\u043e \u0431\u0438\u0442 (1\u0431)] + [\u0421\u0418\u0413\u041d\u0410\u0422\u0423\u0420\u0410 (4\u0431)] + [\u0424\u043b\u0430\u0433 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f (1\u0431)] + [\u0421\u0430\u043c \u0444\u0430\u0439\u043b]<\/code><\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0434\u0435\u0441\u044c \u2014 <strong>\u0421\u0418\u0413\u041d\u0410\u0422\u0423\u0420\u0410 (<\/strong><code><strong>b'S6KB'<\/strong><\/code><strong>)<\/strong>. \u042d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 &#171;\u043c\u0430\u044f\u0447\u043e\u043a&#187;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u0449\u0435\u0442 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u0428\u0430\u0433 2b: \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f (hide)<\/h3>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>hide<\/code> \u0431\u0435\u0440\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0430\u043a\u0435\u0442 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0431\u0438\u0442\u044b \u0432 \u043c\u043b\u0430\u0434\u0448\u0438\u0435 \u0431\u0438\u0442\u044b (LSB) \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\"># steganography_core.py def hide(carrier_bytes: np.ndarray, final_payload: bytes, n_bits: int, is_encrypted: bool) -&gt; np.ndarray:     encryption_flag = b'\\x01' if is_encrypted else b'\\x00'     data_to_hide = MAGIC_NUMBER + encryption_flag + final_payload     metadata_len = len(data_to_hide).to_bytes(4, 'big')     n_bits_val = int(n_bits).to_bytes(1, 'big')     full_data = metadata_len + n_bits_val + data_to_hide     full_bits = data_to_binary(full_data)      carrier_flat = carrier_bytes.flatten().copy().astype(np.uint8)     mask = ~((1 &lt;&lt; n_bits) - 1) &amp; 0xFF     carrier_flat &amp;= mask      bit_index = 0     for i in range(math.ceil(len(full_bits) \/ n_bits)):         chunk = full_bits[bit_index : bit_index + n_bits].ljust(n_bits, '0')         carrier_flat[i] |= int(chunk, 2)         bit_index += n_bits      return carrier_flat.reshape(carrier_bytes.shape) <\/code><\/pre>\n<h3>\u0428\u0430\u0433 2c: \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 (reveal)<\/h3>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e LSB \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442 1 \u0434\u043e 8. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043e\u043d\u0430 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u043d\u0430\u0439\u0442\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443.<\/p>\n<pre><code class=\"python\"># steganography_core.py def reveal(carrier_bytes: np.ndarray) -&gt; Tuple[bytes, bool, bool]:     flat = carrier_bytes.flatten().astype(np.uint8)     METADATA_BITS = 40      for candidate_n in range(1, 9):         bytes_for_metadata = math.ceil(METADATA_BITS \/ candidate_n)         if flat.size &lt; bytes_for_metadata: continue         bitstream = _get_bitstream(flat, candidate_n, bytes_for_metadata)         if len(bitstream) &lt; METADATA_BITS: continue          data_len = int(bitstream[:32], 2)         declared_n = int(bitstream[32:40], 2)          if declared_n != candidate_n: continue          total_bytes_to_read = math.ceil((5 + data_len) * 8 \/ declared_n)         full_bitstream = _get_bitstream(flat, declared_n, total_bytes_to_read)         full_bytes = binary_to_data(full_bitstream)         data_to_hide = full_bytes[5 : 5 + data_len]                  if data_to_hide.startswith(MAGIC_NUMBER):             header_len = len(MAGIC_NUMBER)             is_encrypted = (data_to_hide[header_len] == 1)             packaged_data = data_to_hide[header_len + 1:]             return packaged_data, is_encrypted, True      return b'', False, False <\/code><\/pre>\n<h2>\u0427\u0430\u0441\u0442\u044c 3: \u0421\u0438\u043d\u0435\u0440\u0433\u0438\u044f: \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 + \u0421\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f = \u2764\ufe0f<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u043a\u0438 <code>.cha<\/code> \u0438 \u0441\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0434\u0430\u0435\u0442 \u0434\u0432\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0443\u0440\u043e\u0432\u043d\u044f \u0437\u0430\u0449\u0438\u0442\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c 1: \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u041a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c)<\/strong>: \u0412\u044b \u0431\u0435\u0440\u0435\u0442\u0435 \u0432\u0430\u0448 <code>my_plan.docx<\/code> \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 <code>my_plan.docx.cha<\/code>. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u0435\u0433\u043e \u043d\u0430\u0439\u0434\u0435\u0442, \u043e\u043d \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u043f\u0430\u0440\u043e\u043b\u044f \u0438\u043b\u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b4e\/967\/870\/b4e967870518460021d345f2d7984232.png\" alt=\"\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &quot;ChameleonLab&quot;. \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \" title=\"\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &quot;ChameleonLab&quot;. \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \" width=\"1444\" height=\"867\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b4e\/967\/870\/b4e967870518460021d345f2d7984232.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b4e\/967\/870\/b4e967870518460021d345f2d7984232.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &#171;ChameleonLab&#187;. \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <\/figcaption><\/div>\n<\/figure>\n<\/li>\n<li>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c 2: \u0421\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f (\u0421\u043a\u0440\u044b\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435)<\/strong>: \u0412\u044b \u0431\u0435\u0440\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 <code>my_plan.docx.cha<\/code> \u0438 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e <code>kitten.png<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f \u043d\u0435\u0442 \u0434\u0430\u0436\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0424\u0430\u0439\u043b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0449\u0438\u0449\u0435\u043d \u2014 <strong>\u043e\u043d \u043d\u0435\u0432\u0438\u0434\u0438\u043c<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/350\/d0f\/015\/350d0f015bc86b3e758f95e1e4998335.png\" alt=\"\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &quot;ChameleonLab&quot;. \u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435\" title=\"\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &quot;ChameleonLab&quot;. \u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435\" width=\"1441\" height=\"864\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/350\/d0f\/015\/350d0f015bc86b3e758f95e1e4998335.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/350\/d0f\/015\/350d0f015bc86b3e758f95e1e4998335.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &#171;ChameleonLab&#187;. \u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u0430 \u0434\u0432\u0443\u0445\u0441\u0442\u0443\u043f\u0435\u043d\u0447\u0430\u0442\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u2014 \u0438 \u0435\u0441\u0442\u044c \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0438\u044f ChameleonLab. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u044b\u043c\u0438. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 <strong>\u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435<\/strong>: \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430, \u0438 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u00abSteganographia\u00bb \u043e\u0442 ChameleonLab \u0434\u043b\u044f Windows \u0438 macOS \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435. <a href=\"https:\/\/chalab.ru\" rel=\"noopener noreferrer nofollow\"><strong>https:\/\/chalab.ru<\/strong><\/a><\/p>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439, \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0435\u0434\u0438\u043d\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 Telegram-\u043a\u0430\u043d\u0430\u043b\u0443: <a href=\"https:\/\/t.me\/ChameleonLab\" rel=\"noopener noreferrer nofollow\"><strong>https:\/\/t.me\/ChameleonLab<\/strong><\/a><\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/943402\/\"> https:\/\/habr.com\/ru\/articles\/943402\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043e \u0437\u0430\u0449\u0438\u0442\u0435 \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0434\u0432\u0430 \u043f\u0443\u0442\u0438: <strong>\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong> \u0438 <strong>\u0441\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f<\/strong>. \u041f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445. \u0412\u0442\u043e\u0440\u043e\u0439 \u2014 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0430\u043c \u0444\u0430\u043a\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c. \u0410 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0432 \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0448\u0435\u043c\u0443 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0435 &#171;\u0434\u0432\u043e\u0439\u043d\u043e\u0435 \u0434\u043d\u043e&#187; \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445?<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u0442\u0435\u043e\u0440\u0438\u044e, \u0430 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e, \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c \u043a\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>.cha<\/code> (\u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 Chameleon) \u043d\u0430 Python. \u0410 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c LSB-\u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u00ab<a href=\"https:\/\/habr.com\/ru\/articles\/938684\/\" rel=\"noopener noreferrer nofollow\">ChameleonLab<\/a>\u00bb \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u0438 \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>\u0427\u0430\u0441\u0442\u044c 1: \u041f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f .CHA \u043d\u0430 Python<\/h2>\n<p>\u0426\u0435\u043b\u044c \u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0434\u0435\u0436\u043d\u043e \u0448\u0438\u0444\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u0440\u043e\u043b\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>cryptography<\/code>.<\/p>\n<h3>\u0428\u0430\u0433 1: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0430 \u0438\u0437 \u043f\u0430\u0440\u043e\u043b\u044f (KDF)<\/h3>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f! \u0415\u0433\u043e \u043d\u0443\u0436\u043d\u043e &#171;\u0440\u0430\u0441\u0442\u044f\u043d\u0443\u0442\u044c&#187; \u0434\u043e \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u043e\u0439\u043a\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0435\u0440\u0438\u0432\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 (KDF). \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c PBKDF2 \u0441\u043e 100 000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<pre><code class=\"python\"># \u0418\u0437 crypto_utils.py from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC import base64 import os  def generate_key_from_password(password: str, salt: bytes) -&gt; bytes:     \"\"\"     \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 32-\u0431\u0430\u0439\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0438\u0437 \u043f\u0430\u0440\u043e\u043b\u044f \u0438 \u0441\u043e\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PBKDF2-HMAC-SHA256.     \"\"\"     kdf = PBKDF2HMAC(         algorithm=hashes.SHA256(),         length=32,  # \u0414\u043b\u0438\u043d\u0430 \u043a\u043b\u044e\u0447\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445 (256 \u0431\u0438\u0442 \u0434\u043b\u044f AES)         salt=salt,         iterations=100000, # \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439     )     # \u041a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u044e\u0447 \u0432 URL-safe Base64 \u0434\u043b\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441 Fernet     return base64.urlsafe_b64encode(kdf.derive(password.encode())) <\/code><\/pre>\n<h3>\u0428\u0430\u0433 2: \u0423\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430<\/h3>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0430\u0448\u0435\u0433\u043e <code>.cha<\/code> \u0444\u0430\u0439\u043b\u0430: <code>[\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e] + [\u0421\u043e\u043b\u044c] + [\u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435]<\/code>.<\/p>\n<ul>\n<li>\n<p><strong>\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e (<\/strong><code><strong>b'CHAMELEON'<\/strong><\/code><strong>)<\/strong>: \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u043e\u043f\u043e\u0437\u043d\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u043b\u044c<\/strong>: 16 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0431\u0430\u0439\u0442 \u0434\u043b\u044f PBKDF2.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong>: \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 <strong>Fernet<\/strong> (AES-128-CBC + HMAC-SHA256), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\"># \u0418\u0437 crypto_utils.py from cryptography.fernet import Fernet from pathlib import Path  MAGIC_NUMBER = b'CHAMELEON'  def encrypt_cha_file(input_path: str, output_path: str, password: str):     \"\"\"\u0428\u0438\u0444\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 .cha, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430.\"\"\"     input_path = Path(input_path)     with open(input_path, 'rb') as f:         plaintext = f.read()      # \u0423\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c '|'     packaged_data = input_path.name.encode('utf-8') + b'|' + plaintext     salt = os.urandom(16)     key = generate_key_from_password(password, salt)     f = Fernet(key)     encrypted_data = f.encrypt(packaged_data)      with open(output_path, 'wb') as f_out:         f_out.write(MAGIC_NUMBER)         f_out.write(salt)         f_out.write(encrypted_data) <\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 UI \u043d\u0430 \u0432\u043a\u043b\u0430\u0434\u043a\u0435 &#171;\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432&#187;.<\/p>\n<h3>\u0428\u0430\u0433 3: \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430<\/h3>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439, \u043d\u043e \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c: <code>fernet.decrypt()<\/code> \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442 HMAC-\u043f\u043e\u0434\u043f\u0438\u0441\u044c. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u044b \u0438\u043b\u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0435\u0432\u0435\u0440\u0435\u043d, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>InvalidToken<\/code>, \u0437\u0430\u0449\u0438\u0449\u0430\u044f \u043e\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"python\"># \u0418\u0437 crypto_utils.py def decrypt_cha_file(input_path: str, output_path: str, password: str) -&gt; str:     \"\"\"\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 .cha \u0444\u0430\u0439\u043b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430.\"\"\"     with open(input_path, 'rb') as f:         if f.read(len(MAGIC_NUMBER)) != MAGIC_NUMBER:             raise ValueError(\"\u042d\u0442\u043e \u043d\u0435 \u0444\u0430\u0439\u043b \u0444\u043e\u0440\u043c\u0430\u0442\u0430 .cha \u0438\u043b\u0438 \u043e\u043d \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d.\")         salt = f.read(16)         encrypted_data = f.read()      key = generate_key_from_password(password, salt)     f = Fernet(key)     decrypted_packaged_data = f.decrypt(encrypted_data)      filename_bytes, file_content = decrypted_packaged_data.split(b'|', 1)     original_filename = filename_bytes.decode('utf-8')      with open(output_path, 'wb') as f_out:         f_out.write(file_content)     return original_filename <\/code><\/pre>\n<h2>\u0427\u0430\u0441\u0442\u044c 2: \u041f\u0440\u044f\u0447\u0435\u043c \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u043e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u044b\u043c. \u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438, \u0447\u0442\u043e \u0435\u0449\u0435 \u0432\u0430\u0436\u043d\u0435\u0435, \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0439\u0442\u0438 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438?<\/p>\n<h3>\u0428\u0430\u0433 2a: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 &#171;\u0421\u0442\u0435\u0433\u043e-\u041f\u0430\u043a\u0435\u0442\u0430&#187;<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u043c\u043e\u0433\u043b\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043c\u044b &#171;\u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c&#187; \u043d\u0430\u0448 <code>.cha<\/code> \u0444\u0430\u0439\u043b \u0432 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441\u043e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u0435\u0433\u043e-\u043f\u0430\u043a\u0435\u0442\u0430:<\/p>\n<p><code>[\u0414\u043b\u0438\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (4\u0431)] + [\u0427\u0438\u0441\u043b\u043e \u0431\u0438\u0442 (1\u0431)] + [\u0421\u0418\u0413\u041d\u0410\u0422\u0423\u0420\u0410 (4\u0431)] + [\u0424\u043b\u0430\u0433 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f (1\u0431)] + [\u0421\u0430\u043c \u0444\u0430\u0439\u043b]<\/code><\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0434\u0435\u0441\u044c \u2014 <strong>\u0421\u0418\u0413\u041d\u0410\u0422\u0423\u0420\u0410 (<\/strong><code><strong>b'S6KB'<\/strong><\/code><strong>)<\/strong>. \u042d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 &#171;\u043c\u0430\u044f\u0447\u043e\u043a&#187;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u0449\u0435\u0442 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u0428\u0430\u0433 2b: \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u044f (hide)<\/h3>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>hide<\/code> \u0431\u0435\u0440\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u0430\u043a\u0435\u0442 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0431\u0438\u0442\u044b \u0432 \u043c\u043b\u0430\u0434\u0448\u0438\u0435 \u0431\u0438\u0442\u044b (LSB) \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\"># steganography_core.py def hide(carrier_bytes: np.ndarray, final_payload: bytes, n_bits: int, is_encrypted: bool) -&gt; np.ndarray:     encryption_flag = b'\\x01' if is_encrypted else b'\\x00'     data_to_hide = MAGIC_NUMBER + encryption_flag + final_payload     metadata_len = len(data_to_hide).to_bytes(4, 'big')     n_bits_val = int(n_bits).to_bytes(1, 'big')     full_data = metadata_len + n_bits_val + data_to_hide     full_bits = data_to_binary(full_data)      carrier_flat = carrier_bytes.flatten().copy().astype(np.uint8)     mask = ~((1 &lt;&lt; n_bits) - 1) &amp; 0xFF     carrier_flat &amp;= mask      bit_index = 0     for i in range(math.ceil(len(full_bits) \/ n_bits)):         chunk = full_bits[bit_index : bit_index + n_bits].ljust(n_bits, '0')         carrier_flat[i] |= int(chunk, 2)         bit_index += n_bits      return carrier_flat.reshape(carrier_bytes.shape) <\/code><\/pre>\n<h3>\u0428\u0430\u0433 2c: \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 (reveal)<\/h3>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e LSB \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0442 1 \u0434\u043e 8. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043e\u043d\u0430 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u043d\u0430\u0439\u0442\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443.<\/p>\n<pre><code class=\"python\"># steganography_core.py def reveal(carrier_bytes: np.ndarray) -&gt; Tuple[bytes, bool, bool]:     flat = carrier_bytes.flatten().astype(np.uint8)     METADATA_BITS = 40      for candidate_n in range(1, 9):         bytes_for_metadata = math.ceil(METADATA_BITS \/ candidate_n)         if flat.size &lt; bytes_for_metadata: continue         bitstream = _get_bitstream(flat, candidate_n, bytes_for_metadata)         if len(bitstream) &lt; METADATA_BITS: continue          data_len = int(bitstream[:32], 2)         declared_n = int(bitstream[32:40], 2)          if declared_n != candidate_n: continue          total_bytes_to_read = math.ceil((5 + data_len) * 8 \/ declared_n)         full_bitstream = _get_bitstream(flat, declared_n, total_bytes_to_read)         full_bytes = binary_to_data(full_bitstream)         data_to_hide = full_bytes[5 : 5 + data_len]                  if data_to_hide.startswith(MAGIC_NUMBER):             header_len = len(MAGIC_NUMBER)             is_encrypted = (data_to_hide[header_len] == 1)             packaged_data = data_to_hide[header_len + 1:]             return packaged_data, is_encrypted, True      return b'', False, False <\/code><\/pre>\n<h2>\u0427\u0430\u0441\u0442\u044c 3: \u0421\u0438\u043d\u0435\u0440\u0433\u0438\u044f: \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 + \u0421\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f = \u2764\ufe0f<\/h2>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u043a\u0438 <code>.cha<\/code> \u0438 \u0441\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0434\u0430\u0435\u0442 \u0434\u0432\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0443\u0440\u043e\u0432\u043d\u044f \u0437\u0430\u0449\u0438\u0442\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c 1: \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u041a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c)<\/strong>: \u0412\u044b \u0431\u0435\u0440\u0435\u0442\u0435 \u0432\u0430\u0448 <code>my_plan.docx<\/code> \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 <code>my_plan.docx.cha<\/code>. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u0435\u0433\u043e \u043d\u0430\u0439\u0434\u0435\u0442, \u043e\u043d \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0435\u0433\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u043f\u0430\u0440\u043e\u043b\u044f \u0438\u043b\u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &#171;ChameleonLab&#187;. \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <\/figcaption><\/div>\n<\/figure>\n<\/li>\n<li>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c 2: \u0421\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f (\u0421\u043a\u0440\u044b\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435)<\/strong>: \u0412\u044b \u0431\u0435\u0440\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 <code>my_plan.docx.cha<\/code> \u0438 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044e <code>kitten.png<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0433\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f \u043d\u0435\u0442 \u0434\u0430\u0436\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0424\u0430\u0439\u043b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0449\u0438\u0449\u0435\u043d \u2014 <strong>\u043e\u043d \u043d\u0435\u0432\u0438\u0434\u0438\u043c<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 &#171;ChameleonLab&#187;. \u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u0430 \u0434\u0432\u0443\u0445\u0441\u0442\u0443\u043f\u0435\u043d\u0447\u0430\u0442\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u2014 \u0438 \u0435\u0441\u0442\u044c \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0438\u044f ChameleonLab. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u044b\u043c\u0438. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 <strong>\u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u043d\u0438\u0435<\/strong>: \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430, \u0438 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u00abSteganographia\u00bb \u043e\u0442 ChameleonLab \u0434\u043b\u044f Windows \u0438 macOS \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0430 \u043d\u0430\u0448\u0435\u043c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435. <a href=\"https:\/\/chalab.ru\" rel=\"noopener noreferrer nofollow\"><strong>https:\/\/chalab.ru<\/strong><\/a><\/p>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439, \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u0435\u0434\u0438\u043d\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430\u043c\u0438, \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 Telegram-\u043a\u0430\u043d\u0430\u043b\u0443: <a href=\"https:\/\/t.me\/ChameleonLab\" rel=\"noopener noreferrer nofollow\"><strong>https:\/\/t.me\/ChameleonLab<\/strong><\/a><\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/943402\/\"> https:\/\/habr.com\/ru\/articles\/943402\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-473786","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=473786"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/473786\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}