Friday, December 27, 2024
Google search engine
HomeLanguagesEthical Hacking with Python

Ethical Hacking with Python

As a Computer Science Engineer who encrypts the world, one should know how Hacking activities are done. And we must stand front in protecting our world from cybercriminals.

Being able to gain access to a system that you’re not supposed to have access to is known as Hacking. For example, login into an email account without authorization is considered hacking that account. Gaining access to a remote computer without authorization is hacking that computer. So you can see that there are a large number of ways to hack into a system and the word hacking can refer to a number of things but the main concept is the same. Gaining access or being able to do things that you’re not supposed to be able to do, is considered hacking.

Ethical hacking: 
To crack passwords or to steal data? No, it is much more than that. Ethical hacking is to scan vulnerabilities and to find potential threats on a computer or networks. An ethical hacker finds the weak points or loopholes in a computer, web applications or network and reports them to the organization. So, let’s explore more about Ethical Hacking step-by-step.

These are various types of hackers

  • Black hat hackers: 
    Here, the organization doesn’t allow the user to test it. They unethically enter inside the website and steal data from the admin panel or manipulate the data. They only focus on themselves and the advantages they will get from the personal data for personal financial gain. They can cause major damage to the company by altering the functions which lead to the loss of the company at a much higher extent. This can even lead you to extreme consequences.
     
  • White hat hackers: 
    Here, we look for bugs and ethically report it to the organization. We are authorized as a user to test for bugs in a website or network and report it to them. White hat hackers generally get all the needed information about the application or network to test for, from the organization itself. They use their skills to test it before the website goes live or attacked by malicious hackers.
     
  • 3.Grey hat hackers: 
    They sometimes access to the data and violates the law. But never have the same intention as Black hat hackers, they often operate for the common good. The main difference is that they exploit vulnerability publicly whereas white hat hackers do it privately for the company. 

Note: To know more about types of hackers click here.

Why Python Programming For Hacking

Python is a widely used general-purpose, high-level programming language. Python is a very simple language yet powerful scripting language, it’s open-source and object-oriented and it has great libraries that can be used for both for hacking and for writing very useful normal programs other than hacking programs. In the future and present era python is very popular and it’s easy to learn, learning to hack with python will be fun and you will learn python programming in the best way. There is a great demand for python developers in the market.
Note: To know more about python click here.
 

How Password Are Hacked

Everyone knows that passwords are not stored a plain text in the website’s database. Now we are going to see how to hack a plain text password when you find a password that is in hashed(md5) format. So we take the input_hash(hashed password in the database) and try to compare it with md5 hash of every plain text password which is in a password file(pass_doc) and when the hashes are matched we simply display the plain text password which is in the password file(pass_doc). If the password is not present in the input password file it will say password is not found, this happens only if buffer overflow doesn’t occur. This type of attack can be considered as a dictionary attack.

Below is the implementation. Let’s suppose the text file containing list of password is password.txt.

Python3




import hashlib
print("**************PASSWORD CRACKER ******************")
        
# To check if the password
# found or not.
pass_found = 0                                     
 
input_hash = input("Enter the hashed password:")
 
pass_doc = input("\nEnter passwords filename including path(root / home/):")
  
try:
    # trying to open the password file.
    pass_file = open(pass_doc, 'r')             
except:
    print("Error:")
    print(pass_doc, "is not found.\nPlease give the path of file correctly.")
    quit()
 
 
# comparing the input_hash with the hashes
# of the words in password file,
# and finding password.
 
for word in pass_file:
    # encoding the word into utf-8 format
    enc_word = word.encode('utf-8'
             
    # Hashing a word into md5 hash
    hash_word = hashlib.md5(enc_word.strip())  
  
    # digesting that hash into a hexa decimal value    
    digest = hash_word.hexdigest()        
      
    if digest == input_hash:
        # comparing hashes
        print("Password found.\nThe password is:", word)  
        pass_found = 1
        break
 
# if password is not found.
if not pass_found:
    print("Password is not found in the", pass_doc, "file")  
    print('\n')
print("*****************  Thank you  **********************")


Input: 

Enter the hashed password :  061a01a98f80f415b1431236b62bb10b 
Enter passwords filename including path(root/home/) : password.txt

Output: 

Password found.
The password is : vivek 

Input:  

Enter the hashed password :  aae039d6aa239cfc121357a825210fa3 
Enter passwords filename including path(root/home/) : password.txt

Output  

Password found.
The password is : jessica 

 

RELATED ARTICLES

Most Popular

Recent Comments