1 00:00:00,000 --> 00:00:02,060 How y'all doing? 2 00:00:02,100 --> 00:00:08,260 Thank you for joining us here for our reverse engineering talk. 3 00:00:08,780 --> 00:00:12,660 It's my pleasure to introduce Sydney Jones. 4 00:00:12,660 --> 00:00:23,620 She's a cyber security researcher with expertise in reverse engineering, vulnerability assessment and AI evaluation. 5 00:00:23,620 --> 00:00:41,060 Today she'll be presenting RE for the rest of us, an introduction to reverse engineering, a beginner-friendly session that explores both software and hardware, RE using Arduino and Ghidra. 6 00:00:41,060 --> 00:00:51,510 From toggling LEDs to inspecting binary behavior, Sydney will walk you through our fundamentals in a hands-on, engaging way. 7 00:00:51,650 --> 00:00:54,670 Please join me in welcoming Sydney Jones. 8 00:00:54,670 --> 00:00:55,410 Yay! 9 00:00:56,630 --> 00:00:57,990 Thank you. 10 00:01:01,240 --> 00:01:03,040 Hello, hello, everyone. 11 00:01:03,220 --> 00:01:08,300 This is my second talk that I've given at DEF CON, and I'm truly happy that you're all here. 12 00:01:08,380 --> 00:01:11,040 So first to just talk a little bit about myself. 13 00:01:13,200 --> 00:01:15,440 I've already had a great introduction. 14 00:01:16,140 --> 00:01:17,680 I'm currently a Ph.D. 15 00:01:17,680 --> 00:01:23,160 student at Virginia Tech, and reverse engineering is something that I'm starting to learn more about. 16 00:01:23,160 --> 00:01:27,180 And so for me, it's like, as I learn, I want to be able to teach at the same time. 17 00:01:28,560 --> 00:01:31,640 But outside of work and school, I also have some other interests. 18 00:01:31,640 --> 00:01:33,780 My other interests are gaming. 19 00:01:33,780 --> 00:01:35,140 I like Animal Crossing. 20 00:01:35,140 --> 00:01:37,460 That's a picture of my Animal Crossing house. 21 00:01:37,520 --> 00:01:40,880 So it's like all pink, and I've done all the possible upgrades. 22 00:01:41,180 --> 00:01:44,860 Like my bank account on Animal Crossing is high. 23 00:01:46,060 --> 00:01:48,900 And then I love Apothecary Diaries. 24 00:01:49,820 --> 00:01:52,440 That's one of my favorite ones going on right now. 25 00:01:52,440 --> 00:01:55,140 I also like painting, like acrylic and watercolor. 26 00:01:55,340 --> 00:02:00,220 And that's a photo of me when I went to Paris last, and it was amazing. 27 00:02:03,270 --> 00:02:05,610 So to quickly talk about our agenda. 28 00:02:06,410 --> 00:02:09,890 First, we're going to talk about an intro of what is reverse engineering. 29 00:02:09,890 --> 00:02:16,750 But then we're going to have to start doing a lot of exercises, and it's going to go like really fast for us to complete everything. 30 00:02:16,750 --> 00:02:22,130 We're going to do a continuity test on our Arduino board using the multimeters that were handed out. 31 00:02:22,310 --> 00:02:33,010 We're also going to identify the different chips on the board to see like, oh, this is your whole, like, this is the chip, and this is what it does. 32 00:02:33,410 --> 00:02:37,470 We're then going to look at assembly, and look at the executable. 33 00:02:37,470 --> 00:02:47,690 We're going to flash firmware to the Arduino Uno, and then we're going to go use Ghidra, and show the executable code being decompiled. 34 00:02:47,690 --> 00:02:52,010 And then lastly, we'll talk about any takeaways and resources. 35 00:02:54,470 --> 00:03:02,150 So since we are moving fast through this, if you're interested, download Ghidra here. 36 00:03:02,230 --> 00:03:09,270 And if you're interested in flashing the firmware to the Arduino board, go to this GitHub website. 37 00:03:09,830 --> 00:03:16,130 So that's why I have a picture of Anya there, because we're like, she's Russian, and we'll be moving fast as well. 38 00:03:16,410 --> 00:03:24,290 But also, if you have any questions, like, please stop me, because I want us to be very involved, and for everybody to feel like they gained a lot from this talk as well. 39 00:03:24,390 --> 00:03:33,070 Reverse engineering is the process of analyzing an existing item to extract technical information required to reproduce or understand it. 40 00:03:33,290 --> 00:03:36,890 So reverse engineering looks at something to see how it works. 41 00:03:36,890 --> 00:03:45,530 The goal is not only to replicate it, but it's also to understand the security structure, logic, and it could be hardware-based or more software-based. 42 00:03:45,530 --> 00:03:52,510 A lot of times with reverse engineering, we're either starting out with hardware that's broken, or if we do have software, we only have part of it. 43 00:03:52,510 --> 00:03:54,630 So we have source code, but we don't have it... 44 00:03:55,350 --> 00:03:59,290 we don't have the binary yet, or we have binary with no source code. 45 00:04:00,130 --> 00:04:10,930 But also, reverse engineering involves having physical access to the hardware, and a lot of times we look at data sheets, and we try to find any existing documentation. 46 00:04:13,030 --> 00:04:31,830 Hardware RE is the process of actually taking apart a physical device and looking at it bit by bit to examine the components, whereas software RE is the process of looking at the binary source code that we see on the slide and taking it back to something that is human-readable. 47 00:04:32,810 --> 00:04:38,470 It's also useful for analyzing malware, validating software, or recovering lost code. 48 00:04:39,570 --> 00:04:41,410 So physical disassembly. 49 00:04:41,410 --> 00:04:46,170 We have our meme, we have our sandwich, and we have our sandwich disassembled. 50 00:04:46,170 --> 00:04:55,050 So this is when we take apart tools, and we use specialized tools such as a heat gun to physically remove the different components. 51 00:04:55,050 --> 00:05:00,270 Now, we're not going to do that here with the Arduinos, but that's the main point with this one. 52 00:05:00,270 --> 00:05:03,850 This also comes into play when people are fixing cell phones. 53 00:05:04,050 --> 00:05:07,930 They also take your screen off your phone and just replace it. 54 00:05:07,930 --> 00:05:11,130 That's a part of the physical disassembly process. 55 00:05:13,630 --> 00:05:23,530 So another step when it comes to reverse engineering is we want to identify the different components on our IC board, and we want to look at all the part numbers. 56 00:05:23,770 --> 00:05:26,270 We want to look up the data sheets for each chip. 57 00:05:26,810 --> 00:05:34,030 And to do this, we could simply use a Google reverse image search, or we can use sites like Octopart to identify the components. 58 00:05:36,750 --> 00:05:38,930 So this is our first exercise. 59 00:05:39,390 --> 00:05:44,670 You're going to identify the different IC boards. 60 00:05:44,850 --> 00:05:55,450 So on your Arduino board, we're going to pick one component, write or take a note of the part number, look up the data sheet, and then we want to answer three questions. 61 00:05:55,590 --> 00:05:56,810 What does it do? 62 00:05:56,870 --> 00:05:58,550 How many pins does it have? 63 00:05:58,550 --> 00:06:01,970 And what interfaces or protocols does it use? 64 00:06:03,870 --> 00:06:09,370 So I put that on a slide because I know that it was really hard to see on the boards. 65 00:06:10,810 --> 00:06:16,070 And then I also have a zoomed in picture so that everyone could actually see it. 66 00:06:16,830 --> 00:06:31,850 So the goal is we'll take about five minutes, and we'll search up the this part number, and we want to include the maker, which is Atmel, and we want to include all the number here, and then answer those three questions. 67 00:06:32,530 --> 00:06:33,850 What does it do? 68 00:06:33,850 --> 00:06:35,430 How many pins does it have? 69 00:06:35,470 --> 00:06:37,990 And what interfaces does it use? 70 00:06:38,390 --> 00:06:41,410 And then I'll set a timer for like five minutes. 71 00:06:45,810 --> 00:06:52,470 Also, during this time, if there are any questions, you can ask a question related to the exercise too. 72 00:06:53,630 --> 00:07:14,770 And also, as like a cheat code for this, the GitHub link that I did show earlier for my GitHub, it's... if you have the GitHub code, I mean the GitHub link from earlier, you could just go there, and there will be data sheets to search from instead of having to go online. 73 00:07:16,170 --> 00:07:18,330 I can just show that as well. 74 00:07:18,330 --> 00:07:23,770 So like, go to this GitHub, and then there are data sheets there. 75 00:07:24,510 --> 00:07:27,570 Has anybody found... has anybody found one? 76 00:07:30,310 --> 00:07:30,950 All right. 77 00:07:30,950 --> 00:07:33,290 Well, I'll just go... I'll go into it. 78 00:07:33,570 --> 00:07:34,610 Well, actually, no. 79 00:07:34,730 --> 00:07:37,790 Does anybody have a solution for the first one? 80 00:07:38,530 --> 00:07:44,670 Like with the... with this first Atmel Omega 16, what that does? 81 00:07:46,950 --> 00:07:48,030 Yep. 82 00:07:48,030 --> 00:07:49,030 Okay. 83 00:07:49,030 --> 00:07:49,890 Thank you. 84 00:07:49,890 --> 00:07:51,090 Thank you. 85 00:07:51,090 --> 00:07:52,590 All right. 86 00:07:52,830 --> 00:07:58,830 So, this board here, this is a serial... a USB to serial converter. 87 00:07:58,830 --> 00:08:04,870 It has 32 pins, and it uses UART serial as well as USB. 88 00:08:05,290 --> 00:08:18,830 And the reason why I included this picture is because looking at the data sheet does tell me all that information, but also when I look at the board, I can see that all these connections here, they actually connect to our USB port right here. 89 00:08:18,950 --> 00:08:26,270 So, I know that's like, okay, it's some... it probably has something to do with that component, and I know it's connected to this too. 90 00:08:26,390 --> 00:08:33,590 I can see it connects to other stuff, like maybe my oscillator that's right next to it, some resistors. 91 00:08:33,610 --> 00:08:42,510 So, it's like I'm I'm taking my visual knowledge into account, but then also leaning on the knowledge I gained from the data sheet too. 92 00:08:44,490 --> 00:09:01,150 The next one, this is a 16 megahertz crystal oscillator, and this board is going to be present on... this component is going to be present on most chips because it provides a clock signal that drives... that allows timing for your microcontroller. 93 00:09:01,150 --> 00:09:02,790 It only has two pins. 94 00:09:02,790 --> 00:09:14,270 This is a passive timing component, so it doesn't have any interfaces or protocols, but without this oscillator, the processor wouldn't know how to do a wait command or a delay command. 95 00:09:14,770 --> 00:09:19,970 It would... and this is essential for running everything at the right pace. 96 00:09:21,250 --> 00:09:37,230 Then, next, we have a 47... I think it's called a farad, like micro farad, 25 volt capacitor, and this is important for how we power up our board. 97 00:09:37,230 --> 00:09:49,530 So, our board has two different voltage outputs, a 5 volt and a 2 point... and a 3.3, and our capacitor allows both of those supplies to happen without having any voltage fluctuations. 98 00:09:50,790 --> 00:09:55,230 And this also has two pins, and this is also a passive, just normal component. 99 00:09:57,290 --> 00:10:10,450 And then, lastly, we have our 18 mega, and so this allows us to have our... this is the brain of the Arduino, and this handle handles our input and output and controls peripherals. 100 00:10:10,450 --> 00:10:14,330 It has 28 pins and uses UART. 101 00:10:15,370 --> 00:10:26,930 And because of our 18 mega, these are the 18 mega pins here, and these are our digital pins, we see that it actually bridges the connection there, so it's directly connected to the board. 102 00:10:27,630 --> 00:10:33,170 Like, we could see, like, how it's set up by just the... like our circuit setup. 103 00:10:36,610 --> 00:10:41,650 And this is also important for later on when we use our digital write and digital read commands. 104 00:10:44,260 --> 00:10:51,720 So next, to continue our hardware reverse engineering process, we want to check the board's connectivity. 105 00:10:51,960 --> 00:10:54,900 Sometimes you might order a part and you're like, does this really work? 106 00:10:54,900 --> 00:10:58,720 So we have our multimeters here to make sure that it actually does. 107 00:10:58,720 --> 00:11:05,240 So we want to locate voltage and ground, identify our power and ground pins, and then do a continuity trace. 108 00:11:05,440 --> 00:11:13,080 There are so many times where if the board connects... is ever exposed to too much heat, it won't work the same, and then our continuity test will actually end up failing. 109 00:11:13,680 --> 00:11:16,060 So it's important to sometimes check this. 110 00:11:17,340 --> 00:11:26,700 So not only will I tell you the steps, I'm also going to show a video of how to do it, and then for the people that do have multimeters, you can go and also do this test live too. 111 00:11:27,140 --> 00:11:32,860 So first step is to look at the back of the Arduino board and see the soldered traces. 112 00:11:33,200 --> 00:11:36,480 Choose a single line to trace like I have here. 113 00:11:38,060 --> 00:11:47,780 Place one like your positive probe on at one end and the negative on the other, and then you're going to put your multimeter in continuity mode. 114 00:11:48,160 --> 00:11:51,040 I also have the video as well. 115 00:11:52,820 --> 00:11:57,200 And so for this one, our Arduino is not plugged in yet, so we're all good there. 116 00:11:57,200 --> 00:12:14,000 So for this one, first connect your black and red cords to your multimeter, and then you also want to switch to your continuity mode. 117 00:12:14,980 --> 00:12:19,400 And then once it's on, you're automatically going to see a zero L, and that means open loop. 118 00:12:20,060 --> 00:12:26,600 And then... okay, I hear beep, so that means that somebody might have it working. 119 00:12:29,100 --> 00:12:42,320 Then once you hear... then once it is like actually connected right, you know it's connected because you're going to hear a beeping sound, and you're also going to see 0.00, and that means that you have a zero ohm resistance. 120 00:12:43,220 --> 00:12:52,260 But I just want to give everyone like a chance, like and even if you have your multimeter, you could also hand it to someone like close by and allow them to do the test as well. 121 00:12:52,580 --> 00:12:58,440 But I'll just stop for like a minute or maybe two and just have everyone do the test. 122 00:12:59,420 --> 00:13:04,080 For those doing the continuity test, is it going okay so far? 123 00:13:08,850 --> 00:13:10,930 All right, I think we're all good there. 124 00:13:15,460 --> 00:13:30,640 All right, so now that we've successfully completed the continuity test, another test we could do that I'll just show up here for time so that we can get to other parts is that we also want to test our voltage. 125 00:13:30,900 --> 00:13:38,300 Sometimes this is very important as well because we want to make sure that it's actually functioning as expected. 126 00:13:38,540 --> 00:13:44,020 So what I did was I had a... I hear something working, so that's good. 127 00:13:44,880 --> 00:13:51,640 So I had the three point... I'm testing both my 3.3 and my five voltage outputs to make sure that they're working as they should. 128 00:13:52,920 --> 00:14:00,800 And I see that I have my five volts and I see I have 3.3, so this is just important to make sure that your board works. 129 00:14:03,260 --> 00:14:09,060 All right, so now that we've done that, we're also going to locate our diagnostic ports. 130 00:14:09,060 --> 00:14:11,740 This is another step to hardware reverse engineering. 131 00:14:12,500 --> 00:14:16,500 This provides direct access to the device's internal systems. 132 00:14:16,860 --> 00:14:21,960 Many times you'll have UART, JTAG that allow you to read your system memory. 133 00:14:23,180 --> 00:14:28,980 Shout out to everybody who had... I hear the beep, so I know that it was actually... that y'all had it working, which is cool. 134 00:14:29,640 --> 00:14:39,680 These ports... the ports such as UART and JTAG allow you to bypass many security mechanisms and are valuable to extracting and analyzing your firmware. 135 00:14:39,800 --> 00:14:42,340 And in our Arduino board, that's our focus for this one. 136 00:14:42,340 --> 00:14:49,840 We have a USB socket, a USB type B socket, but this I included as well to just show all the different types of USB. 137 00:14:51,660 --> 00:14:56,640 So now that we've done that, we've completed our hardware part. 138 00:14:56,640 --> 00:15:01,640 Just like Ash, we actually want to collect all the possible firmware extraction. 139 00:15:06,970 --> 00:15:08,170 All right. 140 00:15:08,170 --> 00:15:09,530 It sounds like y'all got it. 141 00:15:09,530 --> 00:15:10,330 That's good. 142 00:15:11,750 --> 00:15:14,770 We want to collect all the possible firmware extraction. 143 00:15:19,590 --> 00:15:27,570 But instead of Ash collecting Pokemon, we want to pull all the different firmware and binaries as possible. 144 00:15:27,670 --> 00:15:34,190 So now we're more so transitioning into a more software-based focus instead of before we were more like hardware-based focus. 145 00:15:34,410 --> 00:15:47,570 So typically to extract your firmware on your Arduino, we want to use the USB port, and we're going to extract it from the bootloader. 146 00:15:48,550 --> 00:16:03,030 And we normally would use tools like AVR Dude, or I don't know how most people do pronounce that one, but we're going to use our tools that allow us to take the contents of the microcontroller's flash memory and save it as a binary file. 147 00:16:03,030 --> 00:16:05,170 Now, in our case, I've made this very easy for us. 148 00:16:05,170 --> 00:16:08,450 I already have the ELF file ready for download. 149 00:16:08,450 --> 00:16:16,150 So instead of having to use the tool and pull the firmware from each of these yourself, the binary is already ready to go. 150 00:16:18,170 --> 00:16:20,970 But this is a very important step overall. 151 00:16:21,270 --> 00:16:27,170 Once we have our binary file, we're then going to do flash analysis. 152 00:16:27,770 --> 00:16:33,170 First we're going to extract the embedded files using tools like Flash ROM. 153 00:16:33,170 --> 00:16:37,350 Then we would use Binwalk to identify the file structure and format. 154 00:16:37,350 --> 00:16:40,850 It's going to tell me do I have an ELF file or an EXE file. 155 00:16:40,930 --> 00:16:45,590 Then we're going to analyze any systems present using Ghidra. 156 00:16:45,590 --> 00:16:49,150 We might find strings, we might find passwords, stuff like that. 157 00:16:50,190 --> 00:16:55,490 And then also we could use tools like Floss or GREP to find more sensitive data. 158 00:16:59,280 --> 00:17:01,720 And we will walk through like this process. 159 00:17:01,720 --> 00:17:03,800 We're actually going to walk through this later on. 160 00:17:05,700 --> 00:17:10,580 Another important discussion to have is to talk about our different binary formats. 161 00:17:10,700 --> 00:17:14,100 So for us, we're looking at an Arduino and it has an ELF format. 162 00:17:14,360 --> 00:17:17,460 That stands for executable and linkable format. 163 00:17:17,720 --> 00:17:21,500 And that is because Arduino is more like a Linux based system. 164 00:17:21,500 --> 00:17:23,180 It's also open source. 165 00:17:24,300 --> 00:17:30,760 And these type of files could be analyzed using Abijay Jump and GDB. 166 00:17:31,480 --> 00:17:34,020 But also EXEs are important as well. 167 00:17:34,020 --> 00:17:36,080 And these are more Windows based systems. 168 00:17:36,520 --> 00:17:40,240 All tools will still work, but Ghidra and IDA Pro are more popular. 169 00:17:44,170 --> 00:17:47,010 So we also got to discuss disassembly. 170 00:17:47,270 --> 00:17:52,750 Because any time we have a binary, we must disassemble it so that we can get it back into human readable format. 171 00:17:53,250 --> 00:18:00,050 I have this meme here because it's like writing code is one thing, but writing code in assembly is another thing. 172 00:18:00,050 --> 00:18:02,510 Like it's a whole different ballgame. 173 00:18:02,510 --> 00:18:14,090 This picture here also here shows what regular C code looks like, what our intermediate code such as assembly looks like, and then what binary code looks like. 174 00:18:14,350 --> 00:18:20,510 So it's the same file, but it's in three different formats as it is on your system. 175 00:18:21,750 --> 00:18:26,110 And I will also show a quick example of this. 176 00:18:30,130 --> 00:18:37,030 So for this example, I actually wrote a C code, just something very, very simple. 177 00:18:37,810 --> 00:18:42,030 And I'm using Nano just to open up the C code that I wrote. 178 00:18:42,070 --> 00:18:44,950 And so all this code is doing is adding two numbers together. 179 00:18:44,950 --> 00:18:47,590 It's adding 5 plus 12 and getting 17. 180 00:18:47,590 --> 00:18:49,330 And then it's printing it out. 181 00:18:49,370 --> 00:18:50,950 Very chill, right? 182 00:18:54,290 --> 00:19:00,460 But once we start to see that in assembly and once we start to see the binary and the hexadecimal, it's not going to be chill. 183 00:19:02,250 --> 00:19:07,130 This is what it is when I executed the code just to show that it does work, no errors. 184 00:19:11,360 --> 00:19:18,900 And then this is the assembly instructions that go with that same code. 185 00:19:18,900 --> 00:19:23,240 But even looking at this, although it is a lot, it's not so bad. 186 00:19:23,240 --> 00:19:29,980 We still see that there's two functions that are declared called EAX and EBX. 187 00:19:30,180 --> 00:19:32,280 We see that they're added together. 188 00:19:32,780 --> 00:19:41,020 We see that it calls printf, which is something that might lead us to say, oh, this is C code versus being another language. 189 00:19:42,340 --> 00:19:46,520 So even though it's slightly more complicated, it's still somewhat. 190 00:19:47,060 --> 00:19:56,100 And I also added some comments here so that I could be able to document and know my thought process here too. 191 00:19:57,700 --> 00:20:01,440 Then we're going to look at our binary instructions as well for this. 192 00:20:08,540 --> 00:20:19,840 I also use object dump to look at some more of the assembly as well as it gives me a visual of what's happening in memory. 193 00:20:21,300 --> 00:20:23,260 But we still see a lot of the same stuff. 194 00:20:23,260 --> 00:20:27,400 We see like a lot of the same add and move components of it. 195 00:20:27,580 --> 00:20:32,240 And then this is a picture of the hex dump of that same file. 196 00:20:32,440 --> 00:20:35,160 And this is more of the binary representation of it. 197 00:20:35,360 --> 00:20:38,100 But as we see, this is not as useful to us. 198 00:20:39,860 --> 00:20:42,320 So what happens is a lot of time we get this one. 199 00:20:42,320 --> 00:20:43,500 We get the binary. 200 00:20:43,500 --> 00:20:47,720 But we need to go back and try to get the C of that same code. 201 00:20:47,720 --> 00:20:49,220 And it's not easy to do that. 202 00:20:50,460 --> 00:20:56,000 But I hope that this was just good to see the different representations of one file that we have. 203 00:20:56,940 --> 00:21:01,520 So now that we've done that, we also want to do code analysis. 204 00:21:01,520 --> 00:21:07,380 There is static analysis of code that allows us to understand the code without executing it. 205 00:21:07,380 --> 00:21:13,120 And then there's dynamic analysis that allows us to run the program to observe behavior. 206 00:21:18,820 --> 00:21:24,340 And that dynamic analysis involves executing and watching the code of what it does. 207 00:21:24,340 --> 00:21:28,760 That's when we were able to see the print and the add, the 5 plus 17. 208 00:21:28,940 --> 00:21:33,840 And our goal whenever we do code analysis is always to understand what the program is doing. 209 00:21:33,840 --> 00:21:36,600 And we construct the logic and the architecture. 210 00:21:38,380 --> 00:21:41,480 But we also have to stop and talk about documentation. 211 00:21:43,100 --> 00:21:47,980 I had this meme because it's like so many times we skip documentation. 212 00:21:47,980 --> 00:21:51,720 But documentation is actually the thing that makes this process easier. 213 00:21:51,720 --> 00:22:07,420 I also include this memory map because as I'm looking at my different tools such as Ghidra, I want to be able to have a location in memory and have some description of what might be happening. 214 00:22:07,620 --> 00:22:11,880 Common tools are flowcharts like is here or a memory map. 215 00:22:12,040 --> 00:22:16,200 We also have diagrams and pseudocode that we write. 216 00:22:19,440 --> 00:22:26,660 So, we're going into the next exercise where we're going to flash software onto the Arduino. 217 00:22:29,220 --> 00:22:33,200 And for this, we will download files and then 218 00:22:37,320 --> 00:22:39,980 first download all the INO files. 219 00:22:40,040 --> 00:22:45,580 And then this is the steps and process as to how to flash that onto your boards. 220 00:22:45,580 --> 00:22:48,140 And I also have a video showing how to do that too. 221 00:22:49,300 --> 00:22:50,940 So, we can do this. 222 00:22:50,940 --> 00:22:56,160 If you do have everything in front of you, you can do this live or watch the video to see. 223 00:23:01,300 --> 00:23:05,820 So, first we're gonna go to our Arduino cloud platform. 224 00:23:06,860 --> 00:23:12,020 This actually, this video assumes that you already have all the INO files. 225 00:23:12,020 --> 00:23:16,220 The first one that I go into, I named this one blink of an eye. 226 00:23:16,220 --> 00:23:22,020 And the purpose of that is just because I have a light blinking on the board. 227 00:23:22,140 --> 00:23:24,160 So, that's the function of the code. 228 00:23:25,980 --> 00:23:30,660 Another important thing is there's always drivers associated with hardware. 229 00:23:30,700 --> 00:23:36,160 So, I must download the Arduino driver to my computer before it can communicate. 230 00:23:37,220 --> 00:23:39,540 So, that's what I'm showing here. 231 00:23:40,200 --> 00:23:43,200 I need to install the Arduino cloud agent. 232 00:23:45,940 --> 00:23:49,900 So, once I do that, then I'm able to talk to the board with no problem. 233 00:24:06,080 --> 00:24:13,180 Okay, now that I have that done, I'm going to verify the code and then I'm going to upload the code to my board. 234 00:24:14,220 --> 00:24:20,480 And so, once it verifies, you get a notification or it shows you everything that happens here. 235 00:24:21,520 --> 00:24:23,540 And this code is actually very simple. 236 00:24:23,540 --> 00:24:32,260 It just blinks the LED for half a minute in 200 millisecond intervals. 237 00:24:34,040 --> 00:24:36,560 Sometimes uploading does take a little while. 238 00:24:45,190 --> 00:24:47,670 Okay, I did not show it actually. 239 00:24:47,910 --> 00:24:51,010 It was uploaded, but I didn't show the end of it being uploaded. 240 00:24:51,710 --> 00:24:55,760 And then once you have that, the main point of it is to see the... 241 00:24:56,950 --> 00:25:00,010 once you upload the code, you'll see your Arduino light blink. 242 00:25:03,560 --> 00:25:12,760 And then there's also the other two INO files that can be downloaded from the GitHub are these two as well. 243 00:25:17,870 --> 00:25:24,310 So, does everybody have the INO files downloaded from GitHub that is following along? 244 00:25:28,020 --> 00:25:29,240 Okay. 245 00:25:29,240 --> 00:25:30,400 All right, that's cool. 246 00:25:30,400 --> 00:25:30,960 No, it's good. 247 00:25:30,960 --> 00:25:32,040 It's good that I'm like... 248 00:25:32,040 --> 00:25:36,920 I don't want to race past things or not fully explain. 249 00:25:40,890 --> 00:25:44,190 But I'll actually... I can do the same with my computer too. 250 00:25:48,910 --> 00:26:01,110 But actually, I'm also going to just go skip to the video that's the last one, because the the INO file, this last one, is actually the most important. 251 00:26:01,110 --> 00:26:02,470 I call this one give me the addr... 252 00:26:02,470 --> 00:26:03,490 give me the addy. 253 00:26:03,590 --> 00:26:07,550 But the point really is because I'm... the addy is not a location like a house. 254 00:26:07,550 --> 00:26:12,230 It's like a... it's actually a location in memory that I'm like referencing. 255 00:26:12,270 --> 00:26:15,130 So, that's why I use that as the name. 256 00:26:15,450 --> 00:26:27,850 But this is the code that is currently a part of the... so, this is the header file also. 257 00:26:28,070 --> 00:26:31,670 And this is the INO file that I mentioned downloading. 258 00:26:32,370 --> 00:26:36,330 And once this is uploaded, it's going to do two things. 259 00:26:36,330 --> 00:26:41,310 It's going to add two integers together, but it's also going to print out the user credentials. 260 00:26:41,470 --> 00:26:44,510 And I show that in the video of how this works. 261 00:26:46,750 --> 00:27:03,850 And this is the one that we'll use as we go into Ghidra and look at the elf in the binary file, because it actually has... it's the best because it has two numbers that we're going to add in memory, as well as having user credentials that we're going to search for. 262 00:27:03,850 --> 00:27:12,670 So, this secret header file, it actually contains... it contains a username for Alice and a password called password. 263 00:27:12,850 --> 00:27:25,770 And when I show my header file back before, when I actually look, I declare two constants and I declare them as chars. 264 00:27:25,770 --> 00:27:35,130 And this is important because when I'm going in Ghidra and I'm trying to find these two in my reverse engineering process, I have to know the data type. 265 00:27:37,030 --> 00:27:46,710 But I'm just going to stop for, like, maybe two minutes, allow everyone to download all the INO files, and then try to flash those files to your board. 266 00:27:46,770 --> 00:27:51,930 And then after that, we're going to jump into the Ghidra reverse engineering process more. 267 00:27:52,070 --> 00:28:00,550 And then also, like, from the audience, give some feedback of, you know, how things are going as well, for those that are following along with it. 268 00:28:03,000 --> 00:28:12,040 Okay, so now that we've successfully flashed to our board, we saw different codes running. 269 00:28:12,200 --> 00:28:18,540 We're now going to go to the actual tutorial of analyzing our C code in Ghidra. 270 00:28:18,680 --> 00:28:23,060 So, as part of this, we have three objectives. 271 00:28:23,060 --> 00:28:26,420 We want to locate the main function in the decompiler. 272 00:28:26,420 --> 00:28:30,820 We want to observe how variables are mapped to registers or memory. 273 00:28:30,900 --> 00:28:38,160 And then lastly, we want to identify the username and password that we saw in the header file from before. 274 00:28:39,400 --> 00:28:46,300 I also had a short tutorial on getting up and running with Ghidra for trying to install. 275 00:28:46,520 --> 00:28:59,120 But for the sake of time, I am just going to jump straight in and show everything instead of starting all the way back at the beginning of just installation. 276 00:29:00,740 --> 00:29:02,200 It's launching right now. 277 00:29:02,200 --> 00:29:04,120 Just give it a second. 278 00:29:06,380 --> 00:29:07,300 All right. 279 00:29:07,300 --> 00:29:13,500 So, this is the main... when you first launch Ghidra, this is what it looks like. 280 00:29:16,700 --> 00:29:19,520 And the text is very small. 281 00:29:22,630 --> 00:29:27,370 But the first thing I did is I opened up the... 282 00:29:30,350 --> 00:29:36,490 this is what the... so, this ELF file is available on my GitHub. 283 00:29:36,830 --> 00:29:42,290 And this is the ELF file of the C file that we saw before. 284 00:29:42,290 --> 00:29:43,730 Or the INO file. 285 00:29:43,890 --> 00:29:53,230 So, when I showed the give me the addy, like, pick the INO, this is what it looks like in binary and in assembly. 286 00:29:54,490 --> 00:29:57,350 Ghidra went in and analyzed it for us. 287 00:29:59,250 --> 00:30:04,590 So, on the right side of the screen... or on this side of the screen, we have... 288 00:30:05,990 --> 00:30:09,570 I want to make the font bigger because it is kind of hard to see. 289 00:30:11,810 --> 00:30:12,150 All right. 290 00:30:12,150 --> 00:30:15,210 So, unfortunately, I'm not going to be able to zoom in. 291 00:30:15,210 --> 00:30:19,630 So, I'm just going to have to go and try to explain the best with the font being little. 292 00:30:20,630 --> 00:30:25,490 But on this side of the screen, this is all of my assembly. 293 00:30:25,570 --> 00:30:27,510 Assembly is good. 294 00:30:27,510 --> 00:30:30,730 But we're not going to spend a lot of time looking at that. 295 00:30:31,350 --> 00:30:36,330 Instead, we want to spend more of our time looking at our decompiled code. 296 00:30:38,290 --> 00:30:39,050 All right. 297 00:30:39,050 --> 00:30:40,490 So, yeah. 298 00:30:40,490 --> 00:30:42,870 I did not mean for that to be that difficult. 299 00:30:42,870 --> 00:30:44,990 But this is actually the view that we want. 300 00:30:48,450 --> 00:30:51,750 This on the left side is our assembly. 301 00:30:51,790 --> 00:30:58,610 And on the right side is our other part of the code, the disassembled code. 302 00:30:59,730 --> 00:31:05,210 And I do appreciate everyone for just kind of, like, being there with me. 303 00:31:05,330 --> 00:31:06,890 There's going to be a lot going on in the screen. 304 00:31:06,890 --> 00:31:08,710 I do have notes up here, too. 305 00:31:09,430 --> 00:31:10,530 But it's fine. 306 00:31:10,530 --> 00:31:12,310 You guys can see them as well. 307 00:31:12,950 --> 00:31:22,150 But just going back, like, here we were able to see that we don't have to do much to find our main function. 308 00:31:22,210 --> 00:31:28,670 Because it already tells us, like... I was trying to do too much. 309 00:31:28,670 --> 00:31:30,070 But I think this is fine. 310 00:31:31,070 --> 00:31:37,350 So, I'm just going to quickly just explain what I was trying to originally explain and try to get back on track. 311 00:31:37,890 --> 00:31:38,510 All right. 312 00:31:38,510 --> 00:31:39,770 I'm sorry about that. 313 00:31:39,950 --> 00:31:45,230 So, first, we have our two different ways of seeing our code. 314 00:31:45,830 --> 00:31:52,830 And in our source code, we have four integers that we wanted to that we want to try to locate. 315 00:31:53,270 --> 00:31:56,590 The first objective was try to locate the main function. 316 00:31:56,610 --> 00:31:59,570 Although it's really small, you can see that. 317 00:32:00,050 --> 00:32:03,550 And it also is there here. 318 00:32:03,810 --> 00:32:10,070 When we go to ELF and we go to... this is really small, but it says functions. 319 00:32:10,290 --> 00:32:12,690 And these are all the functions that's there. 320 00:32:13,050 --> 00:32:15,610 And I believe one of these is main. 321 00:32:15,870 --> 00:32:17,450 This is main there. 322 00:32:17,450 --> 00:32:21,810 It allows you to jump directly to main in the assembly code. 323 00:32:22,130 --> 00:32:29,310 From there, we now want to observe and understand how the variables are mapped together in memory. 324 00:32:29,310 --> 00:32:32,530 The four variables that we have are A, B, C, and D. 325 00:32:32,530 --> 00:32:33,770 A is 5. 326 00:32:33,770 --> 00:32:36,390 B is 12 from our previous tutorial. 327 00:32:36,630 --> 00:32:40,270 And then we have D and E, which are two hexadecimal values. 328 00:32:40,310 --> 00:32:42,970 And I'm actually going to go and search for those. 329 00:32:43,290 --> 00:32:46,970 So, to do that, I'm just going to do control F. 330 00:32:47,390 --> 00:32:52,210 And this allows me to search for them. 331 00:32:52,210 --> 00:32:53,590 One of them was called BD. 332 00:32:53,590 --> 00:32:54,970 So, I type it in. 333 00:32:54,970 --> 00:32:59,010 You also need to hit all fields. 334 00:32:59,010 --> 00:33:05,110 Because just the comments, that's not actually where that variable is found. 335 00:33:05,290 --> 00:33:07,370 So, I search all. 336 00:33:07,710 --> 00:33:10,330 And it highlights it multiple times. 337 00:33:11,270 --> 00:33:23,970 So, from there, I was able to find that whenever I saw this location in memory, I was seeing R24. 338 00:33:23,970 --> 00:33:32,130 And I was able to find some relationship between this hexadecimal value and these assembly lines. 339 00:33:33,490 --> 00:33:41,490 So, I was able to see that... see a relationship between that. 340 00:33:42,370 --> 00:33:50,470 I find that in Ghidra, our value is called also when you search and find... 341 00:33:50,470 --> 00:33:57,870 when I do the control F command and I look at my hexadecimal value, it also gives me search results. 342 00:33:58,110 --> 00:34:01,390 So, these search results are good because you don't have to go and look at all the code. 343 00:34:01,390 --> 00:34:04,010 You're only looking at your search results that you care about. 344 00:34:04,710 --> 00:34:12,070 And I find that my hexadecimal value of BD is R24 on their code. 345 00:34:12,250 --> 00:34:13,730 And I do that for all of them. 346 00:34:13,730 --> 00:34:15,590 I also do that for the other one. 347 00:34:15,590 --> 00:34:21,930 And what I was able to find is I was able to break down where addition was happening. 348 00:34:21,930 --> 00:34:25,250 So, our other code that we're looking for is A1. 349 00:34:25,730 --> 00:34:30,310 So, I search for that and then search all. 350 00:34:30,530 --> 00:34:32,770 It will give me some results. 351 00:34:33,290 --> 00:34:35,530 It is case sensitive as well. 352 00:34:35,790 --> 00:34:38,950 So, searching it out. 353 00:34:40,750 --> 00:34:47,850 And then from there, you'll see all of the different lines where it happens. 354 00:34:57,970 --> 00:35:02,750 So, now I'm going to go to trying to find the user credentials. 355 00:35:04,970 --> 00:35:14,570 And so, what I do for that is I just actually... we discussed a little bit about finding strings in our previous section. 356 00:35:15,150 --> 00:35:22,950 So, for there... so, I go to search and I go to four strings. 357 00:35:26,550 --> 00:35:31,410 And this is going to find every single string that is in my code at all. 358 00:35:31,410 --> 00:35:34,170 I don't have to go through any more work for that. 359 00:35:34,190 --> 00:35:36,830 And these are all of my string values here. 360 00:35:38,610 --> 00:35:54,270 And, again, sorry for the small font, but what you find is that your username being Alice and your password being password123, that all of that was actually... it was hardcoded into the header file that we saw before. 361 00:35:54,270 --> 00:36:00,510 So, because of that, Ghidra is very easily able to track that, even though it only had the binary. 362 00:36:00,570 --> 00:36:09,870 So, it only had the binary of the code, but it could still find the actual username and password that we downloaded and that we used with our Arduino earlier. 363 00:36:13,330 --> 00:36:22,970 I can also find it in assembly, but it won't be as easy or as nice, but I could also just search for it this way as well. 364 00:36:24,930 --> 00:36:28,390 But when I do search it, 365 00:36:34,080 --> 00:36:37,080 I have to... first, you need to click on this one. 366 00:36:46,740 --> 00:36:55,140 And what this shows is these are all of the different letters or characters of the password broken up. 367 00:36:56,900 --> 00:37:00,740 And this is all of the locations in memory where it's actually stored. 368 00:37:00,740 --> 00:37:13,520 So, we're able to find that the way our code works is it saves each letter of our password, one character at a time, and every single one is saved at a different location. 369 00:37:14,420 --> 00:37:19,520 So, this is my very simple and very easy Guidra tutorial here. 370 00:37:19,940 --> 00:37:23,320 It wasn't supposed to be anything too crazy or anything too much. 371 00:37:23,320 --> 00:37:29,660 I kind of just wanted to show some relationship between C code, assembly code, and binary code. 372 00:37:30,040 --> 00:37:33,440 I'm gonna hop back to the slides to close us out. 373 00:37:36,610 --> 00:37:38,650 So, we completed that. 374 00:37:38,890 --> 00:37:41,710 These slides actually also will be available on GitHub. 375 00:37:41,710 --> 00:37:46,850 So, like, if you do have the time and you have the interest, like, you can walk through each everything as well. 376 00:37:49,050 --> 00:37:51,390 And I definitely highly recommend doing that. 377 00:37:51,390 --> 00:37:55,450 I also even have a little video of how to install Guidra and do all that stuff. 378 00:37:56,350 --> 00:38:00,910 So, for our tips and takeaways, I have my Naruto here. 379 00:38:00,950 --> 00:38:12,430 You know, Naruto wants to be Hokage, but it takes time, it takes energy, it takes work, and it also takes some repetition and practice as well for him, just like it does for us when it comes to reverse engineering. 380 00:38:12,630 --> 00:38:16,630 It can feel overwhelming at first, but you don't need to know everything to start. 381 00:38:16,630 --> 00:38:22,730 Focus on learning a few core tools like Guidra, Binwalk, and ObjectDump. 382 00:38:22,730 --> 00:38:27,330 They're all available on Kali Linux, which is free. 383 00:38:27,330 --> 00:38:30,850 And then use this to build your experience. 384 00:38:31,150 --> 00:38:34,150 And you will definitely gain the skills that's needed. 385 00:38:34,350 --> 00:38:46,830 My other tip is to always document your reverse engineering process, because when you find a similar device, it's very helpful if it's already documented, and it will make doing the next task five times faster. 386 00:38:47,190 --> 00:38:49,970 And then lastly, practice makes patterns. 387 00:38:49,970 --> 00:38:52,330 The more you do this, the better it'll get. 388 00:38:52,670 --> 00:39:01,030 Some future learning resources are these two YouTube, one YouTube page, and then one of this GitHub IO. 389 00:39:01,110 --> 00:39:02,950 This one is really good for me. 390 00:39:02,950 --> 00:39:08,670 I've personally walked through at least about half of these, and I'm working on doing the second half of them. 391 00:39:08,670 --> 00:39:12,170 These helped me a lot to gain a lot of skills and experience here as well. 392 00:39:13,150 --> 00:39:23,410 And then I also just want to show you my GitHub page, so that you can easily find all this material, like slides, all the files, the headers, everything that you needed. 393 00:39:24,350 --> 00:39:30,910 Also, I even had the Guidra exported on my GitHub, so that that will be really good as well. 394 00:39:31,110 --> 00:39:32,670 So, this is my page. 395 00:39:33,250 --> 00:39:35,830 Well, actually, my page is shown on the slide. 396 00:39:35,830 --> 00:39:38,230 So, I'll let you go through that as well. 397 00:39:38,450 --> 00:39:42,210 And then this is my LinkedIn also, if you would like to connect with me later. 398 00:39:42,570 --> 00:39:44,370 But I definitely appreciate it. 399 00:39:44,370 --> 00:39:49,290 I appreciate you all attending and taking your time to spend time with me for the last hour or so. 400 00:39:50,530 --> 00:39:51,190 Yeah. 401 00:39:51,190 --> 00:39:56,410 And then if there's any questions, I am welcome to answer them. 402 00:40:06,090 --> 00:40:12,350 You said, have I thought about doing reverse engineering on stuff that I know has known vulnerabilities? 403 00:40:12,830 --> 00:40:14,230 A little bit. 404 00:40:15,150 --> 00:40:15,810 Somewhat. 405 00:40:15,810 --> 00:40:17,250 I would say, yeah. 406 00:40:17,250 --> 00:40:18,470 I mean, it's very helpful. 407 00:40:18,470 --> 00:40:21,730 Especially, let's say you have a binary that has a known vulnerability. 408 00:40:22,130 --> 00:40:24,590 I would say looking at it that way. 409 00:40:24,750 --> 00:40:30,910 Also looking at malware and different executables that I know cause vulnerabilities. 410 00:40:32,170 --> 00:40:32,530 Yeah. 411 00:40:32,530 --> 00:40:33,290 Definitely. 412 00:40:34,510 --> 00:40:35,170 All right. 413 00:40:35,170 --> 00:40:35,830 Yes? 414 00:40:36,470 --> 00:40:37,270 Okay. 415 00:40:37,270 --> 00:40:44,420 That is... that is here. 416 00:40:54,700 --> 00:40:55,200 Yes. 417 00:40:55,200 --> 00:40:57,560 And again, thank you all for just attending the talk. 418 00:40:57,560 --> 00:40:59,000 And I hope you all enjoyed it.