{"id":31080,"date":"2019-10-31T21:39:19","date_gmt":"2019-10-31T18:39:19","guid":{"rendered":"https:\/\/prohoster.info\/blog\/steganografiya-v-fajlovoj-sisteme\/"},"modified":"2019-10-31T21:39:19","modified_gmt":"2019-10-31T18:39:19","slug":"steganografiya-v-fajlovoj-sisteme","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/steganografiya-v-fajlovoj-sisteme","title":{"rendered":"Steganography in file systems","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Hello, Habr. <\/p>\n<p><\/p>\n<p>I want to introduce you to a small project on <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D1%82%D0%B5%D0%B3%D0%B0%D0%BD%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%8F\">steganography<\/a><\/noindex>, created in my free time from studies. <\/p>\n<p><\/p>\n<p>I developed a project for hidden information storage in the file system (hereinafter referred to as <strong>FS<\/strong>).<br \/>\n). This can be applied for stealing confidential information for educational purposes.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Steganography in file systems\" src=\"\/wp-content\/uploads\/2019\/04\/d6639b37e1b1fe57b80288e671176fe3.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>For the proof of concept, I chose a fairly old Linux FS <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/Ext2\">ext2<\/a><\/noindex>. <\/p>\n<p>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h3 id=\"realizaciya\">Implementation<\/h3>\n<p><\/p>\n<h4 id=\"soobrazheniya-o-realizacii\">Implementation Considerations<\/h4>\n<p><\/p>\n<p>If you properly 'examine' the ext2 standard, you can replace it with what is known in the FS <noindex><a rel=\"nofollow\" href=\"http:\/\/www.nongnu.org\/ext2-doc\/ext2.html#SUPERBLOCK\"><strong>Superblocks<\/strong><\/a><\/noindex>, which contains the basic information about the system. I also found <noindex><a rel=\"nofollow\" href=\"http:\/\/www.nongnu.org\/ext2-doc\/ext2.html#BLOCK-BITMAP\"><strong>Block Bitmap<\/strong><\/a><\/noindex> and <noindex><a rel=\"nofollow\" href=\"http:\/\/www.nongnu.org\/ext2-doc\/ext2.html#INODE-TABLE\"><strong>Inode Table<\/strong><\/a><\/noindex>. Almost immediately, the idea came up to write information into currently empty blocks of the FS. Now it was necessary to think about protection against a programmer armed with <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/Hex-%D1%80%D0%B5%D0%B4%D0%B0%D0%BA%D1%82%D0%BE%D1%80\">a hex editor<\/a><\/noindex>. <\/p>\n<p><\/p>\n<p>. If the hidden information is stored without encryption, even though it is dispersed throughout the FS, it will still be too noticeable, especially if the programmer knows what to look for. Therefore, it was decided to encrypt all blocks of the original file. I chose a block cipher <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/Advanced_Encryption_Standard\">AES<\/a><\/noindex>, but as you can understand, this is not critical.<\/p>\n<p><\/p>\n<p>To distinguish the required blocks from the others when reading, it was decided to add a special marker to the beginning of each block. This marker was encrypted based on the block number in the original file. This trick immediately allowed not only to find the necessary blocks, but also to know their correct order.<\/p>\n<p><\/p>\n<p>Overall System Principle.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Steganography in file systems\" src=\"\/wp-content\/uploads\/2019\/04\/cb6e712aeffafe87b1ad10e4ed5b0a39.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h4 id=\"algoritm-zapisi\">Write Algorithm<\/h4>\n<p><\/p>\n<p>In steps:<\/p>\n<p><\/p>\n<ul>\n<li>First, write some information to the original file system;<\/li>\n<li>Delete that information (not necessarily all); <\/li>\n<li>Split the file to be hidden into blocks of equal length, adding a marker;<\/li>\n<li>Encrypt these blocks;<\/li>\n<li>Place the encrypted blocks into empty blocks of the FS.<\/li>\n<\/ul>\n<p>\n<b class=\"spoiler_title\">For fans of flowcharts<\/b><\/p>\n<p>Below is a flowchart of the write algorithm. The algorithm receives four files as input:<br \/>\n-Image of the modified file system;<br \/>\n-File subject to steganography;<br \/>\n-File with encryption key for AES;<br \/>\n-File with marker.<br \/>\n<img decoding=\"async\" alt=\"Steganography in file systems\" src=\"\/wp-content\/uploads\/2019\/04\/3089bf0d55cbdca1a98e4ee992089665.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>It is worth noting that this algorithm has one drawback: after writing the file to the FS, <strong>it cannot be<\/strong> Writing anything new to the file system, as any new information could end up in the blocks allocated to our steganographic file, does open up the opportunity for 'quickly covering tracks'. <\/p>\n<p><\/p>\n<p>However, it is quite obvious how this can be resolved: the algorithm for writing blocks in the file system needs to be rewritten. This is a clear but incredibly labor-intensive task.<br \/>\nI did not implement this for the Proof Of Concept.<\/p>\n<p><\/p>\n<p>As a result, the following changes will occur in the file system; this is how the file system looks before steganography (an audio file has been previously written).<br \/>\n<img decoding=\"async\" alt=\"Steganography in file systems\" src=\"\/wp-content\/uploads\/2019\/04\/a779de50121de2bafacab9d891b5f5df.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nAnd this is how the file system looks with the information already steganographed.<br \/>\n<img decoding=\"async\" alt=\"Steganography in file systems\" src=\"\/wp-content\/uploads\/2019\/04\/5722200a90d720f96c0aad5b4a5a11ae.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h4 id=\"algoritm-chteniya\">Reading Algorithm<\/h4>\n<p><\/p>\n<p>In steps:<\/p>\n<p><\/p>\n<ul>\n<li>Knowing the key and the method for constructing markers, create the first N markers, ensuring that N multiplied by the length of the file system block exceeds the length of the steganographed file;<\/li>\n<li>Search for blocks in the file system starting with markers; <\/li>\n<li>Decrypt the retrieved blocks and separate the markers;<\/li>\n<li>Assemble the retrieved blocks in the correct order to obtain the original file.<\/li>\n<\/ul>\n<p>\n<b class=\"spoiler_title\">For fans of flowcharts<\/b><\/p>\n<p>Below is a flowchart of the writing algorithm. The algorithm receives three files as input:<br \/>\n- File system image;<br \/>\n-File with encryption key for AES;<br \/>\n-File with marker.<br \/>\n<img decoding=\"async\" alt=\"Steganography in file systems\" src=\"\/wp-content\/uploads\/2019\/04\/9dcfe680121a30c1b17b5a4cdbd76dc3.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>After the program runs, a file Read is created, which will be the extracted file from the steganographic file system; if the key or marker was specified incorrectly, the Read file will be empty.<br \/>\n(for those who appreciate aesthetics, you can embed not only the file but also a 'header' containing metadata: filename, permissions, last modified time, etc.)<\/p>\n<p><\/p>\n<h4 id=\"avtomatizaciya-zapuska\">Automation of Startup<\/h4>\n<p><\/p>\n<p>For convenience, bash scripts were created to automate startup on Linux (tested on Ubuntu 16.04.3 LTS).<br \/>\nLet's break down the startup process step by step.<br \/>\nWriting:<\/p>\n<p><\/p>\n<ol>\n<li>sudo Copy_Flash.sh \u201cDEVICE\u201d \u2014 we obtain the file system image from DEVICE (flash);<\/li>\n<li>.\/Write.sh \u201cFILE\u201d \u201cKEY\u201d \u201cMARKER\u201d \u2013 we create a virtual environment, download the necessary libraries, and run the script for writing;<\/li>\n<li>sudo .\/Write_Flash.sh \u201cDEVICE\u201d \u2013 we write the modified file system back to the DEVICE.<\/li>\n<\/ol>\n<p><\/p>\n<p>Reading:<\/p>\n<p><\/p>\n<ol>\n<li>sudo Copy_Flash.sh \u201cDEVICE\u201d \u2014 we obtain the file system image from DEVICE (flash);<\/li>\n<li>.\/Read.sh \u201cKEY\u201d \u2018MARKER\u201d \u2014 we create a virtual environment, download the necessary libraries, and run the script for reading;<\/li>\n<li>In the current directory, we open the Read file \u2013 this is the steganographed information.<\/li>\n<\/ol>\n<p><\/p>\n<h3 id=\"zaklyuchenie\">Conclusion<\/h3>\n<p><\/p>\n<p>This steganography method likely needs further development, additional testing, and extension to more popular file systems such as <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/FAT32\">Fat32<\/a><\/noindex>, <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/NTFS\">NTFS<\/a><\/noindex> and <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/Ext4\">ext4<\/a><\/noindex>.<br \/>\nThe goal of this work was to demonstrate the principle by which hidden information can be stored in a file system.<br \/>\nUsing such algorithms, it is possible to store information safely, and while it may be possible to crack such a system with knowledge of the key (though it would require a lengthy algorithm), without the key, this system seems absolutely resilient to me. However, this could serve as a basis for a separate article.<\/p>\n<p><\/p>\n<p>All the code is implemented in Python version 3.5.2. <noindex><a rel=\"nofollow\" href=\"https:\/\/youtu.be\/FEAE3_xDKkA\">An example of its operation<\/a><\/noindex> is presented on my YouTube channel. The complete project code is available on <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/MalahovMV\/Ext2Stego\">github<\/a><\/noindex>.<br \/>\n(Yes, I know that for the production version one needs to write in something 'faster', like C \ud83d\ude09 )<br \/>\nIn this implementation, the size of the input file for steganography must not exceed 1000 kB.<\/p>\n<p><\/p>\n<p>I would like to express my gratitude to the user <noindex><a rel=\"nofollow\" href=\"https:\/\/habrahabr.ru\/users\/pavelmstu\/\" class=\"user_link\">PavelMSTU<\/a><\/noindex> for valuable advice in planning the research and recommendations for formatting the article.<\/p>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/347604\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u0425\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0441\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u0438, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043e\u0442 \u0443\u0447\u0435\u0431\u044b \u0432\u0440\u0435\u043c\u044f. \u042f \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0441\u043a\u0440\u044b\u0442\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 (\u0434\u0430\u043b\u0435\u0435 \u0424\u0421). \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u043b\u044f \u043a\u0440\u0430\u0436\u0438 \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445. \u0412 \u0432\u0438\u0434\u0435 \u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0432\u0435\u0441\u044c\u043c\u0430 \u0441\u0442\u0430\u0440\u0435\u043d\u044c\u043a\u0430\u044f \u043b\u0438\u043d\u0443\u043a\u0441\u043e\u0432\u0430\u044f \u0424\u0421 ext2. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0421\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0415\u0441\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u043e &#171;\u0440\u0430\u0437\u0434\u0440\u0430\u043a\u043e\u043d\u0438\u0442\u044c&#187; [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":23051,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-31080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/steganografiya-v-fajlovoj-sisteme\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0421\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/steganografiya-v-fajlovoj-sisteme\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T18:39:19+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T18:39:19+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Steganography in the File System | ProHoster","description":"Hello, Habr.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/steganografiya-v-fajlovoj-sisteme","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0421\u0442\u0435\u0433\u0430\u043d\u043e\u0433\u0440\u0430\u0444\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 | ProHoster","og:description":"\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/steganografiya-v-fajlovoj-sisteme","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T18:39:19+00:00","article:modified_time":"2019-10-31T18:39:19+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"31080","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-21 04:26:19","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 03:22:35","updated":"2026-01-21 04:26:19","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/31080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=31080"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/31080\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/23051"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=31080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=31080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=31080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}