Hacking Hardware Picofly - a HWFLY switch modchip

nerirififi

Well-Known Member
Member
Joined
Nov 18, 2015
Messages
160
Trophies
0
Age
43
XP
607
Country
France
guy, just an idea.

Create an emmumc
Downgrade the emmumc with firmware compatible sx os
And try to boot on picofly with cfw sx os ?
Eveybody try atmosphere but maybe sxos can work.

I know sx os work on oled, I have already test.
So I know you can downgrade a switch with a firmware lower than build in factory if the firmware is on emunand.

Like sx os is a different firmware maybe that can work, someone for test ? :)
 

Hackerman_2137

Well-Known Member
Newcomer
Joined
Feb 15, 2017
Messages
48
Trophies
0
XP
1,414
Country
Poland
guy, just an idea.

Create an emmumc
Downgrade the emmumc with firmware compatible sx os
And try to boot on picofly with cfw sx os ?
Eveybody try atmosphere but maybe sxos can work.

I know sx os work on oled, I have already test.
So I know you can downgrade a switch with a firmware lower than build in factory if the firmware is on emunand.

Like sx os is a different firmware maybe that can work, someone for test ? :)
SX OS is based on atmo, so this wouldnt work. Also SX OS is a big mess. Emunand for Mariko units is flawed, updating sysnand to 11+ for some people resulted in not working emunand even if they'd 11 or lower. So why bother and loosing time for this?
 

Piorjade

Well-Known Member
Member
Joined
Nov 8, 2015
Messages
142
Trophies
0
XP
407
Country
Gambia, The
Just off memory isn't this the same shite tx did when they first released their chip. It cleared the keys lots so other cfw wouldn't boot?
This

I honestly think that the "unlocked ubuntu" firmware here is doing exactly that, it's the only reason I can think of why they even bothered to create a custom SD loader / payload with a custom public/private key pair.

It would be so much simpler to just copy-paste HWFLY-NX sdloader and BCTs but the developer made the effort, so that's probably why.

Anyway, development is going slow on my part as I have work and other things to do, but at least I'm able to initialize an SD card in SDIO mode with one DAT line (this is the R/W part of my code, we need this to be able to write the BCTs and sdloader)

1676535221374.png


I know, pretty boring news but SD cards behave pretty much the same way as eMMCs, the commands are just a bit different.
I don't want to take any credit for myself, I've used https://github.com/carlk3/no-OS-FatFS-SD-SPI-RPi-Pico/blob/sdio/src/sd_driver/SDIO/rp2040_sdio.c as my code base and modified it to use one dat line only (this code uses 4 dat lines)

I'm also modifying it to be a bit simpler as this code implements FAT filesystem and the whole shtick and we don't need that. Other than that of course I'll switch it up to the eMMC protocol commands and workflow and probably I'll create a library of some sorts so people can use it with any kind of eMMC in general.
Post automatically merged:

I can also say that the Pico is awesome in general, this is my first time actually working with a microcontroller to do more than just lighting up 3 LEDs :D
 

renoob

Active Member
Newcomer
Joined
Feb 6, 2023
Messages
42
Trophies
0
XP
157
Country
France
Ok I've used "unique_board_id" pico-examples and modified it with the injection to see does the "pico_get_unique_board_id" function really retrieve the modified ID when its modified at boot and it is:
Code:
Port /dev/ttyACM0, 12:00:47

Press CTRL-A Z for help on special keys

Unique identifier: 11 22 33 44 55 66 77 88
Unique identifier: 11 22 33 44 55 66 77 88
Unique identifier: 11 22 33 44 55 66 77 88


Code:
Welcome to minicom 2.8

OPTIONS: I18n
Port /dev/ttyACM0, 11:53:41

Press CTRL-A Z for help on special keys

Unique identifier: e6 61 1c b7 1f 32 68 29

Pico is outputing this via serial so I would say that injection works.
Will modify the fm again with little better code now (I used a lot of nops when I initially created the function, maybe its adding some delay)
BTW tested also with RP-Zero from start and addresses in general (functions and memory) are the same, so it does not change from pico to pico
 
Last edited by renoob,

vittorio

Well-Known Member
Member
Joined
May 12, 2014
Messages
243
Trophies
0
Age
26
XP
968
Country
Italy
in this function in this function it takes the static id which i think is divided into an array of 4 , local20 and local 30 and then it does some sort of check i think
**************************************************************
* FUNCTION *
**************************************************************
undefined call_by_id_statico(void)
undefined r0:1 <RETURN>
undefined4 Stack[-0x20]:4 local_20 XREF[1]: 10002642(W)
undefined4 Stack[-0x30]:4 local_30 XREF[2]: 10002636(W),
1000264e(W)
call_by_id_statico XREF[1]: Get_Id_Statico:1000260c(c)
10002628 30 b5 push {r4,r5,lr}
1000262a 00 25 movs r5,#0x0
1000262c 89 b0 sub sp,#0x24
1000262e 04 00 movs r4,r0
10002630 09 22 movs r2,#0x9
10002632 00 21 movs r1,#0x0
10002634 01 a8 add r0,sp,#0x4
10002636 00 95 str r5,[sp,#0x0]=>local_30
10002638 ff f7 8c fe bl FUN_10002354 undefined FUN_10002354()
1000263c 09 22 movs r2,#0x9
1000263e 00 21 movs r1,#0x0
10002640 05 a8 add r0,sp,#0x14
10002642 04 95 str r5,[sp,#local_20]
10002644 ff f7 86 fe bl FUN_10002354 undefined FUN_10002354()
10002648 4b 23 movs r3,#0x4b
1000264a 6a 46 mov r2,sp
1000264c 68 46 mov r0,sp
1000264e 13 70 strb r3,[r2,#0x0]=>local_30
10002650 04 a9 add r1,sp,#0x10
10002652 0d 22 movs r2,#0xd
10002654 00 f0 30 f9 bl FUN_100028b8 undefined FUN_100028b8()
10002658 15 21 movs r1,#0x15
1000265a 08 22 movs r2,#0x8
1000265c 20 00 movs r0,r4
1000265e 69 44 add r1,sp
10002660 ff f7 7e fe bl call_by_id undefined call_by_id(void)
10002664 09 b0 add sp,#0x24
10002666 30 bd pop {r4,r5,pc}
 

renoob

Active Member
Newcomer
Joined
Feb 6, 2023
Messages
42
Trophies
0
XP
157
Country
France
No that function does not take ID its prepared and generated there. The function at 10002654 is "flash_send_cmd" where it queries the flash chip with command to retreive its ID (you can confirm that since in c code one of the arguments are "0x4b" which is a command for retreiving id) and then its stored in memory at static location (which I'm manipulating with)
Since I've tested unique_board_id from pico-examples with this modification and its outputing the modified ID I would say that it works. But maybe something else is the problem (user added wrong ID, some wiring etc ? just thinking out loud)
 
  • Like
Reactions: vittorio

renoob

Active Member
Newcomer
Joined
Feb 6, 2023
Messages
42
Trophies
0
XP
157
Country
France
how exactly? Would prefer if it can be flashed with picotool since I'm doing that so we can eliminate converting
You have working setup? can you start unlocked_fw?
 

renoob

Active Member
Newcomer
Joined
Feb 6, 2023
Messages
42
Trophies
0
XP
157
Country
France
Ok this time I can prove that injection works 100%

So I checked this:
https://forums.raspberrypi.com/viewtopic.php?t=336409
Guy made uf2 file when you flash it you get output "This software is for this board". Yeah all working fine
Then you dump that firmware, and flash it on different pico and you get "program is not for that board". Everything works as written here, when I did that and flash on my second pico I was getting output:
Code:
Welcome to minicom 2.8

OPTIONS: I18n
Port /dev/ttyACM0, 13:35:20

Press CTRL-A Z for help on special keys

======= THIS SOFTWARE WAS STOLEN =======
This software will not run on this board

======= THIS SOFTWARE WAS STOLEN =======
This software will not run on this board

------------------------------------------
Then I did this injection, on that dump since first uf2 locks the firmware to unique id of first pico, i just injected id of the first pico into dumped one which was outputing error above on second pico... and :

Code:
Welcome to minicom 2.8

OPTIONS: I18n
Port /dev/ttyACM0, 13:51:11

Press CTRL-A Z for help on special keys

This software is for this board
This software is for this board
This software is for this board
It successfully runs and does not give error anymore on second pico. So my conclusion are that injection works 100% since unique_board from pico-examples outputs modified one and this example above was locked and now its unlocked after injection.
....
So maybe the ID that user provided with firmware is not correct OR something else
 
Last edited by renoob,

Rozetkin

New Member
Newbie
Joined
Feb 16, 2023
Messages
2
Trophies
0
Age
20
XP
22
Country
Russia
So maybe the ID that user provided with firmware is not correct OR something else
Or, maybe, there is a another check in firmware.
I also recently reversed and patched this firmware (although I just rewrote function 0x1002608 instead of jmping the written function further). It seems to me that the id is the primary decryption of both the payload and further code. I could not find write accesses to pins 15 and 28, nor could I find the code that makes the onboard led white. So it seems to me that inside the encrypted payload there is more code, which also probably makes a direct system call with 4b, which, in fact, does not allow to simply swap the id.
 

renoob

Active Member
Newcomer
Joined
Feb 6, 2023
Messages
42
Trophies
0
XP
157
Country
France
Or, maybe, there is a another check in firmware.
I also recently reversed and patched this firmware (although I just rewrote function 0x1002608 instead of jmping the written function further). It seems to me that the id is the primary decryption of both the payload and further code. I could not find write accesses to pins 15 and 28, nor could I find the code that makes the onboard led white. So it seems to me that inside the encrypted payload there is more code, which also probably makes a direct system call with 4b, which, in fact, does not allow to simply swap the id.
Will try to modify flash_send_cmd function then, but yeah you are right since this function is referenced in another function aswell
 
  • Like
Reactions: vittorio

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: https://www.youtube.com/watch?v=fv6vlP2qSyo