Can a hacker copy prefs from one device to another to hijack a user session/state? - Security Discussion

Hi all,
I need to test a scenario in which a hacker will try to copy the shared prefs file (or files) from one Android device to another in order to have the same state that the original user has and use the app as if he is the original user (hijack his existing sessions for instance).
I tried to copy the shared prefs file from one device to another (where I had installed a fresh copy of the app with an empty shared prefs file). Copied the file from the original device using adb , copied it to the sd card of the target device and move it to the right shared prefs directory using a file management app with root privileges. This didn't work.
When I start the app on the target device - I can see that the shred prefs file get "rolled-back" to its initial form. Maybe Android has some kin of mechanism to prevent manipulation of an app's files/data.
So my question is - how can I test this scenario in other ways? any way to transfer the shares prefs from one device to another without Android knowing about it?
Thanks!

This is interesting. To get the second app access the original prefs file it would have to run with the same UID than the application that originally created the preference file.
I do not know how you can change the UID however. I am pretty sure that you would need a rooted device.

VilleI said:
This is interesting. To get the second app access the original prefs file it would have to run with the same UID than the application that originally created the preference file.
I do not know how you can change the UID however. I am pretty sure that you would need a rooted device.
Click to expand...
Click to collapse
Indeed you need to fake the UID, you could do this through XPosed. You could develop a method that hooks the https://developer.android.com/reference/android/content/pm/ApplicationInfo.html#uid call. You hook and return the UID value that you want. Under the assumption that this is the call that the Android system uses to load/reset the preference file. I think however, the system uses some low level access through a kernel call to determine the uid of the application. So you would need to hook the kernel which is not that easy. Your best bet then is to edit and recompile the kernel source.

Related

[Q] How to copy a /data file from unrooted Nexus S [I9020XXKD1]?

Hi there,
Is there a way to temporary root my Nexus S [I9020XXKD1] or alternatively a non-root way to access /data so that I can copy a file in and out? Essentially I want to be able to backup and restore some game saves
Most posts I've read basically have folks saying "Just root it", which is good advice to most but isn't right for me - I really don't want to have to wipe my phone and I'd also like to be able to dip my toe into rooting before taking a full leap. That, and aside from needing this one file in /data my phone works exactly as I'd like it to
I only need "su" access for a brief moment to copy off a file to and from /data. I set up the android sdk but ADB didn't work because of the protection of "production builds".
VISIONary seemed like the right kind of thing, but I don't believe it works for the Nexus S or recent firmware, so while temp rooting would be nice so would any solution that allows me to backup and restore some files in /data.
At the moment I am wondering if writing an apk of my own that copies/replaces this one file is the way to go - but that seems perversely long way around!
So any help/suggestions most appreciated
There is no temporary root for the Nexus S. You're either rooted, or you're not. However, if, perchance, you are on Android 2.3.2 or earlier, you might be able to root without wiping.
Without root, you cannot see the files in /data, but you can read/write the files directly if they have the proper permissions and you know the exact path/filenames. After poking around a bit, it seems that read & write permissions vary among apps. Most apps have full permissions reserved for the parent app. Some allow other apps/user to read some files, and read+write others. (The permissions being app-specific, if it can't be done by command line, I doubt it could be done by creating an app, either.)
So, what is the game? Perhaps I can do some exploring.
If you have the old bootloader (2.3.2 i think) you can boot a recovery without flashing. From you computer use "adb boot recovery.img" and boot clockwork recovery. From there you can mount and access the filysystems.
Sent from my Nexus S using XDA App
Maximilian Mary said:
There is no temporary root for the Nexus S. You're either rooted, or you're not. However, if, perchance, you are on Android 2.3.2 or earlier, you might be able to root without wiping.
Without root, you cannot see the files in /data, but you can read/write the files directly if they have the proper permissions and you know the exact path/filenames. After poking around a bit, it seems that read & write permissions vary among apps. Most apps have full permissions reserved for the parent app. Some allow other apps/user to read some files, and read+write others. (The permissions being app-specific, if it can't be done by command line, I doubt it could be done by creating an app, either.)
So, what is the game? Perhaps I can do some exploring.
Click to expand...
Click to collapse
Thanks I figured as much. The game is Dungeon Hunter 2 and essentially I am trying to implement a simple fix to make my save game work again (the fix is here: http://forum.xda-developers.com/showthread.php?t=1042675 a few posts down) but it requires root. So I do know the exact paths and filename.
Thank you for your helpful answer
Ok, I'm not having any luck here, and it's pissing me off. FYI, I don't have that game, so I'm testing it with Angry Birds. I can read and copy the file just fine, but I can't modify it without using root. The data file itself has read/write access, but the containing folder (files/) is read-only, so I can't overwrite the file after I've modified it. Since the file itself has r/w access, I wonder if it would work to modify the file directly, instead of using an outside program to modify it then overwriting it. (I'm a bit ignorant of the finer points of linux permissions.) This would require an app that would allow you to open and modify a file by typing the full path & filename, instead of just browsing the directory tree. You could also try < adb pull /data/data/com.gameloft.android.TBFV.GloftD2HP.ML/files/dh2_000.savegame dh2_000.savegame > (using the correct path, if that's not it). Then see if < adb push dh2_000.savegame /data/data/com.gameloft.android.TBFV.GloftD2HP.ML/files/dh2_000.savegame > works. The fact that you can copy the file out is promising, anyway. So even if you had to root, you could backup the file before rooting wipes everything, then fix it & back it up after you had root.
Btw, what version of Android are you on?
Edit: I think I'm getting somewhere. While you can't modify the file itself, you can modify the file contents. So something like this might work: < adb shell >
< more /sdcard/dh2_000.savegame > /data/data/com.gameloft.android.TBFV.GloftD2HP.ML/files/dh2_000.savegame >
So the next step is to get some help from someone who has the game and is rooted as to the exact path to the savegame file. Once we have that, I think we're golden. (Or, let me know if adb pull works with the path I guessed at.)
wow! Thank you for your help
In answer to your questions: my Nexus s is running 2.3.4 and you are correct about the file path (many other kind xda users died to bring us those paths ) is /data/data/com.gameloft.android.TB with the filename being dh2_000.savegame
I don't want to drive you to distraction! If I could back it up I probably would go ahead then and root the phone given how complexplaying with a non-rooted phone is!
I will try the adb pull method and let you know how I get on.
Thank you again for your help and for showing me why I probably do want to root!

Installing APK files on TELUS/Koodo Moto G

Phone: Koodo Moto G with Motorola Android 4.3
I've seen a post or two about not being able to install Android APK files on the Moto G, and I've seen some solutions. As far as I'm aware, on this particular release of Android this is to prevent malicious apps from installing from SD memory, which makes a lot of sense given the amount of malware, etc. targeting Android. Anyway, conjecture aside, here is my preferred route to installing apk files (like f-droid), since I don't like ES File Manager, and I don't like random hacks which in all probability are just going to introduce another security hole anyway.
First, be sure you have enabled the proper settings under Settings --> Security --> Unknown sources.
Get root. This is mandatory, and why do you want to muck about away from the relative safety of the Play Store if you aren't getting root anyway?
Install a file manager built for accessing protected partitions. My fave is Root Explorer (purchased).
Open your "Download" folder on the SD memory (where your web browser will have saved the apk) and select your apk for copying or moving. Now open the root folder, and here you have a choice. You will need to create a folder in the phone's protected storage. (Delete/Move random files anywhere in here at your own peril!) For simplicity and security, I used
Code:
/data
. I then created a folder named APKs (/data/APKs) and moved my apk files to that location. Now your files are somewhere the operating system considers "safe".
Click, install, enjoy!

[Q] Looking for a file manager able to change permission automatically.

Hi, everybody. I have been looking for a file manager with the auto-permission-modification function for a long time. (yeah I invented this name : p)
This is the function that will automatically change the permissions of the files copied to the system partition.
e.g. If you copy a file from the user folder to system folder(e.g. /system/fonts), usually you have to modify its permissions to make system recognize the file and to avoid breaking your device. Therefore, it would be decent if a file manager could handle that automatically!
AFAIK FX Explorer is the only app with such function. I was wondering if there were any other app with this function.
P.S. FX is great in every aspect, I just do not like the left-margin-slide panel.
I was using FX sometime ago, but I didn't really appreciate the UI. That's why I switched to stock file manager.

How do I modify system files (so they STAY modified)?

I think this is a universal issue that would apply to any android system. But in case it makes a difference, I've got some Samsung devices. I've got an original Tab S (10.5 inches) and a Note 4 (8 inches). The first is running Resurrection Remix (based on Nougat) and the second is running LineageOS 16.
WHAT I WANT TO DO:
I want to modify some files that live in subdirectories of sys and system. Basic text files, whether XML or anything else. I want to change the configuration settings within the files. I'm rooted and all that. I can edit the files, but after I do, the system puts them back the way they were.
I can only draw one conclusion from this: THE SYSTEM THINKS IT'S BETTER THAN ME, AND IT WANTS TO FIGHT.
I need help. How can I modify the files and have them stay modified? How do I put on my digital boxing gloves and show the system who's boss?
FailSafeNow said:
I think this is a universal issue that would apply to any android system. But in case it makes a difference, I've got some Samsung devices. I've got an original Tab S (10.5 inches) and a Note 4 (8 inches). The first is running Resurrection Remix (based on Nougat) and the second is running LineageOS 16.
WHAT I WANT TO DO:
I want to modify some files that live in subdirectories of sys and system. Basic text files, whether XML or anything else. I want to change the configuration settings within the files. I'm rooted and all that. I can edit the files, but after I do, the system puts them back the way they were.
I can only draw one conclusion from this: THE SYSTEM THINKS IT'S BETTER THAN ME, AND IT WANTS TO FIGHT.
I need help. How can I modify the files and have them stay modified? How do I put on my digital boxing gloves and show the system who's boss?
Click to expand...
Click to collapse
Well it looks like the app's data you want to modify is kept by the app itself and gets restored everytime. It's a security precautions and I don't think you can do much about it. Is it a game or something ?
But if you saw someone modify successfully the XML file without it being constantly restored I can't help you much, maybe uninstall/reinstall will do the trick but tbh it would be kinda weird.
Hope this help, good luck with your fight.
It's not an app. These are system files. They belong to the system itself.
FailSafeNow said:
It's not an app. These are system files. They belong to the system itself.
Click to expand...
Click to collapse
Can you precise the path to the file, it may come handy
FailSafeNow said:
I think this is a universal issue that would apply to any android system. But in case it makes a difference, I've got some Samsung devices. I've got an original Tab S (10.5 inches) and a Note 4 (8 inches). The first is running Resurrection Remix (based on Nougat) and the second is running LineageOS 16.
WHAT I WANT TO DO:
I want to modify some files that live in subdirectories of sys and system. Basic text files, whether XML or anything else. I want to change the configuration settings within the files. I'm rooted and all that. I can edit the files, but after I do, the system puts them back the way they were.
I can only draw one conclusion from this: THE SYSTEM THINKS IT'S BETTER THAN ME, AND IT WANTS TO FIGHT.
I need help. How can I modify the files and have them stay modified? How do I put on my digital boxing gloves and show the system who's boss?
Click to expand...
Click to collapse
Ok, you're rooted, that's only part of what you need in order to modify system files. The next step is, are you using an app that has a "root explorer" built-in and do you have your read/write permissions set to r/w? If you haven't set your read/write permissions to r/w, you won't be able make changes and have those changes persist.
Sent from my SM-S767VL using Tapatalk
Droidriven said:
Ok, you're rooted, that's only part of what you need in order to modify system files. The next step is, are you using an app that has a "root explorer" built-in and do you have your read/write permissions set to r/w? If you haven't set your read/write permissions to r/w, you won't be able make changes and have those changes persist.
Sent from my SM-S767VL using Tapatalk
Click to expand...
Click to collapse
Yes, I'm using FX, with the root explorer, and the system is mounted read-write.
Let's go with the example I'm most concerned with currently. My Note 4 has sound coming out of the wrong channels. Right and left are switched. I've tried modifying mixer_paths.xml in system/vendor/etc, which is supposed to be a way of fixing this. But the system just changes the file right back.
Edit: The permissions for the System directory are thus: All can read, but only Owner Root can write. Can I change this somehow?
Further update: I rooted my device even more than it was before. I installed the root binary for Lineage OS and set the built-in root to ADB and Apps. I used chmod from a terminal to change permissions for /system, /system/vendor, and /system/vendor/etc to 775. Those permission changes are sticking. But I can't seem to change the xml file so that it stays changed. I even used FX to modify its permission, but it just doesn't work. Nothing doing.

[Tutorial] [Root] [Samsung] How to stop apps being closed automatically on Samsung devices

Hello,
I recently discovered a way to disable automatically closing apps on Samsung Galaxy devices. This is especially useful for apps such as battery monitoring or fake GPS location apps.
I tested this on my Samsung Galaxy A52 5G, it should work on other models, however I cannot guarantee this. Despite this, it doesn't hurt to try!
First off let's talk a little why this happens. If you have multiple apps open at once, the OS will attempt to close some to free up resource when not currently in use, especially if the apps have not been interacted with for a while since they were last opened. This is normal behaviour, however you may have something like a battery monitoring app (e.g. AccuBattery) that you never want to be terminated. So let's try achieve this.
There's two core parts to this process. You need root for both of these (Magisk).
Part 1
Requirements:
Root file explorer (e.g. Total Commander)
A text file editor (PC is easiest. If you decide to use PC, use a USB transfer cable)
Guide:
On the root file explorer, navigate to /system/etc
Make a copy of floating_feature.xml. Make a second copy to preserve original contents in case things go wrong. If this file doesn't exist, you can't use this method.
Open it in the text editor of your choice (transfer to PC if needed)
Search for this in the file: <SEC_FLOATING_FEATURE_DWB_CONFIG_UNSUSPENDABLE_PACKAGE_NAME>
If it doesn't exist, create it like this: <SEC_FLOATING_FEATURE_DWB_CONFIG_UNSUSPENDABLE_PACKAGE_NAME> </SEC_FLOATING_FEATURE_DWB_CONFIG_UNSUSPENDABLE_PACKAGE_NAME>
Add your app's Package Name inside this tag. For example AccuBattery would be 'com.digibites.accubattery' so the result value would be <SEC_FLOATING_FEATURE_DWB_CONFIG_UNSUSPENDABLE_PACKAGE_NAME>com.digibites.accubattery</SEC_FLOATING_FEATURE_DWB_CONFIG_UNSUSPENDABLE_PACKAGE_NAME> assuming it didn't already exist. If it does exist, add a semi colon ; to the last entry and append the value to the end
Save the file and use your root file explorer to replace the original floating_feature.xml file
Reboot your phone
Part 2
Requirements:
Magisk
Command line interface with root (e.g. Termux)
Guide:
Download and install the App Systemizer Magisk Module
Reboot your phone
Open your command line interface and enable Superuser mode (in Termux this is 'su')
Enter 'systemize' in your command line interface and follow the instructions to systemize the desired app
Reboot your phone
Summary
You'll need to reapply this process whenever you update your phone software. It's a relatively simple process though. I'll be interested to see how successful this is for others so feel free to provide feedback and findings.
Hope this helps!

Categories

Resources