{"id":382,"date":"2023-09-02T18:27:54","date_gmt":"2023-09-02T16:27:54","guid":{"rendered":"https:\/\/linux-bibel.at\/?p=382"},"modified":"2023-09-02T18:27:55","modified_gmt":"2023-09-02T16:27:55","slug":"log-s-anonymisieren","status":"publish","type":"post","link":"https:\/\/linux-bibel.at\/index.php\/2023\/09\/02\/log-s-anonymisieren\/","title":{"rendered":"Log-s anonymisieren"},"content":{"rendered":"\n<p>Jeder kennt sie, oder jeder hat zumindest schon mal davon geh&ouml;rt. Die allerseits beliebte (oder auch nicht) DSGVO.<br>Wer Kunden hat die Log-File-Auszuege wuenschen wei&szlig; wie muehsam es ist diese zu anonymisieren.<br>Ich habe mir daher eine kleine function f&uuml;r die ~\/.<a href=\"https:\/\/linux-bibel.at\/index.php\/enzyklopaedie\/bash\/\" target=\"_self\" title='Die Abk&uuml;rzung \"bash\" steht f&uuml;r \"Bourne Again Shell\". Die Bash ist eine Shell, die als Mensch-Maschine-Schnittstelle dient und eine Umgebung bereitstellt, in der zeilenweise Texteingaben und -ausgaben m&ouml;glich sind. Sie ist eine Weiterentwicklung der Bourne-Shell und wird als Standard-Shell auf den meisten Linux-Systemen verwendet. Die Bash ist auch eine Skriptsprache, die zum Erstellen von Shell-Skripten&hellip;' class=\"encyclopedia\">bash<\/a>rc geschrieben.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function anonym ()\n        {\n        if &#91; \"${1:0:2}\" == \"-h\" ]||&#91; \"${1:0:2}\" == \"-?\" ]\n                then\n                echo $1\n                echo -e \"\\033&#91;0;32mReinis ${FUNCNAME&#91;0]} V1.0\\033&#91;0m\"\n                echo \"${FUNCNAME&#91;0]} \/Pfad\/Datei\"\n                echo -e \"Anonymisiert gueltige IP-Adressen und\"\n                echo -e \"E-Mail-Adressen.\"\n                echo -e \"Liefert XXX.XXX.XXX.XXX fuer IP-Adressen aus und\"\n                echo -e \"Liefert xxx@xxx.TLD fuer E-Mail-Adressen aus.\"\n                return\n        fi\n        if &#91; \"$1\" == \"\" ]\n                then\n                cat -|zless|sed -r 's\/(&#91;0-9]{1,3}).(&#91;0-9]{1,3}).(&#91;0-9]{1,3}).(&#91;0-9]{1,3})\/\u00ae &amp;\/g'|sed -r 's\/ (25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\.(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\.(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\.(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\/ XXX.XXX.XXX.XXX\/g'|sed -r 's\/(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\-(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\-(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\-(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\/XXX-XXX-XXX-XXX\/g'|sed -r 's\/&lt;\/&lt; \/g'|sed -r 's\/&#91;&#91;:graph:]]*@&#91;&#91;:graph:]]*\\.\/xxx@xxx\\.\/g'|sed -r 's\/&lt; \/&lt;\/g'|sed -r 's\/ XXX\/XXX\/g'|sed -r 's\/\u00ae \/\/g'|sed -r 's\/\u00ae\/\/g'\n        else\n                zless $(echo \"$*\")|sed -r 's\/(&#91;0-9]{1,3}).(&#91;0-9]{1,3}).(&#91;0-9]{1,3}).(&#91;0-9]{1,3})\/\u00ae &amp;\/g'|sed -r 's\/ (25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\.(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\.(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\.(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\/ XXX.XXX.XXX.XXX\/g'|sed -r 's\/(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\-(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\-(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\\-(25&#91;0-5]|2&#91;0-4]&#91;0-9]|&#91;01]?&#91;0-9]&#91;0-9]?)\/XXX-XXX-XXX-XXX\/g'|sed -r 's\/&lt;\/&lt; \/g'|sed -r 's\/&#91;&#91;:graph:]]*@&#91;&#91;:graph:]]*\\.\/xxx@xxx\\.\/g'|sed -r 's\/&lt; \/&lt;\/g'|sed -r 's\/ XXX\/XXX\/g'|sed -r 's\/\u00ae \/\/g'|sed -r 's\/\u00ae\/\/g'\n        fi\n}<\/code><\/pre>\n\n\n\n<p>Die Funktion ist natuerlich auf meine Beduerfnisse angepasst und muss eventuell f&uuml;r andere Logs angeglichen werden. (Ich berate gerne bei Bedarf.)<br>Die Anwendung sieht in etwa so aus.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 'das ist &lt; > eine IP192.168.0.1 und das ist eine email g^ibt_s@gar.net eine IP &lt;78-212-12-11> und noch eine email ausser &lt;!#$%&amp;\u2019*+-\/=?^_`.{|}~@example.com> und das ist mit subdomain tester@sub.domain.com und eine Zahl 344.55.16.1'|anonym\ndas ist &lt; > eine IPXXX.XXX.XXX.XXX und das ist eine email xxx@xxx.net eine IP &lt;XXX-XXX-XXX-XXX> und noch eine email ausser &lt;xxx@xxx.com> und das ist mit subdomain xxx@xxx.com und eine Zahl 344.55.16.1\n<\/code><\/pre>\n\n\n\n<p>LG Reini<br><a href=\"https:\/\/call4wall.at\/LB.html\">https:\/\/call4wall.at\/LB.html<\/a><\/p>\n\n\n\n<p class=\"has-light-green-cyan-color has-text-color\">Verfasst von &reg;eini123<\/p>\n<div class=\"pld-like-dislike-wrap pld-custom\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"Gef\u00e4llt mir\" data-post-id=\"382\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                            <img src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/12\/Daumen-Hoch.png\" alt=\"Gef\u00e4llt mir\" \/>\r\n            <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-dislike-trigger pld-like-dislike-trigger  \" title=\"Gef\u00e4llt mir nicht\" data-post-id=\"382\" data-trigger-type=\"dislike\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                            <img src=\"https:\/\/linux-bibel.at\/wp-content\/uploads\/2023\/12\/Daumen-Runter.png\" alt=\"Gef\u00e4llt mir nicht\" \/>\r\n            <\/a>\r\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\r\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Jeder kennt sie, oder jeder hat zumindest schon mal davon geh\u00f6rt. Die allerseits beliebte (oder auch nicht) DSGVO.Wer Kunden hat die Log-File-Auszuege wuenschen wei\u00df wie muehsam es ist diese zu anonymisieren.Ich habe mir daher eine kleine function f\u00fcr die ~\/.bashrc geschrieben. Die Funktion ist natuerlich auf meine Beduerfnisse angepasst und muss eventuell f\u00fcr andere Logs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":61,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12,7,6],"class_list":["post-382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-terminal","tag-kommandozeile","tag-shell","tag-terminal"],"_links":{"self":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/comments?post=382"}],"version-history":[{"count":1,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/posts\/382\/revisions\/383"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media\/61"}],"wp:attachment":[{"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/media?parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/categories?post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linux-bibel.at\/index.php\/wp-json\/wp\/v2\/tags?post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}