Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
- [How to Make a Ransomware in Python](https://www.thepythoncode.com/article/make-a-ransomware-in-python). ([code](ethical-hacking/ransomware))
- [How to Perform DNS Enumeration in Python](https://www.thepythoncode.com/article/dns-enumeration-with-python). ([code](ethical-hacking/dns-enumeration))
- [How to Geolocate IP addresses in Python](https://www.thepythoncode.com/article/geolocate-ip-addresses-with-ipinfo-in-python). ([code](ethical-hacking/geolocating-ip-addresses))
- [How to Crack Hashes in Python](https://thepythoncode.com/article/crack-hashes-in-python). ([code](ethical-hacking/hash-cracker))

- ### [Machine Learning](https://www.thepythoncode.com/topic/machine-learning)
- ### [Natural Language Processing](https://www.thepythoncode.com/topic/nlp)
Expand All@@ -61,6 +62,8 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
- [How to Fine Tune BERT for Semantic Textual Similarity using Transformers in Python](https://www.thepythoncode.com/article/finetune-bert-for-semantic-textual-similarity-in-python). ([code](machine-learning/nlp/semantic-textual-similarity))
- [How to Calculate the BLEU Score in Python](https://www.thepythoncode.com/article/bleu-score-in-python). ([code](machine-learning/nlp/bleu-score))
- [Word Error Rate in Python](https://www.thepythoncode.com/article/calculate-word-error-rate-in-python). ([code](machine-learning/nlp/wer-score))
- [How to Calculate ROUGE Score in Python](https://www.thepythoncode.com/article/calculate-rouge-score-in-python). ([code](machine-learning/nlp/rouge-score))
- [Visual Question Answering with Transformers](https://www.thepythoncode.com/article/visual-question-answering-with-transformers-in-python). ([code](machine-learning/visual-question-answering))
- ### [Computer Vision](https://www.thepythoncode.com/topic/computer-vision)
- [How to Detect Human Faces in Python using OpenCV](https://www.thepythoncode.com/article/detect-faces-opencv-python). ([code](machine-learning/face_detection))
- [How to Make an Image Classifier in Python using TensorFlow and Keras](https://www.thepythoncode.com/article/image-classification-keras-python). ([code](machine-learning/image-classifier))
Expand All@@ -86,6 +89,10 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
- [How to Generate Images from Text using Stable Diffusion in Python](https://www.thepythoncode.com/article/generate-images-from-text-stable-diffusion-python). ([code](machine-learning/stable-diffusion-models))
- [How to Perform Image to Image Generation with Stable Diffusion in Python](https://www.thepythoncode.com/article/generate-images-using-depth-to-image-huggingface-python). ([code](machine-learning/depth2image-stable-diffusion))
- [Real-time Object Tracking with OpenCV and YOLOv8 in Python](https://www.thepythoncode.com/article/real-time-object-tracking-with-yolov8-opencv). ([code](https://github.com/python-dontrepeatyourself/Real-Time-Object-Tracking-with-DeepSORT-and-YOLOv8))
- [How to Control the Generated Images by diffusion models via ControlNet in Python](https://www.thepythoncode.com/article/control-generated-images-with-controlnet-with-huggingface). ([code](machine-learning/control-image-generation-with-controlnet))
- [How to Edit Images using InstructPix2Pix in Python](https://www.thepythoncode.com/article/edit-images-using-instruct-pix2pix-with-huggingface). ([code](machine-learning/edit-images-instruct-pix2pix))
- [How to Upscale Images using Stable Diffusion in Python](https://www.thepythoncode.com/article/upscale-images-using-stable-diffusion-x4-upscaler-huggingface). ([code](machine-learning/stable-diffusion-upscaler))
- [Real-Time Vehicle Detection, Tracking and Counting in Python](https://thepythoncode.com/article/real-time-vehicle-tracking-and-counting-with-yolov8-opencv). ([code](https://github.com/python-dontrepeatyourself/Real-Time-Vehicle-Detection-Tracking-and-Counting-in-Python/))
- [Building a Speech Emotion Recognizer using Scikit-learn](https://www.thepythoncode.com/article/building-a-speech-emotion-recognizer-using-sklearn). ([code](machine-learning/speech-emotion-recognition))
- [How to Convert Speech to Text in Python](https://www.thepythoncode.com/article/using-speech-recognition-to-convert-speech-to-text-python). ([code](machine-learning/speech-recognition))
- [Top 8 Python Libraries For Data Scientists and Machine Learning Engineers](https://www.thepythoncode.com/article/top-python-libraries-for-data-scientists).
Expand DownExpand Up@@ -253,6 +260,9 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
- [How to Make an Accounting App with Django in Python](https://www.thepythoncode.com/article/make-an-accounting-app-with-django-in-python). ([code](web-programming/accounting-app))
- [How to Build a News Site API with Django Rest Framework in Python](https://www.thepythoncode.com/article/a-news-site-api-with-django-python). ([code](web-programming/news_project))
- [How to Create a RESTful API with Flask in Python](https://www.thepythoncode.com/article/create-a-restful-api-with-flask-in-python). ([code](web-programming/restful-api-flask))
- [How to Build a GraphQL API in Python](https://www.thepythoncode.com/article/build-a-graphql-api-with-fastapi-strawberry-and-postgres-python). ([code](https://github.com/menard-codes/PythonGQLArticle))
- [How to Build a Chat App using Flask in Python](https://thepythoncode.com/article/how-to-build-a-chat-app-in-python-using-flask-and-flasksocketio). ([code](https://github.com/menard-codes/FlaskChatApp))
- [How to Build a Full-Stack Web App in Python using FastAPI and React.js](https://thepythoncode.com/article/fullstack-notes-app-with-fastapi-and-reactjs) ([Backend](https://github.com/menard-codes/NotesAppBackend-FastAPI-React), [Frontend](https://github.com/menard-codes/NotesAppFrontend-FastAPI-React))

- ### [GUI Programming](https://www.thepythoncode.com/topic/gui-programming)
- [How to Make a Text Editor using Tkinter in Python](https://www.thepythoncode.com/article/text-editor-using-tkinter-python). ([code](gui-programming/text-editor))
Expand DownExpand Up@@ -288,6 +298,9 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
- [How to Make a Checkers Game with Pygame in Python](https://www.thepythoncode.com/article/make-a-checkers-game-with-pygame-in-python). ([code](gui-programming/checkers-game))
- [How to Make a Snake Game in Python](https://www.thepythoncode.com/article/make-a-snake-game-with-pygame-in-python). ([code](gui-programming/snake-game))
- [How to Create a Slide Puzzle Game in Python](https://www.thepythoncode.com/article/slide-puzzle-game-in-python). ([code](gui-programming/slide-puzzle))
- [How to Make a Maze Game in Python](https://www.thepythoncode.com/article/build-a-maze-game-in-python). ([code](gui-programming/maze-game))
- [How to Create a Platformer Game in Python](https://www.thepythoncode.com/article/platformer-game-with-pygame-in-python). ([code](gui-programming/platformer-game))
- [How to Make a Flappy Bird Game in Python](https://thepythoncode.com/article/make-a-flappy-bird-game-python). ([code](gui-programming/flappy-bird-game))


For any feedback, please consider pulling requests.
14 changes: 14 additions & 0 deletions ethical-hacking/hash-cracker/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
# [How to Crack Hashes in Python](https://thepythoncode.com/article/crack-hashes-in-python)
To run this:
- `pip install -r requirements.txt`
- Get usage: `python crack_hashes.py --help`
- Crack a SHA-256 hash using `wordlist.txt`:
```bash
$ python crack_hashes.py 6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090 wordlist.txt --hash-type sha256
```
**Output:**
```
[*] Cracking hash 6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090 using sha256 with a list of 14344394 words.
Cracking hash: 96%|███████████████████████████████████████████████████████████████████████████████████████████▉ | 13735317/14344394 [00:20<00:00, 664400.58it/s]
[+] Found password: abc123
```
53 changes: 53 additions & 0 deletions ethical-hacking/hash-cracker/crack_hashes.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
import hashlib
from tqdm import tqdm

# List of supported hash types
hash_names = [
'blake2b',
'blake2s',
'md5',
'sha1',
'sha224',
'sha256',
'sha384',
'sha3_224',
'sha3_256',
'sha3_384',
'sha3_512',
'sha512',
]

def crack_hash(hash, wordlist, hash_type=None):
"""Crack a hash using a wordlist.

Args:
hash (str): The hash to crack.
wordlist (str): The path to the wordlist.

Returns:
str: The cracked hash.
"""
hash_fn = getattr(hashlib, hash_type, None)
if hash_fn is None or hash_type not in hash_names:
# not supported hash type
raise ValueError(f'[!] Invalid hash type:{hash_type}, supported are{hash_names}')
# Count the number of lines in the wordlist to set the total
total_lines = sum(1 for line in open(wordlist, 'r'))
print(f"[*] Cracking hash{hash} using{hash_type} with a list of{total_lines} words.")
# open the wordlist
with open(wordlist, 'r') as f:
# iterate over each line
for line in tqdm(f, desc='Cracking hash', total=total_lines):
if hash_fn(line.strip().encode()).hexdigest() == hash:
return line


if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Crack a hash using a wordlist.')
parser.add_argument('hash', help='The hash to crack.')
parser.add_argument('wordlist', help='The path to the wordlist.')
parser.add_argument('--hash-type', help='The hash type to use.', default='md5')
args = parser.parse_args()
print()
print("[+] Found password:", crack_hash(args.hash, args.wordlist, args.hash_type))
1 change: 1 addition & 0 deletions ethical-hacking/hash-cracker/requirements.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
tqdm
Loading