Samsung RIL reversing

Search This thread

iuss

Senior Member
Dec 21, 2010
156
229
Hi,

A while ago I've started to reverse engineer the (userland) baseband interface of my Samsung phone (GT-I8320 aka. H1) in an effort to see how far I can get Android running on the device (it ships with an OS based on LiMo and associated RIL).

Some Googling and inspection of other phones' RILs suggests that possibly quite some other Samsung smartphones use a similar baseband interface (Qualcomm MSM over dpram).

Searching XDA yield quite a few threads of Android upgrades blocked by a proprietary RIL. I couldn't find any traces of attempts to reverse a Samsung RIL though.

So, what I currently have is a really[/n] basic RIL implementation supporting baseband messages related to network registration (power up, imei/network info, signal info) and even outgoing calls (but that's all related to call management).

To anyone still reading this:
- Please direct me to any related effort (couldn't find any, as mentioned before).
- Direct anyone considering reversing a Samsung RIL here.

Finally, a set of goodies of unknown use:
- Known to work with my MSM6290 via a dpram interface.
- No idea how much free time I have to continue my effort.
- Might, or might not be of (limited) use for other Samsung phones.

Code: github.com/ius/samsung_h1_libmsm
 
  • Like
Reactions: minus30

minus30

Member
Jul 5, 2010
27
0
Brugge
You might want to check out this thread:

http : //forum.samdroid.net/f56/ril-development-froyo-3156/

Remove the space, cannot post links yet

This is for the Samsung Galaxy Spica, but may be a bit of help
 

tux@dbox

Member
Jan 19, 2011
13
5
hi!


I also tried to find out how samsung ril over dpram0 works...

@iuss
first of all .. amazing work.. ;) thx

where did you get the information??? do you have any docs??
 

iuss

Senior Member
Dec 21, 2010
156
229
It's all based on reverse engineering of the LiMo telephony library (which is luckily pretty verbose) and it's associated logs.

I've found most similarities with Samsung RILs labeled as 'libsecril'. Those appear to use a similar interface.

I'm currently struggling to get the audio routing from the modem fixed on my board (in order to be able to test call functionality as I add it) before continuing to work on this.
 

tux@dbox

Member
Jan 19, 2011
13
5
I've found most similarities with Samsung RILs labeled as 'libsecril'. Those appear to use a similar interface.

Yes you are right, libsec-ril.so from galaxy spica uses exactly the same interface!
I opened it up in ida-pro and checked it!

@iuss:
are you good at reading asm??
 

tux@dbox

Member
Jan 19, 2011
13
5
I am testing now with your source and i can open dpram0 and power_on!
Further i can send commands, but i do not get an answer???

can you post an example .. (unlocking sim,..)

thx
 

iuss

Senior Member
Dec 21, 2010
156
229
It's not implemented (as is 99% of the rest). Should be trivial to implement though, I think it's the MSM_SEC_ISIM_AUTH message. Will certainly do so after the weekend, if I get my sound to work. - which is still not working. Could you try patching test.c using the following diff (after disabling the pin code if neccessary, and change the number). It should call the number - if it works for you, I'm probably missing a GPIO somewhere.

Code:
diff --git a/test.c b/test.c
index 28fae0e..a449342 100644
--- a/test.c
+++ b/test.c
@@ -18,10 +18,26 @@
  *
  */
 
+#include <unistd.h>
 #include <radio.h>
 
+static int flag = 0;
+
+static void do_stuff()
+{
+       msm_call_outgoing(0, "0123456798");
+}
+
 static void on_receive(struct msm_request_info *info)
 {
+       switch(info->type) {
+               case MSM_NET_REGIST:
+                       if(!flag) {
+                               flag = 1;
+                               do_stuff();
+                       }
+                       break;
+       }
 }
 
 static struct msm_info msm = {
 
Last edited:

tux@dbox

Member
Jan 19, 2011
13
5
thx for the code!

I disabled the pin code and tried your changes!
the only message i get is

Code:
MSM_DISP_ICON_INFO NOTI (15/5) seq=179 req=0

i think the mobile is not connecting to network!
 

iuss

Senior Member
Dec 21, 2010
156
229
Hi,

You're testing this on a GT-I5700 (Spica) right?

Checked the dpram driver source, the ioctls are different. Hence the phone is not properly reset (by msm_power_on(), which turns the modem off first if needed). That's why you're only getting a status message regularly sent by the baseband (contains rssi and such).

Try this. Spica seems to have a few different ioctls too, but I've just dropped those as I'm not using them anyway.

- Edit: Wrong ioctls, see next 2 posts -
 
Last edited:

tux@dbox

Member
Jan 19, 2011
13
5
from where did you have the ioctls??
i checked libsec-ril.so

Code:
EXPORT onedram_phone_pow_on
onedram_phone_pow_on
PUSH    {R4,LR}
LDR     R4, =(_GLOBAL_OFFSET_TABLE_ - 0x33CC8)
LDR     R0, =(fd_onedram_ptr - 0x45164)
LDR     R1, =0x6FD0     ; request
ADD     R4, PC
LDR     R3, [R4,R0]
MOVS    R2, #0
LDR     R0, [R3]        ; fd
BLX     ioctl
CMP     R0, #0
BGE     loc_33CEE
 

iuss

Senior Member
Dec 21, 2010
156
229
My reference is the dpram driver shipped with GT-I5700_OpenSource.zip.

But I see that you're right, in true Samsung-style there are multiple defines for the ioctls. The ones in my patch are unused.

DPRAM_PHONE_POWON is indeed 0x6FD0. Try setting that as power_on ioctl.

DPRAM_PHONE_ON is 0xF0C0 - which seems to be called to init the OneDRAM memory, and appears to depend on POWON. If it doesn't work after the POWON ioctl, send this one as well (or even better, strace your original RIL to see the ioctls required).

There's one more ioctl (0x6FD3) related to booting, but I *think* it's only used when a modem image is uploaded. Refer to dpram.h/dpram.c for more info..
 

tux@dbox

Member
Jan 19, 2011
13
5
hi!

hmm it doesn't work!
Can you tell me how the image upload (over serial) works and if i need to do it??

Further how do you strace rild??
rild is startet from init and the sockets are created on startup!
if i stop rild it restarts and i can not strace it!

so i go to bed... good night
 

iuss

Senior Member
Dec 21, 2010
156
229
I don't know about the image upload. Either the bootloader handles it (didn't check in detail) or it's handled by the baseband itself. For my phone I can simply send the power_on ioctl and off it goes - probably it's just the same for Spica.

As for stracing, you might be able to modify init.rc so rild is started straced.

What might be easier though is simply reversing it. Seeing you already have the RIL lib in IDA, just find all xrefs to ioctl and you should be able to figure all needed.
 

tux@dbox

Member
Jan 19, 2011
13
5
hi,

I tried a lot, but i did not get it to work!
I changed the power_IOCTL to 0x6FD0!
It return 0 = OK

but the phone do not start!
The orignial lib loads a phone-image and a nv_data.bin and then it uses 0x6FD3 to start the phone.
But my assembly knowlegde not so good.

Can you have a look if you have time????
i attach libsec-ril.so. open it with ida and go to function RIL_Init!

the magic happens in dload_test

thx in advance
 

Attachments

  • libsec-ril.zip
    149.6 KB · Views: 384
Last edited:

iuss

Senior Member
Dec 21, 2010
156
229
Had a quick look. You're right, Spica appears to load the phone fw/nvs from Android.

Quick writeup (in order):
- onedram_open(): Open /dev/dpram0
- dload_read_dbl(): Read /dev/bml9, 0x5000 bytes
- onedram_phone_pow_on(): ioctl 0x6fd0 (DPRAM_PHONE_POWON)
- dload_uart_init(): open /dev/s3c_serial0, 115200
- dload_hdlc_init(): init some data related to hdlc parsing
- dload_packet_init(): init some packet struct
- nop_req()
- onedram_phone_image_load(): ioctl 0x6fd1 (DPRAM_PHONEIMG_LOAD)
- onedram_nv_data_load(): load /efv/nv_data.bin 0x80000 bytes, ioctl(fd, 0x6FD2 (DPRAM_NVDATA_LOAD), buf_with_nvdata)
- onedram_phone_boot_start(): ioctl 0x6fd3 DPRAM_PHONE_BOOTSTART

onedram_nv_data_load() reads the nvdata and passes it as a param along with the ioctl, the nop_req is sent over the uart.

The baseband firmware itself seems to be read by libsecril, but not used (?) - the kernel driver contains code to read bml too when DPRAM_PHONEIMG_LOAD is issued.

I haven't traced into nop_req - no time to reverse it right now. You can import these functions from libsec-ril.so for testing (all are exported) and later replace them with your own implementation. (You can then easily strace your binary to recover the nop_req data).
 

iuss

Senior Member
Dec 21, 2010
156
229
I'm looking for RIL logs of Samsung phones in order to speed up development.
'logcat -b radio' might provide some, but given a specific phone model I could look up alternative log locations (i5500 for instance appears to dump RIL traffic to /data/log/).

Anyone able to help?
 

Tuigje

Member
Feb 12, 2011
6
1
Nexus S

Hi,

out of curiosity I opened the 'libsec-ril.so' from the Nexus S in IDA.
although 'ioctl' is imported, I cannot really find calls to it.

Since i'm unfamiliar with Arm opcodes, I probably overlook something.
Does this code make sense to anyone ?

EDIT: Quite a lot of functions seem to call 'IPC_send_singleIPC', so I suppose
I might be looking at the wrong file...

EDIT2: Ahh, 'IPC_send_singleIPC' can print an IOCTL error message, just haven't found the actual call to ioctl() yet..

Code:
.text:00016BC4                 EXPORT requestDTMFStop
.text:00016BC4 requestDTMFStop
.text:00016BC4                 LDR     R3, =(dword_62428 - 0x16BD0)
.text:00016BC6                 PUSH    {R4-R6,LR}
.text:00016BC8                 MOV     R4, R2
.text:00016BCA                 LDR     R2, =0xFFFFFDC4
.text:00016BCC                 ADD     R3, PC
.text:00016BCE                 MOV     R6, R0
.text:00016BD0                 MOV     R5, R1
.text:00016BD2                 LDR     R0, [R3,R2]
.text:00016BD4                 LDRB    R3, [R0]
.text:00016BD6                 CBZ     R3, loc_16BEC
.text:00016BD8                 LDR     R3, =(aOndialtimeout - 0x16BE4)
.text:00016BDA                 MOVS    R0, #6
.text:00016BDC                 LDR     R1, =(aRil - 0x16BE6)
.text:00016BDE                 LDR     R2, =(aS - 0x16BEA)
.text:00016BE0                 ADD     R3, PC          ; "onDialTimeout"
.text:00016BE2                 ADD     R1, PC          ; "RIL"
.text:00016BE4                 ADDS    R3, #0x6C
.text:00016BE6                 ADD     R2, PC          ; "%s()"
.text:00016BE8                 BLX     sub_10D2C    ; NOTE: this seems to be a printf() function
.text:00016BEC
.text:00016BEC loc_16BEC                               ; CODE XREF: .text:00016BD6j
.text:00016BEC                 MOV     R0, R6
.text:00016BEE                 MOV     R1, R5
.text:00016BF0                 MOV     R2, R4
.text:00016BF2                 MOVS    R3, #2
.text:00016BF4                 BL      sub_16B28
.text:00016BF8                 POP     {R4-R6,PC}
.text:00016BFA ; ---------------------------------------------------------------------------
.text:00016BFA                 NOP
.text:00016BFA ; ---------------------------------------------------------------------------
.text:00016BFC off_16BFC       DCD dword_62428 - 0x16BD0 ; DATA XREF: .text:requestDTMFStopr
.text:00016C00 dword_16C00     DCD 0xFFFFFDC4          ; DATA XREF: .text:00016BCAr
.text:00016C04 off_16C04       DCD aOndialtimeout - 0x16BE4 ; DATA XREF: .text:00016BD8r
.text:00016C04                                         ; "onDialTimeout"
.text:00016C08 off_16C08       DCD aRil - 0x16BE6      ; DATA XREF: .text:00016BDCr
.text:00016C08                                         ; "RIL"
.text:00016C0C off_16C0C       DCD aS - 0x16BEA        ; DATA XREF: .text:00016BDEr
.text:00016C0C                                         ; "%s()"
.text:00016C10 ; ---------------------------------------------------------------------------
 
Last edited:

iuss

Senior Member
Dec 21, 2010
156
229
out of curiosity I opened the 'libsec-ril.so' from the Nexus S in IDA.
although 'ioctl' is imported, I cannot really find calls to it.

Did you try to find xrefs to it? ;)

Since i'm unfamiliar with Arm opcodes, I probably overlook something.
Does this code make sense to anyone ?

It does, but it's just an excerpt from a RIL request handler (requestDTMFStop).

EDIT: Quite a lot of functions seem to call 'IPC_send_singleIPC', so I suppose
I might be looking at the wrong file...

Wrong file? What are you looking for exactly? The send_single_IPC function is used to send a message to the baseband, thus it's called quite often.

Nexus S has a slightly different kernel driver for dpram, probably Google kindly requested Samsung to clean their crap up. Instead of a chardev + read/write they use ioctls to perform read/write. That would explain the ioctl references you're seeing in IPC_send_singleIPC.
 
  • Like
Reactions: Tuigje

Tuigje

Member
Feb 12, 2011
6
1
Did you try to find xrefs to it? ;)

Nope. I must have done something wrong loading the libsec-ril.so into IDA. all
imports are shown at the end of the file as:

Code:
extern:0009E54C ; int ioctl(int fd, unsigned __int32 request, ...)
extern:0009E54C                 IMPORT ioctl


It does, but it's just an excerpt from a RIL request handler (requestDTMFStop).

Wrong file? What are you looking for exactly? The send_single_IPC function is used to send a message to the baseband, thus it's called quite often.

Ok. I was wondering whether it is possible to get e.g. 'timing advance' data from the gsm-modem. So I started by digging through the android sources. Now I'm at libsec-ril.so. (and libril.so, but I can't make much sense out of that one yet).

Is it correct that libril.so and the kernel-mode gsm driver are also closed-source for the Nexus S ?
Edit: libril looks awfully similar to the android sources (device/libs/telephony/ril.cpp)

Do you know the name of the kernel driver (module filename), or is it directly compiled into the kernel ?
I haven't stumbled onto it yet, neither in the system.img nor in the ramdisk of the boot.img.

Nexus S has a slightly different kernel driver for dpram, probably Google kindly requested Samsung to clean their crap up. Instead of a chardev + read/write they use ioctls to perform read/write. That would explain the ioctl references you're seeing in IPC_send_singleIPC.

Is there any other place to get such information, or is it all hard work figuring this out by yourself ?
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Hi,

    A while ago I've started to reverse engineer the (userland) baseband interface of my Samsung phone (GT-I8320 aka. H1) in an effort to see how far I can get Android running on the device (it ships with an OS based on LiMo and associated RIL).

    Some Googling and inspection of other phones' RILs suggests that possibly quite some other Samsung smartphones use a similar baseband interface (Qualcomm MSM over dpram).

    Searching XDA yield quite a few threads of Android upgrades blocked by a proprietary RIL. I couldn't find any traces of attempts to reverse a Samsung RIL though.

    So, what I currently have is a really[/n] basic RIL implementation supporting baseband messages related to network registration (power up, imei/network info, signal info) and even outgoing calls (but that's all related to call management).

    To anyone still reading this:
    - Please direct me to any related effort (couldn't find any, as mentioned before).
    - Direct anyone considering reversing a Samsung RIL here.

    Finally, a set of goodies of unknown use:
    - Known to work with my MSM6290 via a dpram interface.
    - No idea how much free time I have to continue my effort.
    - Might, or might not be of (limited) use for other Samsung phones.

    Code: github.com/ius/samsung_h1_libmsm
    1
    out of curiosity I opened the 'libsec-ril.so' from the Nexus S in IDA.
    although 'ioctl' is imported, I cannot really find calls to it.

    Did you try to find xrefs to it? ;)

    Since i'm unfamiliar with Arm opcodes, I probably overlook something.
    Does this code make sense to anyone ?

    It does, but it's just an excerpt from a RIL request handler (requestDTMFStop).

    EDIT: Quite a lot of functions seem to call 'IPC_send_singleIPC', so I suppose
    I might be looking at the wrong file...

    Wrong file? What are you looking for exactly? The send_single_IPC function is used to send a message to the baseband, thus it's called quite often.

    Nexus S has a slightly different kernel driver for dpram, probably Google kindly requested Samsung to clean their crap up. Instead of a chardev + read/write they use ioctls to perform read/write. That would explain the ioctl references you're seeing in IPC_send_singleIPC.
    1
    Hi iuss,
    I checked the "onedram_mailboxAB", which contains value "0x12341234". This value I think indicates that dbl.mbn is successfully loaded and acknowledged by MSM.

    Your assertion seems correct. Refer to modemctl_p.h from crespo's kernel source.

    Code:
    #define MODEM_MSG_SBL_DONE              0x12341234
    #define MODEM_CMD_BINARY_LOAD           0x45674567
    #define MODEM_MSG_BINARY_DONE           0xabcdabcd

    After writing "0x45674567" in "onedram_mailboxBA", I checked the contents of onedram_mailboxBA back but it shows value 00. Also the value in onedram_mailboxAB remains as 0x12341234. In fact I'm not able to write any value to "onedram_mailboxBA". But I can write at any other location in dpram. Is this behavior correct?

    Unfortunately I'm hardly familiar with the inner workings of dpram message passing (my modem apparantly boots itself and my dpram driver 'just worked'). It seems to rely on a specific address space layout for message data and semaphores/'interrupts'/magic values. You may want to confirm that Spica and Jet actually use the same address layout (if you reused the Spica dpram driver), because the modem firmwares for both devices could very well differ. This might be a problem for Spica RIL reuse later on (that's just a guess, you never know).

    Next I'd suggest to disassemble the Spica and/or Jet RIL, to make sure you've got the uploading procedure right. Also ensure your dpram driver doesn't accidentally tap a reset GPIO. Does Spica upload both the low-level bootloader and amss upon initializing the RIL? Then you might opt to do the same..

    Sorry for being off-topic and putting an exhaustive post, but I couldn't find any other place where the baseband interface is discussed in so much details.

    By all means, feel free to post anything baseband-related here. There's too little community research of Samsung's baseband interface(s). For Android-shipped devices people seem to rely on hacks to be able to reuse the proprietary RILs.

    An open source alternative could ease porting self-built Android distributions and allow adding missing functionality (eg. WiFi calling on Nexus S, provided the modem firmware supports the calls not present in the Nexus S RIL).

    As for the RIL, I've got some code done. Far from fully-featured, but in it's current state it supports (for my device) proper network registration status (gsm and gprs), calling, SMS (sending is a hack though), SIM I/O, STK and basic lock handling (SIM unlocking and select facility lock status queries).

    The RIL needs some cleanup, once that's done I'll push it to my Github. The code to access the IPC interface is already available at https://github.com/ius/libsamsung-ipc

    I've recently rewritten the IPC library to support multiple devices, another individual succeeded in writing a backend for Nexus S, next we will be investigating the IPC protocol differences between our devices, with the goal of making the RIL work for both devices. So far I've spotted a handful of additional message types for Nexus S, plus some minor changes in the format of some messages. I hope it stays that way - I'll be able to tell once we've taken a closer look.
    1
    Where does the function ipc_debug_send_ipc send command to?

    Where does the function ipc_debug_send_ipc send command to? In libsec-ril.so.

    Code:
    D/RILJ    (  285): [0073]> OEM_HOOK_RAW[04020004]
    D/RILC    ( 3309): [0073]> OEM_HOOK_RAW (raw_size=4)
    W/RILSWITCH( 3309): RIL REQUEST: OEM_HOOK_RAW received. Switch state is Vendor
    D/RILSWITCH( 3309): Routing to vendor RIL: RIL_REQUEST_OEM_HOOK_RAW - VVM Fix
    W/RILSWITCH( 3309): RIL REQUEST: OEM_HOOK_RAW --> FORCED TO VENDOR RIL
    E/RIL     ( 3309): onRequest: OEM_HOOK_RAW
    E/RIL     ( 3309): CreateRequest(): req(0x1b548), id(59), tok(0x1b530) - FUNC(0x
    8011e8e9)
    E/RIL     ( 3309): [EVT]:Req(1), RX(0)
    E/RIL     ( 3309): requestOEMHookRaw
    E/RIL     ( 3309): requestPersonalization
    E/RIL     ( 3309): sub_func_id is <2>
    E/RIL     ( 3309): <requestPersoStatus>
    E/RIL     ( 3309): TxSEC_GetPhoneLock()
    E/RIL     ( 3309): get_msg_sequence()
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661596210
    E/RIL     ( 3309): TX: Time: 3673701724 / 29841235
    E/RIL     ( 3309): TX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_GET  le
    n:8 mseq:37 aseq:0
    E/RIL     ( 3309): TX: ---- DATA BEGIN ----
    E/RIL     ( 3309): TX: 05
    E/RIL     ( 3309): TX: ---- DATA  END ----
    E/RIL     ( 3309): WaitForExpectedCmd(): cur_time: 29841235, cur_req->timeout: 2
    9901235, ph->near_timeout: 29901235
    E/RIL     ( 3309): processLine():
    E/RIL     ( 3309): processLine: got a single frame.
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661597858
    E/RIL     ( 3309): [EVT]:Req(1), RX(1)
    E/RIL     ( 3309): RX: Time: 3673701725 / 29841237
    E/RIL     ( 3309): RX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_RESP  l
    en:9 mseq:0 aseq:37
    E/RIL     ( 3309): RX: ---- DATA BEGIN ----
    E/RIL     ( 3309): RX: 05 01
    E/RIL     ( 3309): RX: ---- DATA  END ----
    E/RIL     ( 3309): requestOEMHookRaw
    E/RIL     ( 3309): requestPersonalization
    E/RIL     ( 3309): sub_func_id is <2>
    E/RIL     ( 3309): <requestPersoStatus>
    E/RIL     ( 3309): RxSEC_ResPhoneLock
    E/RIL     ( 3309): TxSEC_GetPhoneLock()
    E/RIL     ( 3309): get_msg_sequence()
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661598011
    E/RIL     ( 3309): TX: Time: 3673701726 / 29841237
    E/RIL     ( 3309): TX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_GET  le
    n:8 mseq:38 aseq:0
    E/RIL     ( 3309): TX: ---- DATA BEGIN ----
    E/RIL     ( 3309): TX: 06
    E/RIL     ( 3309): TX: ---- DATA  END ----
    E/RIL     ( 3309): WaitForExpectedCmd(): cur_time: 29841237, cur_req->timeout: 2
    9846237, ph->near_timeout: 29846237
    E/RIL     ( 3309): processLine():
    E/RIL     ( 3309): processLine: got a single frame.
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661604938
    E/RIL     ( 3309): [EVT]:Req(1), RX(1)
    E/RIL     ( 3309): RX: Time: 3673701733 / 29841244
    E/RIL     ( 3309): RX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_RESP  l
    en:9 mseq:0 aseq:38
    E/RIL     ( 3309): RX: ---- DATA BEGIN ----
    E/RIL     ( 3309): RX: 06 00
    E/RIL     ( 3309): RX: ---- DATA  END ----
    E/RIL     ( 3309): requestOEMHookRaw
    E/RIL     ( 3309): requestPersonalization
    E/RIL     ( 3309): sub_func_id is <2>
    E/RIL     ( 3309): <requestPersoStatus>
    E/RIL     ( 3309): RxSEC_ResPhoneLock
    E/RIL     ( 3309): TxSEC_GetPhoneLock()
    E/RIL     ( 3309): get_msg_sequence()
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661605274
    E/RIL     ( 3309): TX: Time: 3673701733 / 29841244
    E/RIL     ( 3309): TX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_GET  le
    n:8 mseq:39 aseq:0
    E/RIL     ( 3309): TX: ---- DATA BEGIN ----
    E/RIL     ( 3309): TX: 07
    E/RIL     ( 3309): TX: ---- DATA  END ----
    E/RIL     ( 3309): WaitForExpectedCmd(): cur_time: 29841244, cur_req->timeout: 2
    9901244, ph->near_timeout: 29846237
    E/RIL     ( 3309): processLine():
    E/RIL     ( 3309): processLine: got a single frame.
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661607105
    E/RIL     ( 3309): [EVT]:Req(1), RX(1)
    E/RIL     ( 3309): RX: Time: 3673701735 / 29841246
    E/RIL     ( 3309): RX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_RESP  l
    en:9 mseq:0 aseq:39
    E/RIL     ( 3309): RX: ---- DATA BEGIN ----
    E/RIL     ( 3309): RX: 07 00
    E/RIL     ( 3309): RX: ---- DATA  END ----
    E/RIL     ( 3309): requestOEMHookRaw
    E/RIL     ( 3309): requestPersonalization
    E/RIL     ( 3309): sub_func_id is <2>
    E/RIL     ( 3309): <requestPersoStatus>
    E/RIL     ( 3309): RxSEC_ResPhoneLock
    E/RIL     ( 3309): TxSEC_GetPhoneLock()
    E/RIL     ( 3309): get_msg_sequence()
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661607349
    E/RIL     ( 3309): TX: Time: 3673701735 / 29841246
    E/RIL     ( 3309): TX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_GET  le
    n:8 mseq:3a aseq:0
    E/RIL     ( 3309): TX: ---- DATA BEGIN ----
    E/RIL     ( 3309): TX: 08
    E/RIL     ( 3309): TX: ---- DATA  END ----
    E/RIL     ( 3309): WaitForExpectedCmd(): cur_time: 29841247, cur_req->timeout: 2
    9901247, ph->near_timeout: 29901244
    E/RIL     ( 3309): processLine():
    E/RIL     ( 3309): processLine: got a single frame.
    E/RIL     ( 3309): ipc_debug_send_ipc: timestamp 1322228661608875
    E/RIL     ( 3309): [EVT]:Req(1), RX(1)
    E/RIL     ( 3309): RX: Time: 3673701736 / 29841248
    E/RIL     ( 3309): RX: (M)IPC_SEC_CMD  (S)IPC_SEC_PHONE_LOCK  (T)IPC_CMD_RESP  l
    en:9 mseq:0 aseq:3a
    E/RIL     ( 3309): RX: ---- DATA BEGIN ----
    E/RIL     ( 3309): RX: 08 00
    E/RIL     ( 3309): RX: ---- DATA  END ----
    E/RIL     ( 3309): requestOEMHookRaw
    E/RIL     ( 3309): requestPersonalization
    E/RIL     ( 3309): sub_func_id is <2>
    E/RIL     ( 3309): <requestPersoStatus>
    E/RIL     ( 3309): RxSEC_ResPhoneLock
    E/RIL     ( 3309): perso Lock Status <1><0><0><0>
    E/RIL     ( 3309): RIL_onRequestComplete: tok(0x1b530)
    D/RILSWITCH( 3309): RILD <-- RIL (token 0x1b530)
    D/RILSWITCH( 3309): atdToken : 0x1b530, bEMCRedirected 0
    D/RILC    ( 3309): [0073]< OEM_HOOK_RAW
    E/RIL     ( 3309): [RM REQ]: req(0x1b548), tok(0x1b530)
    E/RIL     ( 3309): [EVT]:Req(0), RX(0)
    E/RIL     ( 3309): [EVT]:Req(0), RX(0)
    D/RILJ    (  285): [0073]< OEM_HOOK_RAW [B@40688f90
    D/RILJ    (  285): response processed : mRequestMessagesPending = 0, mRequestMes
    sagesWaiting = 0
    D/RILJ    (  285): wakelock released : mRequestMessagesPending = 0, mRequestMess
    agesWaiting = 0
    1
    I9100 unlock by reversing RIL to recover nv_data.bin information

    Hello everyone,

    I've been trying to do some reversing on libsec-ril.so myself for the last couple of days, but my assembly skillz cannot evolve over night, so I'm a bit of a noob.

    My goal is to extract the encryption key used to AES encrypt the hashes corresponding to the network unlock code on my SGS2 I9100, that can be found within nv_data.bin at offset 0x18146e and the salt of the hashes if it is different than 16 bytes equal to 0.

    There is a method SUB_319BC that reads the entire content of nv_data.bin to memory, and there are others that "magically" (i'm joking here, I have a lot to learn about ARM instructions) get access to the data.

    The method called to remove the simlock is "requestNPersoUnlock".

    If any of you have time to spend on this it would be great, as it could basically unlock all/most of our samsung phones if I'm not mistaken...

    Cheers.
    Stefan.