[DEV][THE S-OFF CAMPAIGN] We need electrical engineers & experts in JTAG, OpenOCD!

Search This thread

artturnip

Senior Member
Jan 28, 2012
206
53
Anything for a noob to do here guys? I'd love to see s-off and therefore would love to support your work... but I don't know how... :banghead:

Sent from my Wildfire S A510e using xda app-developers app
 

rezo

Senior Member
Nov 17, 2007
111
105
Ok... after some researching:

(0.90.0000 hboot + 7.54.39.08M radio + 4K partition layout phone) look for the 6th bit at 0x201C in the misc partition. If it is '1' then we got s-on. If it is '0' we got hboot s-off.

gdgdfgy.jpg


So.. 2*, 3*, 6*, 7*, A*, B*, E*, F* would be also doing s-on.


It is possible that other hboots + radios have also that "hboot s-off flag"?
Filling all misc with FF or 00 doesn't do that so that mechanism doesn't exist or it's more complicated.
 
Last edited:

no.human.being

Senior Member
Oct 29, 2011
981
987
I cannot explain this behaviour, however the "actual" secu_flag is not in "misc". In fact it's not anywhere in the "virtual NAND" that HBOOT and Android see. If you binary-compare the entire address space that aARM sees on a phone before and after achieving "Radio S-OFF" via xtc-clip, the only change you'll see is that the backup CID is erased from "misc". Everything else is bit-identical. The secu_flag resides in Iguana and cannot be accessed by aARM. The ways for achieving S-OFF are either ...

1. ... authenticate with Iguana so that it disables security. This is what xtc-clip does, but the authentication cannot be done in software.
2. ... flash Iguana so that it's S-OFF. Don't know if this is possible in software, since I don't know how updates for Iguana are performed.
3. ... make HBOOT never query Iguana for the status of the flag. This works in principle as is proven here, but the status doesn't "stick". "Something" (Iguana? HBOOT itself?) always "restores" an "original" HBOOT image after a very short period of time if you modify something in the HBOOT code. If we find the code where this happens we can most likely do something about it.

That "misc mechanism" probably only works with that strange "special" Radio. I don't have the phone anymore, but there definitely wasn't a single non-zero byte surrounded by many zero bytes somewhere in my "misc" partition and since you say bit unset (zero) is S-OFF, it would have to be set, since my phone was S-ON.

EDIT: Ah, I forgot. HBOOT must restore itself. If you overwrite HBOOT with some code that's really different from an HBOOT (say you overwrite it with no-operations and a jump back to the beginning), there's no HBOOT restored to that memory (and the infinite loop runs forever on aARM). So yes, we can definitely do something about it since we can overwrite the entire HBOOT via this "chainloader" exploit. We "only" have to find where this happens in the HBOOT. And it would be best if we could find it in the 1.09.0099 HBOOT since that's the one we've done the most analysis for.
 
Last edited:
  • Like
Reactions: BeciMester and rezo

rezo

Senior Member
Nov 17, 2007
111
105
I rather thought about that may be two sec flags: h-boot s-flag and radio s-flag (master s-flag). You are right about "that strange "special" Radio" but why it works only with the 0.90.0000 hboot? :eek:


BTW...
Look how the hboot is written in NAND. There is a lot of small differences... You use a raw hboot image but what if you could try with the hboot image extracted from the jtag dump (WildFireS_Full_alive.bin)? Maybe that causes restoring in your exploit?

RAW HBOOT IMAGE VS HBOOT from JTAG DUMP
ggfdgdf.jpg
 
Last edited:

BeciMester

Senior Member
Jul 22, 2010
181
186
Dublin
(0.90.0000 hboot + 7.54.39.08M radio + 4K partition layout phone) look for the 6th bit at 0x201C in the misc partition. If it is '1' then we got s-on. If it is '0' we got hboot s-off.

gdgdfgy.jpg
(emphasis by me)

I rather thought about that may be two sec flags: h-boot s-flag and radio s-flag (master s-flag). You are right about "that strange "special" Radio" but why it works only with the 0.90.0000 hboot?
Yes there are indeed two checks done, and you may have just shed some light on the second one!

The following code shows the whole of the secu_flag check in the 0.90 hboot, edited to show the program flow:
Code:
9D008698    STMFD           SP!, {R4,LR} ; Save registers
9D00869C    BL              sub_9D04414C

	9D04414C    STMFD           SP!, {R4,LR} ; save registers
	9D044150    BL              sub_9D04CE00
	
		9D04CE00    STR             R4, [SP,#var_4]!
		9D04CE04    LDR             R3, =0x9D086A8C
		9D04CE08    LDR             R4, [R3] ; R4 = 0xBD100000
		9D04CE0C    ADD             R4, R4, #0xFC000 ; R4 = 0xBD1FC000
		9D04CE10    ADD             R4, R4, #0xA0 ; R4 = 0xBD1FC0A0
		9D04CE14    LDR             R0, [R4] ; value from 0xBD1FC0A0 into R0
		9D04CE18    AND             R0, R0, #1 ; clear all but 1st bit
		9D04CE1C    LDMFD           SP!, {R4} ; restore registers
		9D04CE20    BX              LR      ; return
		
	9D044154    LDMFD           SP!, {R4,PC} ; return again
	
9D0086A0    CMP             R0, #0  ; if R0 is not 0...
9D0086A4    MOVNE           R0, #1  ; ...load 1 into R0 ...
9D0086A8    LDMNEFD         SP!, {R4,PC} ; ...and return
9D0086AC    BL              sub_9D00769C ; if the first check passed...

	9D00769C    STR             R4, [SP,#var_4]! ; save registers
	9D0076A0    LDR             R3, =dword_9D07A2DC ; = 0x60303000
	9D0076A4    LDR             R4, [R3] ; R4 = 0x60303000
	9D0076A8    LDR             R3, =0x101C ; load the offset
	9D0076AC    LDR             R0, [R4,R3] ; value from 0x6030401C into R0
	9D0076B0    LDMFD           SP!, {R4} ; restore registers...
	9D0076B4    BX              LR      ; ...and return
	
9D0086B0    MOV             R0, R0,LSR#5 ; shift to the right 5 times
					 ; (move the 6th bit into 1st)
9D0086B4    AND             R0, R0, #1 ; clear all but 1st bit
9D0086B8    LDMFD           SP!, {R4,PC} ; return
What it does is, it checks the least significant bit of 0xBD1FC0A0, and if it's not 0, the test fails (R0 returns 1). I think this is the (representation of the) radio flag.

The interesting part is the second, at 0x9D00769C: loads a base address, adds the offset, and returns the 6th bit (!) of the value at 0x6030401C. It seems to be the "misc check", and if that fails, the end result of the secu_flag check will still show "s-on", it doesn't matter if you have radio s-off or not! The interesting info is that the misc partition (or at least part of it) is mapped in from the virtual address 0x60302000. :laugh:

BTW...
Look how the hboot is written in NAND. There is a lot of small differences... You use a raw hboot image but what if you could try with the hboot image extracted from the jtag dump (WildFireS_Full_alive.bin)? Maybe that causes restoring in your exploit?
This makes me think that the "jtag dump" is not accurate. I used the hboot's own built-in memory dump routine to extract the RAM content, and that dump is the exact match of the raw hboot data. Could you have a look at how often the differences occur? They seem to follow a pattern, like after every 0x200 bytes one 4-byte block is missing or something. EDIT: the missing bytes you highlighted are part of the page table and if they were really missing the whole thing wouldn't work. So the dump must be inaccurate.
 
Last edited:
  • Like
Reactions: pihug12 and rezo

no.human.being

Senior Member
Oct 29, 2011
981
987
Well, like I said, unfortunately I can't test anymore since I don't have the phone anymore. However, I think that the HBOOT that aARM "sees" (remember that this is not what's actually in NAND - for example the Radio code that aARM sees looks VERY different compared to the code that's actually stored in NAND) is the same that is in the nb0 and not what is in the JTAG dump (and therefore probably in physical NAND). But like I said I don't have the phone anymore so I actually cannot verify anything at the moment.

We have KNOWN for some time that they perform two checks, but why? Is it for easier testing? Their developers probably test on Radio S-OFF devices. Do they perform this "misc"-check to allow their devs to easily enable security temporarily on their devices by changing a bit in the "misc" partition?
 
Last edited:
  • Like
Reactions: rezo

no.human.being

Senior Member
Oct 29, 2011
981
987
What happened to your phone? :eek:

The micro-switches were worn out. It was still usable, but I decided to send it to HTC to have it fixed before the warrenty period ends. However, they said that the board on which it is based is no longer produced by their supplier, so they can neither replace the board on it nor manufacture new devices of this type, so the device is basically discontinued. Since they don't have any devices left in stock, they could not send me a replacement device either, so they offered me a refund of the entire price I paid for it. Good news for me, as I basically had a phone now for one and a half years basically without paying anything for it, but it also means that I don't have access to the device anymore.

I'm on a Samsung Galaxy Nexus now. As you know that one's based on an OMAP4460 chipset, which has absolutely no security in place, so there's currently nothing I could hack. :D
 

rezo

Senior Member
Nov 17, 2007
111
105
Thanks BeciMester for explaining it to me.

no.human.being said:
However, I think that the HBOOT that aARM "sees" (remember that this is not what's actually in NAND - for example the Radio code that aARM sees looks VERY different compared to the code that's actually stored in NAND) is the same that is in the nb0 and not what is in the JTAG dump (and therefore probably in physical NAND).

I agree. Munjeni also said that. So that jtag dump may be proper.


BTW...

no.human.being said:
We have KNOWN for some time that they perform two checks, but why? Is it for easier testing? Their developers probably test on Radio S-OFF devices. Do they perform this "misc"-check to allow their devs to easily enable security temporarily on their devices by changing a bit in the "misc" partition?

In the 1.09.0099 hboot, the whole value from 0x201C is used in two other places... @BeciMester do you know what for?

sdgsdgsgsdgdsg.jpg



@n.h.b That's sad :( Hope you don't leave this thread... If you want I can send you one of my phones :)




----------------------------------

EDIT:
About comparing:
Yes, 90% is the some kind of pattern.

3% part from whole:
vxcvxvxc.jpg



Bigger parts of non matched data:
Some insertion and all deletions:


asdasfasdf.jpg



dfsfsdfs.jpg
 
Last edited:

no.human.being

Senior Member
Oct 29, 2011
981
987
I agree. Munjeni also said that. So that jtag dump may be proper.

I first thought it may be proper, as I thought that JTAG had the stuff "inserted", so I thought that it might be some sort of redundancy that is created when HBOOT is written to NAND and stripped off again when loaded by the SBL, but now I've seen that the stuff is MISSING from JTAG but is THERE in the nb0, so I no longer think that it's proper. We can be quite sure that what's in the nb0 is what actually gets executed. This is what happens in HBOOT-0.90.0000 (nb0 version) after the MMU was set up.

Code:
     4d4:	e59f0010 	ldr	r0, [pc, #16]	; 0x4ec
     4d8:	e3500000 	cmp	r0, #0
     4dc:	ee011f10 	mcr	15, 0, r1, cr1, cr0, {0}
     4e0:	e1a0f000 	mov	pc, r0
     4e4:	e1a00000 	nop			; (mov r0, r0)
     4e8:	fff00000 			; <UNDEFINED> instruction: 0xfff00000	; IMB
     4ec:	9d000800 	stcls	8, cr0, [r0, #-0]

See that it jumps to 0x9d000800 virtual, which is 0x800 inside the nb0. There's the code that zeroes the BSS, then jumps to 0xbc8 ("main").

Code:
     800:	ea000001 	b	0x80c
     804:	9d0798d0 	stcls	8, cr9, [r7, #-832]	; 0xfffffcc0
     808:	9d08d324 	stcls	3, cr13, [r8, #-144]	; 0xffffff70
     80c:	e51f0010 	ldr	r0, [pc, #-16]	; 0x804
     810:	e51f1010 	ldr	r1, [pc, #-16]	; 0x808
     814:	e3a02000 	mov	r2, #0
     818:	e5802000 	str	r2, [r0]
     81c:	e2800004 	add	r0, r0, #4
     820:	e1500001 	cmp	r0, r1
     824:	1afffffb 	bne	0x818
     828:	e59fd37c 	ldr	sp, [pc, #892]	; 0xbac
     82c:	ea0000e5 	b	0xbc8

So let's have a look at what's at 0xbc8.

Code:
     bc8:	e92d47f0 	push	{r4, r5, r6, r7, r8, r9, sl, lr}

Mmh, saves a lot of registers to the stack. Looks much like the beginning of a function (in fact it's function "main"). So far we've had one branch from 0x9d0004e0 to 0x9d000800 and one branch from 0x9d00082c to 0x9d000bc8 and they all ended up where we expected them.

Contrary, in your JTAG dump 4 bytes are missing at 0x202 to 0x205 and 0x40d to 0x410. That means that this thing at 0x9d000800 would actually be 8 bytes "earlier", at 0x9d0007f8. Thus setting the program counter to 0x9d000800 would actually end up two instructions "after" what we see inside the nb0 at 0x800. It would branch to what we see as 0x808. At this offset there is the word 0x9d08d324, which is clearly a virtual address and not an instruction.

Forget the JTAG dump, it's screwed.
 
  • Like
Reactions: Antagonist42

davidang

Senior Member
Apr 2, 2012
474
134
The micro-switches were worn out. It was still usable, but I decided to send it to HTC to have it fixed before the warrenty period ends. However, they said that the board on which it is based is no longer produced by their supplier, so they can neither replace the board on it nor manufacture new devices of this type, so the device is basically discontinued. Since they don't have any devices left in stock, they could not send me a replacement device either, so they offered me a refund of the entire price I paid for it. Good news for me, as I basically had a phone now for one and a half years basically without paying anything for it, but it also means that I don't have access to the device anymore.

I'm on a Samsung Galaxy Nexus now. As you know that one's based on an OMAP4460 chipset, which has absolutely no security in place, so there's currently nothing I could hack. :D

No!! Chances of s-off our wfs will be gone :(

Sent from my HTC Wildfire S A510e using xda app-developers app
 

artturnip

Senior Member
Jan 28, 2012
206
53
Are they expensive? Or will it just not work with jtag? Yes... I know of the voltage problems... I have been following this thread. But can we fix that? :confused:

Sent from my Wildfire S A510e using xda app-developers app
 

heavy_metal_man

Senior Member
Nov 6, 2011
2,749
752
There is bound to be JTAG for the htc wildfire s specifically. I think the JTAG nhb got was a more generic arm jtag . But if we could get a specific JTAG for the marvel we would at least have a chance. Maybe we could all chip in and get it?

Sent from my HTC Sensation using xda premium

---------- Post added at 03:04 AM ---------- Previous post was at 02:51 AM ----------

http://www.fonefunshop.co.uk/cable_picker/94954_RIFF_Box.html

I have found this, and I saw an Adapter for the marvel as well. What do we think guys? Who here still has the device and the will to get this done?

Sent from my HTC Sensation using xda premium
 

artturnip

Senior Member
Jan 28, 2012
206
53
£130!!!??? Don't think anyone's gonna spend that amount... :banghead:

Sent from my Wildfire S A510e using xda app-developers app
 

no.human.being

Senior Member
Oct 29, 2011
981
987
For the JTAG interface, you usually want to ensure that it's supported by OpenOCD (that's the debugging software). Many interfaces do not support actual "debugging" but merely "programming". This will be sufficient if you want to dump and modify NAND content, but with "debugging" capable interfaces you'll also be able to, well, debug the system code, which, while not absolutely neccessary under all circumstances, will of course be very nice to track what's actually going on inside the phone. :D

With a "debug capable" interface you can e. g. "trap" Iguana when it reaches a specific instruction (breakpoint) and then single-step it, etc. It's like the entire system was running inside a debugger. The interface I have is based on an FTDI FT2232 UART chip. It's capable of "debug mode", but, well, the voltages don't match. :D

Are they expensive? Or will it just not work with jtag? Yes... I know of the voltage problems... I have been following this thread. But can we fix that? :confused:

Yeah, kinda. Say around 60 € for interface + adapter. And MAY you also need additional equipment (cables, clamps, resistors, regulated DC supply, ...) to get the device to boot. I don't think it's neccessary for programming, but it's almost certainly for debugging.

But probably the biggest problem is that, unless there is an interface that can work with 0.9 V targets and does support debugging (I found none) your only chance seems to be "handcrafted" circuitry. However, doing it all with discrete FETs will be a mess (end relatively expensive). It'd be much easier (and cheaper) if there was an "integrated" (IC) solution one could use, but none seems suitable. It's really strange, as I think there have to be a bunch of people that want to debug a low-voltage ARM11, but you really don't find anything about it. It's all for, say, 2.0 - 3.3 V.

Of course apart from a few that appearently work but may not support debugging. :D
 
  • Like
Reactions: wlmeng11

heavy_metal_man

Senior Member
Nov 6, 2011
2,749
752
so are we stuck atm without being able to debug? so shall we hunt for a jtag that is up to the challenge or find an electrician to wire us up a "rig" capable to do the voltage changes?
 

no.human.being

Senior Member
Oct 29, 2011
981
987
Maybe we should harass Lauterbach as Qualcomm use them ;)

GT540 - E320 is poorly

OpenOCD supports these. Lauterbach is not among them. Like I said, most are based on the FTDI FT2232 or FT2232H (mine is based on the latter) UART.

Note that this is only a list of interfaces that OpenOCD supports for debugging. First, you'll only be interested in the USB variants, since practically no computer still features a parallel port these days. :D

The interfaces listed are all sorts of interfaces for all sorts of processors, so not all of them are for ARM. Some are only for specific versions of ARM. E. g. the STM32 is an ARM-clone, but JTAG interfaces that are specifically for STM32 will probably not support other types of ARM, otherwise they would be labelled interfaces for ARM.

Some of the interfaces (e. g. Segger JLINK) are processors themselves, since JTAG can also be used for inter-processor communication. This is of course a bit "overkill" though, since you have an entire processor (with its own firmware) in the box. They may be more prone to failure than the "simpler" UART-based interfaces and they're probably more expensive.

The list will shrink very rapidly based on our needs. Also the 0.9 V voltage is extremely low. The lowest that the site mentions is 1.8 V which is still TWICE AS MUCH as what the MSM7227 uses.

Last, but not least, note that the site mentions the following.

You might need a level converter.

So at least it does not appear to be uncommon to require level conversion between the processor and the interface, however, I haven't found a suitable converter yet. Of course 3.3 V (interface) <--> 0.9 V (processor/target) would be ideal, then you could use an FTDI2232H-based interface. They are high-speed UARTS and cost around 45 €.
 

Top Liked Posts