bcrypt-practical-kit 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bcrypt_practical_kit-1.0.0/PKG-INFO +34 -0
- bcrypt_practical_kit-1.0.0/README.md +24 -0
- bcrypt_practical_kit-1.0.0/bcrypt_practical_kit.egg-info/PKG-INFO +34 -0
- bcrypt_practical_kit-1.0.0/bcrypt_practical_kit.egg-info/SOURCES.txt +16 -0
- bcrypt_practical_kit-1.0.0/bcrypt_practical_kit.egg-info/dependency_links.txt +1 -0
- bcrypt_practical_kit-1.0.0/bcrypt_practical_kit.egg-info/entry_points.txt +2 -0
- bcrypt_practical_kit-1.0.0/bcrypt_practical_kit.egg-info/requires.txt +3 -0
- bcrypt_practical_kit-1.0.0/bcrypt_practical_kit.egg-info/top_level.txt +1 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/__init__.py +2 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/__main__.py +4 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/cli.py +30 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/practicals/__init__.py +1 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/practicals/p01_crypto.py +29 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/practicals/p03_whois.py +8 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/practicals/p07_socket.py +24 -0
- bcrypt_practical_kit-1.0.0/bcryptkit/practicals/p15_flask_session.py +35 -0
- bcrypt_practical_kit-1.0.0/pyproject.toml +17 -0
- bcrypt_practical_kit-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bcrypt-practical-kit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Educational Python demonstrations for four ethical hacking practicals
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: bcrypt>=4.0
|
|
8
|
+
Requires-Dist: python-whois>=0.9
|
|
9
|
+
Requires-Dist: Flask>=3.0
|
|
10
|
+
|
|
11
|
+
# bcrypt-practical-kit
|
|
12
|
+
|
|
13
|
+
A small educational menu for four Python-based ethical hacking practicals:
|
|
14
|
+
|
|
15
|
+
1. Caesar cipher and bcrypt password hashing
|
|
16
|
+
2. WHOIS domain lookup
|
|
17
|
+
3. Localhost socket server/client demonstration
|
|
18
|
+
4. Local Flask session-cookie demonstration
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m pip install bcrypt-practical-kit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Run
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
python -m bcryptkit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
For the socket practical, choose server in one terminal and client in a second terminal. It binds only to `127.0.0.1` for local practice. The Flask demo also binds only to `127.0.0.1` and uses deliberately insecure example credentials/cookies for classroom demonstration only. Do not deploy it or use real credentials.
|
|
33
|
+
|
|
34
|
+
WHOIS lookups require internet access and may be rate-limited by registries.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# bcrypt-practical-kit
|
|
2
|
+
|
|
3
|
+
A small educational menu for four Python-based ethical hacking practicals:
|
|
4
|
+
|
|
5
|
+
1. Caesar cipher and bcrypt password hashing
|
|
6
|
+
2. WHOIS domain lookup
|
|
7
|
+
3. Localhost socket server/client demonstration
|
|
8
|
+
4. Local Flask session-cookie demonstration
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
python -m pip install bcrypt-practical-kit
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Run
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
python -m bcryptkit
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For the socket practical, choose server in one terminal and client in a second terminal. It binds only to `127.0.0.1` for local practice. The Flask demo also binds only to `127.0.0.1` and uses deliberately insecure example credentials/cookies for classroom demonstration only. Do not deploy it or use real credentials.
|
|
23
|
+
|
|
24
|
+
WHOIS lookups require internet access and may be rate-limited by registries.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bcrypt-practical-kit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Educational Python demonstrations for four ethical hacking practicals
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: bcrypt>=4.0
|
|
8
|
+
Requires-Dist: python-whois>=0.9
|
|
9
|
+
Requires-Dist: Flask>=3.0
|
|
10
|
+
|
|
11
|
+
# bcrypt-practical-kit
|
|
12
|
+
|
|
13
|
+
A small educational menu for four Python-based ethical hacking practicals:
|
|
14
|
+
|
|
15
|
+
1. Caesar cipher and bcrypt password hashing
|
|
16
|
+
2. WHOIS domain lookup
|
|
17
|
+
3. Localhost socket server/client demonstration
|
|
18
|
+
4. Local Flask session-cookie demonstration
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m pip install bcrypt-practical-kit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Run
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
python -m bcryptkit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
For the socket practical, choose server in one terminal and client in a second terminal. It binds only to `127.0.0.1` for local practice. The Flask demo also binds only to `127.0.0.1` and uses deliberately insecure example credentials/cookies for classroom demonstration only. Do not deploy it or use real credentials.
|
|
33
|
+
|
|
34
|
+
WHOIS lookups require internet access and may be rate-limited by registries.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
bcrypt_practical_kit.egg-info/PKG-INFO
|
|
4
|
+
bcrypt_practical_kit.egg-info/SOURCES.txt
|
|
5
|
+
bcrypt_practical_kit.egg-info/dependency_links.txt
|
|
6
|
+
bcrypt_practical_kit.egg-info/entry_points.txt
|
|
7
|
+
bcrypt_practical_kit.egg-info/requires.txt
|
|
8
|
+
bcrypt_practical_kit.egg-info/top_level.txt
|
|
9
|
+
bcryptkit/__init__.py
|
|
10
|
+
bcryptkit/__main__.py
|
|
11
|
+
bcryptkit/cli.py
|
|
12
|
+
bcryptkit/practicals/__init__.py
|
|
13
|
+
bcryptkit/practicals/p01_crypto.py
|
|
14
|
+
bcryptkit/practicals/p03_whois.py
|
|
15
|
+
bcryptkit/practicals/p07_socket.py
|
|
16
|
+
bcryptkit/practicals/p15_flask_session.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bcryptkit
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from .practicals import p01_crypto, p03_whois, p07_socket, p15_flask_session
|
|
2
|
+
|
|
3
|
+
MENU = {
|
|
4
|
+
"1": ("Caesar cipher and bcrypt hashing", p01_crypto.run),
|
|
5
|
+
"2": ("WHOIS domain lookup", p03_whois.run),
|
|
6
|
+
"3": ("Socket server/client (localhost only)", p07_socket.run),
|
|
7
|
+
"4": ("Flask session-cookie demonstration", p15_flask_session.run),
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
while True:
|
|
12
|
+
print("\nETHICAL HACKING — PYTHON PRACTICALS")
|
|
13
|
+
for key, (label, _) in MENU.items():
|
|
14
|
+
print(f"{key}. {label}")
|
|
15
|
+
print("0. Exit")
|
|
16
|
+
choice = input("Select practical: ").strip()
|
|
17
|
+
if choice == "0":
|
|
18
|
+
print("Goodbye.")
|
|
19
|
+
return
|
|
20
|
+
item = MENU.get(choice)
|
|
21
|
+
if not item:
|
|
22
|
+
print("Invalid choice. Select 0–4.")
|
|
23
|
+
continue
|
|
24
|
+
try:
|
|
25
|
+
item[1]()
|
|
26
|
+
except KeyboardInterrupt:
|
|
27
|
+
print("\nPractical stopped.")
|
|
28
|
+
except Exception as exc:
|
|
29
|
+
print(f"\nCould not complete this practical: {exc}")
|
|
30
|
+
input("\nPress Enter to return to the menu...")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Individual practical demonstrations."""
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
def caesar(text: str, shift: int, decrypt: bool = False) -> str:
|
|
2
|
+
if decrypt:
|
|
3
|
+
shift = -shift
|
|
4
|
+
result = []
|
|
5
|
+
for char in text:
|
|
6
|
+
if char.isascii() and char.isalpha():
|
|
7
|
+
base = ord('A') if char.isupper() else ord('a')
|
|
8
|
+
result.append(chr((ord(char) - base + shift) % 26 + base))
|
|
9
|
+
else:
|
|
10
|
+
result.append(char)
|
|
11
|
+
return ''.join(result)
|
|
12
|
+
|
|
13
|
+
def run():
|
|
14
|
+
print("\n1. Caesar cipher 2. bcrypt password hashing")
|
|
15
|
+
mode = input("Choose: ").strip()
|
|
16
|
+
if mode == "1":
|
|
17
|
+
text = input("Enter text: ")
|
|
18
|
+
shift = int(input("Enter shift (integer): "))
|
|
19
|
+
encrypted = caesar(text, shift)
|
|
20
|
+
print("Encrypted:", encrypted)
|
|
21
|
+
print("Decrypted:", caesar(encrypted, shift, decrypt=True))
|
|
22
|
+
elif mode == "2":
|
|
23
|
+
import bcrypt
|
|
24
|
+
password = input("Enter a demo password (do not use a real password): ").encode("utf-8")
|
|
25
|
+
hashed = bcrypt.hashpw(password, bcrypt.gensalt())
|
|
26
|
+
print("bcrypt hash:", hashed.decode("utf-8"))
|
|
27
|
+
print("Verification:", bcrypt.checkpw(password, hashed))
|
|
28
|
+
else:
|
|
29
|
+
print("Invalid choice.")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
def run():
|
|
2
|
+
import socket
|
|
3
|
+
print("Choose: 1. Start local server 2. Run local client")
|
|
4
|
+
mode = input("Choose: ").strip()
|
|
5
|
+
host, port = "127.0.0.1", 8080
|
|
6
|
+
if mode == "1":
|
|
7
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server:
|
|
8
|
+
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
9
|
+
server.bind((host, port))
|
|
10
|
+
server.listen(1)
|
|
11
|
+
print(f"Listening on {host}:{port}. Start the client in another terminal.")
|
|
12
|
+
conn, address = server.accept()
|
|
13
|
+
with conn:
|
|
14
|
+
print("Connected by:", address)
|
|
15
|
+
conn.sendall(b"Thank you for connecting! This is a localhost demo.")
|
|
16
|
+
print("Sent demo response.")
|
|
17
|
+
elif mode == "2":
|
|
18
|
+
try:
|
|
19
|
+
with socket.create_connection((host, port), timeout=5) as client:
|
|
20
|
+
print(client.recv(1024).decode("utf-8", errors="replace"))
|
|
21
|
+
except OSError as exc:
|
|
22
|
+
print("Could not connect. Start the local server first.", exc)
|
|
23
|
+
else:
|
|
24
|
+
print("Invalid choice.")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
def run():
|
|
2
|
+
from flask import Flask, request, make_response, redirect
|
|
3
|
+
app = Flask(__name__)
|
|
4
|
+
demo_users = {"student": "demo123"}
|
|
5
|
+
|
|
6
|
+
@app.route("/", methods=["GET"])
|
|
7
|
+
def home():
|
|
8
|
+
if request.cookies.get("demo_session") == "student-demo-session":
|
|
9
|
+
return '<h2>Welcome Student!</h2><p>Demo session cookie is present.</p><a href="/logout">Logout</a>'
|
|
10
|
+
return '''<h2>Local Session Demo</h2>
|
|
11
|
+
<form method="POST" action="/login">
|
|
12
|
+
<label>Username <input name="username"></label><br>
|
|
13
|
+
<label>Password <input name="password" type="password"></label><br>
|
|
14
|
+
<button type="submit">Login</button></form>
|
|
15
|
+
<p>Demo only: student / demo123</p>'''
|
|
16
|
+
|
|
17
|
+
@app.route("/login", methods=["POST"])
|
|
18
|
+
def login():
|
|
19
|
+
username = request.form.get("username", "")
|
|
20
|
+
password = request.form.get("password", "")
|
|
21
|
+
if demo_users.get(username) == password:
|
|
22
|
+
response = make_response(redirect("/"))
|
|
23
|
+
response.set_cookie("demo_session", "student-demo-session", httponly=True, samesite="Lax")
|
|
24
|
+
return response
|
|
25
|
+
return "Invalid demo credentials", 401
|
|
26
|
+
|
|
27
|
+
@app.route("/logout")
|
|
28
|
+
def logout():
|
|
29
|
+
response = make_response(redirect("/"))
|
|
30
|
+
response.delete_cookie("demo_session")
|
|
31
|
+
return response
|
|
32
|
+
|
|
33
|
+
print("Open http://127.0.0.1:5000 in your browser. Press Ctrl+C to stop.")
|
|
34
|
+
print("Classroom demo only; do not deploy or use real credentials.")
|
|
35
|
+
app.run(host="127.0.0.1", port=5000, debug=False)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "bcrypt-practical-kit"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Educational Python demonstrations for four ethical hacking practicals"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = ["bcrypt>=4.0", "python-whois>=0.9", "Flask>=3.0"]
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
bcryptkit = "bcryptkit.cli:main"
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
include = ["bcryptkit*"]
|