This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add how to restore genuine firmware (#4)
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Build genuine firmware | ||
on: | ||
push: | ||
branches: [ 'main' ] | ||
|
||
jobs: | ||
build-openwrt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download encrypted firmware from elecom support | ||
run: | | ||
curl -O https://dl.elecom.co.jp/support/download/network/wireless_lan/ap/wab-i1750-ps/WAB-I1750-PS-FW-V1-5-10.zip | ||
unzip WAB-I1750-PS-FW-V1-5-10.zip | ||
- name: Remove the first 128 bytes. | ||
run: dd if=WAB-I1750-PS-FW-V1-5-10.bin of=WAB-I1750-PS-FW-V1-5-10.bin.enc bs=1 skip=128 | ||
|
||
- name: Decrypt binary file | ||
run: python3 decrypt.py WAB-I1750-PS-uboot-V1.0.2.bin.enc 8844a2d168b45a2d dec.bin | ||
|
||
- run: file dec.bin | ||
|
||
# - name: Upload build result | ||
# uses: actions/upload-artifact@v4 | ||
# with: | ||
# name: restore-genuine-firmware | ||
# path: | | ||
# dec.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sys | ||
|
||
def xor_decrypt(data, key): | ||
key = bytes.fromhex(key) | ||
decrypted_data = bytearray() | ||
|
||
for i in range(len(data)): | ||
decrypted_data.append(data[i] ^ key[i % len(key)]) | ||
|
||
return bytes(decrypted_data) | ||
|
||
def main(): | ||
if len(sys.argv) != 4: | ||
print("Usage: python decrypt.py <encrypted_file_path> <key> <decrypted_file_path>") | ||
sys.exit(1) | ||
|
||
encrypted_file_path = sys.argv[1] | ||
key = sys.argv[2] | ||
decrypted_file_path = sys.argv[3] | ||
|
||
with open(encrypted_file_path, "rb") as encrypted_file: | ||
encrypted_data = encrypted_file.read() | ||
|
||
decrypted_data = xor_decrypt(encrypted_data, key) | ||
|
||
with open(decrypted_file_path, "wb") as decrypted_file: | ||
decrypted_file.write(decrypted_data) | ||
|
||
print("Decrypted!") | ||
|
||
if __name__ == "__main__": | ||
main() |