1 00:00:00,660 --> 00:00:01,493 ‫-: Hi. 2 00:00:01,493 --> 00:00:05,010 ‫Within this lecture, we are going to create an Android app, 3 00:00:05,010 --> 00:00:07,230 ‫which is a very basic app actually; 4 00:00:07,230 --> 00:00:09,090 ‫it's a Hello World App. 5 00:00:09,090 --> 00:00:11,880 ‫And then we're going to reverse engineer it, 6 00:00:11,880 --> 00:00:14,730 ‫or change or manipulate it 7 00:00:14,730 --> 00:00:16,620 ‫in a way that we 8 00:00:16,620 --> 00:00:20,520 ‫are going to leverage APK tool or JDX 9 00:00:20,520 --> 00:00:24,540 ‫to see what we are actually going to do, 10 00:00:24,540 --> 00:00:26,550 ‫how we are actually going to hack 11 00:00:26,550 --> 00:00:29,370 ‫into mobile applications in real world. 12 00:00:29,370 --> 00:00:31,590 ‫So this is going to be a practice, 13 00:00:31,590 --> 00:00:34,230 ‫a very basic fundamentals 14 00:00:34,230 --> 00:00:37,890 ‫of reverse engineering lesson for us. 15 00:00:37,890 --> 00:00:40,140 ‫So make sure you open your Android Studio, 16 00:00:40,140 --> 00:00:41,760 ‫and create a new project. 17 00:00:41,760 --> 00:00:42,810 ‫Okay. 18 00:00:42,810 --> 00:00:45,660 ‫Or you know already how to do that. 19 00:00:45,660 --> 00:00:49,560 ‫So I'm gonna start with empty project, empty activity. 20 00:00:49,560 --> 00:00:53,310 ‫I mean we are going to only need one activity, 21 00:00:53,310 --> 00:00:57,390 ‫and actually we are going to just display a few views 22 00:00:57,390 --> 00:00:59,430 ‫and with a simple, 23 00:00:59,430 --> 00:01:01,260 ‫few lines of code. 24 00:01:01,260 --> 00:01:05,103 ‫So I'm going to call this MyReverseApp, okay. 25 00:01:06,857 --> 00:01:09,240 ‫I'm not gonna change package name, I'm just, 26 00:01:09,240 --> 00:01:12,120 ‫I'm gonna go for Java here, 27 00:01:12,120 --> 00:01:13,800 ‫and for... 28 00:01:13,800 --> 00:01:15,360 ‫it really doesn't matter right now 29 00:01:15,360 --> 00:01:18,420 ‫if I choose Java or Kotlin at this point, 30 00:01:18,420 --> 00:01:21,780 ‫because we are going to reverse engineer it anyway, 31 00:01:21,780 --> 00:01:23,880 ‫but since we have learned Java, 32 00:01:23,880 --> 00:01:26,550 ‫I'm going to continue within Java. 33 00:01:26,550 --> 00:01:30,000 ‫A minimum API level is not important at this point. 34 00:01:30,000 --> 00:01:34,680 ‫You're more than welcome to continue with 23, for example. 35 00:01:34,680 --> 00:01:37,710 ‫Okay, make sure you open your project like this, 36 00:01:37,710 --> 00:01:39,540 ‫and make sure you wait 37 00:01:39,540 --> 00:01:41,790 ‫until it's finished building, 38 00:01:41,790 --> 00:01:45,780 ‫and then you can continue on editing your layout 39 00:01:45,780 --> 00:01:48,660 ‫and Java file as well. 40 00:01:48,660 --> 00:01:49,800 ‫So what we are gonna do, 41 00:01:49,800 --> 00:01:53,910 ‫we're going to create a very basic project as I said before, 42 00:01:53,910 --> 00:01:55,950 ‫and we're going to start learning 43 00:01:55,950 --> 00:01:58,710 ‫about fundamentals of reverse engineering, 44 00:01:58,710 --> 00:02:02,520 ‫and have a take a look at Dalvik bytecodes. 45 00:02:02,520 --> 00:02:05,010 ‫For example, we have seen the theory, 46 00:02:05,010 --> 00:02:07,110 ‫but we haven't seen even at 47 00:02:07,110 --> 00:02:09,690 ‫single Dalvik bytecode yet. 48 00:02:09,690 --> 00:02:11,670 ‫We don't know how it looks. 49 00:02:11,670 --> 00:02:13,800 ‫We're going to see a lot of those 50 00:02:13,800 --> 00:02:16,020 ‫in upcoming lectures. 51 00:02:16,020 --> 00:02:19,110 ‫So let me open my Java file over here. 52 00:02:19,110 --> 00:02:20,580 ‫So this is my Java file, 53 00:02:20,580 --> 00:02:22,200 ‫this is my activity. 54 00:02:22,200 --> 00:02:25,380 ‫If you have skipped android development section 55 00:02:25,380 --> 00:02:26,340 ‫for some reason, 56 00:02:26,340 --> 00:02:28,498 ‫I suggest you go back and watch that 57 00:02:28,498 --> 00:02:32,910 ‫if you don't know how to code in Java or in Kotlin, 58 00:02:32,910 --> 00:02:36,540 ‫if you don't know how to develop Android applications. 59 00:02:36,540 --> 00:02:37,560 ‫Okay. 60 00:02:37,560 --> 00:02:39,720 ‫So over here, 61 00:02:39,720 --> 00:02:40,950 ‫we are going to 62 00:02:40,950 --> 00:02:43,410 ‫not do anything right now, 63 00:02:43,410 --> 00:02:46,590 ‫because first of all we are going to have to 64 00:02:46,590 --> 00:02:48,120 ‫open our layout, 65 00:02:48,120 --> 00:02:49,560 ‫which is our... 66 00:02:49,560 --> 00:02:51,540 ‫main activity... 67 00:02:51,540 --> 00:02:53,070 ‫XML, 68 00:02:53,070 --> 00:02:54,780 ‫as you might remember. 69 00:02:54,780 --> 00:02:56,880 ‫And I'm going to say show layout decorations 70 00:02:56,880 --> 00:02:58,620 ‫to have our title bar, 71 00:02:58,620 --> 00:03:02,553 ‫and we're just going to start working on our layout. 72 00:03:03,480 --> 00:03:07,020 ‫So first, you can just get rid of this text view, 73 00:03:07,020 --> 00:03:07,853 ‫okay, 74 00:03:07,853 --> 00:03:09,393 ‫and bring in new wheels. 75 00:03:10,470 --> 00:03:14,490 ‫So all I want to do is display some TextViews 76 00:03:14,490 --> 00:03:17,660 ‫over here like Hello world or Hello Java 77 00:03:17,660 --> 00:03:19,410 ‫or Hello Reverse-Engineering, 78 00:03:19,410 --> 00:03:20,243 ‫okay. 79 00:03:20,243 --> 00:03:23,340 ‫So I'm going to bring in new TextViews, 80 00:03:23,340 --> 00:03:28,230 ‫maybe bring two so that we can see multiple 81 00:03:28,230 --> 00:03:32,730 ‫TextViews at one time, and we can see multiple views 82 00:03:32,730 --> 00:03:33,750 ‫and we can see actually 83 00:03:33,750 --> 00:03:37,020 ‫how it looks on Dalvik bytecode as well. 84 00:03:37,020 --> 00:03:40,230 ‫So as you can see we have TextView ID 85 00:03:40,230 --> 00:03:41,580 ‫on one of them, 86 00:03:41,580 --> 00:03:44,280 ‫and the other one should be named TextView two. 87 00:03:44,280 --> 00:03:46,680 ‫Of course, we can change the IDs 88 00:03:46,680 --> 00:03:48,510 ‫if we want like we did before 89 00:03:48,510 --> 00:03:52,320 ‫in the calculator lectures, for example. 90 00:03:52,320 --> 00:03:55,470 ‫And, we can actually connect those IDs 91 00:03:55,470 --> 00:03:58,830 ‫with our Java coding section, 92 00:03:58,830 --> 00:04:01,560 ‫by using FindView by Id comment, 93 00:04:01,560 --> 00:04:04,050 ‫maybe you remember that, right? 94 00:04:04,050 --> 00:04:06,840 ‫So this ID is very important, 95 00:04:06,840 --> 00:04:11,310 ‫and we can actually find these IDs in Dalvik bytecodes 96 00:04:11,310 --> 00:04:14,190 ‫or in reverse engineering as general. 97 00:04:14,190 --> 00:04:19,190 ‫So yeah, make sure your view has one of the IDs. 98 00:04:19,200 --> 00:04:23,730 ‫This is one of the reasons I deleted the default text 99 00:04:23,730 --> 00:04:25,500 ‫because it doesn't have an ID, 100 00:04:25,500 --> 00:04:28,500 ‫and people sometimes forget about adding IDs, 101 00:04:28,500 --> 00:04:31,380 ‫and they actually experience some problems. 102 00:04:31,380 --> 00:04:32,490 ‫As you can see, 103 00:04:32,490 --> 00:04:36,270 ‫we have this text over here which is TextView 104 00:04:36,270 --> 00:04:39,240 ‫right now what we can change it anytime we want, 105 00:04:39,240 --> 00:04:41,190 ‫like this, Hello Java. 106 00:04:41,190 --> 00:04:44,400 ‫Okay, we can make this bigger like that, 107 00:04:44,400 --> 00:04:46,740 ‫and we can move this around 108 00:04:46,740 --> 00:04:49,680 ‫anywhere we want on our screen. 109 00:04:49,680 --> 00:04:52,650 ‫We can come over here and we can make this 110 00:04:52,650 --> 00:04:54,030 ‫like central, 111 00:04:54,030 --> 00:04:55,530 ‫we can increase 112 00:04:55,530 --> 00:04:58,950 ‫the font size like that. 113 00:04:58,950 --> 00:05:00,340 ‫We can just choose 114 00:05:00,340 --> 00:05:02,550 ‫18 or 20, 115 00:05:02,550 --> 00:05:04,803 ‫whatever we want from here. 116 00:05:05,640 --> 00:05:06,900 ‫And... 117 00:05:06,900 --> 00:05:08,340 ‫yeah, you can make this bold, 118 00:05:08,340 --> 00:05:09,960 ‫you can make this italic, 119 00:05:09,960 --> 00:05:13,110 ‫you can make this anything you want. 120 00:05:13,110 --> 00:05:15,450 ‫I'm gonna leave it as it is, 121 00:05:15,450 --> 00:05:17,550 ‫and move on to the next one. 122 00:05:17,550 --> 00:05:21,060 ‫So let me bring this into center as well, 123 00:05:21,060 --> 00:05:22,590 ‫like that, 124 00:05:22,590 --> 00:05:25,710 ‫and let me just change this text 125 00:05:25,710 --> 00:05:27,810 ‫to Hello World, 126 00:05:27,810 --> 00:05:30,330 ‫or Hello reverse-engineering, 127 00:05:30,330 --> 00:05:32,010 ‫Hello Android, 128 00:05:32,010 --> 00:05:34,140 ‫whatever you want, okay. 129 00:05:34,140 --> 00:05:36,300 ‫Just make it into central, 130 00:05:36,300 --> 00:05:39,330 ‫and just change the text. 131 00:05:39,330 --> 00:05:41,010 ‫So here you go. 132 00:05:41,010 --> 00:05:44,370 ‫We have Hello Java and we have a Hello Android. 133 00:05:44,370 --> 00:05:45,203 ‫Great. 134 00:05:46,080 --> 00:05:48,750 ‫Once you are done over here, 135 00:05:48,750 --> 00:05:50,760 ‫you can just come over here to 136 00:05:50,760 --> 00:05:52,980 ‫hit on infer constraints buttons; 137 00:05:52,980 --> 00:05:56,520 ‫It adds some constraints, remember these are for locating 138 00:05:56,520 --> 00:05:58,620 ‫the views in a proper way, 139 00:05:58,620 --> 00:06:00,120 ‫on our activity. 140 00:06:00,120 --> 00:06:01,380 ‫If we don't do that, 141 00:06:01,380 --> 00:06:03,060 ‫it will be concentrated 142 00:06:03,060 --> 00:06:06,180 ‫on the left, upper side of our activity, 143 00:06:06,180 --> 00:06:07,710 ‫which is not what we want, 144 00:06:07,710 --> 00:06:11,100 ‫so make sure you hit the Infer Constraints, 145 00:06:11,100 --> 00:06:12,840 ‫but after you're done 146 00:06:12,840 --> 00:06:14,520 ‫with your design. 147 00:06:14,520 --> 00:06:15,900 ‫Of course you're more than welcome 148 00:06:15,900 --> 00:06:17,490 ‫to change the other attributes, 149 00:06:17,490 --> 00:06:19,230 ‫like you can change the text color, 150 00:06:19,230 --> 00:06:23,310 ‫you can change whatever you want from the attributes pane, 151 00:06:23,310 --> 00:06:25,710 ‫but I'm not gonna do that, okay. 152 00:06:25,710 --> 00:06:27,180 ‫We're not here for that. 153 00:06:27,180 --> 00:06:29,670 ‫But rather I'm just gonna go for this 154 00:06:29,670 --> 00:06:32,760 ‫main activity Java section. 155 00:06:32,760 --> 00:06:35,610 ‫So over here, what do we do? 156 00:06:35,610 --> 00:06:38,910 ‫So we can actually connect 157 00:06:38,910 --> 00:06:40,343 ‫our TextViews, 158 00:06:40,343 --> 00:06:43,080 ‫our main activity.Java, right? 159 00:06:43,080 --> 00:06:45,210 ‫So that we can change the attributes 160 00:06:45,210 --> 00:06:46,500 ‫like change the text, 161 00:06:46,500 --> 00:06:47,700 ‫change the text color, 162 00:06:47,700 --> 00:06:51,180 ‫change the font size from there as well. 163 00:06:51,180 --> 00:06:53,040 ‫Even though I hit the round button, 164 00:06:53,040 --> 00:06:55,200 ‫it isn't open yet. 165 00:06:55,200 --> 00:06:56,880 ‫And this is one of the app's 166 00:06:56,880 --> 00:06:58,770 ‫that we're going to work on later on. 167 00:06:58,770 --> 00:07:02,070 ‫It's a three door app and we're going to hack it. 168 00:07:02,070 --> 00:07:03,420 ‫So... 169 00:07:03,420 --> 00:07:05,460 ‫let's wait until it's finished. 170 00:07:05,460 --> 00:07:07,500 ‫Yeah, I believe now it's finished. 171 00:07:07,500 --> 00:07:11,370 ‫And let's open our emulator and see how it looks. 172 00:07:11,370 --> 00:07:12,480 ‫Yeah, it looks great. 173 00:07:12,480 --> 00:07:13,920 ‫Hello Java, Hello Andre. 174 00:07:13,920 --> 00:07:16,110 ‫This is exactly what we want. 175 00:07:16,110 --> 00:07:20,610 ‫Now for just example, let's try to connect all these views 176 00:07:20,610 --> 00:07:23,070 ‫into our Java coding section, 177 00:07:23,070 --> 00:07:27,240 ‫and then change the text using our 178 00:07:27,240 --> 00:07:31,980 ‫code methods like set text like we have seen before, right? 179 00:07:31,980 --> 00:07:34,290 ‫So you know how to do that. 180 00:07:34,290 --> 00:07:36,240 ‫I suggest you pause the video, 181 00:07:36,240 --> 00:07:37,920 ‫and close this down, 182 00:07:37,920 --> 00:07:39,960 ‫and try to define 183 00:07:39,960 --> 00:07:42,570 ‫TextViews on your onCreate, 184 00:07:42,570 --> 00:07:47,280 ‫and then just change the TextView to whatever you want 185 00:07:47,280 --> 00:07:50,283 ‫like hello, your name for example, okay. 186 00:07:51,330 --> 00:07:53,580 ‫I hope you managed to do that. 187 00:07:53,580 --> 00:07:55,080 ‫It's really easy. 188 00:07:55,080 --> 00:07:58,140 ‫Again, if you skip the under development section, 189 00:07:58,140 --> 00:08:00,570 ‫I suggest you go back and watch it, 190 00:08:00,570 --> 00:08:03,363 ‫because we have already covered this. 191 00:08:04,230 --> 00:08:05,580 ‫So in order to do that, 192 00:08:05,580 --> 00:08:07,410 ‫we start with 193 00:08:07,410 --> 00:08:08,700 ‫the class type, 194 00:08:08,700 --> 00:08:11,730 ‫like the type of the object that we are going to define, 195 00:08:11,730 --> 00:08:13,080 ‫like TextView. 196 00:08:13,080 --> 00:08:14,160 ‫Okay. 197 00:08:14,160 --> 00:08:16,740 ‫And if you get an error like this, 198 00:08:16,740 --> 00:08:20,550 ‫all you have to do is just hit Alt + Enter on your keyboard, 199 00:08:20,550 --> 00:08:23,790 ‫and it will import the class over here. 200 00:08:23,790 --> 00:08:26,130 ‫As you can see we now have import 201 00:08:26,130 --> 00:08:27,780 ‫under it's widget TextView. 202 00:08:27,780 --> 00:08:30,900 ‫So it's recognized by our activity, 203 00:08:30,900 --> 00:08:33,330 ‫and then you can give it a name 204 00:08:33,330 --> 00:08:36,090 ‫like TextView or you can call it 205 00:08:36,090 --> 00:08:39,390 ‫Jack or Brian, whatever your name is. 206 00:08:39,390 --> 00:08:40,223 ‫Okay. 207 00:08:40,223 --> 00:08:42,600 ‫But it's not very conventional, 208 00:08:42,600 --> 00:08:44,760 ‫it's not how we do that. 209 00:08:44,760 --> 00:08:48,210 ‫The developers generally gives some real names 210 00:08:48,210 --> 00:08:50,520 ‫like a reasonable name, 211 00:08:50,520 --> 00:08:52,080 ‫like a TextView. 212 00:08:52,080 --> 00:08:55,260 ‫They don't give up names like this text we want, 213 00:08:55,260 --> 00:08:57,720 ‫but something like result text 214 00:08:57,720 --> 00:09:00,180 ‫or name displaying text or something, 215 00:09:00,180 --> 00:09:03,210 ‫you have to understand what it does, okay. 216 00:09:03,210 --> 00:09:07,830 ‫But in our case, it's very easy to name a text we want, 217 00:09:07,830 --> 00:09:12,720 ‫because we will only have two views in this activity 218 00:09:12,720 --> 00:09:16,170 ‫and I believe we won't confuse them later on. 219 00:09:16,170 --> 00:09:19,380 ‫So TextView is the type and text we want, 220 00:09:19,380 --> 00:09:22,710 ‫is the name of the object that we are going to create 221 00:09:22,710 --> 00:09:24,813 ‫from TextView class. 222 00:09:25,650 --> 00:09:29,340 ‫So after doing that, we can actually connect it 223 00:09:29,340 --> 00:09:31,980 ‫with the layout that we have. 224 00:09:31,980 --> 00:09:35,850 ‫And we use FindView by ID method in order to do that. 225 00:09:35,850 --> 00:09:39,000 ‫And it will ask for an ID as a parameter. 226 00:09:39,000 --> 00:09:42,000 ‫So this is the ID that I was talking about. 227 00:09:42,000 --> 00:09:45,213 ‫So I'm going to say are that R.id.textView, 228 00:09:46,080 --> 00:09:49,260 ‫as you can see, we can see the both of the text 229 00:09:49,260 --> 00:09:51,750 ‫over here like textView, textView two. 230 00:09:51,750 --> 00:09:54,810 ‫So first one will be textView, 231 00:09:54,810 --> 00:09:57,360 ‫and we are gonna do that from scratch. 232 00:09:57,360 --> 00:09:58,650 ‫TextView, 233 00:09:58,650 --> 00:10:01,260 ‫and I'm gonna call this textView two, 234 00:10:01,260 --> 00:10:06,260 ‫and just say findViewById R.id.textView two. 235 00:10:06,930 --> 00:10:09,570 ‫So this is how we connect TextViews 236 00:10:09,570 --> 00:10:13,110 ‫or any views to our coding section. 237 00:10:13,110 --> 00:10:15,773 ‫And then we can actually use this variables: 238 00:10:15,773 --> 00:10:18,900 ‫textView one and textView two like this. 239 00:10:18,900 --> 00:10:21,210 ‫In order to change the attributes, 240 00:10:21,210 --> 00:10:26,210 ‫like, I can just say texView one dot setText, for example. 241 00:10:26,940 --> 00:10:28,648 ‫And it will change the text 242 00:10:28,648 --> 00:10:30,660 ‫of the text views 243 00:10:30,660 --> 00:10:33,390 ‫once this activity is created. 244 00:10:33,390 --> 00:10:37,740 ‫So we can reach all the attributes that we see from here, 245 00:10:37,740 --> 00:10:39,930 ‫from there as well like this. 246 00:10:39,930 --> 00:10:41,400 ‫So if you hit that, 247 00:10:41,400 --> 00:10:45,210 ‫you can see all the attributes here as well. 248 00:10:45,210 --> 00:10:47,040 ‫So you can get the attributes 249 00:10:47,040 --> 00:10:52,040 ‫or you can set the attributes from this page here right now. 250 00:10:52,590 --> 00:10:56,820 ‫So I'm going to say textView one dot setText. 251 00:10:56,820 --> 00:11:00,540 ‫And over here, I'm going to open double quotation marks 252 00:11:00,540 --> 00:11:02,583 ‫because this is a strength, remember. 253 00:11:03,630 --> 00:11:05,520 ‫We've talked about strengths. 254 00:11:05,520 --> 00:11:10,520 ‫So I'm going to say Hello World rather than Hello Java. 255 00:11:10,680 --> 00:11:15,000 ‫And for textView two, I'm going to say again 256 00:11:15,000 --> 00:11:18,360 ‫one more time something like Hello World two. 257 00:11:18,360 --> 00:11:19,680 ‫So this is great. 258 00:11:19,680 --> 00:11:23,611 ‫Now rather than seeing Hello Java or Hello World, 259 00:11:23,611 --> 00:11:26,010 ‫we are going to say Hello World and Hello World two 260 00:11:26,010 --> 00:11:29,130 ‫because it's called in onCreate. 261 00:11:29,130 --> 00:11:32,640 ‫Remember, onCreate is the first method 262 00:11:32,640 --> 00:11:34,980 ‫to be called when an activity 263 00:11:34,980 --> 00:11:38,190 ‫is actually fired up and when an activity started. 264 00:11:38,190 --> 00:11:41,310 ‫So user will see Hello World and Hello World two, 265 00:11:41,310 --> 00:11:44,430 ‫rather than Hello Java or other thing, 266 00:11:44,430 --> 00:11:48,330 ‫because this is called even before user sees 267 00:11:48,330 --> 00:11:51,120 ‫the activity itself like this. 268 00:11:51,120 --> 00:11:54,210 ‫Here you go, Hello World and Hello World two. 269 00:11:54,210 --> 00:11:58,800 ‫I believe I hit the uppercase button in the attribute, 270 00:11:58,800 --> 00:12:00,810 ‫so it's all in uppercase right now. 271 00:12:00,810 --> 00:12:02,370 ‫Hello Java, Hello World. 272 00:12:02,370 --> 00:12:03,600 ‫It really doesn't matter, 273 00:12:03,600 --> 00:12:05,910 ‫it's an attribute for TextViews. 274 00:12:05,910 --> 00:12:08,130 ‫So if you want to display them in lower case, 275 00:12:08,130 --> 00:12:09,870 ‫you can just undo it, 276 00:12:09,870 --> 00:12:12,540 ‫but it doesn't matter in our case. 277 00:12:12,540 --> 00:12:15,900 ‫So we have built our Hello World application. 278 00:12:15,900 --> 00:12:17,700 ‫Now it's time to manipulate it 279 00:12:17,700 --> 00:12:19,950 ‫or it's time to reverse engineer it 280 00:12:19,950 --> 00:12:21,600 ‫to see what we have learned 281 00:12:21,600 --> 00:12:25,140 ‫in the previous section to practice what we have learned 282 00:12:25,140 --> 00:12:28,500 ‫in the previous section to learn the details 283 00:12:28,500 --> 00:12:31,350 ‫of JDX and a APK tool as well. 284 00:12:31,350 --> 00:12:35,373 ‫So let's stop here and meet me in the near lecture.