• Offers
    • RegisterLogin
      • Learn More
    PythonPoint.netPythonPoint.net
    • Offers
    • RegisterLogin
      • Learn More

      Python

      SKILL IS IMPORTANT THAN DEGREE Be skill full.
      • Home
      • Blog
      • Python
      • How to use Python for Hacking

      How to use Python for Hacking

      • Posted by Python Point Team
      • Categories Python
      • Date December 31, 2022
      • Comments 0 comment
      how to use python for hacking

      Hacking is an attempt to exploit a computer system or a private network inside a computer. Simply put, it is the unauthorized access to or control over computer network security systems for some illicit purpose.

      Ethical hacking is to scan vulnerabilities and to find potential threats on a computer or networks.

      Python is a widely used general-purpose, high-level programming language. It has great libraries that can be used for hacking.

      In this article, we will see an example of hacking passwords with Python. 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 type of attack can be considered as a dictionary attack.

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

      import hashlib 
      print("******PASSWORD CRACKER******") 
      		 
      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') 
      			
      	# Hasing 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 :  061a01a98f80f459b1431236b62bb10b 
      Enter passwords filename including path(root/home/) : password.txt

      Output:

      Password found.
      The password is : anie
      • Share:
      author avatar
      Python Point Team

      Previous post

      How to Use PyCharm for Python
      December 31, 2022

      Next post

      How to use Python in Android Studio
      December 31, 2022

      You may also like

      15 Powerful Step for Mastering JSON Parsing in Python: Boosting Data Manipulation and Validation
      21 June, 2023

      Introduction In the world of programming, data plays a crucial role, and managing it efficiently is of utmost importance. JSON (JavaScript Object Notation) has emerged as a popular data interchange format due to its simplicity and flexibility. In this article, …

      Introduction to Transfer Learning with Python: A Practical Guide
      31 December, 2022

      Introduction: Definition of transfer learning Overview of how transfer learning works in the context of machine learning Why transfer learning is useful and important Section 1: Transfer learning in Python with Keras In this section, we will explore how to …

      How to Check Type in Python
      31 December, 2022

      In this article, we will learn to check type in Python. The built-in function type() can be used to check the type of data in Python.

      Subscribe
      Login
      Notify of
      Please login to comment
      0 Discussion
      Inline Feedbacks
      View all comments

      Latest Courses

      (Hindi) Ways to earn minimum 1 Lakh Per month as Programmer

      (Hindi) Ways to earn minimum 1 Lakh Per month as Programmer

      ₹10,000
      (HINDI) Full Stack Web Development In Python 3.8 And Django 3.1

      (HINDI) Full Stack Web Development In Python 3.8 And Django 3.1

      ₹25,000 ₹2,500

      Latest Posts

      • 15 Powerful Step for Mastering JSON Parsing in Python: Boosting Data Manipulation and Validation
      • Introduction to Transfer Learning with Python: A Practical Guide
      • How to Check Type in Python
      • How to make web crawler in python?
      • Why was the language called “python”?
      Contact
      •   support@pythonpoint.com

      We get you the best Python Courses and Blogs aiming to provide skill.

      We Believe Skill is much more important than a Degree

      Company
      • About Us
      • Blog
      • Offers
      • Contact
      Useful Links
      • Courses
      Support
      • Need Support

      © 2020 ALL RIGHTS RESERVED​ PYTHONPOINT.NET

      PythonPoint

      • Terms of Use
      • Refund Policy
      • Privacy Policy

      Login with your site account

      Lost your password?

      Not a member yet? Register now

      Register a new account

      Are you a member? Login now

      wpDiscuz