How y'all doing? Thank you for joining us here for our reverse engineering talk. It's my pleasure to introduce Sydney Jones. She's a cyber security researcher with expertise in reverse engineering, vulnerability assessment and AI evaluation. 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. From toggling LEDs to inspecting binary behavior, Sydney will walk you through our fundamentals in a hands-on, engaging way. Please join me in welcoming Sydney Jones. Yay! Thank you. Hello, hello, everyone. This is my second talk that I've given at DEF CON, and I'm truly happy that you're all here. So first to just talk a little bit about myself. I've already had a great introduction. I'm currently a Ph.D. student at Virginia Tech, and reverse engineering is something that I'm starting to learn more about. And so for me, it's like, as I learn, I want to be able to teach at the same time. But outside of work and school, I also have some other interests. My other interests are gaming. I like Animal Crossing. That's a picture of my Animal Crossing house. So it's like all pink, and I've done all the possible upgrades. Like my bank account on Animal Crossing is high. And then I love Apothecary Diaries. That's one of my favorite ones going on right now. I also like painting, like acrylic and watercolor. And that's a photo of me when I went to Paris last, and it was amazing. So to quickly talk about our agenda. First, we're going to talk about an intro of what is reverse engineering. 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. We're going to do a continuity test on our Arduino board using the multimeters that were handed out. 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. We're then going to look at assembly, and look at the executable. 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. And then lastly, we'll talk about any takeaways and resources. So since we are moving fast through this, if you're interested, download Ghidra here. And if you're interested in flashing the firmware to the Arduino board, go to this GitHub website. 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. 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. Reverse engineering is the process of analyzing an existing item to extract technical information required to reproduce or understand it. So reverse engineering looks at something to see how it works. 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. 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. So we have source code, but we don't have it... we don't have the binary yet, or we have binary with no source code. 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. 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. It's also useful for analyzing malware, validating software, or recovering lost code. So physical disassembly. We have our meme, we have our sandwich, and we have our sandwich disassembled. So this is when we take apart tools, and we use specialized tools such as a heat gun to physically remove the different components. Now, we're not going to do that here with the Arduinos, but that's the main point with this one. This also comes into play when people are fixing cell phones. They also take your screen off your phone and just replace it. That's a part of the physical disassembly process. 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. We want to look up the data sheets for each chip. And to do this, we could simply use a Google reverse image search, or we can use sites like Octopart to identify the components. So this is our first exercise. You're going to identify the different IC boards. 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. What does it do? How many pins does it have? And what interfaces or protocols does it use? So I put that on a slide because I know that it was really hard to see on the boards. And then I also have a zoomed in picture so that everyone could actually see it. 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. What does it do? How many pins does it have? And what interfaces does it use? And then I'll set a timer for like five minutes. Also, during this time, if there are any questions, you can ask a question related to the exercise too. 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. I can just show that as well. So like, go to this GitHub, and then there are data sheets there. Has anybody found... has anybody found one? All right. Well, I'll just go... I'll go into it. Well, actually, no. Does anybody have a solution for the first one? Like with the... with this first Atmel Omega 16, what that does? Yep. Okay. Thank you. Thank you. All right. So, this board here, this is a serial... a USB to serial converter. It has 32 pins, and it uses UART serial as well as USB. 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. 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. I can see it connects to other stuff, like maybe my oscillator that's right next to it, some resistors. 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. 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. It only has two pins. 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. It would... and this is essential for running everything at the right pace. 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. 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. And this also has two pins, and this is also a passive, just normal component. 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. It has 28 pins and uses UART. 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. Like, we could see, like, how it's set up by just the... like our circuit setup. And this is also important for later on when we use our digital write and digital read commands. So next, to continue our hardware reverse engineering process, we want to check the board's connectivity. Sometimes you might order a part and you're like, does this really work? So we have our multimeters here to make sure that it actually does. So we want to locate voltage and ground, identify our power and ground pins, and then do a continuity trace. 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. So it's important to sometimes check this. 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. So first step is to look at the back of the Arduino board and see the soldered traces. Choose a single line to trace like I have here. 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. I also have the video as well. And so for this one, our Arduino is not plugged in yet, so we're all good there. 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. And then once it's on, you're automatically going to see a zero L, and that means open loop. And then... okay, I hear beep, so that means that somebody might have it working. 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. 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. But I'll just stop for like a minute or maybe two and just have everyone do the test. For those doing the continuity test, is it going okay so far? All right, I think we're all good there. 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. Sometimes this is very important as well because we want to make sure that it's actually functioning as expected. So what I did was I had a... I hear something working, so that's good. 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. 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. All right, so now that we've done that, we're also going to locate our diagnostic ports. This is another step to hardware reverse engineering. This provides direct access to the device's internal systems. Many times you'll have UART, JTAG that allow you to read your system memory. 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. 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. And in our Arduino board, that's our focus for this one. 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. So now that we've done that, we've completed our hardware part. Just like Ash, we actually want to collect all the possible firmware extraction. All right. It sounds like y'all got it. That's good. We want to collect all the possible firmware extraction. But instead of Ash collecting Pokemon, we want to pull all the different firmware and binaries as possible. So now we're more so transitioning into a more software-based focus instead of before we were more like hardware-based focus. 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. 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. Now, in our case, I've made this very easy for us. I already have the ELF file ready for download. So instead of having to use the tool and pull the firmware from each of these yourself, the binary is already ready to go. But this is a very important step overall. Once we have our binary file, we're then going to do flash analysis. First we're going to extract the embedded files using tools like Flash ROM. Then we would use Binwalk to identify the file structure and format. It's going to tell me do I have an ELF file or an EXE file. Then we're going to analyze any systems present using Ghidra. We might find strings, we might find passwords, stuff like that. And then also we could use tools like Floss or GREP to find more sensitive data. And we will walk through like this process. We're actually going to walk through this later on. Another important discussion to have is to talk about our different binary formats. So for us, we're looking at an Arduino and it has an ELF format. That stands for executable and linkable format. And that is because Arduino is more like a Linux based system. It's also open source. And these type of files could be analyzed using Abijay Jump and GDB. But also EXEs are important as well. And these are more Windows based systems. All tools will still work, but Ghidra and IDA Pro are more popular. So we also got to discuss disassembly. Because any time we have a binary, we must disassemble it so that we can get it back into human readable format. I have this meme here because it's like writing code is one thing, but writing code in assembly is another thing. Like it's a whole different ballgame. 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. So it's the same file, but it's in three different formats as it is on your system. And I will also show a quick example of this. So for this example, I actually wrote a C code, just something very, very simple. And I'm using Nano just to open up the C code that I wrote. And so all this code is doing is adding two numbers together. It's adding 5 plus 12 and getting 17. And then it's printing it out. Very chill, right? 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. This is what it is when I executed the code just to show that it does work, no errors. And then this is the assembly instructions that go with that same code. But even looking at this, although it is a lot, it's not so bad. We still see that there's two functions that are declared called EAX and EBX. We see that they're added together. We see that it calls printf, which is something that might lead us to say, oh, this is C code versus being another language. So even though it's slightly more complicated, it's still somewhat. And I also added some comments here so that I could be able to document and know my thought process here too. Then we're going to look at our binary instructions as well for this. 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. But we still see a lot of the same stuff. We see like a lot of the same add and move components of it. And then this is a picture of the hex dump of that same file. And this is more of the binary representation of it. But as we see, this is not as useful to us. So what happens is a lot of time we get this one. We get the binary. But we need to go back and try to get the C of that same code. And it's not easy to do that. But I hope that this was just good to see the different representations of one file that we have. So now that we've done that, we also want to do code analysis. There is static analysis of code that allows us to understand the code without executing it. And then there's dynamic analysis that allows us to run the program to observe behavior. And that dynamic analysis involves executing and watching the code of what it does. That's when we were able to see the print and the add, the 5 plus 17. And our goal whenever we do code analysis is always to understand what the program is doing. And we construct the logic and the architecture. But we also have to stop and talk about documentation. I had this meme because it's like so many times we skip documentation. But documentation is actually the thing that makes this process easier. 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. Common tools are flowcharts like is here or a memory map. We also have diagrams and pseudocode that we write. So, we're going into the next exercise where we're going to flash software onto the Arduino. And for this, we will download files and then first download all the INO files. And then this is the steps and process as to how to flash that onto your boards. And I also have a video showing how to do that too. So, we can do this. If you do have everything in front of you, you can do this live or watch the video to see. So, first we're gonna go to our Arduino cloud platform. This actually, this video assumes that you already have all the INO files. The first one that I go into, I named this one blink of an eye. And the purpose of that is just because I have a light blinking on the board. So, that's the function of the code. Another important thing is there's always drivers associated with hardware. So, I must download the Arduino driver to my computer before it can communicate. So, that's what I'm showing here. I need to install the Arduino cloud agent. So, once I do that, then I'm able to talk to the board with no problem. 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. And so, once it verifies, you get a notification or it shows you everything that happens here. And this code is actually very simple. It just blinks the LED for half a minute in 200 millisecond intervals. Sometimes uploading does take a little while. Okay, I did not show it actually. It was uploaded, but I didn't show the end of it being uploaded. And then once you have that, the main point of it is to see the... once you upload the code, you'll see your Arduino light blink. And then there's also the other two INO files that can be downloaded from the GitHub are these two as well. So, does everybody have the INO files downloaded from GitHub that is following along? Okay. All right, that's cool. No, it's good. It's good that I'm like... I don't want to race past things or not fully explain. But I'll actually... I can do the same with my computer too. 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. I call this one give me the addr... give me the addy. But the point really is because I'm... the addy is not a location like a house. It's like a... it's actually a location in memory that I'm like referencing. So, that's why I use that as the name. But this is the code that is currently a part of the... so, this is the header file also. And this is the INO file that I mentioned downloading. And once this is uploaded, it's going to do two things. It's going to add two integers together, but it's also going to print out the user credentials. And I show that in the video of how this works. 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. So, this secret header file, it actually contains... it contains a username for Alice and a password called password. And when I show my header file back before, when I actually look, I declare two constants and I declare them as chars. 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. 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. And then after that, we're going to jump into the Ghidra reverse engineering process more. 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. Okay, so now that we've successfully flashed to our board, we saw different codes running. We're now going to go to the actual tutorial of analyzing our C code in Ghidra. So, as part of this, we have three objectives. We want to locate the main function in the decompiler. We want to observe how variables are mapped to registers or memory. And then lastly, we want to identify the username and password that we saw in the header file from before. I also had a short tutorial on getting up and running with Ghidra for trying to install. 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. It's launching right now. Just give it a second. All right. So, this is the main... when you first launch Ghidra, this is what it looks like. And the text is very small. But the first thing I did is I opened up the... this is what the... so, this ELF file is available on my GitHub. And this is the ELF file of the C file that we saw before. Or the INO file. So, when I showed the give me the addy, like, pick the INO, this is what it looks like in binary and in assembly. Ghidra went in and analyzed it for us. So, on the right side of the screen... or on this side of the screen, we have... I want to make the font bigger because it is kind of hard to see. All right. So, unfortunately, I'm not going to be able to zoom in. So, I'm just going to have to go and try to explain the best with the font being little. But on this side of the screen, this is all of my assembly. Assembly is good. But we're not going to spend a lot of time looking at that. Instead, we want to spend more of our time looking at our decompiled code. All right. So, yeah. I did not mean for that to be that difficult. But this is actually the view that we want. This on the left side is our assembly. And on the right side is our other part of the code, the disassembled code. And I do appreciate everyone for just kind of, like, being there with me. There's going to be a lot going on in the screen. I do have notes up here, too. But it's fine. You guys can see them as well. But just going back, like, here we were able to see that we don't have to do much to find our main function. Because it already tells us, like... I was trying to do too much. But I think this is fine. So, I'm just going to quickly just explain what I was trying to originally explain and try to get back on track. All right. I'm sorry about that. So, first, we have our two different ways of seeing our code. And in our source code, we have four integers that we wanted to that we want to try to locate. The first objective was try to locate the main function. Although it's really small, you can see that. And it also is there here. When we go to ELF and we go to... this is really small, but it says functions. And these are all the functions that's there. And I believe one of these is main. This is main there. It allows you to jump directly to main in the assembly code. From there, we now want to observe and understand how the variables are mapped together in memory. The four variables that we have are A, B, C, and D. A is 5. B is 12 from our previous tutorial. And then we have D and E, which are two hexadecimal values. And I'm actually going to go and search for those. So, to do that, I'm just going to do control F. And this allows me to search for them. One of them was called BD. So, I type it in. You also need to hit all fields. Because just the comments, that's not actually where that variable is found. So, I search all. And it highlights it multiple times. So, from there, I was able to find that whenever I saw this location in memory, I was seeing R24. And I was able to find some relationship between this hexadecimal value and these assembly lines. So, I was able to see that... see a relationship between that. I find that in Ghidra, our value is called also when you search and find... when I do the control F command and I look at my hexadecimal value, it also gives me search results. So, these search results are good because you don't have to go and look at all the code. You're only looking at your search results that you care about. And I find that my hexadecimal value of BD is R24 on their code. And I do that for all of them. I also do that for the other one. And what I was able to find is I was able to break down where addition was happening. So, our other code that we're looking for is A1. So, I search for that and then search all. It will give me some results. It is case sensitive as well. So, searching it out. And then from there, you'll see all of the different lines where it happens. So, now I'm going to go to trying to find the user credentials. And so, what I do for that is I just actually... we discussed a little bit about finding strings in our previous section. So, for there... so, I go to search and I go to four strings. And this is going to find every single string that is in my code at all. I don't have to go through any more work for that. And these are all of my string values here. 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. So, because of that, Ghidra is very easily able to track that, even though it only had the binary. 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. 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. But when I do search it, I have to... first, you need to click on this one. And what this shows is these are all of the different letters or characters of the password broken up. And this is all of the locations in memory where it's actually stored. 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. So, this is my very simple and very easy Guidra tutorial here. It wasn't supposed to be anything too crazy or anything too much. I kind of just wanted to show some relationship between C code, assembly code, and binary code. I'm gonna hop back to the slides to close us out. So, we completed that. These slides actually also will be available on GitHub. So, like, if you do have the time and you have the interest, like, you can walk through each everything as well. And I definitely highly recommend doing that. I also even have a little video of how to install Guidra and do all that stuff. So, for our tips and takeaways, I have my Naruto here. 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. It can feel overwhelming at first, but you don't need to know everything to start. Focus on learning a few core tools like Guidra, Binwalk, and ObjectDump. They're all available on Kali Linux, which is free. And then use this to build your experience. And you will definitely gain the skills that's needed. 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. And then lastly, practice makes patterns. The more you do this, the better it'll get. Some future learning resources are these two YouTube, one YouTube page, and then one of this GitHub IO. This one is really good for me. I've personally walked through at least about half of these, and I'm working on doing the second half of them. These helped me a lot to gain a lot of skills and experience here as well. 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. Also, I even had the Guidra exported on my GitHub, so that that will be really good as well. So, this is my page. Well, actually, my page is shown on the slide. So, I'll let you go through that as well. And then this is my LinkedIn also, if you would like to connect with me later. But I definitely appreciate it. I appreciate you all attending and taking your time to spend time with me for the last hour or so. Yeah. And then if there's any questions, I am welcome to answer them. You said, have I thought about doing reverse engineering on stuff that I know has known vulnerabilities? A little bit. Somewhat. I would say, yeah. I mean, it's very helpful. Especially, let's say you have a binary that has a known vulnerability. I would say looking at it that way. Also looking at malware and different executables that I know cause vulnerabilities. Yeah. Definitely. All right. Yes? Okay. That is... that is here. Yes. And again, thank you all for just attending the talk. And I hope you all enjoyed it.