Stupid SU: Galaxy S 4 stock+root helper

Status
Not open for further replies.
Search This thread

supercurio

Retired Senior Recognized Developer
May 31, 2010
3,550
5,041
Chambéry
spectrastudy.com
Hi guys!

As some of you must have noticed, latest Samsung GT-I9500 firmwares carry a kernel configuration supposed to prevent SETUID privilege elevation.
Stock unmodified firmware with root is my preferred setup but also a strong dependency for all my development, for me this change is a massive setback if not a dealbreaker.

While poking around I found in about an hour something weird that reveled being a vulnerability, so I created a little thing to make it useful for now.

README:
Stupid SU: Galaxy S4 root helper by François SIMOND aka @supercurio

Circumvent an extremely weak false-security "Anti Root" mechanism implemented
on latest Samsung Galaxy S4 devices (on both Exynos and Qualcomm versions)

Preventing proper root function on official firmware breaks all my Voodoo apps
requiring stock+root and is a move that's hostile to both users and developers.

Samsung security might be embarassed by this proof of concept, as it defeats
their mechanism in a single line... not even with complex ARM assembler
but *one* line of shell script.
However, the goal here is to show Superuser solutions developers how to
deal with those devices for now, and provide a working solution to people who
bought a Galaxy S4 expecting to root it cleanly and easily but cannot.

This proof of concept is slightly slowing down Superuser calls, but its
"plain text" implementation has the merit of showing how stupid this exploit is.

SELinux configuration stays unmodified and active.

Features:
- Detect and supports both SuperSU and Koush's Superuser
- Installs Super SU binary by default

Make sure you have one of those Superuser apps installed:
- https://play.google.com/store/apps/details?id=com.koushikdutta.superuser
- https://play.google.com/store/apps/details?id=eu.chainfire.supersu

Root feature doesn't rely on a "StupidSU kernel" which is only an installer.
Feel free to flash back Samsung's original boot.img from their official firmware
after booting at least once.

Important Note:
This "exploit" is so lame that it will be fixed in no time, making updated S4
a pain to root again.

I wish Samsung will reconsider their "Anti Root" approach, which is damageable
in every regard and defective by design as demonstrated here.
Also, I'm simply not interested developing for and promoting devices from
manufacturers hostile to developers: It's just a waste of valuable time.

INSTALL
1/ copy rooting/ directory in your initramfs

Make sure "root.sh" file is has an executable permission (chmod 744 recommended)


2/ Add those lines at init.universal5410.rc end:

# Stupid SU
service rooting /stupidsu/root.sh
class main
user root
group root
oneshot

3/ Assemble your initramfs with the associated Samsung official kernel binary
of choice in a regular boot image

4/ flash as boot.img

5/ At each boot, Superuser app are detected automatically and su binary adjusted
accordingly.


Source code

On GitHub


License ;)


Kernels downloads, only for demo purposes of the concept, you can flash back original Samsung boot.img once rooted

GT-I9500 Stock + root StupidSU v4 UBUAMDE
GT-I9500 Stock + root StupidSU v4 XXUAMDK
GT-I9500 Stock + root StupidSU v4 XXUAME1

What's next

Owners of Qualcomm Galaxy S 4 devices experiencing the same dificulties with Samsung the anti root strategy might want to try this method, please let me know if you're ready for some experimentations.
 
Last edited:

muhamet

Senior Member
Feb 8, 2011
1,292
262
Skopje
Supercurio pleas add thraed t General section i think ther well bee lots of testers for i9505.thx for suport

Sent from my LG-P500 using xda app-developers app
 

grgsiocl

Senior Member
Nov 9, 2009
2,891
4,547
Kurnool, Andhra Pradesh
Going to try this on latest LE1 stock kernel now .....thread is in correct section

edit: did not work on LE1 kernel. I will try once again. DId any one tried the MDK kernel..I am having again the problem with SU binaries installation..

Edit: Thanks bro. working on ME1 kernel now. Did mistake while doing tar. Appreciate it! Root is working fine but cant update the binaries of Supersu, still the root works fine.
 
Last edited:

walda

Senior Member
Apr 2, 2010
1,387
249
Hope chainfire will start working on mobileOdin soon. So much easier to flash than.

... tapat*lked
 

grgsiocl

Senior Member
Nov 9, 2009
2,891
4,547
Kurnool, Andhra Pradesh
Thanks fo much! Will Titanium Backup work on this kernel?

wrong file uploaded. Please download the same in 5 minutes. Uploading is on and the kernel date should be MAY 04

---------- Post added at 12:33 PM ---------- Previous post was at 12:28 PM ----------

Thanks fo much! Will Titanium Backup work on this kernel?

it should work as i dont use titanium backup and instead i use gobackup pro and it works fine anyway
 
  • Like
Reactions: GSeeker

aslak89

Senior Member
Jul 4, 2012
110
58
i repacked the kernel of Samsung-Updates.com-KERNEL-GT-I9500-XSE-I9500XXUAME1-1367637350 using supercurio method. Root works fine. All we need to is install it from ODIN and dont update the binaries of supersu.

Download Link

Edit: New file uploaded

I'm trying to repack the kernel of korean gs4,
but I am a noob in kernel devs.
I can edit ramdisc, but fist trying in initramfs, zImage.

Is rooting directory means both root.sh and files(folder)?
and paste them on first class route?

hope you give some advices.. thanks
 

grgsiocl

Senior Member
Nov 9, 2009
2,891
4,547
Kurnool, Andhra Pradesh
I'm trying to repack the kernel of korean gs4,
but I am a noob in kernel devs.
I can edit ramdisc, but fist trying in initramfs, zImage.

Is rooting directory means both root.sh and files(folder)?
and paste them on first class route?

hope you give some advices.. thanks

when you unpack the kernel you will have two folders one is ramdisk and other one is split_img (zimage). You need to copy the folder stupidsu folder in ramdisk and modify the init.universal5410.rc as per OP stated and repack the image
 
  • Like
Reactions: aslak89

aslak89

Senior Member
Jul 4, 2012
110
58
when you unpack the kernel you will have two folders one is ramdisk and other one is split_img (zimage). You need to copy the folder stupidsu folder in ramdisk and modify the init.universal5410.rc as per OP stated and repack the image

then, is not necessary to recompile zImage?
ok I m going to try it right now, thank you grgsiocl:)
 

supercurio

Retired Senior Recognized Developer
May 31, 2010
3,550
5,041
Chambéry
spectrastudy.com
Supercurio pleas add thraed t General section i think ther well bee lots of testers for i9505.thx for suport

Yes in fact I was hesitating, but as soon as someone is ready to assist me to try on a Qualcomm device (I9505 or T-Mobile Galaxy S4) I'll make a thread here too.

Going to try this on latest LE1 stock kernel now .....thread is in correct section

edit: did not work on LE1 kernel. I will try once again. DId any one tried the MDK kernel..I am having again the problem with SU binaries installation..

Edit: Thanks bro. working on ME1 kernel now. Did mistake while doing tar. Appreciate it! Root is working fine but cant update the binaries of Supersu, still the root works fine.

Great then :)
 
  • Like
Reactions: muhamet

supercurio

Retired Senior Recognized Developer
May 31, 2010
3,550
5,041
Chambéry
spectrastudy.com
then, is not necessary to recompile zImage?
ok I m going to try it right now, thank you grgsiocl:)

The point here is to have stock (unmodified Samsung binary) kernel running, with associated modules and no other modification.

Which gives you several usage options:
  • keep the StupidSU stock+root kernel (same kernel binary, same kernel modules, only very slightly initramfs scripts) that will auto-root depending on which Superuser APK you installed
  • you can flash back the official kernel and still enjoy root the same.
 

aslak89

Senior Member
Jul 4, 2012
110
58
The point here is to have stock (unmodified Samsung binary) kernel running, with associated modules and no other modification.

Which gives you several usage options:
  • keep the StupidSU stock+root kernel (same kernel binary, same kernel modules, only very slightly initramfs scripts) that will auto-root depending on which Superuser APK you installed
  • you can flash back the official kernel and still enjoy root the same.

Thank you for awsering:)

then I repacked my kernel but still not work.
copyed stupidsu and edited init.universal5410.rc in ramdisk and repacked boot.img.
I guess permission is the thing,

attach my shots
hope you loot at once.


Sent from my SHV-E300S using XDA Premium HD app
 

Attachments

  • Screenshot_2013-05-18-19-36-26.jpg
    Screenshot_2013-05-18-19-36-26.jpg
    14.2 KB · Views: 535
  • Screenshot_2013-05-18-19-36-31.jpg
    Screenshot_2013-05-18-19-36-31.jpg
    21.5 KB · Views: 540
Last edited:

Chainfire

Moderator Emeritus / Senior Recognized Developer
Oct 2, 2007
11,452
87,862
www.chainfire.eu
I'll look into a fixed CF-Auto-Root for the I9505 as soon as I'm back on Sunday. I imagine that will be tested by Sunday evening, with a I9500 test version available sometime Monday. If all is well :)

In StupidSU environment and for this initial release Koush's Superuser app would
be preffered as SuperSU main UI refuses to launch because it cannot detect its
original su binary. Aside from that both work as expected.

This is because you're not installing the backup su binary. The UI app detects this is missing and triggers an update. Bug in StupidSU :p
 

supercurio

Retired Senior Recognized Developer
May 31, 2010
3,550
5,041
Chambéry
spectrastudy.com
Thank you for awsering:)

then I repacked my kernel but still not work.
copyed stupidsu and edited init.universal5410.rc in ramdisk and repacked boot.img.
I guess permission is the thing,

attach my shots
hope you loot at once.p

Alright I'm adding some logging in my scripts so you'll be able to see what's happening − or not ;)
 
  • Like
Reactions: aslak89
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 41
    Hi guys!

    As some of you must have noticed, latest Samsung GT-I9500 firmwares carry a kernel configuration supposed to prevent SETUID privilege elevation.
    Stock unmodified firmware with root is my preferred setup but also a strong dependency for all my development, for me this change is a massive setback if not a dealbreaker.

    While poking around I found in about an hour something weird that reveled being a vulnerability, so I created a little thing to make it useful for now.

    README:
    Stupid SU: Galaxy S4 root helper by François SIMOND aka @supercurio

    Circumvent an extremely weak false-security "Anti Root" mechanism implemented
    on latest Samsung Galaxy S4 devices (on both Exynos and Qualcomm versions)

    Preventing proper root function on official firmware breaks all my Voodoo apps
    requiring stock+root and is a move that's hostile to both users and developers.

    Samsung security might be embarassed by this proof of concept, as it defeats
    their mechanism in a single line... not even with complex ARM assembler
    but *one* line of shell script.
    However, the goal here is to show Superuser solutions developers how to
    deal with those devices for now, and provide a working solution to people who
    bought a Galaxy S4 expecting to root it cleanly and easily but cannot.

    This proof of concept is slightly slowing down Superuser calls, but its
    "plain text" implementation has the merit of showing how stupid this exploit is.

    SELinux configuration stays unmodified and active.

    Features:
    - Detect and supports both SuperSU and Koush's Superuser
    - Installs Super SU binary by default

    Make sure you have one of those Superuser apps installed:
    - https://play.google.com/store/apps/details?id=com.koushikdutta.superuser
    - https://play.google.com/store/apps/details?id=eu.chainfire.supersu

    Root feature doesn't rely on a "StupidSU kernel" which is only an installer.
    Feel free to flash back Samsung's original boot.img from their official firmware
    after booting at least once.

    Important Note:
    This "exploit" is so lame that it will be fixed in no time, making updated S4
    a pain to root again.

    I wish Samsung will reconsider their "Anti Root" approach, which is damageable
    in every regard and defective by design as demonstrated here.
    Also, I'm simply not interested developing for and promoting devices from
    manufacturers hostile to developers: It's just a waste of valuable time.

    INSTALL
    1/ copy rooting/ directory in your initramfs

    Make sure "root.sh" file is has an executable permission (chmod 744 recommended)


    2/ Add those lines at init.universal5410.rc end:

    # Stupid SU
    service rooting /stupidsu/root.sh
    class main
    user root
    group root
    oneshot

    3/ Assemble your initramfs with the associated Samsung official kernel binary
    of choice in a regular boot image

    4/ flash as boot.img

    5/ At each boot, Superuser app are detected automatically and su binary adjusted
    accordingly.


    Source code

    On GitHub


    License ;)


    Kernels downloads, only for demo purposes of the concept, you can flash back original Samsung boot.img once rooted

    GT-I9500 Stock + root StupidSU v4 UBUAMDE
    GT-I9500 Stock + root StupidSU v4 XXUAMDK
    GT-I9500 Stock + root StupidSU v4 XXUAME1

    What's next

    Owners of Qualcomm Galaxy S 4 devices experiencing the same dificulties with Samsung the anti root strategy might want to try this method, please let me know if you're ready for some experimentations.
    13
    Chainfire's SuperSU su binary is now capable of gaining root by itself without helper.

    I'm also assisting him to make an autoroot for I9500, which will make Stupid SU definitely obsolete, as intended.
    6
    AutoRoot for GT-I9500 is now available from Chainfire so Stupid SU is now definitely obsolete!

    Just keeping this thread for reference but this project is now dead.
    6
    Thread cleaned.

    Let's keep all discussions respectful and relevant. Nothing wrong with debating, but there's a thick line between debating, and arguing in a public forum.

    If anybody wishes to discuss this further with me, feel free to PM me.

    Thanks a lot,

    Kind regards,

    Lady Android
    Forum Moderator & XDA News Writer
    6
    I'll look into a fixed CF-Auto-Root for the I9505 as soon as I'm back on Sunday. I imagine that will be tested by Sunday evening, with a I9500 test version available sometime Monday. If all is well :)

    In StupidSU environment and for this initial release Koush's Superuser app would
    be preffered as SuperSU main UI refuses to launch because it cannot detect its
    original su binary. Aside from that both work as expected.

    This is because you're not installing the backup su binary. The UI app detects this is missing and triggers an update. Bug in StupidSU :p