Vampirism and the Donut Economy (Video)

Presented by: Christopher Crowley

Presentation

The video "Vampirism and the Donut Economy" presents a technical overview of mobile device security, focusing on the differences between iOS and Android operating systems. Chris, the speaker, discusses the security implications of using mobile devices, including the importance of community policing and vigilance in identifying and mitigating potential vulnerabilities. The video covers various cybersecurity concepts related to Android and iOS devices, such as man-in-the-middle attacks, rooting/jailbreaking, file system analysis, runtime manipulation, and static code analysis, as well as mobile app penetration testing.

Featured Clips

"The idea of being always connected is an incredible enabler for a lot of people. And at the same time, it creates circumstances of distraction from focus, human experience, isolation, human experience, and expression of narcissism."
"My opinion is iOS has a superior security architecture."

Full Transcript / Content

--- Page 1 --- Okay, thank you very much. I appreciate you tuning in for this. This is a little bit about me to start off with. I've been working in computers for a really long time. Basically, when I was 15 years old, I ran tape backup on Alteryx and VMS systems. I basically had this kid that they brought in after the workday was over to run tape, literally run tape to make backups. I've been working in operating systems and other components of information security for a while, and this has entailed a number of things. A number of different platforms. Initially, it was BlackBerry. There were Nokia, Symbian stuff. I've dealt with iOS platforms, a little bit of Windows Phone. That was kind of a flash in the pan anyway. Android as well. I've worked in the educational sector, U.S. government, U.S. Department of Defense, development environments, financial companies, software development, basically telecommunications providers, ISPs. I've worked for a lot of different companies. Essentially, all of them. I've always been a consultant. That's pretty much the environment that I've always been in. I wrote a class on security operations. Mobile is just a small part of that, but it's an area where I've consistently done some work. Basically, for SANS, I teach a number of classes. I've taught at varying times. There are 401, there are 503, there are 504, there are 560, the 511. If you don't know what these numbers mean, it doesn't matter as much. The most important one, and relevant to this particular class, is the SEC Security 575, which is mobile device pen testing. I've also taught the mobile forensics class. Essentially, the reason why I'm telling you these things about me is to explain why I've got some pretty strong opinions on the topic and some of the various aspects of what I'm going to talk about that maybe don't always exactly substantiate my opinion. I try to. I try to provide references, and there's a lot of references in the material, and you'll be able to download this. I also did a different talk, which is kind of like the opposite side of this, and it was more institutionally focused. And if you're interested in what the defensive topography is of the mobile device infrastructure, you can go to this soc-class.com slash pres, and the link there at this time, because I change this particular directory pretty frequently as I do new presentations, but the current link for this is the idea of, you know, the defensive mobile topography. And so I talk about the attack surface, and this is basically an excerpt from this particular slide as an excerpt from that talk, just so you get an understanding of the full attack surface. It's the hardware itself, all the firmware, the operating system component of it, the multi-homed network connectivity as you move from Wi-Fi onto cellular networks, and then all the other components of the device in terms of, you know, NFC, USB connection, --- Page 2 --- lightning bolt connections, all the different radio frequency connections, Bluetooth included in that, the operating system of the device itself, the applications which are installed on the device, and the user operating the device. That's the attack surface. Now, for this particular talk, I'm really focusing more on a very specific component of that attack surface related to applications. And the, the title of this talk is kind of strange, Vampirism and the Donut Economy. The idea of that is, you have mobile devices because they're very useful to you. They've been constructed to be useful to you, but they've also been constructed in order to put you on a treadmill of providing your data to the platform and the infrastructure for these mobile devices so that you are fueling that particular system. OK, that's fine. So long as you're aware of that, so long as you know that that's what it is, that's fine. Don't eat all the doughnuts, right? Just have one. I mean, be careful about eating too many because they taste really good. But if you eat too many doughnuts, you're going to make yourself sick. You're going to end up causing a problem for yourself. It's not the one doughnut one day. It's the every doughnut every day that ends up being unhealthy. OK, and they taste great. And if you're at all like me, having one doughnut is actually kind of an impossible thing. I can have zero doughnuts or I can have 12 to 28 doughnuts. It's like very hard for me to have only one doughnut if there's a box of doughnuts there. So this talk is really about the not so good habits that come along with mobile devices, right? The idea of being always connected is an incredible enabler for a lot of people. And at the same time, it creates circumstances of distraction from focus, human experience, isolation, human experience, and expression of narcissism. The idea of inconsistency of people adopt different personas depending upon the context or use that they're actually expressing for that particular mobile device, which also potentially lends itself to fraud and theft and other sort of bad behaviors. Morally, I consider, you know, fraud and theft morally objectionable. In terms of this, you also have governments and corporations who are leveraging mobile devices and the rich amount of data that they have present in order to watch you, to track you. This is eavesdropping on your communication in order to deliver targeted advertisements because that's part of what this ecosystem is, okay? And so that behavior is encouraged in many ways by a lot of these corporations and governmental entities. The other part of this is that it creates an opportunity for social or societal manipulation, which ultimately actually factors into geopolitical stability. Now, hopefully what's being created is geopolitical stability and equality and people having the assets that they need in order to do the things that everybody wants to do. That's sort of my optimistic view of the way that the world should be. --- Page 3 --- You can disagree with that. That's fine. But this is the approach that I have, is that hopefully these things are being used for good. However, the danger is that they might be used for bad. And so I'm explaining a lot of this stuff to you with the intention that you use it at least to defend yourself and your own interests. And honestly, even if those interests are, you know, contrary to what I think is the right thing, I don't presume to know what's good for you. Okay, so my opinion, and I'm going to start off with some opinion-based things before I get into the factual details of how to actually do some of the work that I'm encouraging you to do. My opinion is iOS has a superior security architecture. And this is based on the fact that the iOS ecosystem is more restrictive than Android. So the restrictions also entail the fact that the company, which controls this ecosystem, Apple, really supports only about 10 devices for iOS at any given moment in time. And you can go look at iOS support matrix and see the currently supported devices. But at rough order of magnitude, and it's pretty close to this, about 10 mobile devices are supported at any given time. Whereas the Android operating system supports about a thousand different devices. Rough order of magnitude, if I had a count, I could probably come up with a thousand, but it would take me a while. In terms of different hardwares, which are supported by the Android operating system at any given moment in time. Now, in addition to the fact that we have a restriction of the amount of hardware that it runs on, there's actually a single company which largely controls the ecosystem. Apple does. And they actually have a very restrictive security posture. This is part of their approach to things. And I'll explain why I think that is in a couple of slides. And they basically control the hardware design, the hardware manufacturer, the operating system production. And yes, I know it's based on an open source operating system, but they implement it specifically. And all of the apps need to be vetted before they're delivered and you can only get an app from them. And case in point, it is based on the research that I've done, the world's largest application white listing deployment from an operating system perspective. 1.5 billion devices globally, which actually deploy digital signature restriction for execution for any application which attempts to run on that particular operating system. I don't know of any other and I've looked, I don't know of any other instances of an operating system with 1.5 billion devices, which is currently using digital signatures to extremely restrictively control which programs are authorized to instantiate on that particular instance. Now, Android provides greater liberty and that comes with more responsibility. You have to be much more careful when you're running Android --- Page 4 --- if you choose to run that as your operating system. There are some vendors who will provide a phone which is compiled with security restrictions available to you. Copperhead OS and Silent Circle are two of them that are largely consumer-oriented. There are others that are out there that are only exclusively focused on businesses, but you could go buy the Copperhead OS Pixel, whatever the latest is that they're supporting. Same for the Silent Circle. Now, what's also interesting about this ecosystem for Android is that the Android open source project, and it really isn't an open source project, but it's something that is in their name, they don't actually control the operating system to the degree that it would prevent someone else from co-opting the operating system and redeploying it in a different channel. And Amazon is a good example of this, right? And so Amazon supports their version and flavor of it. They cut out all the Google Play Store stuff. And you know what? That's part of the ecosystem. That's the way that it's designed. And this allows for substantial variation and a lot of development for the hardware because if someone says, well, I need this thing to change in the operating system to be able to run that Android on this particular piece of hardware, good, go ahead and do it. It isn't truly open source. It's pretty close. It leverages a lot of open source products, but there are things which are not truly open source. And if you go look at the source, there's a lot of binary blob type stuff that isn't open. Now, that being said, there is a lot of open source in there. It's just not 100% open source from a project. So my opinion, still in the Chris's opinion section, my opinion is that Apple is a media company, whereas Google is an advertisement company. And the second part you probably will grant me without any, you know, any further consideration. But here's why I think Apple is a media company. And this is why I think that they came up with such a restrictive platform as it actually makes sense for a media company to provide a piece of hardware for delivery of media, which is tamper resistant, which is difficult to extract data off of, and which is in many ways bound to a single individual. And so this makes it really hard for the user to steal the music and the videos and whatever other media they're actually buying. And as a corollary, it makes it really hard for other people who want to steal your data to do the same. But I think that that the notion of this, originated from the notion of having a digital rights management platform in order to deliver the media. I think the Google ecosystem is largely driven by marketing share. 75% of the global distribution of mobile devices runs Android. It's a much lower cost of entry for consumers. --- Page 5 --- Hardware manufacturers can use the OS if they want to, unlike iOS. It's not an option to do it on your own hardware. Also important to realize is that the iOS applications are delivered as compiled executables. It's either Objective-C or Swift where they've actually been written and then they're compiled. In order to have an application on your iOS device, that application must come from Apple with a digital signature. And even the two primary exceptions which are granted, which are Enterprise Certificates and Developer Certificates, both of which are actually still signed by Apple. It's just that the Enterprise or Developer Certificates authorize you to further sign applications. So it's still actually got digital signatures in place in order to have code signing for things to run. A couple interesting examples of ways that these were circumvented. If you go back and look at Charlie Miller's Instastock, it was a very clever implementation where he actually identified a way that an application could circumvent the executable restrictions using some just-in-time memory space for basically being able to execute code. He didn't include the malicious code when he sent his app to Apple for vetting. He just saw that there was a download. And then he downloaded it, marshalled some executable memory space violating the writable or executable dep-type protections that are in place for applications, and then was able to download this code and then execute it later, which is exactly what Apple tries to avoid by making it so that it's a compiled executable. You shouldn't be able to download more code later and run it. It's part of what they have created in terms of the restrictive architecture. Another example of this was Xcode Ghost. You can go do a search on this, get more details on it. But the interesting thing about this is it was actually the malice was introduced by a manipulated version of Xcode, the development environment, which automatically included a DYLIB, which included the library, which kind of looked like an ad library, only they also had the ability to download additional code and execute it, again, circumventing restrictions by Apple, which were intended to be in place. Now, Android apps have digital signatures, but they don't function in terms of preventing things from running. What they're really supposed to do is provide it so that a developer can give updates to his own or her own application, but another developer can't inject a malicious update. The Android apps are actually allowed to be installed from anywhere. Now, there have been restrictions put in place for that. So on modern Android, you can specify per application whether that application is allowed to download APKs and install them. But there's really no single authority that verifies the identity of any developer. They're all basically self-signed certs, and a user can choose to install an APK from anywhere, largely different than the iOS components of app install. The application itself on Android includes the potential for some compiled components, --- Page 6 --- and we call this the NDK. There are libraries which are shipped in ELF format, but most of the code is usually the Dalvik bytecode, which is written in Java, even though there was a big lawsuit between Oracle and Google about this. Basically, it's Java, but it's not Java. And so Oracle sued Google around the fact that they were, Google was using something that was largely like the Java programming language, but then not paying Oracle for their licensing. Google, as a result of that, has changed to a different programming language called Kotlin, which is now available, both of which get compiled into Dalvik bytecode. And then that Dalvik bytecode is included in a file called classes.dex inside of the APK file, which is just a zip file. So it's actually, I think, harder for the Google security people who are supposed to be doing the inspection of the apps that are being delivered to them. And Maddy Stone, one of the security researchers at Google, actually gave a really good talk at Black Hat 2018, where she talks about unpiling the packed unpacker or something like that. I can never remember the name of it. But if you look for Wedding Cake and Maddy Stone and Black Hat 2018, you can get that. It's like unpacking the packed unpacker. And she talks about the difficulty of dealing with these obfuscated libraries that are provided in the NDK in order to basically hide the presence of the malicious code. The developer policies in Android are a little bit more permissive than they are in Apple. It's a little less expensive for developers to just create and move to a new profile because you don't have to pay for the developer licensing. You can basically submit apps pretty quickly. In addition to this, the other component of this is that the system apps, which are installed as part of the operating system, frequently have some of the same attack surface that I'm going to talk about when I talk about you actually doing assessments of applications. And these system apps actually sometimes have flaws that are unaddressed and the user can't do anything about it. They can install updates, but they can't fundamentally disable the system apps. So let's look on the bright side in terms of what we're dealing with. This little image is something that I use to understand how attackers attack us. And this is actually adapted from a paper written by the U.S. Department of Defense Defense Science Board. It's a really good articulation of the problem. They said there's the ten dollar club, the million dollar club and the billion dollar club. Ten dollar club reuses existing vulnerability vulnerabilities. The million dollar club discovers new vulnerabilities. And the billion dollar club is able to leverage the full spectrum of capability in order to introduce vulnerabilities into the environment. And so I'm not even dealing with the billion dollar club in this particular talk. That may be a problem that you need to deal with. --- Page 7 --- If you individually are being targeted by that level of attacker, which which happens, I understand it. If you individually are being targeted by that level of attacker, maintain hyper vigilance and look at the Citizen Lab resources. And Citizen Lab actually is a place where if I was an individual who is targeted by a governmental entity or a billion dollar club entity, they're not always governments, but they usually are. I would basically go to Citizen Labs if I needed help. Like, I think that's your best bet. If you are that individual who needs that help. And here's an example. If you do this, this search sequence, Mansour, Pegasus, Citizen, NSO, Lookout and Lookout isn't Lookout Mobile, not as Lookout. This is circumstance of some individual being attacked with some very sophisticated malware and Citizen Labs and Lookout Mobile actually basically did the investigation associated with them. If you are an individual who works for a company that is being targeted by the billion dollar club, again, this talk doesn't really deal with that level of considerations. I would suggest that you go look at the available threat intelligence, look at all the resources that are available from whatever your country cert is or your regional cert for that sort of state sponsored activity. And if you are really mostly concerned about your country where you live being the threat, then do a Google search for that one privacy guy VPN comparison. He has phenomenal resources in terms of how you can actually consider this. So your mobile device is being used to target you, at least for advertising, at least for some privacy violations. So what I'm about to suggest to you is the little bit that you individually can do in order to address that particular problem. So all these different actors need to evade detection. And if one individual actually finds something interesting, that individual can actually share that with other individuals and the problem gets addressed. So I want you to be vigilant in inspecting the mobile applications that you're using on your devices. I want you to maintain sort of situational awareness. I want you to also realize that the Android space largely depends on community policing. There's a lot of work being done within the the Google security team, but there is a larger need for community vigilance. And this is why one of the reasons why I'm doing this. You can still do all these same things on iOS. It's just harder. There's a there's a greater barrier of entry versus the Android stuff is relatively simple. So I'm going to walk through sort of my suggested assessment steps. There are a lot of different forks that you can go down in terms of what you actually care about. There is stuff available on iOS to do these same things. This talk largely far focuses on Android jailbreak jailbroken. iOS devices is essentially a prerequisite. for doing this sort of work on the Apple side. --- Page 8 --- And thanks to Axiomix, sorry if I pronounced it wrong, you can tell me, and the released Checkmate tool, actually a lot of people can jailbreak in Apple devices. Really phenomenal opportunity that's been basically developed extensively by the Checkra1n developers. You can go take a look at those resources in order to see how to jailbreak iOS. The sequence that I think that you should do to get the most value is initial behavioral analysis, use of some of the automated tools, using app manipulation, and I'll talk about what that is, and then doing static code analysis. There starts to be some iteration and backtracking. Once you start to go down a certain thread with automated tools, it actually is useful to then jump into a little bit of manipulation and a little bit of static code analysis, and then maybe you go back into some of the behavioral stuff now that you've gained deeper insight into what the tool actually does. So I want you to realize that this is all fairly technically involved. None of it is really beyond you, but it's really tough. And actually both Apple and Google, with dedicated staff doing this work every single day, they make mistakes too. Okay. They've missed circumstances where this is actually, actually been gotten by the people who are specifically intended to be looking for this sort of attack type stuff. So if you want to do this and you want to do it well, I would suggest that you focus on methodology. Start with everything that you do being repeatable and taking good notes. And I know that's super lame from the perspective of I just want to hack on stuff, but it actually will get you farther in the long run than going fast or trying to get really far. Because when you start to encounter little errors and you cannot reproduce the sequence, then all of a sudden you're going to have to end up with lots of additional work. And it's going to be very frustrating. Take it from me. It's very, very frustrating when you have something that you thought that you had it stable and then it wasn't. And then you go back and you can't repeat the circumstance of how you got there. In the amount of time that I've been working on this sort of stuff, I've realized it's actually better to go slow and track things. Okay. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. That's how I can get farther faster. So every single step matters. Even better if you can script the stuff so that I can just rerun the script and recreate the circumstance of where I'm going to. And most of the good tools that are out there help us to do that. In addition to all the technical stuff, I have to warn you, some of the stuff that you do based on this could potentially be illegal in the jurisdiction where you're doing it. --- Page 9 --- Sometimes the difference between it being legal or illegal is the way that you acquired it and the intention of what you're doing. So you should. Make sure that you consult with your lawyer and also make sure that you do this only on networks and with assets where you have written permission. But if you own the assets and it's the network that you manage and you can give yourself written permission, I don't know, talk to your lawyer, see if that works. So the idea here is that there is a bunch of guidance that is out there that you could just go and look at. I'm going to summarize some of those things. But if you want a reference, go look at the. MASVS and the MSTG Mobile Security Testing Guide and the Mobile Application Security Verification Standard, great resources produced by OWASP. They're imperfect, but everything is, right? This Android App Pen Testing Guide is another one where it basically is a specific implementation of the MSTG. The person took the list, went down the list and said, here's how I do this, here's how I do this, here's how I do this with specific tools. And in some cases, the tool and the switches, in order to, in order to actually implement that particular check. It's got some gaps, but it's really good. It's like 80, 90% complete in terms of MSTG. So if you just want a sequence of steps to do, go to the AAPG and execute that stuff. And if you feel totally comfortable with this, I'd go look at that and basically say, yeah, I know that tool, yeah, I know that tool, yeah, I know that tool. And if you do for every single one, great, but you might pick up one or two tools out of a list of 50 tools and say, oh, there's something I can remember for if I encountered that particular thing. Another thing that you need to think about in terms of setting stuff up is, do I use a virtual device or do I use an actual phone? So there's some benefits with using a virtual device. It's much easier in terms of having snapshots. It's much lower cost of entry. You have to download some software in order to create the virtual device. You do also need to have a Play Store circumstance where if you want to, install apps on a virtual device, you need to have a Play Store ready operating system to do this. I'll show you that in just a second. It's also super easy network interception. Basically you start the emulator with the HTTP proxy, push it into Burp or whatever you're gonna use for inspection, and then there's your traffic right there coming off of the emulator. The hardware, it's faster, it's more costly though. The downside, the biggest downside I feel in terms of the hardware is no snapshot. It's really nice to be able to take a snapshot, --- Page 10 --- go back to it, take a snapshot, go back to it, have a standard sort of test harness that's ready to go where I can drop the thing in and then repeat tests multiple times. Can't really do that on hardware. There's no revert type button for that. In some circumstances, the apps will check to see if you're running on a virtual instance. And if you don't wanna basically manipulate that at runtime, you just put it on a phone and then you don't have to manipulate that at runtime. Okay. So the Play Store options are really good. This is actually out of the Android Virtual Device Manager, where you can see that the Play Store image is available and you have to pick that particular one if that's what you want. You can go through all sorts of trouble in order to make that work, but it's much harder than just saying, okay, here's the one that I want. So let's get into some of the aspects of what we're actually going to assess. The first one is the idea of behavioral analysis. And I'll talk about a couple different things and I'm gonna start with network analysis for this. This is actually the easiest to perform without any real specialized tools. You put the mobile device on a network where you're a man in the middle and watch the communication. There are some challenges to this. The traffic should be TLS protected and that should be protecting you. Also realize that it's protecting you from a network that's eavesdropping on you, but there may be an attack against the TLS. And so that is a negative thing. So I wanna attack that myself to verify that. Even if I get inside of the TLS, there might be ways that they're actually obfuscating the data or encrypting it or doing other things at runtime to make it hard for me to see. So if I break open TLS and I see some data, I may still have other work to do in order to see that. I might also have an application that has a trigger condition that I haven't met. This is time, this is I have to do X number of things. Maybe there's a GPS specification in the app that says you don't start this bad behavior until I'm within this range of this building in the app. And if you haven't satisfied the trigger condition, then the behavioral analysis will never identify the objectionable behavior, okay? So if you do have a physical device, cause I already showed you how to do it with the virtual device, with the emulator HTTP proxy option. If you do have a physical device, there are two basic options. You have the host provide an access point and then be the man in the middle, or you have a virtual machine where you take a USB connected network card or access point, which then creates the access point --- Page 11 --- that becomes man in the middle because that USB is passed into the virtual device. I tend to do the latter. That is I have an access point connected to a virtual machine. The virtual machine is almost always Linux when I'm doing this. It's just easier for me to use Linux to do the network manipulations. I can use Windows as an example, if I'm doing a host circumstance and I'll explain this just so if you wanna set this up, you have a host Windows system. You're gonna get a USB NIC, plug it into the host. You configure the USB card as an access point and I'll show you how to do that in a second, but you're gonna use the Wi-Fi card that's built into the host to be able to connect to the internet. And then you have to enable an internet connection sharing for that built-in Wi-Fi in order to establish the Wi-Fi man in the middle position. Then you're going to associate the mobile device with the access point. So you will also want to install burp on the host. You'll want to install the CA cert from the burp instance that you're using into the user store of the device so that you can actually intercept. This is something that you should actually check to see if cert pinning's in place. You want that, right, for you to be protected, but you also wanna be able to undo it when you want to. And so this takes a bunch of work. So TLS interception is, is something that if it can be accomplished, basically your ISP can do it. A Wi-Fi network provider, you know, like in your hotel could potentially do it. In addition to that, a cellular network provider could also do it, okay? So if TLS interception works and you're able to get that working, realize that some threat actor could actually do that against you. So for the way that we're gonna structure this is that I have a Windows host. I have a connected USB device. So this is my, USB device is basically the WLAN2. I'm going to, in order to make this work, it's easier, disable the built-in Wi-Fi interface, then run this command, netsh wlan set hosted network mode equals allow, SSID equals your SSID, I'm using Montance, and then key equals, it isn't really a word. And then this is what I would use as the passphrase when I connect my mobile device to the Montance ESSID. You set it to whatever you want, don't use this. So the next command is netsh wlan start hosted network, and actually type hosted network, not Montance there, okay? That actually establishes your access point on Windows. Now go ahead and enable the other network interface, the other Wi-Fi network interface. And now you have internet connection sharing, allowing that connection up. That's establishing the routing. Then you actually have the mobile device connected to the Montance or whatever you call it, ESSID. --- Page 12 --- And now all the traffic is routing through the Windows device, and you can intercept and watch that. I don't like that. I've only done that when I had to. I would prefer basically a Kali VM, USB connected to the Kali VM using my, you know, my workstation or whatever software to do this. I connect a Wi-Fi access point. I tend to use my Wi-Fi, my Wi-Fi pineapple for this. And I run the WP4.sh script. Yes, it's an old one, but I've modified it. So you can go download my modified one, which does the routing. It does some better checks in terms of the, in terms of making sure that the interface is the right interface name and all this other, all this other stuff for that. And so this basically what it does is in addition to doing the routing, it also sets up the IP table rules to do the NATing so that you're actually pushing the traffic from 80 and 443. So that you're actually pushing the traffic from 80 and 443. So that you're actually pushing the traffic from 80 and 443. Into your burp proxy. Good. And so I have this as a separate script available for download as well. Simple stuff. It does what you want, but basically it checks to see if you have burp running and then creates these firewall rules to get the traffic into burp so that you can actually, actually see it. If you don't want to do it that way, you could also configure the device to send the traffic to a proxy. If you are doing it this way, you're doing a transparent proxy. So make sure your burp realizes that it's being used as a transparent proxy because what it's going to do is it's going to inspect the headers of the network traffic because the client isn't going to include the proxy headers because the client doesn't know it's going through a proxy. So you need to tell burp to be ready for that. Burp needs to do extra work for it. And now you start to see traffic going through the burp proxy. This is where you should see the traffic. And the plain text stuff is just available and there is still plain text stuff coming off of your mobile device. And that would be an opportunity to attack you if there's any plain text stuff coming off if you're on a malicious network, okay? So the next thing that we need to do is basically start dealing with the TLS because we want to get inside of that as well. We want to do TLS intercept. We don't like it when it works, but we want to do it so that we can see the traffic inside of there. Now burp actually serves up a .der format file if you go to the CA directory. So what you can do is after you download that der file, you've got to run this command, --- Page 13 --- open SSL X 509, inform der, outform pem, in and then the cacert.der, whatever the name of the file is that you downloaded, and then out cacert.pem. And then you can basically host this Python 2.7, sorry, dash M simple HTTP server 9090. That's the listening port. Then you connect to that interface, download that from the mobile device, save it on the Android, and then go to install that certificate in the settings security, install from storage, select that file that you just downloaded, cacert.pem and install it. Now you installed that into the user trust store and current Android devices actually won't allow the cert to be trusted if you put it in the user store, unless the application specifically authorizes the user certificate storage for trusting certificate CAs for TLS cert pinning. Okay, it's confusing, but basically on the Android device, there are two different storage containers for certification authorities, the system container and the user container. And the applications usually specify only trust the system container. But as it turns out, you can change that. And this is one of the manipulation things that you can do, which is take an APK, decompile it using APK tool, and then change the code. You have to rewrite the Dalek byte code, but you can also just rewrite things like the configuration specifications. And if you APK tool decompile, there's a directory called res XML. And inside of res XML, there is a specification called network underscore security underscore config dot XML. You can go into the network security config, base config, trust anchors and add a line, which says certificates source equals user. And now all of a sudden that APK, once you recompile it and reinstall it, but remember, you can sign it with anything you want because there's no authority, which says that this is truly that particular APK. It's so long as the user trusts the signature for the APK, this now gets reinstalled, modified. And that actually works. So the idea here is that you could on a rooted phone actually use Magisk. I think that's how you say it. Magic mask, Magisk, which is a module to mask the presence of a rooted environment. And there's actually a Enviso Magisk module, which will take the user search store and copy it into the system search store at startup. So you don't have to redo that on the APKs because some applications are actually resistant to being rewritten. They actually do checks because they know that people like you are doing this, right? So this is a useful tool. It's one of the other things that you can do in terms of manipulation and change. I do want to add my opinion about rooted phones is do not use a rooted phone as your daily phone. Okay, if you do this sort of work, or if you're interested in it, if you're doing this as sort of a convenience thing, have a separate phone, which is for your research --- Page 14 --- and use for your daily phone, the most protected phone that you can. Now, that being said, that is my guidance. And if you know what you're doing, and you're willing to take risks, I actually understand that. I just hope that you don't hurt yourself. And I hope that someone isn't able to hurt you because something happens to you that you didn't anticipate, right? Sort of like this, you're not aware that that bad thing could happen until after it happens. My suggestion to you is don't run a rooted phone as your daily driver. And a lot of other security professionals would not agree with me on that, but a lot would. This is, you take my advice and do whatever you want with it. Now, now that we've got man in the middle, it depends basically on like what the app does in terms of dealing with this, okay? So if there is cert pinning, then we need to do runtime manipulation or to disable this. And you can, I'll talk about runtime manipulation in a second. I would also suggest that while you're doing this sort of observation of the network that you run some sort of a full packet capture in order to watch what's there, it's hard to watch this real time. So make it slow, make it easier on yourself. And this may not sound like it's easier, but it really is. Start up the phone, have all your collection running, and then just let the phone sit there for 20 minutes. Go make your tea, drink your coffee, you know, look at your whatever you look at when you've got idle time, Instagram, Duolingo, that's what I use. Those are my two main ones. My two main time wasters, my donuts that I love to eat, Duolingo and Instagram. So with this, you basically have this circumstance of let it run for a while. Just give yourself a baseline. This is useful for when you're like, do I need to pay attention to this or not? Or what was that from? If it was in the 20 minutes, when you literally weren't doing anything with the phone, you can basically say, okay, ignore all that traffic. Now, you may actually care what that traffic is, but if you're looking at a specific time, if you're looking at a specific app that helps you to eliminate that initially. Also, just as guidance, because I've made this mistake before, when you're going through and doing this work, don't click, click, click, click, click, click, click really fast. Do it slowly. Write down the time of when you did a certain thing and wait 15 or 30 seconds between each action. You will love yourself later. If when you go back, you actually have the time and you can correlate that time to the, you know, the Wireshark view of the network traffic. And you're like, oh, that's exactly when I clicked that, that makes perfect sense. --- Page 15 --- But if you click, click, click, click like a normal user would, then all of a sudden it's like, well, which one actually created this particular network request? It's much harder to look at it later and assess what it's actually doing. Another thing is if you have data entry opportunities, make it distinct so that you can actually go look for those things and then take all that stuff that you put in and record what you put in and then try variations on it, base 64, encrypted using, you know, various encryption techniques, you know, MD5, hash it, and then see if that stuff gets sent. If you know what you're looking for, it's easier to look for it. So this is what we end up with most of the time, all these different conversations where you have to go filter through what app was doing what, and this takes a bunch of times. Don't expect that you're gonna like look in Wireshark and all of a sudden, boom, it's super easy. I start with the conversations view in order to see what's there. This is actually a nice way to approach it. Another thing that you can do behaviorally, which is really interesting, is you do the file system content. Now, if you have a rooted or a jailbroken phone, it's super easy. You just go grab the entirety of the file system and look at it. But if you don't have root on an Android device, you can actually use ADB to pull a bunch of the files. You'll start to run into permission problems with this, but what you could do is actually make a backup of the application that you're interested in in order to pull the files off of the phone in order to be able to store them later. But after you pull them off the phone, then you actually just look at them and see what's there and see what's data inside of this. And it's a lot easier if you get a baseline by installing the app completely plain, making a backup, looking at the files that are there, use it a little bit, like create an account, make a backup, look at what changed, and now this is the things. Especially useful if you actually are doing it in a predictable way, where you can then look at the delta between snapshots of the backups to see what's actually happening. So as an example, you can do ADB backup dash F to say this is the file that I want to put out, and then the package of the installed application. In my experience, you have to use that dash F if you're doing individual packages, otherwise it crashes. If you don't specify it and you're doing the entire phone, then that's fine, but if you're just doing one package, the dash F seems to actually preserve it. So that's a lot of things. Now, the problem is you're actually going to end up --- Page 16 --- with an encrypted backup. It's going to challenge you for a passcode. You have to set the passcode, and then you end up with this data that you can't really do anything with. This is what the file will look like. Android backup for one AES-256, and then there's some stuff in there, which represents the content for the decryption. And then after that, you've basically got the encrypted data of the stuff that's there. But since you made the backup and you know the passcode, then you can actually just, you know, you can just, you know, dump the stuff out. Now, backup decrypt PL is old. It doesn't really work in most cases, but I mention it just because if you have a much older version, that might be a tool that you can use for it. But Android backup extractor, ABE.jar, is actually the tool that you can use to get the decrypted version of this back. In order to use ABE.jar to decrypt the Android backups, you need AES-256 support. AES-256 support only comes with an additional crypto library. Read the readme. It's very straightforward. You download the crypto library. You make sure that you agree that you're not going to export it to, you know, nations which are, you know, listed on some list for the US government. So don't do that. And then basically load it into the directory and then it'll work with that particular backup. So this is the syntax of it. Java.jar, ABE.jar, because you're going to use that jar file. Unpack. The output is decrypted ABE. And the thing that is the, the encrypted backup file goes first. Then you can tar XVF, the decrypted Android backup, and you have the apps. And then underneath apps, you've got each of the app packages. In this case, I basically only did one. So you just have that one. And then inside of there, there's a whole bunch of data. SQLite databases is where most of the data is going to be. There are going to be some XML files as well that might have some interesting data. Um, I'm usually pretty lazy. And if I'm just looking for stuff, I'll pretty much do a, you know, like a for loop for all the different databases that I find on the directory. And then I do a dot dump and then grep for items that I'm interested in because I've usually put in specific items that I know are easy to get back. And then I look what files contain that. So SQLite and then the name dot dump, because you can go into an interactive shell with SQLite, but you can also issue the select commands or other SQLite appropriate commands at the command line, to just dump all the content out. Okay. So that's an easy way to start to go through the mountain of data that you need to inspect. It's interesting if the, if an actor is taking data off by using the app --- Page 17 --- to actually monitor you, in my experience, most of the time that data gets written to the file system in addition to actually exfiltrating it. Why? Because they don't always know that you're going to have network connectivity. So they do some sort of transient storage in order to exfiltrate. This stuff. And they figure, hell, I'm already here. What do I care? This, you know, this, you know, donut eater doesn't care about this app there. They're perfectly happy to keep using it. So whatever, just, you know, let it go. So you're looking for trace data that they may be extracting. It might be the data that's coming from this specific app itself only, but it might also be data from other apps that this app has used. So interesting thing, you could go and like create a whole bunch of fake contacts. Put them in to your contact database and then look to see if those contacts were moved from the contact content provider to this application. Now it's supposed to actually request permission for that. Maybe you granted it when you installed it and clicked through it. Text messages, other things that are in there, anything that you typed, any sort of clips of anything where you were speaking near the phone might also be interesting to look for. Look for things which look like, for instance, recordings. So other things that help to make this easier, MobSF is an awesome tool. Basically you can get a Docker instance and then just start uploading APKs into it and it'll do static analysis, iOS and APKs. Now there is a non-Docker version which will allow behavioral analysis where you can actually run it. That depends on being able to virtualize an instance in order to run the APK. So that is something that you cannot do behavioral analysis in the Dockerized version, but if you want to try it, the Docker instance is fantastic for it. There's a whole bunch of documentation that they have. It's really well-maintained. They have a very inexpensive training class for you to look at in terms of how to use this particular tool. Andrew Warren's another tool that does some sort of automated analysis. Quark is an older one that's there as well. Next topic I want to talk about is the idea of runtime manipulation. There are several tools that I'm going to talk about for this, but the notion is that you are going to change the environment on the program while it's running in order to facilitate your inspection of it. In order to basically look at this, you also have to think about how this might be used at runtime by a malicious application to interact with other applications to steal data from them. On Android, inter-process communication is leveraged doing something called an intent, and this is message passaging within an app, and this is message passaging within an app, and this is message passaging within an app, --- Page 18 --- and this is message passaging within an app, and between applications. Now, iOS actually implements a restriction of a true root where the application doesn't truly know the entirety of the file system. Android, actually the application runs with a full view of the file system all the time. iOS provides the different user space sharing mechanisms like a document picker and other sharing techniques where I can do an action, and they previously supported the ability to do that with supported URL extensions and URL handlers. So these are the ways that you can move data between applications on iOS. So if we want to assess the inter-process communications that are available on Android, we're probably going to use Drozr in order to do this. Needle has basically a capability for doing this on iOS. It's not exactly automated, but it is a way that you can actually inspect that. Your challenge is really the amount of time that you have to go start passing down through all of this. So what you want to do is enumerate the opportunity for interacting with the app, and then you're going to pass data to it or pass no data to it and see if it crashes. If it crashes, then there's an opportunity for further investigation. And if an app crashes, you have to know that somebody else who's interested in stealing data from that particular app might be developing, right? That discovering new exploit opportunities is what the Million Dollar Club is. Drozr, basically, you don't need a rooted phone to do this. You will connect to the instance, either on the virtual device here or the IP address of the phone where it's actually installed. There's tons of capability inside of Drozr that I'm not really going down into the details of. It's all learnable. It all makes sense. You just need to kind of start exploring and have some ideas of what to look for. This is how you start with Drozr. Run app package attack surface, and then the package name that you want to enter. And then the package name that you want to interact with. This says that seven activities are actually exported on this particular guitar tuner application that I was looking at. And then what I can do is look at specific activities using run app activity info. The first one was package attack surface. This one is app activity info. And I need to specify the activity that I'm interested in specifically if I want to start to mess with that particular activity. Okay? So I can get information about the activity on the particular app. Then I have to go to the source code, and I'll talk about how to do that in a second, and look for opportunities for extras when I can start to shove data to that other thing, and also understand the type and variable name that it expects me to pass when I send over the extra. --- Page 19 --- Okay? An interesting example of this came out recently where actually Android was vulnerable to one application triggering the camera to actually take photos. So this is the sort of way that an attacker might leverage this. If I can trigger an intent and say, hey, camera, take a photograph for me, then maybe I could take a photograph when the phone's sitting on the desk, or I could basically turn on the microphone or something like that in order to abuse the intent. Another runtime tool is Frida. It basically requires you to have some basic programming knowledge, a little bit of understanding about what's capable for within an application. It also is useful to have a little bit of how Android apps are developed. This is something where you can run it both on an unrooted and a rooted device, but rooted is actually a more powerful circumstance. Another one that's awesome in terms of runtime manipulation that's a really cool idea is Artist. Now, Artist actually replaces the compiled, optimized, executable, which is what is created out of the apk.classes.dex file. And it does this after the signature verification, so you can instrument the ELF. Super cool idea. So you can check out some of the talk at Black Hat 2018 by Schrantz on Artist. Other ones that are out there, I mentioned Needle for iOS. Objection basically sits on top of Frida in order to do some runtime stuff, expose, city of substrate. There are a whole bunch of tools that help you to do this. So I want to talk a little bit about static code analysis. I also want to caution you at this point. Before this point is where it ends for a lot of people. But don't be afraid of static code. You can actually read it. Read it out loud if it's difficult for you to understand. This is way more complex than the other stuff. It just takes time. So first off, you have to actually acquire the APK. My favorite way to do it is to actually install ES File Explorer. You can also use real APK leecher. You can download them from the internet. You can use ADB to include the APK file when you do the backup. For iOS to do this, you need a jailbroken phone. The best way to do it is actually to do like dump decrypted on the jailbroken phone to extract it out. What do you end up with? Assembly. So if you can read that, great. But that's what you need to do sort of next. My method that I prefer, install ES File Explorer. Inside of there, go to the app section. Long press the app of interest, then down at the bottom. You can check multiple as well. Click backup. And what it does is it actually dumps that APK to the SD card backups directory. And then you have the permissions with ADB to pull that file off. --- Page 20 --- Now you have the APK, right? And APKs are just zip files. So what you can do is basically unzip it. Don't work on the original one, just in case you screw something up. Unzip it. And then use the, axmlprinter2.jar in order to look at the Android manifest. The Android manifest declares a whole bunch of permissions. It shows what intents are actually available. It declares all of the activities. It declares all of the services and broadcast receivers and content providers that are in there. And so you should look inside of this to see what permissions are declared because the permissions actually specify what's available for the thing to run. Okay. And so with a little bit of sort of understanding of what, permissions enable an app to do, you can start to look through and see what's there. I tend to use JADX most of the time, but Bytecode Viewer is an awesome option for this because what Bytecode Viewer does is it uses multiple different decompilers to prevent, to present the static code as decompiled by multiple different ones. So if one doesn't do a good job, you look at the other one. And so I don't usually use DextaJar anymore. Jeb, I've used a couple of times. Jeb is a commercial tool, but it makes a lot of the work, you know, a lot of the work that you would do in static decompilation a lot easier. Simplify is another tool for the obfuscated code. Simplify actually removes a bunch of dead and obfuscated code by running it in a smallie instance to see what code actually runs and what the simplified version is of the code. There's also still a whole bunch of obfuscated stuff that you may need to fight with. If you do this with any frequency, ByJab, it's a great tool. ByJab is a great tool. But if you don't want to pay for it, you can jadex decompile at the command line. Then you take the decompiled code and open it up in Android Studio, read the code, actually refactor it, rename it, and then you end up with commented and refactored code. Josh Wright has a great webcast on how to do this and walks through some of it. So there's tons of tools that are out there. I have an old view of a whole bunch of tools. I haven't updated in a long time, sorry. There's also this mobile app pen test cheat sheet, which is a really good resource for you to look at in terms of what's there. Santoku, Kali, Mobisec, and AndroLab are basically platforms that you can start to run this stuff on. They don't have everything that you need, but they're actually a really good start. So I suggest that you do this, get better at it, and share your results with other people because it actually helps everybody by doing this. The more you do this, the better you get at it, --- Page 21 --- maybe a little more. The more paranoid you get as a result of it. But eventually, you'll start to realize, do I really want to give my data to these companies? Are they doing things that are right? And until consumers actually demand that companies protect the data appropriately and treat their data with due concern and consideration, they're probably not going to change. So more people looking at it and addressing this problem is actually going to help all of us. I have a whole bunch of slide decks available for download, including this one. This one will be available at this location. This links to a Google Drive. Inside of this Google Drive are all the publicly shared slide decks that I actually have. And I will say, I do really want to hear your thoughts on this. So if you have things that are of interest that you'd like to share with me, you can tweet. That's probably the easiest way. If you were an astute observer, you saw my email address earlier in the presentation. You can go back and grab that. And email me. But other than that, thanks for your time and attention. And happy hacking.

Related Q&A

  • Q: Overview
    A: Presentation details for Vampirism and the Donut Economy