Posted on

Beginners guide to Commix

Hello, aspiring ethical hackers. In one of our previous blogposts, you learnt what is command injection, types of command injection etc. In this blogpost, you will learn about Commix, a tool that is used to automatically exploit command injection vulnerability.

Commix, which is short for (comm) and (injection) e(x)ploiter is an open source pen testing tool written by Anastasior Stasinopolos that is useful in automatically detecting and exploiting command injection vulnerabilities. Written in Python, commix can be installed on any platform that supports Python.

On pen testing distros like Kali Linux, commix is installed by default. So, we will be using it for this tutorial. As target, we will be using mutillidae in Metasploitable 2. Mutillidae, is an intentionally vulnerable web application for practicing ethical hacking. See how to install Metasploitable 2 in virtualBox and set up a virtual hacking lab.

A webpage “dns-lookup.php” in mutillidae has a command injection vulnerability in the Hostname/IP field. These vulnerabilities can be detected using web vulnerability scanners like OWASP ZAP (aka zaproxy), Nikto, Burpsuite etc.

Commix 1

What this webpage does is when you provide an IP or hostname, it performs a DNS lookup of that IP or hostname (For example, we have used it on google.com).

Commix 2

This is its name functioning but when you join another command to the IP/hostname using ampersand as shown below, it also executes that command as shown below.

Commix 3
Commix 4 1

Commix allows us to exploit this vulnerability automatically. To do this, with commix, we need information about the parameter being sent while sending this query. This can be achieved by using OWASP ZAP as an intercepting proxy. See how to set OWASP ZAP as an intercepting proxy.

Commix 5

The target can be specified in commix using the “-u” option and POST data can be specified using “–data” option as shown below.

Commix 28

When you execute this command, commix will prompt you to set cookies. Cookies are not needed in this case.

Commix 29

Then, commix says the parameters we are testing is vulnerable to command injection and it will prompt you for a pseudo-terminal access.

Commix 30

Selecting ‘Yes” will give us access to the commix shell a shown below.

Commix 31

Apart from giving you a terminal on the target system, commix provides a lot of enumeration options. Let’s see some of them here.

–hostname

It retrieves the hostname of the target system.

Commix 6
Commix 7

–current-user

This command retrieves the current user on the target system.

Commix 8
Commix 9

–is-root

This command checks if the current user has root privileges.

Commix 10
Commix 11

–is-admin

This command checks if the current user has admin privileges.

Commix 12

–sys-info

As you might have guessed by now, this command retrieves the system information of the target.

Commix 13
Commix 14

–users

This command retrieves all the users on the target system.

Commix 15
Commix 16

–passwords

This command retrieves passwords of all the users on the system.

Commix 17
Commix 18

Here, of course we did not get any password hashes, as we do not have enough privileges to get those.

–privileges

This command retrieves the privileges of all the users on the target system.

Commix 19

–ps-version

This command retrieves the version of the PowerShell installed on the target system.

Commix 20

–all

Instead of enumerating each item separately, you can retrieve all the information from the target system using the “–all” option.

Commix 21
Commix 22
Commix 23

–os-cmd

This command is used to execute a single operating system command on the target system. For example, let’s execute “ls” command on the target system.

Commix 24
Commix 25

–os=

This command is used to force the backend operating system (For example, Windows or UNIX.

Commix 26
Commix 27
Posted on

Beginners guide to XSSer

Hello, aspiring ethical hackers. In one of our previous blogposts, you learnt what XSS vulnerability is, what are the different types of XSS vulnerabilities and its impact on web security. Wouldn’t it be good if there was a tool that can automatically detect and exploit XSS vulnerabilities? In this blogpost, you will be learning about one such tool named XSSer which is an automatic framework to detect, exploit and report XSS vulnerabilities in web applications.

XSSer is a python script and can be installed on all Linux systems with python installed. It is installed by default in Kali Linux and we are going to use the same for this tutorial. See how to install kali Linux in virtual Box. We will be using Mutillidae in Metasploitable 2 as target to test with XSSer as it is easily available to download and this tutorial is easily reproducible. See how to install Metasploitable 2 in VirtualBox.

Mutillidae is a vulnerable web app that intentionally consists of all OWASP 10 vulnerabilities for practicing web application hacking. Also see how to create a virtual hacking lab in virtual Box. In the page shown below belonging to Mutillidae, the blog entry field consists of a XSS vulnerability. These vulnerable pages can be detected using web vulnerability scanners like OWASP ZAP aka Zaproxy, Nikto and Burpsuite etc.

XSSer 1

XSSer can also be used to scan for XSS vulnerabilities using the “–all” option” as shown below.

XSSer 2
XSSer 3
XSSer 4
XSSer 5
XSSer 6

However, here XSSer failed to find any XSS vulnerability. Let’s see how to find any XSS vulnerability in this specific section. For this, I start OWASP ZAP as intercepting proxy to capture web requests. Then, I change the setting in the browser to access the web through this proxy and visit the vulnerable page again on this browser.

XSSer 7

I type “This is a new blogpost” in the blogpost entry and save the blogpost. Now, when we view the captured web request in OWASP ZAP as shown below, we can see the request being sent to the target.

XSSer 8

Now, we copy the highlighted data above and use it in our XSSer tool. The only difference is to find out the XSS vulnerability, we add text “XSS” in the place of any vector that us vulnerable to XSS.

XSSer 9

Note the method the query is using to pass this data. There are two methods by which data is sent and received: GET and POST. XSSer has an option to use both the methods: (-g) for GET method and (-p) for POST method. OWASP ZAP has shown us that this data is being passed using the POST method. So, we will be using the same with XSSer.

XSSer 10
XSSer 11
XSSer 12
XSSer 13

Now, you can see that vector “blog_entry” is vulnerable to cross site scripting using URL method. Here, we tried one vector. XSSer provides an option to inject a list of vectors provided by XSSer. To test all these vectors, we can use the “—auto” option. XSSer in total has 1291 injection vectors.

XSSer 14
XSSer 15

As you can see, XSSer found 1287 of 1291 injection vectors in the web app. XSSer also has the option of using payloads. Here the payload can be anything even the most popular <script> alert (“HC”)</script). Here is how we specify the payload in XSSer.

XSSer 16

Here I have given the same above-mentioned script as payload.

XSSer 17

Specify your own payload

Using the “-Fp” option, you can even specify your own payload for final injection.

XSSer 18

Execute payload remotely

The “-Fr” option is used to execute the payload remotely.

XSSer 19
XSSer 20

Posted on

Cewl wordlist generator: Complete guide

Hello, aspiring ethical hackers. This blogpost is a complete guide to Cewl wordlist generator. Cewl stands for Custom Word List generation. It is written in ruby language. Unlike crunch that takes input from us to generate a wordlist, this tool spiders a given website to the depth specified by us and then creates a dictionary or wordlist from it. This wordlist can then be used for password cracking with tools the Brutus, Hydra, Medusa and John The Ripper. It was designed by Robin Wood based on a discussion on PaulDotCom about creating wordlists by spidering a target website.

Cewl can be downloaded from here. Kali Linux has cewl installed by default and for this tutorial we are using the same. Metasploitable 2will be used as target since it has lot of applications installed that can be used for testing it.

Cewl 1

To use cewl, all we have to do is simply supply the URL you want to spider for as shown below.

Cewl 2

Then it will create the wordlist for you as shown below.

Cewl 3
Cewl 4

Keeping the downloaded file (-k)

Specifying the ‘-k’ option the downloaded file can be saved.

Cewl 5

Depth of spidering (-d)

When you specify a target to Cewl, it spiders to the dept of 2 by default. You can change it using this option. For example, let’s set the depth to 1.

Cewl 6

Or 3 may be.

Cewl 7

Minimum word length (-m)

This option can be used to set the minimum length of the passwords cewl creates. For example, nowadays, most services set the minimum length of the password to at least 5. So there’s no use creating passwords with length less than the minimum length your target has set, If you have noticed the above results, the default minimum length for cewl is 3. Let’s set it to 5 for example.

Cewl 8
Cewl 9

As you can see in the above image, there are no longer passwords of length less than 5.

Spidering other sites (-o)

Setting this option allows cewl to spider another external sites during spidering of the target.

Cewl 10

Don’t scan specified paths (–exclude)

If the target website is too large, you may want to skip some paths or maybe you just want to skip some paths as they may not have any passwords. You can use this option what cewl to exclude the paths you don’t want to scan. Then paths should be supplied in a file.

Cewl 11
Cewl 12

–allowed

This option is used to specify regex patterns of the path to be followed. If the pattern doesn’t match, it drops the scan.

Cewl 13

No wordlist please (-n)

If you don’t want the wordlist to be printed, you can use the “-n” option.

Cewl 17

Saving the output (-w)

Till now, you have seen that Cewl has been printing the wordlists it creates to the terminal. The output can be copied and pasted in another file to be saved from using as a wordlist. But why take all this effort when we can just save the output to file, using the ‘-w’ option.

Cewl 14
Cewl 15

Use User agent (-u))

A user agent is a characteristic string that allows web server to identify the browser and operating system and we are using. You can see your user agent here. Using the (-u) option, cewl allows you to be get a specific user agent while spidering the website.

Cewl 16

Groups of words (-g)

Setting this option allow cewl to return group of words along with single words.

Cewl 18

Turn all generated passwords to lowercase (–lowercase)

Setting this option allows us to 16 turn all the passwords cewl generates into lower case.

Cewl 19

Here is the result.

Cewl 20

Include words with numbers too (–with-numbers)

While spidering, if cewl finds any words with numbers in them, it just ignores them. But many passwords contain numbers too. By setting this option, cewl collects numbers as well.

Cewl 21
Cewl 22

–convert-umlauts

Setting this option to while using cewl converts common ISO-8859-1 umlauts.

Cewl 23

Include meta data too (-a)

When we set this option, Cewl includes metadata found while spidering the website apart from the words.

Cewl 24

This metadata found is included at the end of the output files as shown below.

Cewl 25

Save metadata found to a different file (–meta-file)

You can even save all the metadata found on the target site to a different file as shown below using the “–meta-file” option.

Cewl 26

In the above image, you can see that cewl, while processing metadata creates a temporary file. This file known as cewl-temp.pdf is created in the /tmp directory by default. We can change the location of this file by using the “—meta-temp-dir” option as shown below.

Cewl 27

Gather emails too (-e)

Not just metadata, you can even process emails using cewl with the ‘-e’ option.

Cewl 28
Cewl 29

Save collected emails in another file (–email-file)

These collected emails can also be saved in another file using the “–email-file” option.

Cewl 30
Cewl 31

Show the count for each word (-c)

Setting this option shows the count for each word.

Cewl 32
Cewl 33

Verbose mode (-v)

Just like every other tool, this tool to has verbose mode that gives detailed information.

Cewl 34
Cewl 35

Debug mode (–debug)

Similarly, the “–debug” option gives detailed debugging information too.

Cewl 36
Cewl 37

Authentication

Some sites need authentication to spider it. Cewl allows authentication of websites too.

Cewl 38

It supports both basic authentication and digest authentication. The “auth_type” option is used to set the type of authentication. The “–auth _user” and “–auth_pass” option can be used to set username and passwords respectively.

Cewl 39

Here’s the output.

Cewl 40

Spidering through proxy

Spidering, no matter what the purpose is very noisy. Cewl has an option to spider through a proxy using the “–proxy_host” option.

Cewl 41

You can even specify the port of the proxy using the “–proxy-port” option.

Cewl 42

Cewl even has feature of authenticating to the proxy server using the “–proxy_username” and “–proxy_password” options.

Cewl 43
Posted on

Hydra password cracker: Complete guide

Hello, aspiring ethical hackers. This blogpost is a complete guide to Hydra password cracker. Hydra password cracker runs on Linux, Windows, Solaris, FreeBSD/openBSD, QNX and macOS. Using Hydra, we can crack passwords of various protocols like Asterisk, AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP, HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-POST, HTTP-PROXY, HTTPS-FORM-GET, HTTPS-FORM-POST, HTTPS-GET, HTTPS-HEAD, HTTPS-POST, HTTP-Proxy, ICQ, IMAP, IRC, LDAP, MEMCACHED, MONGODB, MS-SQL, MYSQL, NCP, NNTP, Oracle Listener, Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, Radmin, RDP, Rexec, Rlogin, Rsh, RTSP, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP v1+v2+v3, SOCKS5, SSH (v1 and v2), SSHKEY, Subversion, Teamspeak (TS2), Telnet, VMware-Auth, VNC and XMPP.

Hydra can be downloaded from here. This guide uses Hydra installed on default in Kali Linux and Metasploitable2 as target.

Single username (-l) and Password (-P)

If you want to check a single username and password with Hydra, the syntax is given below. Here we are testing the credentials on target system’s FTP server. This is normally useful when we have a general idea about at least one credential pair.

Hydra Password Cracker 1 1

Hydra will test this credential and come with a result. Here it is found this credential accurate.

Hydra Password Cracker 2

What if you can’t guess a password or have no knowledge about at least one credential pair. Then we need to test a large list of credentials using brute forcing by using a wordlist.

Specifying wordlist for usernames (-L) and passwords (-P)

You can specify wordlist containing usernames using the (-L) option and specify the wordlist containing passwords using the (-P) option as shown below.

Hydra Password Cracker 3

Here, I am suing the same wordlist for both username and passwords. “Metsaploitable.txt”. These wordlists are normally created or obtained during the enumeration stage. For example, we obtained this during SMB enumeration of the target. Hydra found three credentials valid from this wordlist.

Hydra Password Cracker 4

Restore a cancelled session (-R)

Sometimes we may need to test a large wordlist, with thousands of credentials in it. This may obviously take a lot of time and we may have to hit “CTRL+C” sometimes to cancel the session or maybe a power cut ended our scan abruptly.

Hydra Password Cracker 5

Do we have to start from the beginning again? Don’t worry. You can restore the session from where you stopped in Hydra as shown below.

Hydra Password Cracker 6

RIgnore the previous session (-I)

What if we don’t want to restart that session and to start a session afresh. We can just use the ignore (-I) command which asks it to ignore the previous session.

Hydra Password Cracker 7

Scanning unconventional ports (-s)

You know every service has a default port on which it runs. For example, FTP (21), Telnet (23), and HTTP (80) etc. Sometimes administrators configure this service to run on unconventional ports to make them less conspicuous. Using Hydra we can even run password attack on these ports using the (-s) option. For example, imagine FTP is running on the port 2121 and not 21.

Hydra Password Cracker 8

Target has SSL enabled (-S)

Using Hydra, we can connect using SSL with this option.

Hydra Password Cracker 9

If the service has an old version of SSL, we can use the “-O” option.

Hydra Password Cracker 10

Additional checks (-e)

Using this option, you can check accounts for null passwords (n), using username as password (-s) and using password as username and vice versa (-r).

Hydra Password Cracker 11

Combo (-C)

Sometimes, instead of an usual wordlist, we have wordlists that have credentials in “login:pass” format as shown below.

Hydra Password Cracker 12

If we want to use this type of wordlist, you can use this option.

Hydra Password Cracker 13
Hydra Password Cracker 14

-U

When you are using a wordlist with Hydra, by default it checks all passwords for the first username and then tries the next username. Using this option, we can loop around the passwords. The first password is checked for all the usernames and then it moves to next password and does the same.

Hydra Password Cracker 15

Stop after getting the first successful pair of credentials (-f)

This option (-f) makes Hydra stop password cracking as soon as one successful pair of credentials are found.

Hydra Password Cracker 16
Hydra Password Cracker 17

Target multiple servers (-M)

Hydra allows us to perform password cracking on multiple servers at once. We need to provide a file containing IP addresses of the targets.

Hydra Password Cracker 19

Stop after getting once successful pair on multiple servers (-F)

Setting the ‘-F’ option, Hydra stops after getting the first successful pair of credentials on multiple servers.

Hydra Password Cracker 18

Saving the output (-o)

Till now, we have seen Hydra showing output on stdout. However, with the “-o” option, we can save the output of the tool to a file.

Hydra Password Cracker 20
Hydra Password Cracker 21

Format of the output file (-b)

Hydra allows you to save output in three formats, although the default format is text. It also allows you to save output in Json and Json v2 format.

Hydra Password Cracker 22
Hydra Password Cracker 23

Number of tasks (-t)

Tasks are number of persistent connections Hydra makes while testing. By default, it makes 16 tasks, but this can be changed using this option. For example, let’s set it to 19.

Hydra Password Cracker 24

Module specific options (-m)

This option allows us to set module specific options. For example, FTP module in Hydra doesn’t have any module specific options. But other modules like HTTP have it. All the options for a specific module can be seen using the -U option. For example, lets change the option for http-get.

Hydra Password Cracker 25
Hydra Password Cracker 26
Hydra Password Cracker 27

Waiting time (-w)

Hydra waits for 32 seconds for receiving responses for it queries. This option can be used to change this time. For example, let’s set it to 10 seconds.

Hydra Password Cracker 28
Hydra Password Cracker 29
Hydra Password Cracker 30

Waiting time for login attempts (-c)

This option can be used set the waiting time for login attempts Hydra performs. It is useful only when a low task time is used.

Hydra Password Cracker 31

Verbose mode (-v) (-V)

Hydra has two verbose mode. The lowercase verbose mode is the default verbose mode in any other tool.

Hydra Password Cracker 32

If you want to see each login attempt Hydra makes, you need to use the (-V) option.

Hydra Password Cracker 33
Hydra Password Cracker 34

That’s all about Hydra password cracker.

Posted on

Complete guide to DNSrecon

Hello, aspiring ethical hackers. This is a complete guide to dnsrecon tool. In our previous blogpost on DNS enumeration, you read what DNS is, what are the various types of DNS records, what is the information about the network can DNS enumeration reveal to a pen tester or a Black Hat Hacker. DNSrecon is one such tool used for enumerating DNS.

DNSrecon is written by Carlos Perez. He wrote it initially in Ruby to learn about that programming language and about DNS way back in 2007. As time passed by, he wanted to learn python and he posted dnsrecon tool to python.

The features of DNSrecon tool are,

  1. Checks all NS Records for Zone Transfers.
  2. Enumerates general DNS Records for a given domain (MX, SOA, NS, A, AAAA, SPF and TXT).
  3. Performs common SRV Record enumeration.
  4. Top Level Domain (TLD) expansion.
  5. Checks for Wildcard resolution.
  6. Brute forces subdomains and host A and AAAA records given in a domain and a wordlist.
  7. Performs PTR record lookup for a given IP Range or CIDR.
  8. Checks a DNS server’s cached records for A, AAAA and CNAME.
  9. Records provided a list of host records in a text file to check.

Let’s see how to enumerate DNS with DNSrecon. DNSrecon is installed by default in Kali Linux. To use DNSrecon, all we have to do is use the command below.

dnsenum -d <domain>

DNSrecon 12

–name_server (-n)

By default, DNSrecon will use SOA of the target server to enumerate DNS. You can use a different server, you can use it using this option.

DNSrecon 3

-a

This option is used to do a zone transfer along with standard enumeration performed above.

DNSrecon 4

As expected it failed.

DNSrecon 5

-y, -b, -k

Similarly, you can perform yandex (-y), bing(-b), crt.sh (-k) enumeration along with standard enumeration.

DNSrecon 7
DNSrecon 8
DNSrecon 9
DNSrecon 10

-w

This option is used to perform deep whois record analysis and reverse lookup of IP ranges found when doing standard enumeration.

DNSrecon 11

-z

This option is used to perform a DNSSEC zone walk along with standard enumeration.

DNSrecon 12 1
DNSrecon 13

–dictionary (-d)

This option is used to use a dictionary file containing subdomains and hostnames to use for brute force.

DNSrecon 14

–range (-r)

Specify a IP range to perform reverse lookup.

DNSrecon 15

–type (-t)

This option is used to perform a specific type of enumeration only. The various possible types of enumeration that can be performed using dnsrecon are,

  • Std: all SOA, NS, A, AAAA, MX and SRV.
  • rvl: reverse lookup
  • brt: brute force using a given dictionary
  • srv: SRV records.
  • axfr: zone transfer from NS server.
  • bing: Bing search for hosts and subdomains.
  • Yand: Yandex search for hosts and subdomains.
  • Crt: crt.sh enumeration for subdomains and hosts.
  • Snoop: cache snooping argument at NS server.
  • tld: test against all TLD’s registered with IANA.
  • Zonewalk: perform DNS sec Zone using NSEC records.
DNSrecon 16
DNSrecon 17
DNSrecon 18
DNSrecon 19
DNSrecon 20

Saving results

You can save the results of the found records to a database (-db), XML (-X), CSV (-c) and Json(-j) files.

DNSrecon 21
DNSrecon 22 1
DNSrecon 23

–lifetime

This option is used to set the time the tool has to wait until the target server responds. The default time is 3 seconds.

DNSrecon 24

–threads

This option is useful to specify the number of threads to be used while performing reverse lookup, forward lookup, brute force and SRV record enumeration.

DNSrecon 25

That’s all about DNSrecon.