{"id":272,"date":"2014-12-18T02:11:09","date_gmt":"2014-12-18T02:11:09","guid":{"rendered":"http:\/\/scottyrotten.wordpress.com\/?p=272"},"modified":"2022-06-03T05:40:41","modified_gmt":"2022-06-03T05:40:41","slug":"overthewire-bandit-2","status":"publish","type":"post","link":"https:\/\/hackmethod.com\/overthewire-bandit-2\/","title":{"rendered":"OvertheWire &#8211; Bandit 2"},"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; custom_padding=&#8221;3px|||||&#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;3.27.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221;]<strong><span style=\"color: #404040;\"><\/span><\/strong><\/p>\n<p><span style=\"color: #404040;\"><strong>Recap of Level 1:<\/strong><span style=\"font-size: medium; color: #333333;\"><\/span> We logged into the overthewire Bandit\u00a01 after reading the file &#8220;readme&#8221; located in the \/home\/bandit0 directory.\u00a0<\/span><\/p>\n<p><span style=\"color: #404040;\"><\/span><\/p>\n<p><span style=\"color: #404040;\"><\/span><\/p>\n<p><a title=\"Bandit Level 2\" href=\"http:\/\/overthewire.org\/wargames\/bandit\/bandit2.html\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Bandit Level 2<\/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>Password is in a file named &#8216;-&#8216;<\/li>\n<li>&#8216;-&#8216; is in the home directory<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h4><strong>How to: <\/strong><\/h4>\n<p><span style=\"font-family: inherit;\">Normally we would read this simple human readable text document by using the command &#8216;cat -&#8216; however the usage of the dash as a filename presents some problems. &#8211; In BASH is used to redirect from\/to STDIN(Standard In) or STDOUT (Standard Out). Technically you can change STDIN and STDOUT to anything, but for the sake of simplicity trust me when I say the defaults are your Keyboard and Bash prompt.<\/span><\/p>\n<p>So what happens when we type &#8216;cat -&#8216;? Essentially what this command is saying is &#8220;read standard in, and display it on standard out&#8221;. Which if we break down into further layman terms means, everything I type AFTER I enter this command, will be repeated. Go ahead and give it a try.<\/p>\n<p>So how to get around this? Well we just explicitly tell Bash that we mean &#8211; the FILE and not &#8211; the operator. To do that we just list the entire path in the command. This is a concept that you&#8217;ll discover will help execute files as you advance further in your linux experience.<\/p>\n<p>&#8216;cat .\/-&#8216; should give you the results you&#8217;re looking for. A period in bash denotes the current working directory, in this case it means \/home\/bandit1\/ so you could also type &#8216;cat \/home\/bandit1\/-&#8216; and have the same result, but its much simpler and a much more common syntax to type it in the way I showed above.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Conclusion:<\/strong><\/h4>\n<p>I recommend research what STDIN and STDOUT as well as briefly search for Bash or Linux special characters.<\/p>\n<p>[\/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-1&#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-3&#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 1: We logged into the overthewire Bandit\u00a01 after reading the file &#8220;readme&#8221; located in the \/home\/bandit0 directory.\u00a0 Bandit Level 2 Objective: Find the password to the next level Intel Given: Password is in a file named &#8216;-&#8216; &#8216;-&#8216; is in the home directory How to: Normally we would read this simple human [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"<strong><span style=\"color: #404040;\">Recap of Last&nbsp;Lesson:<\/span><\/strong><span style=\"color: #404040;\">&nbsp;We logged into the overthewire Bandit&nbsp;1 after reading the file \"readme\" located in the \/home\/bandit0 directory.&nbsp;<\/span>\n\n<a title=\"Bandit Level 2\" href=\"http:\/\/overthewire.org\/wargames\/bandit\/bandit2.html\" target=\"_blank\" rel=\"noopener\"><strong>Bandit Level&nbsp;1<\/strong><\/a>\n\n<strong>Objective<\/strong>\n\nFind the password to the next level\n\n<strong>Intel Given<\/strong>\n\n<ul>\n    <li>Password is in a file named '-'<\/li>\n    <li>'-' is in the home directory<\/li>\n<\/ul>\n\n<!--more-->\n\n<strong>How to: <\/strong>Normally we would read this simple human readable text document by using the command 'cat -' however the usage of the dash as a filename presents some problems. - In BASH is used to redirect from\/to STDIN(Standard In) or STDOUT (Standard Out). Technically you can change STDIN and STDOUT to anything, but for the sake of simplicity trust me when I say the defaults are your Keyboard and Bash prompt.\n\nSo what happens when we type 'cat -'? Essentially what this command is saying is \"read standard in, and display it on standard out\". Which if we break down into further layman terms means, everything I type AFTER I enter this command, will be repeated. Go ahead and give it a try.\n\nSo how to get around this? Well we just explicitly tell Bash that we mean - the FILE and not - the operator. To do that we just list the entire path in the command. This is a concept that you'll discover will help execute files as you advance further in your linux experience.\n\n'cat .\/-' should give you the results you're looking for. A period in bash denotes the current working directory, in this case it means \/home\/bandit1\/ so you could also type 'cat \/home\/bandit1\/-' and have the same result, but its much simpler and a much more common syntax to type it in the way I showed above.\n\n<strong>Conclusion:<\/strong> I recommend research what STDIN and STDOUT as well as briefly search for Bash or Linux special characters.","_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,49],"tags":[43,45,46],"class_list":["post-272","post","type-post","status-publish","format-standard","hentry","category-overthewire","category-tutorials","tag-bandit","tag-overthewire","tag-tutorials"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5zY4D-4o","_links":{"self":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/272","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=272"}],"version-history":[{"count":17,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/272\/revisions"}],"predecessor-version":[{"id":27474,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/posts\/272\/revisions\/27474"}],"wp:attachment":[{"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/media?parent=272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/categories?post=272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hackmethod.com\/wp-json\/wp\/v2\/tags?post=272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}