Skip to content

Commit

Permalink
refactor: enforce print's order, remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
seppzer0 committed Mar 15, 2024
1 parent 16875d6 commit eb2be89
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 55 deletions.
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ An advanced Android kernel builder with Kali NetHunter support.

- [zero\_kernel](#zero_kernel)
- [Contents](#contents)
- [**Disclaimer**](#disclaimer)
- [**Important**](#important)
- [Description](#description)
- [Kernel Features](#kernel-features)
- [Supported ROMs](#supported-roms)
- [ROM Artifacts in Releases](#rom-artifacts-in-releases)
- [Supported Devices \& ROMs](#supported-devices--roms)
- [Usage](#usage)
- [Prerequisites](#prerequisites)
- [Kernel](#kernel)
Expand All @@ -20,18 +19,29 @@ An advanced Android kernel builder with Kali NetHunter support.
- [See also](#see-also)
- [Credits](#credits)

## **Disclaimer**
## **Important**

> [!IMPORTANT]
> **\- Disclaimer \-**
>
> **This kernel is made for educational purposes only.**
>
> **I am not responsible for anything that may or may not happen to your device by installing any custom ROMs, kernels and/or any other forms of software.**
>
> **Anything you do with this kernel and your device you do at your own risk. By using it, you take the responsibility upon yourself and in case of any issue you are not to blame me or other related contributors.**
> [!NOTE]
> \- ROM artifacts in releases \-
>
> The contents of each release include ROM builds compatible with corresponding kernel builds. These ROM files are <u>**unmodified and mirrored from official sources**</u>.
>
>This can be verified via the checksums, which should be identical to the ones presented on the ROM project's official web page.
>
>You can always download the same ROM file from official sources if you'd like. The mirroring in this repository is only done due to the fact that some ROM projects remove their older builds once they become too outdated.
## Description

Technically speaking, the codebase of this project is an extensive wrapper automating the entire Android kernel build process, starting from kernel source collection and ending with artifact packaging.
The codebase of this project is essentially an extensive wrapper automating the entire Android kernel build process, starting from kernel source collection and ending with artifact packaging.

The key goal is to modify the kernel in such a way that enables unique features of [Kali NetHunter](https://www.kali.org/docs/nethunter) — a ROM layer designed to add extended functionality for penetration testing in a mobile form factor.

Expand All @@ -46,30 +56,31 @@ The kernel has the following features:
- packet injection support for internal Wi-Fi chipset;
- optional KernelSU support.

## Supported ROMs
## Supported Devices & ROMs

For **OnePlus 5/T** devices:
<details>
<summary>OnePlus 5/T</summary>

- 4.4 Linux kernel version:
- LineageOS;
- ParanoidAndroid;
- x_kernel supported (universal)*.
- 4.14 Linux kernel version:
- ParanoidAndroid (unofficial & testing);
- x-ft_kernel supported (universal)**.
<br>

\* -- this is mostly relevant to ROMs based on LineageOS; however, technically speaking, this includes ParanoidAndroid as well, which makes x_kernel-based builds universal.
4.4 Linux kernel version:

\** -- this, **in theory**, is relevant to all 4.14-based ROMs for this device in existence.
- LineageOS;
- ParanoidAndroid;
- x_kernel supported (universal)*.

## ROM Artifacts in Releases
4.14 Linux kernel version:

> [!NOTE]
> The contents of each release include ROM builds compatible with corresponding kernel builds. These ROM files are **unmodified and mirrored from official sources**.
- ParanoidAndroid (unofficial & testing);
- x-ft_kernel supported (universal)**.

---

This can be verified via the checksums, which should be identical to the ones presented on the ROM project's official web page.
\* -- this is mostly relevant to ROMs based on LineageOS; however, technically speaking, this includes ParanoidAndroid as well, which makes x_kernel-based builds universal.

\** -- this, **in theory**, is relevant to all 4.14-based ROMs for this device in existence.

You can always download the same ROM file from official sources if you'd like. The mirroring in this repository is done due to the fact that some ROM projects remove their older builds once they become too outdated.
</details>

## Usage

Expand Down
4 changes: 3 additions & 1 deletion docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@
- [ ] break down (or create inheritance from) KernelBuilder into LineageOsKernelBuilder, ParanoidAndroidKernelBuilder, XKernelBuilder etc;
- [ ] investigate project restructuring to avoid circular import;
- [ ] consider creating a separate "errors" subpackage for all errors;
- [ ] add GKI kernels support.
- [ ] add GKI kernels support;
- [ ] separate "standard" kernel building from NetHunter-specific modifications;
- [ ] add a differentiator/parameter to indicate whether the specified kernel source already has NetHunter patches.
43 changes: 22 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import subprocess
from typing import List
from pathlib import Path
from subprocess import CompletedProcess

Expand All @@ -23,12 +22,12 @@ def pyright_checks(self) -> CompletedProcess:
"""Run type (hint) checks with Pyright."""
return self._launch_cmd("python3 -m pyright wrapper")

def bandit_checks(self) -> List[CompletedProcess]:
def bandit_checks(self) -> list[CompletedProcess]:
"""Run SAST with Bandit."""
fmts = ("json", "html")
cps = []
for fmt in fmts:
cps.append(self._launch(f"python3 -m bandit -r -f {fmt} {ROOTPATH} -o report.{fmt}"))
cps.append(self._launch_cmd(f"python3 -m bandit -r -f {fmt} {ROOTPATH} -o report.{fmt}"))
return cps


Expand Down
5 changes: 3 additions & 2 deletions wrapper/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import io
import sys
import json
import argparse
Expand Down Expand Up @@ -274,6 +275,6 @@ def main(args: argparse.Namespace) -> None:


if __name__ == "__main__":
# for print's to show in the right order
os.environ["PYTHONUNBUFFERED"] = "1"
# for print's to show in the right order in various build / CI/CD systems
sys.stdout = io.TextIOWrapper(open(sys.stdout.fileno(), "wb", 0), write_through=True)
main(parse_args())
4 changes: 0 additions & 4 deletions wrapper/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from .cleaning import remove, git, root
from .commands import launch
from .fileoperations import ucopy, download
from .messages import banner, note, error, cancel, done, outputstream
6 changes: 3 additions & 3 deletions wrapper/utils/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def main(args: argparse.Namespace) -> None:
case _:
# if no command was selected, then shared tools are (supposed to be) installed
if args.shared:
tconf = ResourceManager()
tconf.path_gen()
tconf.download()
rm = ResourceManager()
rm.path_gen()
rm.download()
else:
# technically this part of code cannot be reached and is just an extra precaution
msg.error("Invalid argument set specified, please review")
Expand Down

0 comments on commit eb2be89

Please sign in to comment.