{"id":389,"date":"2015-01-14T16:19:40","date_gmt":"2015-01-14T16:19:40","guid":{"rendered":"https:\/\/www.hackmethod.com\/?p=389"},"modified":"2022-06-03T05:40:09","modified_gmt":"2022-06-03T05:40:09","slug":"overthewire-bandit-9","status":"publish","type":"post","link":"https:\/\/hackmethod.com\/overthewire-bandit-9\/","title":{"rendered":"OvertheWire &#8211; Bandit 9"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221; _builder_version=&#8221;3.22&#8243;][et_pb_row admin_label=&#8221;row&#8221; _builder_version=&#8221;3.25&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text admin_label=&#8221;Text&#8221; _builder_version=&#8221;4.7.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; hover_enabled=&#8221;0&#8243; sticky_enabled=&#8221;0&#8243;]<strong>Recap of Level 8:\u00a0<\/strong>Used grep to search for our password from a large text file.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/overthewire.org\/wargames\/bandit\/bandit9.html\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Bandit Level 9<\/strong><\/a><\/p>\n<h4><strong>Objective:<\/strong><\/h4>\n<p>Find the password to the next level<\/p>\n<h4><strong>Intel Given:<\/strong><\/h4>\n<ul>\n<li>The password is located in data.txt<\/li>\n<li>The password is the only line that occurs once<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h4><strong>How to:<\/strong><\/h4>\n<p>Reading the file shows us that data.txt is a large list of many passwords. According to our intel we know that all of the passwords except for one repeat and so we need to focus on finding the unique password.<\/p>\n<p>To do this we need to use the command <code>uniq<\/code> which reports or omits <strong>repeated<\/strong> lines dependent on which switch you use. When we looked at the contents of the data.txt file we saw that the passwords were scrambled so we need to figure out a way to reorganize the contents of the file.<\/p>\n<p>To do this we use the <code>sort<\/code> command. Using sort on our given file will give us the result below.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"391\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-bandit-9\/screen-shot-2015-01-14-at-9-52-35-am\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png?fit=237%2C258&amp;ssl=1\" data-orig-size=\"237,258\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2015-01-14 at 9.52.35 AM\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png?fit=237%2C258&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png?fit=237%2C258&amp;ssl=1\" class=\" size-full wp-image-391 aligncenter\" src=\"https:\/\/i0.wp.com\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png?resize=237%2C258&#038;ssl=1\" alt=\"Screen Shot 2015-01-14 at 9.52.35 AM\" width=\"237\" height=\"258\" \/><\/a><\/p>\n<p>Now that we have our file formatted correctly we can inject the result of the sort command into our <span style=\"color: #666666;\">uniq <\/span>command. By reading the <code>uniq<\/code> man page we find that the <code>-u<\/code> switch will print only unique lines to standard out. Putting it all together we get the result below.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"392\" data-permalink=\"https:\/\/hackmethod.com\/overthewire-bandit-9\/screen-shot-2015-01-14-at-10-10-41-am\/\" data-orig-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png?fit=315%2C37&amp;ssl=1\" data-orig-size=\"315,37\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2015-01-14 at 10.10.41 AM\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png?fit=300%2C35&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png?fit=315%2C37&amp;ssl=1\" class=\" size-full wp-image-392 aligncenter\" src=\"https:\/\/i0.wp.com\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png?resize=315%2C37&#038;ssl=1\" alt=\"Screen Shot 2015-01-14 at 10.10.41 AM\" width=\"315\" height=\"37\" srcset=\"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png?w=315&amp;ssl=1 315w, https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png?resize=300%2C35&amp;ssl=1 300w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><\/a><\/p>\n<h4><strong>Conclusion:<\/strong><\/h4>\n<p>We&#8217;re now beginning to combine commands. As you can see redirection of Input and Output (I\/O) is becoming more important. If you need a quick refresher on I\/O please go back to the <a href=\"https:\/\/www.hackmethod.com\/bandit-6\/\">Bandit 6<\/a> tutorial to review. Understanding that you&#8217;re not combining the commands per say, but instead the OUTPUTS of the commands is a crucial thought process when using the pipe.[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row column_structure=&#8221;1_2,1_2&#8243; _builder_version=&#8221;4.7.4&#8243; _module_preset=&#8221;default&#8221;][et_pb_column type=&#8221;1_2&#8243; _builder_version=&#8221;4.7.4&#8243; _module_preset=&#8221;default&#8221;][et_pb_image src=&#8221;https:\/\/hackmethod.com\/wp-content\/uploads\/2020\/12\/Previous.png&#8221; alt=&#8221;Previous Level&#8221; title_text=&#8221;Previous&#8221; url=&#8221;https:\/\/hackmethod.com\/overthewire-bandit-8&#8243; _builder_version=&#8221;4.7.4&#8243; _module_preset=&#8221;default&#8221;][\/et_pb_image][\/et_pb_column][et_pb_column type=&#8221;1_2&#8243; _builder_version=&#8221;4.7.4&#8243; _module_preset=&#8221;default&#8221;][et_pb_image src=&#8221;https:\/\/hackmethod.com\/wp-content\/uploads\/2020\/12\/Next.png&#8221; alt=&#8221;Next Level&#8221; title_text=&#8221;Next&#8221; url=&#8221;https:\/\/hackmethod.com\/overthewire-bandit-10&#8243; align=&#8221;right&#8221; _builder_version=&#8221;4.7.4&#8243; _module_preset=&#8221;default&#8221;][\/et_pb_image][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recap of Level 8:\u00a0Used grep to search for our password from a large text file. &nbsp; Bandit Level 9 Objective: Find the password to the next level Intel Given: The password is located in data.txt The password is the only line that occurs once How to: Reading the file shows us that data.txt is a [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":391,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"<strong>Recap of <a href=\"https:\/\/www.hackmethod.com\/overthewire-bandit-8\/\">Last\u00a0Lesson<\/a>:\u00a0<\/strong>Used grep to search for our password from a large text file\r\n\r\n<a href=\"http:\/\/overthewire.org\/wargames\/bandit\/bandit9.html\" target=\"_blank\"><strong>Bandit Level 9<\/strong><\/a>\r\n\r\n<strong>Objective<\/strong>\r\n\r\nFind the password to the next level\r\n\r\n<strong>Intel Given<\/strong>\r\n<ul>\r\n\t<li>The password is located in data.txt<\/li>\r\n\t<li>The password is the only line that occurs once<\/li>\r\n<\/ul>\r\n<!--more-->\r\n\r\n<strong>How to<\/strong>\r\n\r\nReading the file shows us that data.txt is a large list of many passwords. According to our intel we know that all of the passwords except for one repeat and so we need to focus on finding the unique password.\r\n\r\nTo do this we need to use the command 'uniq' which reports or omits <strong>repeated<\/strong> lines dependent on which switch you use. When we looked at the contents of the data.txt file we saw that the passwords were scrambled so we need to figure out a way to reorganize the contents of the file.\r\n\r\nTo do this we use the 'sort' command. Using sort on our given file will give us the result below.\r\n\r\n<a href=\"https:\/\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png\"><img class=\" size-full wp-image-391 aligncenter\" src=\"https:\/\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png\" alt=\"Screen Shot 2015-01-14 at 9.52.35 AM\" width=\"237\" height=\"258\" \/><\/a>\r\n\r\nNow that we have our file formatted correctly we can inject the result of the sort command into our uniq command. By reading the uniq man page we find that the '-u' switch will print only unique lines to standard out. Putting it all together we get the result below.\r\n\r\n<a href=\"https:\/\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png\"><img class=\" size-full wp-image-392 aligncenter\" src=\"https:\/\/www.hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-10.10.41-AM.png\" alt=\"Screen Shot 2015-01-14 at 10.10.41 AM\" width=\"315\" height=\"37\" \/><\/a>\r\n\r\n&nbsp;\r\n\r\n<strong>Conclusion<\/strong>\r\n\r\nWe're now beginning to combine commands. As you can see redirection of Input and Output (I\/O) is becoming more important. If you need a quick refresher on I\/O please go back to the <a href=\"https:\/\/www.hackmethod.com\/bandit-6\/\">Bandit 6<\/a> tutorial to review. Understanding that you're not combining the commands per say, but instead the OUTPUTS of the commands is a crucial thought process when using the pipe.","_et_gb_content_width":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[44,1],"tags":[43,45,46],"class_list":["post-389","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-overthewire","category-uncategorized","tag-bandit","tag-overthewire","tag-tutorials"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/hackmethod.com\/wp-content\/uploads\/2015\/01\/Screen-Shot-2015-01-14-at-9.52.35-AM.png?fit=237%2C258&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5zY4D-6h","_links":{"self":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/comments?post=389"}],"version-history":[{"count":7,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/389\/revisions"}],"predecessor-version":[{"id":27501,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/389\/revisions\/27501"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/media\/391"}],"wp:attachment":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/media?parent=389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/categories?post=389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/tags?post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}