mirror of
https://github.com/elseif/MikroTikPatch.git
synced 2026-09-07 10:34:36 +00:00
Compare commits
11 Commits
7.22.1
...
7.23rc4-ar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30d6ac5fe6 | ||
|
|
7fd1b6c563 | ||
|
|
ed3dcd0ab1 | ||
|
|
0a270a1108 | ||
|
|
7a6fdb6323 | ||
|
|
44bc4346c6 | ||
|
|
98d6af79f7 | ||
|
|
11eec19e7d | ||
|
|
9e1d7a5239 | ||
|
|
569e0b5749 | ||
|
|
5d9cc6d745 |
4
.github/workflows/mikrotik_patch_6.yml
vendored
4
.github/workflows/mikrotik_patch_6.yml
vendored
@@ -98,10 +98,10 @@ jobs:
|
|||||||
RELEASE: ${{ needs.Set_Variables.outputs.RELEASE }}
|
RELEASE: ${{ needs.Set_Variables.outputs.RELEASE }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
|
|||||||
24
.github/workflows/mikrotik_patch_7.yml
vendored
24
.github/workflows/mikrotik_patch_7.yml
vendored
@@ -109,10 +109,10 @@ jobs:
|
|||||||
RELEASE: ${{ needs.Set_Variables.outputs.RELEASE }}
|
RELEASE: ${{ needs.Set_Variables.outputs.RELEASE }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ jobs:
|
|||||||
- name: Cache mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
- name: Cache mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
if: steps.get_latest.outputs.has_new_version == 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
||||||
id: cache-mikrotik
|
id: cache-mikrotik
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
mikrotik.iso
|
mikrotik.iso
|
||||||
@@ -222,7 +222,7 @@ jobs:
|
|||||||
- name: Cache refind
|
- name: Cache refind
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
||||||
id: cache-refind
|
id: cache-refind
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: refind-bin-0.14.2.zip
|
path: refind-bin-0.14.2.zip
|
||||||
key: refind
|
key: refind
|
||||||
@@ -230,12 +230,12 @@ jobs:
|
|||||||
|
|
||||||
- name: Get refind
|
- name: Get refind
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true'
|
||||||
run: sudo wget --no-check-certificate -nv -O refind-bin-0.14.2.zip https://nchc.dl.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip
|
run: sudo wget -O refind-bin-0.14.2.zip https://downloads.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip
|
||||||
|
|
||||||
- name: Patch mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
- name: Patch mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
if: steps.get_latest.outputs.has_new_version == 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -y mkisofs xorriso > /dev/null
|
sudo apt-get install -y build-essential binutils-arm-linux-gnueabi mkisofs xorriso > /dev/null
|
||||||
sudo mkdir ./iso
|
sudo mkdir ./iso
|
||||||
sudo mount -o loop,ro mikrotik.iso ./iso
|
sudo mount -o loop,ro mikrotik.iso ./iso
|
||||||
sudo mkdir ./new_iso
|
sudo mkdir ./new_iso
|
||||||
@@ -332,7 +332,7 @@ jobs:
|
|||||||
- name: Cache chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img.zip
|
- name: Cache chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img.zip
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
if: steps.get_latest.outputs.has_new_version == 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
||||||
id: cache-chr-img
|
id: cache-chr-img
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
chr.img
|
chr.img
|
||||||
@@ -588,7 +588,7 @@ jobs:
|
|||||||
- name: Cache all_packages${{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
- name: Cache all_packages${{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch != 'x86' && matrix.arch != 'arm64'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch != 'x86' && matrix.arch != 'arm64'
|
||||||
id: cache-all-packages
|
id: cache-all-packages
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: all_packages.zip
|
path: all_packages.zip
|
||||||
key: all_packages${{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
key: all_packages${{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
||||||
@@ -602,7 +602,7 @@ jobs:
|
|||||||
- name: Cache Main package routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
- name: Cache Main package routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch != 'x86' && matrix.arch != 'arm64'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch != 'x86' && matrix.arch != 'arm64'
|
||||||
id: cache-main-package
|
id: cache-main-package
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: routeros.npk
|
path: routeros.npk
|
||||||
key: routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
key: routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
||||||
@@ -672,7 +672,7 @@ jobs:
|
|||||||
- name: Cache NetInstall ${{ env.LATEST_VERSION }}${{ env.ARCH }}
|
- name: Cache NetInstall ${{ env.LATEST_VERSION }}${{ env.ARCH }}
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && env.RELEASE == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && env.RELEASE == 'true'
|
||||||
id: cache-netinstall
|
id: cache-netinstall
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
netinstall.zip
|
netinstall.zip
|
||||||
@@ -775,7 +775,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Create Release tag ${{ env.LATEST_VERSION }} ${{ env.ARCH }}
|
- name: Create Release tag ${{ env.LATEST_VERSION }} ${{ env.ARCH }}
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ env.ARCH }}"
|
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ env.ARCH }}"
|
||||||
body_path: "CHANGELOG"
|
body_path: "CHANGELOG"
|
||||||
@@ -792,7 +792,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload Files as Artifact (No Release)
|
- name: Upload Files as Artifact (No Release)
|
||||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'false'
|
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'false'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}
|
name: mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
@@ -274,6 +274,14 @@
|
|||||||
<span class="iconify text-xl transition-transform duration-300 group-hover:rotate-12" data-icon="ph:github-logo-bold"></span>
|
<span class="iconify text-xl transition-transform duration-300 group-hover:rotate-12" data-icon="ph:github-logo-bold"></span>
|
||||||
<span class="font-semibold text-sm">GitHub</span>
|
<span class="font-semibold text-sm">GitHub</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<!-- Telegram Keyget Bot link -->
|
||||||
|
<a href="https://t.me/ROS_Keygen_Bot" target="_blank"
|
||||||
|
class="group flex items-center gap-3 px-6 py-3 rounded-xl bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white shadow-md hover:shadow-lg transition-all duration-300 hover:scale-105">
|
||||||
|
<span class="iconify text-xl transition-transform duration-300 group-hover:rotate-12" data-icon="ph:telegram-logo-bold"></span>
|
||||||
|
<span class="font-semibold text-sm">Keygen Bot</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
105
patch.py
105
patch.py
@@ -321,46 +321,79 @@ def patch_loader(loader_file):
|
|||||||
print("loader module import failed. cannot run patch_loader.py")
|
print("loader module import failed. cannot run patch_loader.py")
|
||||||
|
|
||||||
def patch_squashfs(path,key_dict):
|
def patch_squashfs(path,key_dict):
|
||||||
|
url_replacements = {
|
||||||
|
os.environ.get('MIKRO_LICENCE_URL', '').encode(): os.environ.get('CUSTOM_LICENCE_URL', '').encode(),
|
||||||
|
os.environ.get('MIKRO_UPGRADE_URL', '').encode(): os.environ.get('CUSTOM_UPGRADE_URL', '').encode(),
|
||||||
|
os.environ.get('MIKRO_CLOUD_URL', '').encode(): os.environ.get('CUSTOM_CLOUD_URL', '').encode(),
|
||||||
|
os.environ.get('MIKRO_CLOUD_PUBLIC_KEY', '').encode(): os.environ.get('CUSTOM_CLOUD_PUBLIC_KEY', '').encode(),
|
||||||
|
}
|
||||||
|
url_replacements = {k: v for k, v in url_replacements.items() if k and v}
|
||||||
|
renew_replacements = {
|
||||||
|
os.environ.get('MIKRO_RENEW_URL', '').encode(): os.environ.get('CUSTOM_RENEW_URL', '').encode(),
|
||||||
|
}
|
||||||
|
renew_replacements = {k: v for k, v in renew_replacements.items() if k and v}
|
||||||
|
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for _file in files:
|
if 'mode' in files and 'keyman' in files:
|
||||||
file = os.path.join(root,_file)
|
for file_path in [os.path.join(root, 'mode'),os.path.join(root, 'keyman')]:
|
||||||
if os.path.isfile(file):
|
with open(file_path, 'rb') as f:
|
||||||
if _file =='loader':
|
data = f.read()
|
||||||
patch_loader(file)
|
modified = False
|
||||||
continue
|
|
||||||
if _file =='BOOTX64.EFI':
|
|
||||||
print(f'patch {file} ...')
|
|
||||||
data = open(file,'rb').read()
|
|
||||||
data = patch_kernel(data,key_dict)
|
|
||||||
open(file,'wb').write(data)
|
|
||||||
continue
|
|
||||||
data = open(file,'rb').read()
|
|
||||||
for old_public_key,new_public_key in key_dict.items():
|
for old_public_key,new_public_key in key_dict.items():
|
||||||
_data = replace_key(old_public_key,new_public_key,data,file)
|
new_data = replace_key(old_public_key,new_public_key,data,file_path)
|
||||||
if _data != data:
|
if new_data != data:
|
||||||
open(file,'wb').write(_data)
|
data = new_data
|
||||||
url_dict = {
|
modified = True
|
||||||
os.environ['MIKRO_LICENCE_URL'].encode():os.environ['CUSTOM_LICENCE_URL'].encode(),
|
assert modified, f'{file_path} key not patched'
|
||||||
os.environ['MIKRO_UPGRADE_URL'].encode():os.environ['CUSTOM_UPGRADE_URL'].encode(),
|
with open(f'{file_path}_', 'wb') as f:
|
||||||
os.environ['MIKRO_CLOUD_URL'].encode():os.environ['CUSTOM_CLOUD_URL'].encode(),
|
f.write(data)
|
||||||
os.environ['MIKRO_CLOUD_PUBLIC_KEY'].encode():os.environ['CUSTOM_CLOUD_PUBLIC_KEY'].encode(),
|
if 'loader' in files and os.path.isfile(os.path.join(root, 'loader')):
|
||||||
}
|
loader_file = os.path.join(root, 'loader')
|
||||||
data = open(file,'rb').read()
|
patch_loader(loader_file)
|
||||||
for old_url,new_url in url_dict.items():
|
|
||||||
|
if 'BOOTX64.EFI' in files and os.path.isfile(os.path.join(root, 'BOOTX64.EFI')):
|
||||||
|
efi_file = os.path.join(root, 'BOOTX64.EFI')
|
||||||
|
with open(efi_file, 'rb') as f:
|
||||||
|
data = f.read()
|
||||||
|
new_data = patch_kernel(data,key_dict)
|
||||||
|
assert new_data != data, f'{file_path} key not patched'
|
||||||
|
with open(efi_file, 'wb') as f:
|
||||||
|
f.write(new_data)
|
||||||
|
|
||||||
|
|
||||||
|
for filename in files:
|
||||||
|
if filename in ['mode','keyman','loader','BOOTX64.EFI']:
|
||||||
|
continue
|
||||||
|
file_path = os.path.join(root,filename)
|
||||||
|
if not os.path.isfile(file_path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
modified = False
|
||||||
|
with open(file_path, 'rb') as f:
|
||||||
|
data = f.read()
|
||||||
|
|
||||||
|
for old_public_key,new_public_key in key_dict.items():
|
||||||
|
new_data = replace_key(old_public_key,new_public_key,data,file_path)
|
||||||
|
if new_data != data:
|
||||||
|
data = new_data
|
||||||
|
modified = True
|
||||||
|
|
||||||
|
for old_url,new_url in url_replacements.items():
|
||||||
|
if old_url in data:
|
||||||
|
print(f'{file_path} url patched {old_url.decode()[:7]}...')
|
||||||
|
data = data.replace(old_url,new_url)
|
||||||
|
modified = True
|
||||||
|
|
||||||
|
if filename == 'licupgr':
|
||||||
|
for old_url,new_url in renew_replacements.items():
|
||||||
if old_url in data:
|
if old_url in data:
|
||||||
print(f'{file} url patched {old_url.decode()[:7]}...')
|
print(f'{file_path} url patched {old_url.decode()[:7]}...')
|
||||||
data = data.replace(old_url,new_url)
|
data = data.replace(old_url,new_url)
|
||||||
open(file,'wb').write(data)
|
modified = True
|
||||||
|
|
||||||
if os.path.split(file)[1] == 'licupgr':
|
if modified:
|
||||||
url_dict = {
|
with open(file_path, 'wb') as f:
|
||||||
os.environ['MIKRO_RENEW_URL'].encode():os.environ['CUSTOM_RENEW_URL'].encode(),
|
f.write(data)
|
||||||
}
|
|
||||||
for old_url,new_url in url_dict.items():
|
|
||||||
if old_url in data:
|
|
||||||
print(f'{file} url patched {old_url.decode()[:7]}...')
|
|
||||||
data = data.replace(old_url,new_url)
|
|
||||||
open(file,'wb').write(data)
|
|
||||||
|
|
||||||
def run_shell_command(command):
|
def run_shell_command(command):
|
||||||
process = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|||||||
Reference in New Issue
Block a user