Identifying Android rootkits - android

Currently involved in a University project and could use any help from members regarding rootkits designed for Android.
I have little knowledge of Android malware and the project so far has got us decompiling apks to view the java class files (if readable) and the AndroidManfiest.xml file. I have also managed to root a phone in the uni lab using various adb commands and pushing files over to it.
What I would like to know is if it's relatively easy to spot malicious rootkit code within a class file? Is there something I can look out for? Is it a case of getting su status or does it involve adding users? Assume to next stage would be to then contact a server so the developer has remote access..
Also, is there a system or service that can process an apk to spot if it contains a rootkit (not just malicious)?
reply:
hi sorry about late reply - tried responding immediately but wasn't allowed as I'm new, but then forgot!
Thanks for the info! I appreciate that I may sound naive, but I guess I have to be seeing as I don't know anything about rootkits or the way they work..
You're right, they are not asking about 3rd party scanners, that was just my interest. So on that topic, are you saying there are scanners out there that specifically look for rootkits in a sample? Or is this detection all part of the overall AV service they offer.. If specific to rootkits alone, then I would really like to know which ones, so i can research them..
Also, with regards to exploitation of a bug - I assume you mean a bug within the Android OS? Would this mean that when patch updates are pushed out from Google then the rootkit is unable to function?
Thanks

A mallicious rootkit tries its best to get certain access, secretly. So any generalisations you make about how it does its business will probably be already worked around by any good rootkit.
"setting su status" is hardly worthy of being called a 'rootkit', that's just 'using root permissions' that you seem to have given the app. A rootkit would look for a way to actually get this without permission, by exploiting some sort of bug.
Systems of services that spot those things are commonly called virus and/or mallware scanners. Yes they exist.
Not to be negative, but this seems like a naive post about the subject, and probably not a good start for a project: I'd say using a 3rd party malware scanner is probably not wat is asked?
You could, for instance, look for known exploit-methods. One that for some reason comes to mind is the overflow, but that's just a random thing. Read up on rootkits, their methods, heuristics to find them etc.

Related

Developing an Android app with monthly subscription

I want to develop an app which I stream basic text information about sports. First of all I believe I need a server which my users connect to see my stream as soon as something new is published. But I don't have an idea about how to build something like that. I did some search on web to find lessons or answers but I wasn't able to find anything useful. If it's true that I need a server, is Java language good to code server's program? Because I only know a little bit of Java.
And I want my app to have a monthly fee. I'm completely new to programming but I guess I need a database to keep track of my user information. Do I have to build my own user membership system - which people register with their e-mails etc- for all this? Is it hard to do that? And again I don't have any source of information about this one too.
I'm lost at this point. I don't know what to search to get some answers. So I'm asking you guys. What do I need to build an app with monthly fee that streams live information? I'm not expecting a full answer here but at least I believe you guys can tell me where to look for answers. Thanks.
While I agree the question is very vague and open (we could write a thesis on the topic in question and everyone will have their own way to complete) my suggestion would be to research the following:
Java - read as much as you can about the language and ensure that you are happy with (or know where you can get access to good helpers) the syntax (you mention that you know a little about Java so that is a good start).
Android programming in general. Look up the Activity lifecycle (The Android documentation is good, read as much as you can, follow the examples and try out the tutorials! https://developer.android.com/training/basics/activity-lifecycle/index.html)
Read up on Firebase; this should make the server side a little simpler (although I have only a parsing knowledge (i.e., none) of Firebase, it looks like it will be a good start). Again walk through the examples / tutorials; do the Hello World and then pull it apart to see if you can figure out how it is holding together.
Then when you have questions (which you will, we all do!) come back and I know that you will get some great help!
Once you have a few applications under your belt (personal 'play' apps) then and only then would I consider looking at the Google Play API (https://developers.google.com/android-publisher/).
Hope this gets you on the starting grid at least! Good luck!
Gav

Android App with HTML/CSS/jQuery. [How] Can it be done?

I know this has been asked before (did not find a straight forward answer) but can I (Or how can I) create and Android App using CSS/HTML/Jquery ?
I will not need to hook into native functions, such as the accelerometer, camera, or even the Toast Messages...I only need to create an app to show a list of names and some details when name is selected, therefore I don't know if it's worth learning to make my life more complicated for something like this.
PS: I need the app to work offline, otherwise I would have just made it with jQuery Mobile and uploaded it on a server.
UPDATE AFTER GETTING DOWNVOTED
Ok, so I get downvotes for this question, probably because it's been asked before, or maybe not, since he/she didn't take the time to write a reason...
Anyway, my point is: I did googled it and searched, but at this moment there are a lot of ads of websites and web apps that will help you do this BUT are they reliable, safe..do they really do the trick or it comes with bugs? That is why I asked the question, to see who used what and what was their experience with it. So yeah, you can downvote me for not trusting every ad and not taking the time to try out everything out there!
Well you can use https://software.intel.com/en-us/html5/tools to develop cross-platform apps. I used it to develop too. It is quite good but it only has one major issue: you can't use php. It also enables you to do on-device testing.

Downloading an unsigned or unproperly signed apk file caused loss of data

Background:
* I am new to developing for Android but I am a programmer/front-end web developer so I'm not totally new to this sort of thing
* My personal phone is the Samsung Droid Charge, on Verizon - I am unsure if this will really matter or not.
Problem:
It seems like I have lost all of my photos and videos, so I'm reaching out to see if anyone knows whether or not for sure I am in trouble, or if there's still hope of recovering this data loss.
What I believe caused the problem:
I followed the tutorial on how to make a simple Hello World application, as a first step in learning how to develop using Eclipse. I was unfamiliar, at the time, with signing applications. So, I just used the apk which was in the bin folder of my project. I placed it onto my web server using FileZilla, and pointed my phone browser to the file. It downloaded it, but when I clicked on it, it said something along the lines of "File is too big." or "Application is too big." or "Not enough room to install." or something along those lines. The application was only 28k, but I'm sure that it had something to do with the fact that I did not sign it properly before attempting to use it on my phone.
So - my theory is that since it looked at it as "too big," that it removed other things on my phone which were too big, in order to make room for it. I noticed that my phone suddenly forgot all my ringtone and other sound settings - because it moved them all to my 32GB micro-SD card (which came with the phone). Previously, this data was stored on the internal memory along with my photos and videos. However - I am now not even able to view the files on my internal memory when I go to "My Files" from the apps. Why this would happen, I don't know - it doesn't seem like a very good feature to have. A fellow developer at my office mentioned that it may be something Verizon has set in place for some odd reason.
If the photos are still there, which is very possible, I'm not sure how to view them. The gallery app does not recognize any files, and I am otherwise completely unable to look at my internal memory - even using a program called AndExplorer.*
As a new developer for android, this is extremely frustrating. Sure, perhaps I should have backed up my data before testing my app on my own device, but there's absolutely no reason that this should have happened.
I'm sure I can't be the only one who has ever done this. I tried searching for the issue ALL OVER the web AND on stack overflow and was not able to find anything.
Any and all help is greatly appreciated. And I have certainly learned my lesson - I need to back up my stuff before testing anything.
*EDIT: It turns out I actually can view the internal memory using AndExplorer, but there doesn't seem to be anything on there, as far as my missing photos and videos.
I placed it onto my web server using FileZilla, and pointed my phone browser to the file.
Is your Web server configured with the proper MIME type for APK files?
but I'm sure that it had something to do with the fact that I did not sign it properly before attempting to use it on my phone.
I rather doubt that. You have to explicitly do things to avoid signing an APK.
So - my theory is that since it looked at it as "too big," that it removed other things on my phone which were too big, in order to make room for it.
That seems unlikely. Even if true, this is a question for Verizon/Motorola, not StackOverflow, as only they can help you with end user device issues such as lost data.
Sure, perhaps I should have backed up my data before testing my app on my own device, but there's absolutely no reason that this should have happened.
It doesn't, in the course of normal development.
I'm sure I can't be the only one who has ever done this.
You are probably the only person on the face of the planet whose photos, etc. were lost or misplaced as the result of trying to install a hello-world APK.
And I have certainly learned my lesson - I need to back up my stuff before testing anything.
Then you did not learn your lesson. You need to back up your "stuff", period, unless you are somehow personally invulnerable and believe that this protection will extend to your device. Otherwise, you are as likely as the rest of us to have your phone accidentally get dunked in a toilet, run over by a bakery truck, caught in a fireball triggered by a terrorist attack on a natural gas pipeline, etc. And, in those cases, you would lose your data as well.
In a nutshell, Android development does not typically adversely affect a device, certainly not the mere act of installing an app. Whatever problem you have experienced is due to some combination of events triggering some bug in the Charge (possibly just your individual device).
BTW, the preferred way to test an app on a device is to use the USB cable, then run it from Eclipse on the device itself. FileZilla and downloading from the Web can work with a properly-configured Web server, but that's usually reserved for later in the development process.
CommonsWare, some of what you've said is helpful, but some of it not-so-much. Who says I don't already backup my data? Perhaps I do, and I just hadn't done it in a day? You don't know that much detail about my situation. Maybe I am only missing photos from one day. You can't definitively say I have not learned my lesson. I'll decide if I've learned my lessons or not ;). That should not have been my main focus and for that I apologize.
I'm more interested in why this happened than I am interested in getting my data back. I certainly wouldn't want this happening again. If it has nothing to do with "size" or proper signing, what else could possibly ever make something like this happen? Like I said - I am new to developing apps for phones - I can only assume so much using the developer guide provided to me by Android. A lot of the steps assume that the user knows certain things. And perhaps that's my fault and I should start somewhere else for basics.
But I still attest that the issue must have been caused by the app. I did not change anything with mime types, but according to what you're saying, that shouldn't affect things. That should not have had any effect on data loss. Yet, it absolutely, without a doubt did.
I've used a program to scan the flash drive to see if it could find any deleted files. That didn't work. So I've pretty much given up on getting the data back. Like I said - my focus should just be to prevent it from happening again.

Android Game Keeps Getting Hacked [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
So we've been through this several times now, we release a game (for cheap) and someone hacks it and puts it up on a mirror. We setup Google Alerts for all our apps, so we get told daily who's doing the hacking. So far, we have implemented the licensing service as Google has suggested, our salt is randomly made each time the license is initiated with the unique device ID. We run the check service once, when the application is started for the first time. We then generate a 512 character hash for the key and the stored value that is compared against in SharedPreferences from there on out.
Now, I know that checking once is probably where the application is being blocked. Our bytecode has most likely been looked at and recompiled without the line that initiates the check.
From here, I don't want to obfuscate our code as I have seen it broken before. I want something a little more solid, and I also want to learn how to do this properly. I am more interested in learning than making money at this point since only 2% of people will ever look for a hacked version.
So far, on my own, I have come up with a random number generator that is placed in several startup areas of the game. When initiated (say, 1 out of 50 times) the license is checked. I know this would make it harder to hack because the cracker would have to eliminate each case, compile, eliminate, compile. This method however, is still crackable...so what do you guys suggest? Again, I am really interested in this process of security, so please educate, don't turn this into a discussion on obfuscation or checking periodically based on a timestamp.
Thanks
My idea isnt hacker proof, but might remove some of the interest for hacking the game.
Freemium model
1) Make the first 5-10 levels free so people can learn the game and have some fun without paying. Less will want to hack the first level and the game will spread even further by Freemium model.
Shareware/clustered levelpacks
2) Let part of the game levels or logic stay online. Eg. when reaching for level 5 or 10 or 15, then download small parts for the game, and every time submit the progress-log from the game and validate this against possible values + hashcodes. This could perhaps make it possible to automatically close down of hacked accounts.
Stealth cheater protection
3) You could also just count "small warning flags" that you place around in the game. Dont just check for the "validation" in the beginning, no build these flags into the game logic itself. Dont make it break the gameplay, because then noone will look for it.
Then when the user reached the end of level monster, check if there were any logged warning flags. These will not show up inside the game, so the unknowing user with a hacked edition could be playing for hours/days and suddently realize that he/she couldnt finish the game or advance to next level, because the game had a "bug". What the user didnt know was that this bug only occures on hacked clients.
Conclusion
Be smarter than the crackers. Fool them into thinking the job was done. Make a copyprotection and know that the more advanced crackers will be able to remove it. But they probably dont want to play 50 levels to check if the crack also works all the way.
Once they realize this problem, they might start to crack it too. But if you break the game up into level-packs, you can still validate between each pack download. So once you receive hacked client hash data, then just execute an exeception and crash the game on the client. Whoops the game crashed. Dont tell its because its hacked. A program error can happend. :-)
Again, its not hacker proof. But it might annoy them enough to move on to the next game. Lastly, you could also put out regular updates for the game and only the latest version should be able to "post the records" etc. so the active users would have to update to keep in the loop.
I have been doing some apk decompiling and hacking for a while (not warez, but mods and hacks mostly to the google apps and the android framework, always abiding xda-developers policies).
Once you learn to read smali, it is almost as reading the original java code (but with way more LOCs). So, any code you add to check for keys can be found and deleted or replaced. You don't even need to recompile each time to eliminate more than one (some searches do miracles to find similar pieces of code) and, even if compilation/recompilation cycles are needed to find them, it's just a matter of one or two minutes to decompile: everything is automated by apktool and even more by apkmanager.
Having said that, my suggestion to you is to implement some sort of online scoring table or similar, and when the user looks at the score table online, you can check the hash code you implemented and compare it with the associated gmail account. That way you can report the hack to google and send a nasty message to the user of the warez, explaining why that is illegal.
Of course, a new hack could be implemented to eliminate the scoring table, but that would reduce the interest for the warez.
Good luck.
Update
After researching to answer this question: Injecting code into APK (really about the Amazon DRM mechanism), I can tell a little bit on how Amazon is protecting the apps: it includes methods for checking for the installation validity everywhere (you can see an example of how they do it in my answer to that question). This will make any attempt to hack an app not very difficult, but extremely tedious. I believe that is a strong point: hackers won't want to spend so much time doing so many repetitive tasks: it's not challenging and it's boring. The main flaw I see in that approach is the possibility to hack the Amazon app itself to always return a valid answer, of course. But, if you mix your current hash checks with some sort of online check scattered among your methods, I believe the chances of it getting hacked may be drastically reduced.
Taken from my solution from this post Avoid apk cracked
Implement your own licensing library
I'd also refer you to check out this from Google I/O 2011 YouTube recording:
Evading Pirates and Stopping Vampires
EDIT:
The Presentation Notes from Evading Pirates and Stopping Vampires
Some basic keypoints
Modify the LVL
Implement LVL Tamper Resistance
Use obfuscation
Add reflection
I know you're not really into obfuscation, but I really need to react to this:
From here, I don't want to obfuscate
our code as I have seen it broken
before. I want something a little more solid, and I also want to learn how to do this properly.
ProGuard is very reliable in my experience, and this although I use a couple of advanced features such as AIDL and some native code which calls Java method.. It takes a little work to read the documentation and do things properly, but once you're there ProGuard is extremely reliable and also optimizes your app.
Custom security/cryptographic tricks are good, but without obfuscation it's like throwing a stone in the water in my humble opinion.
I've used ProGuard in production for many months, and it just works flawlessly.
If you're into learning, then read the ProGuard manual carefully, experiment with it, and inspect its output logs.
Chance, that there are more talented programmers then YOU (applies for all programmer), is 100%. And if that is true, you can not fix hacking. But you can spend as much time and effort on it to go bankrupt.
If you want to make some serious money you need to do some research on your target user group, and behavioral science. You need to make users playing that bring in new money, and thats it.
Besides, you got it all wrong. Hackers are most active members of your user base, thy just behave in a way you did not intend them to.
Take Zynga games on Facebook for example, do you think thy get hacked? - Sure, and about +100000 players only play, because thy can use bots, that automate everything.
Having huge active user base botnet of actual people, makes archiver type gamers want to play the game - and if thy play, and it looks cool, then Avarage Joe will also want to play. If Avarage Joe plays, then his friends might want to play, and thy probably will not care anything other, then being better then his/her friend, killing time or having something to chat about. Avarage Joe friends will most likely be willing to pay to be better then Joe, but rather thy would like to invest in something that makes them able to be better.
Besides if the real value is playing the game for free, then users who use the free hacked version, will most likely never would have payed for it. But thy are Avarage Joes and their friends just might. So this is like the cheapest commercial you can have. If you want to make money of your large userbase, then just make new versions of the game with small changes to levels and graphics.
Piracy will always be an issue. By in large crackers are better at playing this Security Though Obscurity game than developers.
What an interesting and disturbing question. :-) As an exercise, you might try releasing an app through Amazon; they have their own DRM mechanism; I wonder if it works any better than ProGuard...
One of the key elements in my opinion is to spread out the code so it's not all in one place. If you have a function called LicenseChecker.checkLicense() which retrieves the license and checks it, you can be sure it will be disabled promptly.
The one advantage you have is that the crackers cannot see the comments of your code (and, if you obfuscate, method/variable names), so come up with something weird. In the onCreate() of one activity, you get the license ID. In onResume(), you get another value to check it against. Maybe create a thread and do some checks there. And then, some other irrelevant piece of code (maybe the player control) might pick up the value and compare it and store the result somewhere. Then three other irrelevant pieces of code will all independently check that value and disable your application if it doesn't match.
Now I should say upfront that this can cause headache for yourself - obviously, cluttered, nasty code is harder to debug and prone to cause errors. Worst case, you create false positives in legitimately purchased applications.
And, of course, everything can be reverse-engineered - once the crackers find the place where the app is disabled, they trace back the value that's being read from. They could then trace back where it's being stored, and trace that back..... or, much easier, they can just disable the final check (which is why I recommended 3 different places, all triggering delayed). Security is only as good as the weakest link.
You will not be able to stop piracy. Your best bet is to delay the spreading of a pirated copy until the initial hype about your app has calmed down.
First, I do NOT consider myself a pro in the SW security field whatsoever, but:
I think an important thing is to let the application be dependent in some part(s) on the signature check. Don't let it affect immediately, but let it set some flags or change some values. later on, use those flags, check them, let the absence/incorrectness of them cause an exception of some kind which will terminate the application maybe. As long as the signature check is only relevant at the moment, it is easy to bypass it, to remove the line, once it touches more areas in the code, your application becomes harder (or less easier...) to hack. Also as I see it, not all checks should call the same routine for the sanction, because this will also make it easy to find the protection mechanism and terminate it.
Of course, the sanction to take in cases of illegal SW may vary, you might want to crash the application when used illegally, but you might as well want to keep it running, and only send message that asks the user to buy a legal copy of the application.
If this is just what you didn't want to hear, then I'm sorry for your time :)
Android users are just going to have accept the pain of constant phone-homes. The only secure Android app is an always-connected Android app.
This is, in large part, due to Google's refusal to lock-down the installation, like Apple has. On IOS you have to jailbreak the phone. On Android you can load any APK on a stock, factory install.
Keep some/most/all your content on the server; deliver it in chunks; validate the license/session on each call.
It will be incredibly hard to inhibit this kind ov behavior. Anything that is handled on the client-side is hackable using APK decompilation and modding, memory editing with software such as Game Guardian ect.
The only way I can see how partially getting around it, would be to make an online game instead. Or have certain functions handled online. Or if anti-tamper encryption like denuvo ever is available for Android / iOS.

Strong security precautions for an Android app to prevent it from being cracked

Can you suggest me any good anti-crack approaches (other than a code obfuscation), considering that the paid apps on the Market are easily cracked, and the same goes for a basic server check after a PayPal transaction?
My idea is to have one (very important for the app) Java object saved on the server, and passed to the app each time when it starts. Do you think that this sounds good ?
Note that it is more like of a theoretical question, as I am not going to implement it in an app, I am more like seeking the knowledge for this rather than a concrete solution to a problem.
Any ideas would be appreciated, even ones that you are not very sure if they are good or not. Remember, the question is for Android apps. Thanks.
EDIT: I know that there can't be an unbreakable client side application, I am asking for a good option to prevent it other than a obfuscation
No. Code stored on the server and provided for execution on the device can be grabbed and stored elsewhere such as locally. (And that's probably going to be as hard for you to implement as it will be for the attacker to patch around)
Ultimately, you have to face the fact that preventing run authorization just isn't possible on a general purpose computing platform.
Unless you move actual functionality to execution on a server requiring an individually authorized account, all you can hope for with regard to code running on the user owned device is to achieve a higher than average shade of difficulty.

Categories

Resources