{"id":1243,"date":"2019-09-10T22:10:26","date_gmt":"2019-09-10T14:10:26","guid":{"rendered":"http:\/\/van-yzt.com\/?p=1243"},"modified":"2019-09-10T22:10:26","modified_gmt":"2019-09-10T14:10:26","slug":"bandit-level-22-%e2%86%92-level-23","status":"publish","type":"post","link":"https:\/\/huzi-baozi.com\/?p=1243","title":{"rendered":"Bandit Level 22 \u2192 Level 23"},"content":{"rendered":"<p>A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in \/etc\/cron.d\/ for the configuration and see what command is being executed.<\/p>\n<p>NOTE: Looking at shell scripts written by other people is a very useful skill. The script for this level is intentionally made easy to read. If you are having problems understanding what it does, try executing it to see the debug information it prints.<\/p>\n<h2>\n\u89e3\u5bc6<\/h2>\n<pre><code class=\"language-shell\">bandit22@bandit:~$ ls -l \/etc\/cron.d\/\ntotal 12\n-rw-r--r-- 1 root root 120 Oct 16  2018 cronjob_bandit22\n-rw-r--r-- 1 root root 122 Oct 16  2018 cronjob_bandit23\n-rw-r--r-- 1 root root 120 Oct 16  2018 cronjob_bandit24\nbandit22@bandit:~$ cat \/etc\/cron.d\/cronjob_bandit23\n@reboot bandit23 \/usr\/bin\/cronjob_bandit23.sh  &amp;&gt; \/dev\/null\n* * * * * bandit23 \/usr\/bin\/cronjob_bandit23.sh  &amp;&gt; \/dev\/null\nbandit22@bandit:~$ cat \/usr\/bin\/cronjob_bandit23.sh\n#!\/bin\/bash\n\nmyname=$(whoami)\nmytarget=$(echo I am user $myname | md5sum | cut -d ' ' -f 1)\n\necho &quot;Copying passwordfile \/etc\/bandit_pass\/$myname to \/tmp\/$mytarget&quot;\n\ncat \/etc\/bandit_pass\/$myname &gt; \/tmp\/$mytarget\nbandit22@bandit:~$ echo 'I am user bandit23' | md5sum | cut -d ' ' -f 1\n8ca319486bfbbc3663ea0fbe81326349\nbandit22@bandit:~$ cat \/tmp\/8ca319486bfbbc3663ea0fbe81326349\njc1udXuA1tiHqjIsL8yaapX5XIAI6i0n\n<\/code><\/pre>\n<h2>\n\u77e5\u8bc6\u70b9<\/h2>\n<ol>\n<li>\n<code>whoami<\/code>\u8fd9\u4e2a\u547d\u4ee4\uff0c\u4f1a\u6253\u5370\u51fa\u5f53\u524d\u6267\u884c\u4eba\u662f\u8c01\uff0c\u6b64\u5904\u662f<code>bandit23<\/code>\uff1b<\/li>\n<li>\n<code>md5sum<\/code>\u662f\u5bf9\u8f93\u5165\u8fdb\u884cmd5\u54c8\u5e0c\uff1b<\/li>\n<li>\n<code>cut<\/code>\u662f\u5206\u5272\u7a7a\u683c\uff0c<code>-d<\/code>\u8868\u660e\u98ce\u683c\u5b57\u7b26\uff0c<code>-f<\/code>\u53d6\u5206\u5272\u540e\u7684\u7b2c\u51e0\u4e2a\u5b57\u7b26\u4e32\uff1b<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in \/etc\/cron.d\/ for the configuration and see what command is being executed. NOTE: Looking at shell scripts written by other people is a very useful skill. The script for this level is intentionally made easy to read. If you are &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/huzi-baozi.com\/?p=1243\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bandit Level 22 \u2192 Level 23&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1243","post","type-post","status-publish","format-standard","hentry","category-bandit"],"_links":{"self":[{"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=\/wp\/v2\/posts\/1243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1243"}],"version-history":[{"count":1,"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=\/wp\/v2\/posts\/1243\/revisions"}],"predecessor-version":[{"id":1244,"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=\/wp\/v2\/posts\/1243\/revisions\/1244"}],"wp:attachment":[{"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huzi-baozi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}