Ethical Hacking with Python
Last Updated :
07 Jul, 2021
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 ******************" )
pass_found = 0
input_hash = input ( "Enter the hashed password:" )
pass_doc = input ( "\nEnter passwords filename including path(root / home/):" )
try :
pass_file = open (pass_doc, 'r' )
except :
print ( "Error:" )
print (pass_doc, "is not found.\nPlease give the path of file correctly." )
quit()
for word in pass_file:
enc_word = word.encode( 'utf-8' )
hash_word = hashlib.md5(enc_word.strip())
digest = hash_word.hexdigest()
if digest = = input_hash:
print ( "Password found.\nThe password is:" , word)
pass_found = 1
break
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
Similar Reads
eval in Python
Python eval() function parse the expression argument and evaluate it as a Python expression and runs Python expression (code) within the program. Python eval() Function SyntaxSyntax: eval(expression, globals=None, locals=None) Parameters: expression: String is parsed and evaluated as a Python expres
6 min read
What Can I Do With Python?
Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code readability with its notable use of significant whitespace. Let's see what Python programming does: Uses of PythonIn terms of
5 min read
Getting Started with Python Programming
Python is a versatile, interpreted programming language celebrated for its simplicity and readability. This guide will walk us through installing Python, running first program and exploring interactive codingâall essential steps for beginners. Install PythonBefore starting this Python course first,
3 min read
Higher-Lower Game with Python
In this article, we will be looking at the way to design a game in which the user has to guess which has a higher number of followers and it displays the scores. Game Play:The name of some Instagram accounts will be displayed, you have to guess which has a higher number of followers by typing in the
8 min read
How to Build a Python package?
In this article, we will learn how to develop the package in Python. Packages are nothing but a collection of programs designed to perform a certain set of task(s). Packages are of two types, namely Built-in Packages like collection, datetime, sqlite, etc.External packages like flask, django, tensor
5 min read
Normalizing Textual Data with Python
In this article, we will learn How to Normalizing Textual Data with Python. Let's discuss some concepts : Textual data ask systematically collected material consisting of written, printed, or electronically published words, typically either purposefully written or transcribed from speech.Text normal
7 min read
Chat Bot in Python with ChatterBot Module
Nobody likes to be alone always, but sometimes loneliness could be a better medicine to hunch the thirst for a peaceful environment. Even during such lonely quarantines, we may ignore humans but not humanoids. Yes, if you have guessed this article for a chatbot, then you have cracked it right. We wo
3 min read
How to Learn Python Basics With ChatGPT
Python is one of the most popular programming languages, known for its simplicity and versatility. Whether you're a complete beginner or an experienced programmer looking to expand your skillset, mastering the basics of Python is essential. In this guide, we'll walk you through the fundamentals of P
4 min read
Data Hiding in Python
In this article, we will discuss data hiding in Python, starting from data hiding in general to data hiding in Python, along with the advantages and disadvantages of using data hiding in python. What is Data Hiding? Data hiding is a concept which underlines the hiding of data or information from the
3 min read
Detect script exit in Python
Python is a scripting language. This means that a Python code is executed line by line with the help of a Python interpreter. When a python interpreter encounters an end-of-file character, it is unable to retrieve any data from the script. This EOF(end-of-file) character is the same as the EOF that
2 min read