1 00:00:00,560 --> 00:00:13,420 She's going to give you a presentation about riddles. Well, close enough. I'm 2 00:00:13,420 --> 00:00:17,980 talking about runtime riddles and I'm also standing on a platform so I hope everybody is 3 00:00:17,980 --> 00:00:23,660 able to see me and I hope I don't fall off. But today I'm going to be talking to you about 4 00:00:23,660 --> 00:00:28,520 abusing manipulation points in the Android 13 runtime for anti-reverse engineering. 5 00:00:30,000 --> 00:00:35,960 So who am I? I'm Lori Kirk. I'm a reverse engineer at Microsoft. I specialize in cross 6 00:00:35,960 --> 00:00:41,440 platform malware analysis with a focus on mobile threats. I also run a YouTube channel under 7 00:00:41,440 --> 00:00:47,320 my alias Lori Wired and I'm also on GitHub and Twitter if you want to connect with me. And 8 00:00:47,320 --> 00:00:54,060 today I will be representing myself as a security researcher, not representing Microsoft. And 9 00:00:54,060 --> 00:00:59,020 if you'd like to follow along with this presentation at all, feel free to go ahead and scan 10 00:00:59,020 --> 00:00:59,980 the sketchy code. I'm going to show you how to do that. I'm going to show you how to do that. 11 00:01:10,400 --> 00:01:17,780 So let's get right into it. Now, imagine you're a seasoned security analyst and you're 12 00:01:17,780 --> 00:01:22,380 analyzing an Android application and you've checked every single method inside of this 13 00:01:22,380 --> 00:01:28,020 application and it's all looking clean and you're not finding any malicious indicators inside 14 00:01:28,020 --> 00:01:29,960 of this application. So you're going to go ahead and scan the sketchy code and you're going to 15 00:01:29,960 --> 00:01:36,740 call it and say that this application is indeed clean. And then you get to this part of the 16 00:01:36,740 --> 00:01:42,980 code. And you might think this looks entirely benign. We have a log.e method which is an 17 00:01:42,980 --> 00:01:48,860 official method inside of the Android framework used to log an error to the console. And it 18 00:01:48,860 --> 00:01:52,900 looks like it's setting a button to the Android application screen that the user can interact 19 00:01:52,900 --> 00:01:59,360 with. You might think this code is perfectly safe. This code has actually been dynamically 20 00:01:59,360 --> 00:02:05,900 modified and hooked during run time of the application so that every time the official log.e 21 00:02:05,900 --> 00:02:11,400 method inside of the Android framework is invoked, it's actually executing an underlying info 22 00:02:11,400 --> 00:02:19,120 stealer inside of custom code. So this actually just stole your data. Which brings me into my 23 00:02:19,120 --> 00:02:24,580 agenda for today. We're going to manipulate the Android 13 run time. We're actually going to 24 00:02:24,580 --> 00:02:29,340 replace the official Android APIs while our application is executing. And we're going to 25 00:02:29,340 --> 00:02:36,960 execute our own custom code. This also works on Android 14 in the upside down cake release, the 26 00:02:36,960 --> 00:02:42,480 beta version. And I'm also going to provide a new open source tool to the community that I just 27 00:02:42,480 --> 00:02:48,340 released about an hour ago. And this is going to let you import this as a library into your own 28 00:02:48,340 --> 00:02:54,580 Android applications to provide additional obfuscation for your Android APKs. And this will 29 00:02:54,580 --> 00:02:59,320 work for any device that you're trying to protect your Android applications against. And it's going 30 00:02:59,340 --> 00:03:07,440 to be designed specifically for Android 13 and 14. Now for a little bit of background before we 31 00:03:07,440 --> 00:03:14,340 really get into it. So the primary goals for obfuscation inside of Android for dynamic 32 00:03:14,340 --> 00:03:20,980 obfuscation is to load additional code into the Android run time. So basically this is trying to 33 00:03:20,980 --> 00:03:29,040 defeat static analysis of Android applications. Basically there's an additional class or method 34 00:03:29,340 --> 00:03:36,200 or even executable that is defined on disk that Android malicious or benign developers will try 35 00:03:36,200 --> 00:03:42,340 and include inside of their Android applications to prevent static analysis of their code on disk. 36 00:03:42,660 --> 00:03:47,820 So if they load and execute this code while the application is actually running, and a reverse 37 00:03:47,820 --> 00:03:52,460 engineer is taking a look at this code, they actually won't know unless they dynamically 38 00:03:52,460 --> 00:03:59,260 analyze their code that this additional code is actually executing. So we're going to go ahead and 39 00:04:01,280 --> 00:04:05,700 take a look at that. So there's a few methods that are really commonly used for dynamic code 40 00:04:05,700 --> 00:04:11,800 loading. These can be found inside of the Android framework. You might see dex class loader, path 41 00:04:11,800 --> 00:04:17,300 class loader, or even some different Java reflective calls. And basically they will take an 42 00:04:17,300 --> 00:04:23,600 additional Dalvik executable on disk and load that into the Android run time or they can even work 43 00:04:23,600 --> 00:04:29,320 on different methods, classes, or variables. So these are all effective, but there's a lot of 44 00:04:29,340 --> 00:04:34,340 things that can be done at actually altering the dynamic flow of the application. The only problem 45 00:04:34,340 --> 00:04:41,840 is, is that these are really easy, easily searchable inside of the code. So I took a malicious 46 00:04:41,840 --> 00:04:48,200 application and I threw this into my favorite Android decompiler, jdex, and all I need to do is 47 00:04:48,200 --> 00:04:54,940 go search, text, and then start typing in my favorite Android APIs, and I can find all of these 48 00:04:54,940 --> 00:04:59,320 dynamic code loading calls in plain text. So this is really simple, and I'm going to show you a 49 00:04:59,340 --> 00:05:02,400 few examples of how to do this. And at that point, I'm able to fully understand what this is 50 00:05:02,400 --> 00:05:10,180 doing and be able to potentially analyze those additional code loading calls. Furthermore, there's 51 00:05:10,180 --> 00:05:15,300 a lot of default frameworks inside of Android. You might be familiar with Frida that's actually 52 00:05:15,300 --> 00:05:20,880 able to hook methods for a lot of different platforms, not just Android, while the application 53 00:05:20,880 --> 00:05:26,540 is running. Or there are hooking frameworks that are designed specifically for Android 54 00:05:26,540 --> 00:05:29,320 applications. A popular one might be Medusa. And then there's a lot of other frameworks that are 55 00:05:29,340 --> 00:05:33,160 designed specifically for Android, which actually, by default, hooks a lot of these different 56 00:05:33,160 --> 00:05:39,180 Android APIs that are specifically targeted for code loading, and will dump the executable for you 57 00:05:39,180 --> 00:05:44,880 so that you can take a look really easily and actually statically analyze that additional 58 00:05:44,880 --> 00:05:52,720 binary. So when I started working on this presentation, I wanted to think, is there a way that I 59 00:05:52,720 --> 00:05:59,320 could actually bypass these common API calls so I could try to hide the dynamic malicious code 60 00:05:59,340 --> 00:05:59,720 that's going on within my application? And I ended up doing that. So I'm going to go ahead and 61 00:05:59,720 --> 00:06:01,340 look at this. I'm going to go ahead and talk about the modification of my Android application. 62 00:06:03,160 --> 00:06:08,180 Which brings me into my first point, which is going to be manipulating the Android runtime 63 00:06:08,180 --> 00:06:15,440 directly. First of all, a little background, if you're not familiar. The Android runtime, also 64 00:06:15,440 --> 00:06:23,040 known as ART, is responsible for taking in binaries that are defined on disk. So these are going to be 65 00:06:23,040 --> 00:06:29,320 your Android applications, your APK files. And actually parsing out all of the code from inside of it, when you're 66 00:06:29,320 --> 00:06:34,600 of those, bringing those into the actual Android runtime environment, mapping those into memory, 67 00:06:34,840 --> 00:06:41,020 making the relevant portions executable and actually executing the entry point of the 68 00:06:41,020 --> 00:06:47,360 particular executable binary. So basically you have your Android runtime responsible for 69 00:06:47,360 --> 00:06:52,420 taking your code on disk and bringing it into the runtime environment and importing any 70 00:06:52,420 --> 00:06:59,200 necessary data inside of your application. The high level of it looks like this. You 71 00:06:59,200 --> 00:07:04,380 have your method defined on disk and then you have ART, which is going to parse out all of that 72 00:07:04,380 --> 00:07:10,420 data that I mentioned, bring that inside of our process memory and actually execute those 73 00:07:10,420 --> 00:07:19,260 underlying instructions. So from here I had an idea. What if I could actually modify those 74 00:07:19,260 --> 00:07:25,060 methods that have already been mapped inside of memory or even modify an entire executable that 75 00:07:25,060 --> 00:07:29,000 has already been brought into the runtime environment instead of actually just 76 00:07:29,000 --> 00:07:29,180 mapping it into memory? So I'm going to go ahead and do that. I'm going to go ahead and 77 00:07:29,200 --> 00:07:37,000 mess with it on disk. This means that we would avoid any of those plain text API calls that I 78 00:07:37,000 --> 00:07:42,460 mentioned earlier that dex class loader, path class loader or in memory dex class loader that 79 00:07:42,460 --> 00:07:47,740 are so commonly used and so common, such common targets for Android reverse engineers 80 00:07:47,740 --> 00:07:54,020 already. This would also mean that we would not have any standard methods to hook with a lot of 81 00:07:54,020 --> 00:07:58,940 those default Android frameworks that will commonly just dump the dynamic binaries that we're 82 00:07:58,940 --> 00:08:06,860 trying to execute and hide. Now the only problem with this is that Android has a lot of 83 00:08:06,860 --> 00:08:11,720 abstraction layers that we have to keep in mind if we're trying to actually hook and modify 84 00:08:11,720 --> 00:08:18,740 these methods. So it's not just as easy as hooking the Java method, altering the behavior and 85 00:08:18,740 --> 00:08:24,460 just having the execution. If we're actually trying to swap out entire methods or entire 86 00:08:24,460 --> 00:08:31,540 executables and fields inside of our memory of our application, we actually need to modify the 87 00:08:31,540 --> 00:08:39,600 underlying native structure of those Android methods. Now what you might be familiar with is 88 00:08:39,600 --> 00:08:45,200 that the Android framework is actually written in Java. So this means that Android developers 89 00:08:45,200 --> 00:08:53,740 write in Java or Kotlin and they'll import those Java defined official APIs into their code. So 90 00:08:53,740 --> 00:09:00,060 the developer is only interfacing with the Java portion of these APIs. But what you might not be 91 00:09:00,060 --> 00:09:07,520 familiar with is that the underlying implementation is actually defined in native C++ code. So the 92 00:09:07,520 --> 00:09:14,740 Java basically works as a wrapper around a lot of underlying C++ implementation. The same thing 93 00:09:14,740 --> 00:09:22,700 goes for the official Android APIs as well as in our own user binaries. We often have Java invoking 94 00:09:22,700 --> 00:09:23,720 the native C++ code. So it's a little bit more complicated than that, but it's a little bit more 95 00:09:23,740 --> 00:09:29,980 complicated than the C++ which actually contains a lot of the implementation. The high level 96 00:09:29,980 --> 00:09:35,180 view looks something like this. You have your developer on top interfacing with the Java portion 97 00:09:35,180 --> 00:09:40,580 of our application. And then we have this special thing called the Java Native Interface or JNI 98 00:09:41,000 --> 00:09:46,840 that actually lets the developer and the Java code communicate with the C++ code underneath and 99 00:09:46,840 --> 00:09:52,000 vice versa. So if you're trying to think of the JNI, this is important so we're going to use it 100 00:09:52,000 --> 00:09:53,720 later. Think of it as a C++ code. So if you're trying to think of the JNI, this is important so 101 00:09:53,720 --> 00:09:56,720 we're going to use the JNI. Think of it as the bridge between our managed Java code and our 102 00:09:56,720 --> 00:10:06,220 native C++ code. And remember, we want to modify the underlying C++ in our process memory 103 00:10:06,820 --> 00:10:11,680 instead of just looking at the Java portion of this. So we're going to use the JNI to do that. 104 00:10:13,440 --> 00:10:17,780 This means that our new methodology is going to be something like this. We're going to locate 105 00:10:17,780 --> 00:10:23,700 our Java target on top. We're going to intercept those specific targets and we're going to call 106 00:10:23,720 --> 00:10:28,840 using that Java native interface bridge between managed code and native code and then we're 107 00:10:28,840 --> 00:10:34,740 actually going to dereference a pointer that we're able to get with the JNI to modify and 108 00:10:34,740 --> 00:10:42,320 overwrite that underlying native data inside of our process memory. So let's get on to our 109 00:10:42,320 --> 00:10:47,860 first point. We're going to talk about finding entry points and targets within the Android 110 00:10:47,860 --> 00:10:53,640 source code inside of the Android framework. This means that I'm going to first dive into the 111 00:10:53,640 --> 00:10:58,720 actual source code of the Android framework. One thing that I really like about Android is 112 00:10:58,720 --> 00:11:03,100 that it's all available for you online. You can read any of the source code. There's even 113 00:11:03,100 --> 00:11:08,780 really helpful developer comments inside a lot of the code for you to understand. So we're 114 00:11:08,780 --> 00:11:13,420 going to look into that top point right there and take a look at the Android platform and see 115 00:11:13,420 --> 00:11:18,180 if there's any Java methods of interest that we could potentially use to actually swap 116 00:11:18,180 --> 00:11:23,620 different relevant data inside of our application. Now, if you look at the Android 117 00:11:23,640 --> 00:11:29,220 framework, the first target I looked at was trying to swap an entire DEX file. A DEX file is a 118 00:11:29,220 --> 00:11:36,320 executable file and it contains all of the actual Java byte code or executable code that's 119 00:11:36,320 --> 00:11:41,720 inside of your application that's actually going to be run on the underlying processor. And if 120 00:11:41,720 --> 00:11:48,060 you take a look inside of the Android framework, we have this DEX file.Java class that's defined 121 00:11:48,440 --> 00:11:53,620 that we're able to locate. And this contains all of the relevant data for the actual Java 122 00:11:53,640 --> 00:12:01,760 byte code that's being mapped from disk into memory. Specifically, if you look at that M cookie 123 00:12:01,760 --> 00:12:07,620 field there on the left-hand side, this is containing a reference to that open Dalvik 124 00:12:07,620 --> 00:12:13,680 executable file. So my first target was, what if we took that M cookie field and we actually 125 00:12:13,680 --> 00:12:19,340 swapped that with another field during execution so that we're executing an entirely separate 126 00:12:19,340 --> 00:12:23,620 executable than what we would expect and what a reverse engineer or a developer would expect. 127 00:12:27,980 --> 00:12:34,060 But this didn't work super well for a few different reasons. The main problem is kind of chicken an 128 00:12:34,060 --> 00:12:42,020 egg. So your main Dalvik executable file is already initially kicked off, as soon as a Rt gets 129 00:12:42,020 --> 00:12:47,140 the input from the user to actually run this application, it's going to immediately call that 130 00:12:47,140 --> 00:12:53,560 DEX file that's already been mapped into memory. Now, how would you actually invoke your code to do the 131 00:12:53,640 --> 00:12:59,460 hook and swap if that main DEX file hasn't already been mapped inside. And if you're trying 132 00:12:59,460 --> 00:13:05,020 to map an additional DEX file into memory, you have to use those pesky API calls like 133 00:13:05,020 --> 00:13:09,700 DEX class loader or path class loader that we were trying to avoid that are so commonly 134 00:13:09,700 --> 00:13:14,720 hooked. Or else what's the point of doing any of this? So this does not really seem like a 135 00:13:14,720 --> 00:13:22,360 viable option for us. So I moved on to trying to modify individual members inside of a 136 00:13:22,360 --> 00:13:27,860 DEX file. Specifically, I found a very interesting portion of code inside of the Android 137 00:13:27,860 --> 00:13:33,460 platform. So Android is actually built on top of Java. And you can see a lot of the original 138 00:13:33,460 --> 00:13:40,100 Java definitions and references are defined inside of our platform. This is a field object. So 139 00:13:40,100 --> 00:13:45,480 every single field inside of an Android application is going to be instantiated and get its 140 00:13:45,480 --> 00:13:51,040 own version of this when the application is actually running. And this contains all of the 141 00:13:51,040 --> 00:13:52,340 relevant runtime data. So it's going to be instantiated and get its own version of this when 142 00:13:52,340 --> 00:13:53,080 the application is actually running. And this contains all of the relevant runtime data for 143 00:13:53,080 --> 00:13:58,040 every single field inside of an Android application. You can see we have our access flags, 144 00:13:58,400 --> 00:14:03,520 declaring class, and all of the different runtime data that we're actually going to need to 145 00:14:03,520 --> 00:14:09,740 use this field. So if I keep on looking around here and try to find an interesting place to 146 00:14:09,740 --> 00:14:17,200 actually modify and manipulate, I found this executable.Java file. And this actually contains an 147 00:14:17,200 --> 00:14:22,320 ART method variable inside of it, which is sounding really interesting. And basically what 148 00:14:22,340 --> 00:14:28,000 And if you take a closer look at the ART method variable that I have highlighted right here 149 00:14:28,320 --> 00:14:35,620 from our Android source code, this is going to contain the actual ART method structure for 150 00:14:35,620 --> 00:14:41,020 every single method that is defined inside of an Android Dalvik executable file. So every 151 00:14:41,020 --> 00:14:47,380 method that's defined on disk gets a corresponding instantiation inside of the runtime as 152 00:14:47,380 --> 00:14:54,760 defined by this ART method structure in native code. So I had an idea here, how about we take 153 00:14:54,760 --> 00:15:00,640 this ART method field and we try and swap two methods while the application is actually 154 00:15:00,640 --> 00:15:07,820 running. So that's going to be my plan. We're going to have two methods and we're going to try 155 00:15:07,820 --> 00:15:12,440 and overwrite one behavior with the behavior of another method to see if we can actually do 156 00:15:12,440 --> 00:15:17,360 some manipulation. So I have my benign method, my fake malicious method, and my fake 157 00:15:17,380 --> 00:15:22,080 malicious method. And as soon as the application starts running, we're going to hook both 158 00:15:22,080 --> 00:15:28,800 instantiations of these methods and try to overwrite that ART method field so that we can see 159 00:15:28,800 --> 00:15:39,340 if we can get benign method to be called but malicious method code actually executed. So now we 160 00:15:39,340 --> 00:15:44,360 need to move on to intercepting methods via the Java native interface. Remember that was that 161 00:15:44,360 --> 00:15:47,360 really important bridge between native code and managed code. So now we need to move on to the 162 00:15:47,360 --> 00:15:53,580 rendering Jupyter code. So what we need to do is we actually need to call the JNI from our own 163 00:15:53,580 --> 00:15:59,740 native application in android. And we need to use that to retrieve a reference or handle to 164 00:15:59,740 --> 00:16:05,820 both of those objects. And then we actually need to load the corresponding ART method field 165 00:16:06,260 --> 00:16:13,020 for both of those. And then once we've actually done that, we can do our overriding. So this is 166 00:16:13,020 --> 00:16:17,340 going to be the code that's actually going to be able to perform that. On the time when we're going toso 167 00:16:17,340 --> 00:16:22,660 there you can see we're trying to find the executable class that was defined inside of our 168 00:16:22,660 --> 00:16:30,100 Android platform and then from there we're able to find that ART method field that is inside of 169 00:16:30,100 --> 00:16:35,680 that class defined in our Android platform. And we also need to get this for malicious 170 00:16:35,680 --> 00:16:41,960 method and benign method so that we actually have the instantiations of both of these since 171 00:16:41,960 --> 00:16:49,900 every single method is going to get its own. Now there's one problem you probably didn't notice or 172 00:16:49,900 --> 00:16:56,360 maybe you did. That ART method field is actually private. So this means that only instances of 173 00:16:56,360 --> 00:17:03,040 that executable class or its children can actually access this ART method field which is kind 174 00:17:03,040 --> 00:17:07,840 of a problem because we're trying to access that from code that has nothing to do with the 175 00:17:07,840 --> 00:17:11,500 Android platform. We're just using it inside of our own user code. 176 00:17:12,300 --> 00:17:18,820 So this actually is a really big problem because the ART method object is completely hidden from 177 00:17:18,820 --> 00:17:28,880 us. Or is it? So actually the Java native interface does not respect access modifiers. So if we 178 00:17:28,880 --> 00:17:34,340 just ignore the warning like any good hacker would, we can just run this code and it's going to 179 00:17:34,340 --> 00:17:39,700 run and execute this just fine. Even though Android studio is telling me that this is wrong and 180 00:17:39,700 --> 00:17:41,940 I should not be doing this, that's okay. We can just run this code and it's going to run and 181 00:17:41,940 --> 00:17:48,300 execute this just fine because it still runs. So now the first thing that I wanted to do is I 182 00:17:48,300 --> 00:17:54,500 wanted to do something kind of simple. I basically just took the handles to both of those 183 00:17:54,500 --> 00:18:00,600 objects that we were targeting and just set benign method equal to malicious method and let's 184 00:18:00,600 --> 00:18:11,920 just see if it's actually going to work. So let's go to test time. So I'm going to run this 185 00:18:11,940 --> 00:18:16,800 code and I'm going to pull up my first video here. And let's take a look at this code actually 186 00:18:16,800 --> 00:18:24,380 running. And if you're able to see here, I have two methods defined inside of my Android 187 00:18:24,380 --> 00:18:30,120 application. I have benign method, which is going to return the string I am benign. I have 188 00:18:30,120 --> 00:18:37,080 malicious method, which is going to return the string LOL. And we're just printing the return 189 00:18:37,080 --> 00:18:41,920 value of benign method to the Android screen inside of our Android application. So I'm going to 190 00:18:41,940 --> 00:18:44,660 print the return value of benign method to the Android application. Now, this is my native 191 00:18:44,660 --> 00:18:48,540 code that we saw a little bit earlier. We're getting that executable class with the 192 00:18:48,540 --> 00:18:53,980 respective ART method field. We're getting the objects for both of those benign and 193 00:18:53,980 --> 00:18:58,440 malicious methods. And then if you can see highlighted there, we're doing something really 194 00:18:58,440 --> 00:19:03,880 silly, just setting benign method equal to malicious method. But hopefully this actually 195 00:19:03,880 --> 00:19:09,780 works. And if it does, we're going to see LOL printed to the Android application instead of the 196 00:19:09,780 --> 00:19:11,580 text I am benign. So now we're going to run this code and we're going to run this code and we're 197 00:19:11,580 --> 00:19:14,820 going to see if this is going to work. So let's actually let that run and see if this is going to 198 00:19:14,820 --> 00:19:22,980 work. So real quick, show of hands, who thinks this is going to work? Show of hands, who thinks 199 00:19:22,980 --> 00:19:33,940 this isn't going to work? Show of hands, anybody asleep, drunk? I don't know. Okay, that 200 00:19:33,940 --> 00:19:41,560 didn't work. That's too bad. So now we're going to run this code and we're going to see if this 201 00:19:41,580 --> 00:19:52,080 works. So let's go back to our slides. And we finished our actual test, which was kind of a dumb 202 00:19:52,080 --> 00:19:56,320 test, just setting one value equal to another. We didn't actually do any effort to understand 203 00:19:56,320 --> 00:20:00,800 what was happening underneath. So all that means is we just need to dive deeper and we need to 204 00:20:00,800 --> 00:20:06,060 actually understand that underlying native structure inside of our Android application, inside 205 00:20:06,060 --> 00:20:11,040 of our Android framework. So let's go through and let's understand that native structure. 206 00:20:11,760 --> 00:20:16,500 First of all, if we kept on going and we started spending a lot of time or too much time 207 00:20:16,500 --> 00:20:22,480 inside of the Android source code, then we would find out that that ART method field is actually 208 00:20:22,480 --> 00:20:29,980 a pointer to an underlying native ART method structure. So this ART method actually defines 209 00:20:30,380 --> 00:20:38,040 the whole representation for a native ART method object that's mapped into process memory. So this 210 00:20:38,040 --> 00:20:44,780 is the native representation of an ART method inside of our Android runtime. And we can 211 00:20:44,780 --> 00:20:51,340 actually find the declaration of this which is put inside of ARTMethod.h and this contains 212 00:20:51,340 --> 00:20:55,820 all of the relevant data for any method that's going to be running inside of our Android 213 00:20:55,820 --> 00:21:01,900 application. It's going to contain the access modifiers, the actual executable code or any 214 00:21:01,900 --> 00:21:08,780 data that is needed for this method to fully execute and run. And if we keep on going, we can 215 00:21:08,780 --> 00:21:15,500 find the individual fields to find inside of this ARTMethod.h. And one field of interest, if you 216 00:21:15,500 --> 00:21:21,600 take a look, you can see entry point from quick compiled code. And as I said, really 217 00:21:21,600 --> 00:21:26,960 helpfully, the Android source code provides a ton of comments defining what it's actually 218 00:21:26,960 --> 00:21:31,880 doing. So we can figure out exactly what this variable stands for and what it's actually 219 00:21:31,880 --> 00:21:39,340 doing. And this is going to be the actual native instructions compiled from this method that 220 00:21:39,340 --> 00:21:44,340 are going to run directly on your underlying processor. So that sounds really interesting. 221 00:21:44,600 --> 00:21:49,720 What if we actually change the instructions that are pointed to by this entry point from 222 00:21:49,720 --> 00:21:57,680 quick compiled code? And I kept causing repeated crashes. So what I was doing is I was working 223 00:21:57,680 --> 00:22:01,860 in a 64-bit operating system. So I just tried to take eight bytes of code and put it inside of my 224 00:22:01,860 --> 00:22:02,260 pytm and five bytes of code. And I just found five bytes of code. And the data was actually 225 00:22:02,260 --> 00:22:02,600 reading the code the way I wanted it to read. I just added a few bytes for each byte increments 226 00:22:02,600 --> 00:22:09,900 and I just keep overriding those bytes bit by bit. And seeing if I could find where that entry 227 00:22:09,900 --> 00:22:16,840 point from quick compiled code actually lived inside of the process memory since we had a handle to 228 00:22:16,840 --> 00:22:21,100 the beginning of that ARTMethod field. But we don't actually know where everything else is 229 00:22:21,100 --> 00:22:27,380 inside of that ARTMethod field in memory. So my new plan was, okay, I'm going to test every two 230 00:22:27,380 --> 00:22:31,840 bytes, kept going forward and forward and forward, with eight byte increments. And basically, 231 00:22:31,840 --> 00:22:38,060 and actually see if I could accidentally overwrite this pointer in memory and then cause the 232 00:22:38,680 --> 00:22:44,520 malicious method to actually execute. But that was totally not working and it was getting 233 00:22:44,520 --> 00:22:49,780 really frustrating because I was like I don't even know if I'm doing the right thing. I don't 234 00:22:49,780 --> 00:22:54,860 even know if I'm starting out correctly right here because what if it's actually not the 235 00:22:54,860 --> 00:22:58,880 native structure? What if I'm looking at something completely different and wrong? So I 236 00:22:58,880 --> 00:23:06,140 eventually just gave up on that and then I had a new bright idea. I thought, okay, I'm just 237 00:23:06,140 --> 00:23:12,900 going to take 64 random bytes from malicious method and overwrite those with 64 bytes of 238 00:23:12,900 --> 00:23:18,680 benign method because I'm working in a 64 bit operating system and there were like roughly 239 00:23:18,680 --> 00:23:23,760 eight variables inside of my ART method class. So I was trying to account for those sizes 240 00:23:23,760 --> 00:23:28,740 roughly. You can shout it out if you disagree and think it should be another side. But we 241 00:23:28,740 --> 00:23:28,860 want to make sure that we're doing the right thing. So I was trying to account for those 242 00:23:28,860 --> 00:23:34,760 sizes. So I went with 64 bytes here. So let's go to a second test and let's actually see if 243 00:23:34,760 --> 00:23:53,740 this is going to work. All right. So this should look familiar for you. We have our 244 00:23:53,740 --> 00:23:58,840 executable class that we're trying to get a reference to. We found our respective ART 245 00:23:58,840 --> 00:24:05,680 method field. We have our malicious and benign method. And then we have that nice pretty silly 246 00:24:05,680 --> 00:24:10,940 line there of mem copy, completely unsafe. Let's just copy over 64 bytes from malicious 247 00:24:10,940 --> 00:24:24,060 method to benign method. And let's see if that's going to work. So what we want to see is LOL 248 00:24:24,400 --> 00:24:28,820 written to the screen instead of I am benign. So show of hands now if you're going to be able to 249 00:24:30,280 --> 00:24:40,620 use this. I think this is going to work. So let's see how it's going to work. So I'm going to 250 00:24:40,620 --> 00:24:53,540 start my application. Here we go. And it worked. So I appreciate the vote of confidence from 251 00:24:53,540 --> 00:24:58,800 everybody who thought it wasn't going to work but it did. Okay. So now I'm going to go ahead and 252 00:25:07,760 --> 00:25:12,320 So I kept on going after I figured out that it was that easy and you could just make it work. 253 00:25:12,520 --> 00:25:17,200 And I wanted to see what are the actual specifications and what can we do with this. So 254 00:25:17,200 --> 00:25:22,260 after a lot of testing and a lot of breaking stuff, I found out that the methods have to have 255 00:25:22,260 --> 00:25:26,960 the same signature, meaning they have to have the same parameters and they have to return the 256 00:25:26,960 --> 00:25:32,920 same type. They must be static. They can be declared in separate classes or wherever you 257 00:25:32,920 --> 00:25:38,240 want inside of your Android application. They can have completely different functionality and 258 00:25:38,240 --> 00:25:42,940 they will work inside of the application context, meaning that if you're in your app, you 259 00:25:42,940 --> 00:25:47,600 actually can't modify the methods of another app, but you can do whatever you want inside of 260 00:25:47,600 --> 00:25:54,160 your own application, which is good enough for us and for obfuscation. So that's cool and 261 00:25:54,160 --> 00:25:56,940 overwriting random 64 bytes in memory is a good thing. But it's also a great way to 262 00:25:56,940 --> 00:26:00,660 make sure that your memory does work. But let's actually try to increase our accuracy a little bit. 263 00:26:01,720 --> 00:26:06,480 So I'm going to do some byte math now and we're going to calculate all of the different offsets for 264 00:26:06,480 --> 00:26:12,540 this ART method object and see where everything actually is in the process memory of our 265 00:26:12,540 --> 00:26:20,360 application. So the Android source code, I was taking a look at it and it itself is actually 266 00:26:20,360 --> 00:26:26,920 finding these offsets in memory using the actual size of the variables defined in the process 267 00:26:26,940 --> 00:26:28,100 memory. So I took this ART method class, this is the class that we defined in our ART method 268 00:26:28,100 --> 00:26:34,900 dot H that defined all of our method components. So this is actually used by the Android, the 269 00:26:34,900 --> 00:26:42,140 official Android run time for getting and setting these values. So I thought I could either count 270 00:26:42,140 --> 00:26:47,220 the sizes of all of these different variables inside of here or I could let it calculate 271 00:26:47,220 --> 00:26:54,540 itself, which is exactly what I did. So I created a dummy ART method class. I stole all of the 272 00:26:54,540 --> 00:26:56,920 source code that I thought was relevant for the ART method class and then I put it in the process memory. 273 00:26:56,920 --> 00:27:02,660 the ART method class, put it in my own application and just added the necessary member 274 00:27:02,660 --> 00:27:08,940 variables for that and then I let the program calculate itself and print its own offsets to 275 00:27:08,940 --> 00:27:15,760 all of those in memory. And this is what it looked like. It worked really well. I found the 276 00:27:15,760 --> 00:27:21,980 corresponding variables defined inside of our ARTMethod.h and I wrote those down so that it 277 00:27:21,980 --> 00:27:28,580 would print out the offsets for every single one based off of the defined sizes that the actual 278 00:27:28,580 --> 00:27:34,520 application, that dummy application that I was running actually found. So those are all the 279 00:27:34,520 --> 00:27:41,800 correct offsets in memory for every single variable as defined inside of our native C++ ART 280 00:27:41,800 --> 00:27:51,360 method structure. So now it's time for a little bit of byte math. If we keep going and use those 281 00:27:51,360 --> 00:27:58,860 actual offsets that we found, we can take the actual bytes for two objects or two methods that we 282 00:27:58,860 --> 00:28:04,640 were trying to calculate in memory and associate those particular bytes with their actual 283 00:28:04,640 --> 00:28:10,820 variables and types. And you can see we have our declaring class, our access flags, that really 284 00:28:10,820 --> 00:28:16,700 important entry point from quick compiled code there on the bottom right hand side. And I was 285 00:28:16,700 --> 00:28:21,220 working in a 64-bit architecture so those are eight bytes long because those are actually 286 00:28:21,360 --> 00:28:26,960 pointers to different locations in memory that are actually defining the implementation and data 287 00:28:26,960 --> 00:28:34,760 for our ARTMethod object. So now that looks cool but I wanted to know did it actually work? Are 288 00:28:34,760 --> 00:28:40,500 these offsets correct? Because I'm saying they are and it looks kind of okay but did it actually 289 00:28:40,500 --> 00:28:46,720 define the specific locations in memory and do those bytes point to anything? So I wanted to look 290 00:28:46,720 --> 00:28:51,260 specifically at that entry point from quick compiled code because this should just be 291 00:28:51,260 --> 00:28:56,660 arbitrary native code that's going to execute on your underlying processor. So this is actually 292 00:28:56,660 --> 00:29:03,140 going to be assembly instructions if you disassemble them. And I look at it, I mean that 293 00:29:03,140 --> 00:29:07,480 looks like disassembly to me. It looks like a function prologue that's going to be setting up 294 00:29:07,480 --> 00:29:14,160 the actual code for our Android method. And we have all of that, all of those relevant native 295 00:29:14,160 --> 00:29:21,000 instructions that are going to be setting up this native method. So I think that worked and I think we 296 00:29:21,000 --> 00:29:21,240 actually got a lot of training for this. All right. So the next thing I want to do is go back and look at the 297 00:29:21,240 --> 00:29:25,600 actually have are correct offsets and we know exactly where everything stands in memory and 298 00:29:25,600 --> 00:29:31,240 we can overwrite it if we wish. Now we have the exact sizes that we need to do if we're 299 00:29:31,240 --> 00:29:36,640 trying to overwrite an entire method or affect any of the individual variables inside of that 300 00:29:36,640 --> 00:29:41,680 method. And if you want you can look closely. I have all the sizes written there but I won't 301 00:29:41,680 --> 00:29:46,960 go into the details too much. Feel free to do that byte math on your own. And additionally 302 00:29:46,960 --> 00:29:52,740 you'll have to account for if you're running in a 32 bit or 64 bit operating system but you 303 00:29:52,740 --> 00:30:00,380 should still have the same offsets for ARM or x86. So our calculations are actually complete at 304 00:30:00,380 --> 00:30:05,700 this point and now we have successfully finished our byte math and we fully understand the 305 00:30:05,700 --> 00:30:10,680 native and Java structure of our ART method objects. And we can pretty much do whatever we 306 00:30:10,680 --> 00:30:16,860 want from here. So I thought, okay, let's have some fun. How far can we push this and what 307 00:30:16,860 --> 00:30:16,940 can we get out of this? So I thought, okay, let's have some fun. How far can we push this and what 308 00:30:16,940 --> 00:30:22,820 can we do with this? So I had another bright idea. What if we took all of the official Android 309 00:30:22,820 --> 00:30:29,420 APIs and we tried to replace them with our own custom code so that the developer or reverse 310 00:30:29,420 --> 00:30:34,760 engineer is going to think that we're calling those official Android APIs but we're actually 311 00:30:34,760 --> 00:30:41,460 executing something entirely different. So my target now was the official log.e method, 312 00:30:41,660 --> 00:30:46,600 which again is just logging a string error to the console. If you look at it in the 313 00:30:46,600 --> 00:30:51,740 Android logcat you're able to see these messages. This is used by many different Android 314 00:30:51,740 --> 00:30:57,000 applications both malicious and benign. It's a very common method. Reverse engineers will 315 00:30:57,000 --> 00:31:02,400 pretty much completely gloss over this method if they actually see it because it's entirely 316 00:31:02,400 --> 00:31:10,420 benign. So what if we took this benign log.e method and we actually had it steal all of the 317 00:31:10,420 --> 00:31:19,040 data on the device and replaced the log.e functionality with a malicious info stealer? So 318 00:31:19,040 --> 00:31:24,860 what we would have to do is I had to create a static method that had a matching signature. So 319 00:31:24,860 --> 00:31:29,620 remember it's going to have to have the same parameters and return value. But the actual 320 00:31:29,620 --> 00:31:35,800 implementation can be entirely different. So this is going to contain the code that's actually 321 00:31:35,800 --> 00:31:40,400 going to get executed every time that log.e official Android application is executed. So 322 00:31:40,960 --> 00:31:48,440 this is going to invoke my code instead of theirs. So let's do a test and let's see if that's 323 00:31:48,440 --> 00:32:08,040 actually successful and see if it will work. I'm going to open up my video inside of here. 324 00:32:08,200 --> 00:32:09,300 Looks like it's already running. 325 00:32:10,420 --> 00:32:16,260 And this should start looking familiar to you. We have the Java native interface which is 326 00:32:16,260 --> 00:32:21,600 hooking both instances. One is going to be the instance of the log.e method and then one is 327 00:32:21,600 --> 00:32:27,840 going to be the instance of our new custom method that's actually going to get executed. And 328 00:32:27,840 --> 00:32:33,860 then we're going to overwrite 32 bytes in memory since we upgraded from our random 64 bytes to 329 00:32:33,860 --> 00:32:38,540 actually account for the correct size so that we can actually completely overwrite this and 330 00:32:38,540 --> 00:32:39,760 execute our custom code. 331 00:32:41,200 --> 00:32:46,920 So now I'm going to be running this and I'm going to pull up my application. And I'm actually 332 00:32:46,920 --> 00:32:54,260 invoking that log.e method repeatedly. So every time that log.e method is invoked, it's then going 333 00:32:54,260 --> 00:33:01,540 to sleep for two seconds and instead it's going to be executing our fake info stealing functionality. 334 00:33:02,700 --> 00:33:09,220 And on the right-hand side, after it's sleeping for two seconds, you can see it's going found installed 335 00:33:09,220 --> 00:33:09,740 application. 336 00:33:09,740 --> 00:33:15,300 Found installed application. Enumerating through all of the applications in your device to 337 00:33:15,300 --> 00:33:21,480 actually steal that data from those. Even though this has actually never been invoked if you take a 338 00:33:21,480 --> 00:33:24,400 look at the method on the device statically. 339 00:33:37,180 --> 00:33:38,640 So let's go back to our slides. 340 00:33:44,360 --> 00:33:52,880 So now it's your turn to try your hand at manipulating the Android runtime. I have just released an open 341 00:33:52,880 --> 00:33:59,220 source tool about an hour ago. This is called Artful. And it's built for manipulating the Android 342 00:33:59,220 --> 00:34:06,120 13 runtime. But I did just do a check on Android 14 upside down cake and it was perfectly successful 343 00:34:06,120 --> 00:34:09,720 at manipulating that as well. This should work on many Android devices. So I'm going to go ahead and 344 00:34:09,720 --> 00:34:10,440 application. It's been around for many, many years. I have been using it for many different API 345 00:34:10,440 --> 00:34:15,080 versions of Android, although I have just tested on the latest versions since those were my 346 00:34:15,080 --> 00:34:21,320 primary targets. So what is this? This is a library that you can include inside of your Android 347 00:34:21,320 --> 00:34:27,320 applications for dynamically swapping the behavior of methods from those that you would expect on 348 00:34:27,320 --> 00:34:33,420 disk. So it's doing all of the complicated calculations on the back end so that you don't have to 349 00:34:33,420 --> 00:34:36,600 to worry about calling the Java native interface directly or 350 00:34:36,600 --> 00:34:40,160 actually doing the calculations of those underlying bytes and 351 00:34:40,160 --> 00:34:46,760 native code. This works for your user methods. I have default 352 00:34:46,760 --> 00:34:50,660 methods that will take either an object or the signature of two 353 00:34:50,660 --> 00:34:53,880 methods that are defined inside of your application and you 354 00:34:53,880 --> 00:34:57,500 simply call the artful library that you very easily included 355 00:34:57,500 --> 00:35:00,800 into your app and then you can swap the behavior of any of 356 00:35:00,800 --> 00:35:03,940 those two methods. Additionally, I have some default 357 00:35:03,940 --> 00:35:08,420 Android framework official APIs that this will replace and you 358 00:35:08,420 --> 00:35:11,580 can call those and simply pass in the object that you would 359 00:35:11,580 --> 00:35:14,960 like that has your new custom code that's going to actually be 360 00:35:14,960 --> 00:35:18,520 run every time that Android framework method is called. Or 361 00:35:18,520 --> 00:35:20,940 you can call the first method and actually swap out different 362 00:35:20,940 --> 00:35:24,680 Android APIs if those are not implemented. Additionally, I 363 00:35:24,680 --> 00:35:29,520 included the dummy ART method class that's defined inside of 364 00:35:29,520 --> 00:35:30,780 the Android source code and it's actually going to be 365 00:35:30,800 --> 00:35:33,000 updated. So that you could print those offsets if you wanted to 366 00:35:33,000 --> 00:35:36,480 do additional calculations. And if you want to actually try this 367 00:35:36,480 --> 00:35:41,080 and extend it to support a different API version, all you 368 00:35:41,080 --> 00:35:43,660 need to do is take those variables that are defined 369 00:35:44,330 --> 00:35:49,700 inside of the ART method object of the specific API that you're 370 00:35:49,700 --> 00:35:52,840 trying to support and it will calculate the updated offsets 371 00:35:52,840 --> 00:35:58,500 for you. So let's go through and let's summarize some of our 372 00:35:58,500 --> 00:36:00,780 results. Press the start button and you'll see that it's 373 00:36:00,800 --> 00:36:03,100 running. Primarily the main challenges for this are 374 00:36:03,100 --> 00:36:06,980 understanding the code inside of the Android open source project. 375 00:36:07,260 --> 00:36:10,100 It might be open source but there's a lot of overhead that 376 00:36:10,100 --> 00:36:13,980 you need to understand to be able to actually follow the flow 377 00:36:13,980 --> 00:36:18,380 of control inside of the Android source code. You need to be able 378 00:36:18,380 --> 00:36:22,900 to follow from Java land over to native C++ land and understand 379 00:36:22,900 --> 00:36:25,760 where you're going. Additionally, you need to be able 380 00:36:25,760 --> 00:36:30,080 to know which Java target you have and be able to calculate the 381 00:36:30,080 --> 00:36:30,780 sizes of the data you're running into. So you can see the 382 00:36:30,800 --> 00:36:33,500 values of the underlying C++ objects that you're trying to 383 00:36:33,500 --> 00:36:39,060 manipulate. Also you have to do that complicated pointer math if 384 00:36:39,060 --> 00:36:42,700 you're trying to find the offset to a particular variable inside 385 00:36:42,700 --> 00:36:46,900 of the Android source code. And you also have to account for the 386 00:36:46,900 --> 00:36:50,760 differences in Android versions since with every single code 387 00:36:50,760 --> 00:36:54,480 change inside of every single Android API release or update, 388 00:36:54,880 --> 00:36:58,020 these calculations could be entirely different if they added 389 00:36:58,020 --> 00:37:00,780 additional functionality or if they were moved to the 390 00:37:00,800 --> 00:37:05,240 different variables from the source code. Now the benefits of 391 00:37:05,240 --> 00:37:08,060 this, if you're able to do that, is you're going to be able to 392 00:37:08,060 --> 00:37:12,160 avoid all of those standard class loader API calls from 393 00:37:12,160 --> 00:37:16,060 inside of your code and you're going to be able to completely 394 00:37:16,060 --> 00:37:20,300 avoid that dex class loader, path class loader, or any of 395 00:37:20,300 --> 00:37:24,220 those Java reflective calls. And this means that you're going to 396 00:37:24,220 --> 00:37:28,000 be able to execute unexpected code while the application is 397 00:37:28,000 --> 00:37:30,780 running. So if you have your two main classes, you're going to 398 00:37:30,780 --> 00:37:36,060 be able to define your entire custom code. And if a reverse 399 00:37:36,060 --> 00:37:39,780 engineer is taking a look at your application on disk, they 400 00:37:39,780 --> 00:37:43,240 won't realize that your actual target method is being invoked 401 00:37:43,240 --> 00:37:47,160 and they'll only see the invocations of the benign 402 00:37:47,160 --> 00:37:51,640 methods that appear on disk. So this effectively thwarts a lot of 403 00:37:51,640 --> 00:37:55,840 different reverse engineering and any static analysis of your 404 00:37:55,840 --> 00:37:59,360 binary so that you can further obfuscate and protect your 405 00:37:59,360 --> 00:38:00,760 applications without you having to worry about any of those 406 00:38:00,780 --> 00:38:06,300 use of the standard API calls. So here's an example of an 407 00:38:06,300 --> 00:38:11,620 application that I created using my artful library. And I had one 408 00:38:11,620 --> 00:38:15,300 call that's going to replace a benign method with a new method 409 00:38:15,300 --> 00:38:19,280 that had custom behavior inside of it. And I threw this again 410 00:38:19,280 --> 00:38:23,160 into my favorite Android decompiler, JDEX, and I just hit 411 00:38:23,160 --> 00:38:26,680 the cross references button and there's actually no references 412 00:38:26,680 --> 00:38:30,680 to this method. So if a reverse engineer is taking a look, top 413 00:38:30,780 --> 00:38:34,100 down from the application, they might entirely avoid actually 414 00:38:34,100 --> 00:38:37,440 looking at this method and never see that it's referenced and see 415 00:38:37,440 --> 00:38:43,260 that it's completely hidden. Additionally, this has no calls 416 00:38:43,260 --> 00:38:46,440 to those standard class loaders for dex class loader or path 417 00:38:46,440 --> 00:38:50,260 class loader or the standard Java reflective calls. So that 418 00:38:50,260 --> 00:38:54,240 means if you remember those frameworks that automatically 419 00:38:54,240 --> 00:38:57,960 hook a lot of relevant methods that reverse engineers will try 420 00:38:57,960 --> 00:39:00,760 to use to dump the dynamic code that's getting executed, they'll 421 00:39:00,780 --> 00:39:03,840 execute it on the system. All of those checks are going to 422 00:39:03,840 --> 00:39:07,220 actually fail and they're not going to be able to find these 423 00:39:07,220 --> 00:39:11,180 methods that are getting invoked. Now, they could try to hook the 424 00:39:11,180 --> 00:39:14,040 different Java native interface calls that are actually doing 425 00:39:14,040 --> 00:39:18,420 the manipulation of these methods. But those JNI calls 426 00:39:18,420 --> 00:39:22,800 actually look entirely benign since a lot of applications will 427 00:39:22,800 --> 00:39:25,620 use the Java native interface to communicate back and forth 428 00:39:25,620 --> 00:39:30,520 between their managed Java code and their native C++ code. So 429 00:39:30,780 --> 00:39:34,360 how would anybody know that this is actually an obfuscation 430 00:39:34,360 --> 00:39:39,540 technique? Now, go modify the Android runtime and you should be 431 00:39:39,540 --> 00:39:43,200 able to solve this. So thank you so much, everyone. 432 00:39:53,660 --> 00:39:57,300 So I do have time for questions if anybody wants to ask them. 433 00:39:57,440 --> 00:40:00,560 Otherwise, I'll step down up front if you would like to. 434 00:40:00,780 --> 00:40:04,880 You can ask me directly. And this, again, is another sketchy QR 435 00:40:04,880 --> 00:40:08,120 code, but it links to the Artful tool that I was talking about. So 436 00:40:08,120 --> 00:40:12,780 if you're feeling brave, go ahead and scan it. Yes? 437 00:40:45,800 --> 00:40:50,060 So the question was, if you're having reflective calls inside of 438 00:40:50,060 --> 00:40:53,120 Java code and you're having reflective calls inside of native 439 00:40:53,120 --> 00:40:57,540 code, how does this benefit if you're having those reflective 440 00:40:57,540 --> 00:41:00,760 calls inside of native code instead? So the way that you can 441 00:41:00,780 --> 00:41:02,760 calls. And the way that a lot of the hooking frameworks actually 442 00:41:02,760 --> 00:41:07,020 work is they'll hook these API calls no matter what if they're 443 00:41:07,020 --> 00:41:10,280 invoked from Java code or native code. It actually doesn't matter. 444 00:41:10,500 --> 00:41:15,960 So if you're using these JNI calls, yes, they could be hooked 445 00:41:15,960 --> 00:41:20,620 and analyzed by a reverse engineer. But there's nothing to 446 00:41:20,620 --> 00:41:24,280 say that they'll know exactly what's happening. They'll 447 00:41:24,280 --> 00:41:27,080 probably just be very, very confused and not realize that 448 00:41:27,080 --> 00:41:29,580 this is doing anything interesting. Since it's actually 449 00:41:29,580 --> 00:41:34,000 not commonly used as a dynamic code loading thing. It's 450 00:41:34,000 --> 00:41:37,860 basically just hooking the actual ART method object. So 451 00:41:37,860 --> 00:41:41,480 there's not any dynamic code loading happening since this 452 00:41:41,480 --> 00:41:44,360 method has already been loaded into the run time. So it 453 00:41:44,360 --> 00:41:54,620 basically just looks benign. Any other questions? All right. 454 00:41:54,680 --> 00:41:55,260 Thanks, everybody.