Email.apk Without Exchange Security

Discussion in 'Android Hacks and Help' started by Tvo14, Apr 15, 2011.

  1. Tvo14

    Tvo14 Member

    Joined:
    Sep 19, 2010
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    6
    Ratings:
    +0
  2. SirHenryXI

    SirHenryXI New Member

    Joined:
    Jan 23, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indiana
    Ratings:
    +0
  3. Tvo14

    Tvo14 Member

    Joined:
    Sep 19, 2010
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    6
    Ratings:
    +0
    Thanks but it fails on me like all the other email APK's I have tried. I have a rooted Samsung Fascinate with Froyo. Do I need to get rid of the old Email first? If so, how do I remove it?
     
  4. SirHenryXI

    SirHenryXI New Member

    Joined:
    Jan 23, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indiana
    Ratings:
    +0
    You should be able to navigate with root explorer to /system/app/ (or similar) and find and delete the email.apk. (note: you'll have to mount R/W, just hit the gray box at the top, in root explorer to delete the apk) Then install the new .apk.

    This worked for me on my moto droid. I do not have a Fascinate to try this with though. :(
     
  5. Tvo14

    Tvo14 Member

    Joined:
    Sep 19, 2010
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    6
    Ratings:
    +0
    I give up. I can't delete email.apk
    I used Root Explorer, Super Manager. Super manager says it deletes it and it comes back.
    Root Explorer shows the files in the path and grey little box just says Remount as R/O so I assume its already in R/W mode. I'm a bit of newb with phones but pretty technical but for the life of me cant figure this out
     
  6. SirHenryXI

    SirHenryXI New Member

    Joined:
    Jan 23, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indiana
    Ratings:
    +0

    Sorry I couldn't be of anymore help, that's the only way I know of. :/ I'm sure there's a way to delete it using ADB. Although I personally don't know how to do it. :(

    Sorry man!
     
  7. Phatdaddyz01

    Phatdaddyz01 Member

    Joined:
    Jun 23, 2010
    Messages:
    81
    Likes Received:
    0
    Trophy Points:
    6
    Ratings:
    +0
    Search for Enhanced Email on the market. Its the updated version of that app. You'll have to
    Pay for it though, but it should install for you with no problems & you don't have to delete the stock email app.
     
  8. raidzero

    raidzero n00b.
    Theme Developer Premium Member Developer

    Joined:
    Apr 15, 2010
    Messages:
    1,054
    Likes Received:
    3
    Trophy Points:
    38
    Ratings:
    +3
    I can provide simple instructions for deleting all the exchange policy stuff from the APK's java code itself - via smali if you don't want to do it in java source... should work with any phone or ROM, since we will be working with the email.apk from your device. basic overview: just pull the file with adb, baksmali the classes.dex, basically nullify two methods in SecurityPolicy.java (remove all code in the methods and just return true or false - trick the device into thinking policy has been applied) then smali, reinsert into apk, reboot to recovery, push email.apk back onto system and that's it.

    ORIGINAL SecurityPolicy.java (from 2.3.3_r1a): http://android.git.kernel.org/?p=pl...a;hb=4ff77b1e4f746aec45a7857ae3bd770173281bfa

    DETAILS: the methods we want to nullify are called IsActive, and IsActiveAdmin...


    IsActive:
    Code:
    .method public isActive(Lcom/android/email/SecurityPolicy$PolicySet;)Z
        .registers 9
        .parameter "policies"
    
        .prologue
        const/4 v6, 0x1
    
        const/4 v5, 0x0
    
        .line 216
        if-nez p1, :cond_8
    
        .line 217
        invoke-virtual {p0}, Lcom/android/email/SecurityPolicy;->getAggregatePolicy()Lcom/android/email/SecurityPolicy$PolicySet;
    
        move-result-object p1
    
        .line 220
        :cond_8
        sget-object v1, Lcom/android/email/SecurityPolicy;->NO_POLICY_SET:Lcom/android/email/SecurityPolicy$PolicySet;
    
        if-ne p1, v1, :cond_e
    
        move v1, v6
    
        .line 252
        :goto_d
        return v1
    
        .line 223
        :cond_e
        invoke-direct {p0}, Lcom/android/email/SecurityPolicy;->getDPM()Landroid/app/admin/DevicePolicyManager;
    
        move-result-object v0
    
        .line 224
        .local v0, dpm:Landroid/app/admin/DevicePolicyManager;
        iget-object v1, p0, Lcom/android/email/SecurityPolicy;->mAdminName:Landroid/content/ComponentName;
    
        invoke-virtual {v0, v1}, Landroid/app/admin/DevicePolicyManager;->isAdminActive(Landroid/content/ComponentName;)Z
    
        move-result v1
    
        if-eqz v1, :cond_5b
    
        .line 226
        iget v1, p1, Lcom/android/email/SecurityPolicy$PolicySet;->mMinPasswordLength:I
    
        if-lez v1, :cond_2a
    
        .line 227
        iget-object v1, p0, Lcom/android/email/SecurityPolicy;->mAdminName:Landroid/content/ComponentName;
    
        invoke-virtual {v0, v1}, Landroid/app/admin/DevicePolicyManager;->getPasswordMinimumLength(Landroid/content/ComponentName;)I
    
        move-result v1
    
        iget v2, p1, Lcom/android/email/SecurityPolicy$PolicySet;->mMinPasswordLength:I
    
        if-ge v1, v2, :cond_2a
    
        move v1, v5
    
        .line 228
        goto :goto_d
    
        .line 231
        :cond_2a
        iget v1, p1, Lcom/android/email/SecurityPolicy$PolicySet;->mPasswordMode:I
    
        if-lez v1, :cond_44
    
        .line 232
        iget-object v1, p0, Lcom/android/email/SecurityPolicy;->mAdminName:Landroid/content/ComponentName;
    
        invoke-virtual {v0, v1}, Landroid/app/admin/DevicePolicyManager;->getPasswordQuality(Landroid/content/ComponentName;)I
    
        move-result v1
    
        invoke-virtual {p1}, Lcom/android/email/SecurityPolicy$PolicySet;->getDPManagerPasswordQuality()I
    
        move-result v2
    
        if-ge v1, v2, :cond_3c
    
        move v1, v5
    
        .line 233
        goto :goto_d
    
        .line 235
        :cond_3c
        invoke-virtual {v0}, Landroid/app/admin/DevicePolicyManager;->isActivePasswordSufficient()Z
    
        move-result v1
    
        if-nez v1, :cond_44
    
        move v1, v5
    
        .line 236
        goto :goto_d
    
        .line 239
        :cond_44
        iget v1, p1, Lcom/android/email/SecurityPolicy$PolicySet;->mMaxScreenLockTime:I
    
        if-lez v1, :cond_59
    
        .line 241
        iget-object v1, p0, Lcom/android/email/SecurityPolicy;->mAdminName:Landroid/content/ComponentName;
    
        invoke-virtual {v0, v1}, Landroid/app/admin/DevicePolicyManager;->getMaximumTimeToLock(Landroid/content/ComponentName;)J
    
        move-result-wide v1
    
        iget v3, p1, Lcom/android/email/SecurityPolicy$PolicySet;->mMaxScreenLockTime:I
    
        mul-int/lit16 v3, v3, 0x3e8
    
        int-to-long v3, v3
    
        cmp-long v1, v1, v3
    
        if-lez v1, :cond_59
    
        move v1, v5
    
        .line 242
        goto :goto_d
    
        :cond_59
        move v1, v6
    
        .line 249
        goto :goto_d
    
        :cond_5b
        move v1, v5
    
        .line 252
        goto :goto_d
    .end method
    
    isActiveAdmin:
    Code:
    .method public isActiveAdmin()Z
        .registers 3
    
        .prologue
        .line 598
        invoke-direct {p0}, Lcom/android/email/SecurityPolicy;->getDPM()Landroid/app/admin/DevicePolicyManager;
    
        move-result-object v0
    
        .line 599
        .local v0, dpm:Landroid/app/admin/DevicePolicyManager;
        iget-object v1, p0, Lcom/android/email/SecurityPolicy;->mAdminName:Landroid/content/ComponentName;
    
        invoke-virtual {v0, v1}, Landroid/app/admin/DevicePolicyManager;->isAdminActive(Landroid/content/ComponentName;)Z
    
        move-result v1
    
        return v1
    .end method
    
    as you can see, these methods are doing stuff, editing lockscreen timeouts, password requirements, etc. This is the part we want to get rid of. So to "hack" it, just replace all the code in both of these methods (at the end they return either true or false - 1 or 0 depending on how the above code executed.) with a return value. they become as follows:
    Code:
    .method public isActive(Lcom/android/email/SecurityPolicy$PolicySet;)Z
        .registers 1
        .parameter "policies"
    
        .prologue
        const/4 v0, 0x1
    
        return v0
    
    explanations of things changed:

    .registers directive sets how many registers the method needs to have allocated to run, in our case, the only register is true/false, so just 1. the .line directives are not used by the assembler, so I don't include them in my mods thy are just there to help find java code from the bytecode, since that's what the .line directive point to. set v1 to 1 (true) and then return that value and that's it.
    and
    Code:
    .method public isActiveAdmin()Z
        .registers 1
    
        .prologue
        const/4 v0, 0x0
    
        return v0
    .end method
    
    same as above, but return false...

    so when it goes to check this stuff, it just automatically assumes the policies have been applied correctly and moves on with life. enjoy!
     
  9. tannor

    tannor Member

    Joined:
    Dec 3, 2010
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    6
    Ratings:
    +0
    Thanks for this great info!


    One question once I am done and used smali to create new dex file, how do i reinsert into email.apk?

    do I just copy it to the original email.apk that i extracted using 7zip, and then rezip it and change extension to apk?


    Thanks
     
  10. dschu012

    dschu012 New Member

    Joined:
    Dec 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    Thanks for all of the info, I am kind of new to this and am having issues following you steps. On my device the email.apk does not have a classes.dex but I do have a email.odex. I tried using baksmali and am getting
    Code:
    C:\andriod>java -Xmx512m -jar baksmali-1.3.0.jar -a 12 -d framework -x apps/Email.odex
    
    
    Error occured while loading boot class path files. Aborting.
    org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find interface Ljava/awt/datatransfer/Transferable;
    
    
    That class is in rt.jar in my JRE, why wouldn't it be found....
     
  11. raidzero

    raidzero n00b.
    Theme Developer Premium Member Developer

    Joined:
    Apr 15, 2010
    Messages:
    1,054
    Likes Received:
    3
    Trophy Points:
    38
    Ratings:
    +3
    you must deodex your ROM first, cannot disassemble odex files.
     
  12. dschu012

    dschu012 New Member

    Joined:
    Dec 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    Thanks. Didn't need to deodex ROM. Just had to run that command I was running with the -I flag. I was then able to make the changes you suggested in the previous post and it is working well.
     
Search tags for this page
android 2.3.6 email.apk
,
android 2.3.6 gingerbread e-mail apk
,
apk email 2.3.6
,
cm7 email.apk exchange security
,

email apk gingerbread

,
email.apk without exchange security
,
hacked email apk
,
razr i orginal mail.apk
,
samsung email .apk
,
samsung galaxy s4 email apk