diff --git a/README.md b/README.md index cf508b1..478aca6 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,45 @@ -# Guideline how to implement solution for Python tasks - -## Prepare the project -1. Fork the repo (GitHub repository) -1. Clone the forked repo - ``` - git clone the-link-from-your-forked-repo - ``` - - You can get the link by clicking the `Clone or download` button in your repo -1. Open the project folder in your IDE -1. Open a terminal in the project folder -1. Create a branch for the solution and switch on it - ``` - git checkout -b develop - ``` - - You can use any other name instead of `develop` -1. If you are using PyCharm - it may propose you to automatically create venv for your project - and install requirements in it, but if not: - ``` - python -m venv venv - venv\Scripts\activate (on Windows) - source venv/bin/activate (on macOS) - pip install -r requirements.txt - ``` - -## Implement the solution -1. Implement the solution within a function in `app/main.py` - ![Where to write a solution](./assets/where-to-write-a-solution.png) -1. Run `pytest` to check if your solution is correct (from command line, or using PyCharm `pytest` support) - - If at least one test fails fix the solution and check again. -1. Run `flake8` to see if your code follows the [flake8 rules](https://www.flake8rules.com/) - - If you see some errors fix them and check again -1. Save the solution - ``` - git commit -am 'Solution' - ``` -1. Push the solution to the repo - ``` - git push origin develop - ``` - - If you created another branch (not `develop`) use its name instead - -Note: if changes were added to GitHub task when you already forked it and -downloaded to your local machine, follow this -[guideline](./pull-changes-from-mate-repo-guideline/pull-changes-from-mate-repo-guideline.md) to pull changes. - -## Create a Pull Request (PR) -1. Open your repo on GitHub and create a `Pull Request` (PR) - ![New PR button](./assets/new-pull-request-button.png) -1. Select your branch in the dropdown! - ![Create PR button](./assets/create-pull-request-button.png) -1. Verify the PR details and code (scroll down to see it) and confirm - ![Create PR confirmation](./assets/create-pull-request-confirmation.png) - -## If a mentor requested changes on your PR -1. Repeat [Implement the solution](#implement-the-solution) section -1. PR is updated automatically after a push to your branch on GitHub - -> After updating your PR - click on re-request button at PR page IF YOU NEED ADDITIONAL REVIEW OF YOUR CODE. -![Image of re-request button](https://user-images.githubusercontent.com/38065883/104471439-89929200-55c3-11eb-824a-596bfb8aa246.png) +import time +from hashlib import sha256 +from itertools import product + +PASSWORDS_TO_BRUTE_FORCE = [ + "b4061a4bcfe1a2cbf78286f3fab2fb578266d1bd16c414c650c5ac04dfc696e1", + "cf0b0cfc90d8b4be14e00114827494ed5522e9aa1c7e6960515b58626cad0b44", + "e34efeb4b9538a949655b788dcb517f4a82e997e9e95271ecd392ac073fe216d", + "c15f56a2a392c950524f499093b78266427d21291b7d7f9d94a09b4e41d65628", + "4cd1a028a60f85a1b94f918adb7fb528d7429111c52bb2aa2874ed054a5584dd", + "40900aa1d900bee58178ae4a738c6952cb7b3467ce9fde0c3efa30a3bde1b5e2", + "5e6bc66ee1d2af7eb3aad546e9c0f79ab4b4ffb04a1bc425a80e6a4b0f055c2e", + "1273682fa19625ccedbe2de2817ba54dbb7894b7cefb08578826efad492f51c9", + "7e8f0ada0a03cbee48a0883d549967647b3fca6efeb0a149242f19e4b68d53d6", + "e5f3ff26aa8075ce7513552a9af1882b4fbc2a47a3525000f6eb887ab9622207", +] + + +def sha256_hash_str(to_hash: str) -> str: + return sha256(to_hash.encode("utf-8")).hexdigest() + + +def brute_force_password() -> None: + targets = set(PASSWORDS_TO_BRUTE_FORCE) + found = {} + + for digits in product("0123456789", repeat=8): + candidate = ''.join(digits) + candidate_hash = sha256_hash_str(candidate) + + if candidate_hash in targets: + print(f"[FOUND] {candidate} -> {candidate_hash}") + found[candidate_hash] = candidate + + # Optionnel : arrĂȘter si on a tout trouvĂ© + if len(found) == len(PASSWORDS_TO_BRUTE_FORCE): + break + + +if __name__ == "__main__": + start_time = time.perf_counter() + brute_force_password() + end_time = time.perf_counter() + + print("Elapsed:", end_time - start_time)