{"id":86,"date":"2022-07-17T22:11:01","date_gmt":"2022-07-17T22:11:01","guid":{"rendered":"http:\/\/moveax.me\/?p=86"},"modified":"2022-07-17T22:14:55","modified_gmt":"2022-07-17T22:14:55","slug":"nebula-level11-a-newbies-approach","status":"publish","type":"post","link":"https:\/\/giga-rapid.com\/esites\/moveaxme\/nebula-level11-a-newbies-approach\/","title":{"rendered":"Nebula Level11: A Newbie\u2019s Approach"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Level11 is once more a good challenge to understand the importance of careful designing of SUID programs and the sanitization of all the input, either if it comes from an user or some other source.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What you\u2019ll need to know\u2026<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>C<\/li><li>Level 7 (So you can create your own SUID program)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Level11<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before we go through this challenge, let me make an aside note. After facing some problems, I decided to google about this challenge, where I ended up finding that it has some problems. I read on various websites that the&nbsp;<a href=\"\">code<\/a>&nbsp;presented on the official webpage is not the one that originated the program present in \/home\/flag11. Therefore, I\u2019ve decided to upload the original code to the \/home\/flag11 and compile it, using the nebula account for this task.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Having said that, let\u2019s move on.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Level11 has, once more, a SUID program, flag11. Also, it has a system call with non sanitized arguments. Two nice ingredients to cook something\u2026<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, you run the flag11 program and it\u2019ll wait for some kind of input, \u201cContent-Length: \u201c, that will be verified in the first two if clauses. After this, the program can follow two paths. The first one is the case of the number provided is between 1 and 1023. If you provide 1024 or some number above it will fall in the second clause. Negative numbers won\u2019t be accepted due to the while statement (and also due to mmap).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The easiest way to get to the system call and exploit the program is by passing 1 as a length and then, as input, pass a random letter (except a, A, z and Z) or number. If you go through the function process, you\u2019ll notice that your character will end up being XORed with the length, 1. I\u2019ll go with \u201cl\u201d letter.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"wp-content\/uploads\/2018\/06\/attempts.png\" alt=\"attempts\" class=\"wp-image-716\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><br>Now, when you execute the program, you\u2019ll see an \u201cm\u201d popping up. Within a few tries, you notice that the letter \u201cm\u201d appears all alone.<br>I\u2019ll use the old trick from&nbsp;<a href=\"nebula-level07\/\">challenge 7<\/a>&nbsp;and created my own SUID program. Can you see where I\u2019m going?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, after the letter \u201cl\u201d is&nbsp;<em>encrypted<\/em>, process function will try to call the system function to execute \u201cm\u201d (\u201cl\u201d XORed). \u201cm\u201d command does not exist, so I\u2019ll create a symbolic link to my script wich will compile my SUID program.<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_723\"><img decoding=\"async\" src=\"wp-content\/uploads\/2018\/06\/scripts-1.png\" alt=\"Scripts\" class=\"wp-image-723\"\/><figcaption>Scripts<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_718\"><img decoding=\"async\" src=\"wp-content\/uploads\/2018\/06\/link.png\" alt=\"Symbolic link\" class=\"wp-image-718\"\/><figcaption>Symbolic link<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We also need to add the \/tmp folder to the environment variable PATH (export PATH=\/tmp\/:$PATH).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After a few attempts, I get the \u201cm\u201d all alone and check the \/home\/flag11 directory I get the result of the following image.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"wp-content\/uploads\/2018\/06\/suid.png\" alt=\"suid\" class=\"wp-image-719\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Then, it\u2019s just a matter of running the program and get the flag.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"wp-content\/uploads\/2018\/06\/result_level11.png\" alt=\"result level11\" class=\"wp-image-720\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Solved. 8 more to go!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Challenges completed: 12\/20<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Mitigation<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Same advices given for&nbsp;<a href=\"nebula-level09\">level09<\/a>,&nbsp;<a href=\"nebula-level07\">level07<\/a>&nbsp;and&nbsp;<a href=\"nebula-level00\/\">level00<\/a>&nbsp;apply.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Walkthrough<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Nebula Level 10-14\" width=\"500\" height=\"375\" src=\"https:\/\/www.youtube.com\/embed\/xGOqq_6blPo?start=177&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Further Reading<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Stream_cipher\">Stream cipher<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Level11 is once more a good challenge to understand the importance of careful designing of SUID programs and the sanitization of all the input, either&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/giga-rapid.com\/esites\/moveaxme\/nebula-level11-a-newbies-approach\/\">Continue reading<span class=\"screen-reader-text\">Nebula Level11: A Newbie\u2019s Approach<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-nebula","category-uncategorized","entry"],"_links":{"self":[{"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":3,"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/posts\/86\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/giga-rapid.com\/esites\/moveaxme\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}