WEBVTT

00:00.000 --> 00:02.060
How y'all doing?

00:02.100 --> 00:08.260
Thank you for joining us here for our reverse engineering talk.

00:08.780 --> 00:12.660
It's my pleasure to introduce Sydney Jones.

00:12.660 --> 00:23.620
She's a cyber security researcher with expertise in reverse engineering, vulnerability assessment and AI evaluation.

00:23.620 --> 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.

00:41.060 --> 00:51.510
From toggling LEDs to inspecting binary behavior, Sydney will walk you through our fundamentals in a hands-on, engaging way.

00:51.650 --> 00:54.670
Please join me in welcoming Sydney Jones.

00:54.670 --> 00:55.410
Yay!

00:56.630 --> 00:57.990
Thank you.

01:01.240 --> 01:03.040
Hello, hello, everyone.

01:03.220 --> 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.

01:08.380 --> 01:11.040
So first to just talk a little bit about myself.

01:13.200 --> 01:15.440
I've already had a great introduction.

01:16.140 --> 01:17.680
I'm currently a Ph.D.

01:17.680 --> 01:23.160
student at Virginia Tech, and reverse engineering is something that I'm starting to learn more about.

01:23.160 --> 01:27.180
And so for me, it's like, as I learn, I want to be able to teach at the same time.

01:28.560 --> 01:31.640
But outside of work and school, I also have some other interests.

01:31.640 --> 01:33.780
My other interests are gaming.

01:33.780 --> 01:35.140
I like Animal Crossing.

01:35.140 --> 01:37.460
That's a picture of my Animal Crossing house.

01:37.520 --> 01:40.880
So it's like all pink, and I've done all the possible upgrades.

01:41.180 --> 01:44.860
Like my bank account on Animal Crossing is high.

01:46.060 --> 01:48.900
And then I love Apothecary Diaries.

01:49.820 --> 01:52.440
That's one of my favorite ones going on right now.

01:52.440 --> 01:55.140
I also like painting, like acrylic and watercolor.

01:55.340 --> 02:00.220
And that's a photo of me when I went to Paris last, and it was amazing.

02:03.270 --> 02:05.610
So to quickly talk about our agenda.

02:06.410 --> 02:09.890
First, we're going to talk about an intro of what is reverse engineering.

02:09.890 --> 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.

02:16.750 --> 02:22.130
We're going to do a continuity test on our Arduino board using the multimeters that were handed out.

02:22.310 --> 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.

02:33.410 --> 02:37.470
We're then going to look at assembly, and look at the executable.

02:37.470 --> 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.

02:47.690 --> 02:52.010
And then lastly, we'll talk about any takeaways and resources.

02:54.470 --> 03:02.150
So since we are moving fast through this, if you're interested, download Ghidra here.

03:02.230 --> 03:09.270
And if you're interested in flashing the firmware to the Arduino board, go to this GitHub website.

03:09.830 --> 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.

03:16.410 --> 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.

03:24.390 --> 03:33.070
Reverse engineering is the process of analyzing an existing item to extract technical information required to reproduce or understand it.

03:33.290 --> 03:36.890
So reverse engineering looks at something to see how it works.

03:36.890 --> 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.

03:45.530 --> 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.

03:52.510 --> 03:54.630
So we have source code, but we don't have it...

03:55.350 --> 03:59.290
we don't have the binary yet, or we have binary with no source code.

04:00.130 --> 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.

04:13.030 --> 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.

04:32.810 --> 04:38.470
It's also useful for analyzing malware, validating software, or recovering lost code.

04:39.570 --> 04:41.410
So physical disassembly.

04:41.410 --> 04:46.170
We have our meme, we have our sandwich, and we have our sandwich disassembled.

04:46.170 --> 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.

04:55.050 --> 05:00.270
Now, we're not going to do that here with the Arduinos, but that's the main point with this one.

05:00.270 --> 05:03.850
This also comes into play when people are fixing cell phones.

05:04.050 --> 05:07.930
They also take your screen off your phone and just replace it.

05:07.930 --> 05:11.130
That's a part of the physical disassembly process.

05:13.630 --> 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.

05:23.770 --> 05:26.270
We want to look up the data sheets for each chip.

05:26.810 --> 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.

05:36.750 --> 05:38.930
So this is our first exercise.

05:39.390 --> 05:44.670
You're going to identify the different IC boards.

05:44.850 --> 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.

05:55.590 --> 05:56.810
What does it do?

05:56.870 --> 05:58.550
How many pins does it have?

05:58.550 --> 06:01.970
And what interfaces or protocols does it use?

06:03.870 --> 06:09.370
So I put that on a slide because I know that it was really hard to see on the boards.

06:10.810 --> 06:16.070
And then I also have a zoomed in picture so that everyone could actually see it.

06:16.830 --> 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.

06:32.530 --> 06:33.850
What does it do?

06:33.850 --> 06:35.430
How many pins does it have?

06:35.470 --> 06:37.990
And what interfaces does it use?

06:38.390 --> 06:41.410
And then I'll set a timer for like five minutes.

06:45.810 --> 06:52.470
Also, during this time, if there are any questions, you can ask a question related to the exercise too.

06:53.630 --> 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.

07:16.170 --> 07:18.330
I can just show that as well.

07:18.330 --> 07:23.770
So like, go to this GitHub, and then there are data sheets there.

07:24.510 --> 07:27.570
Has anybody found... has anybody found one?

07:30.310 --> 07:30.950
All right.

07:30.950 --> 07:33.290
Well, I'll just go... I'll go into it.

07:33.570 --> 07:34.610
Well, actually, no.

07:34.730 --> 07:37.790
Does anybody have a solution for the first one?

07:38.530 --> 07:44.670
Like with the... with this first Atmel Omega 16, what that does?

07:46.950 --> 07:48.030
Yep.

07:48.030 --> 07:49.030
Okay.

07:49.030 --> 07:49.890
Thank you.

07:49.890 --> 07:51.090
Thank you.

07:51.090 --> 07:52.590
All right.

07:52.830 --> 07:58.830
So, this board here, this is a serial... a USB to serial converter.

07:58.830 --> 08:04.870
It has 32 pins, and it uses UART serial as well as USB.

08:05.290 --> 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.

08:18.950 --> 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.

08:26.390 --> 08:33.590
I can see it connects to other stuff, like maybe my oscillator that's right next to it, some resistors.

08:33.610 --> 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.

08:44.490 --> 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.

09:01.150 --> 09:02.790
It only has two pins.

09:02.790 --> 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.

09:14.770 --> 09:19.970
It would... and this is essential for running everything at the right pace.

09:21.250 --> 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.

09:37.230 --> 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.

09:50.790 --> 09:55.230
And this also has two pins, and this is also a passive, just normal component.

09:57.290 --> 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.

10:10.450 --> 10:14.330
It has 28 pins and uses UART.

10:15.370 --> 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.

10:27.630 --> 10:33.170
Like, we could see, like, how it's set up by just the... like our circuit setup.

10:36.610 --> 10:41.650
And this is also important for later on when we use our digital write and digital read commands.

10:44.260 --> 10:51.720
So next, to continue our hardware reverse engineering process, we want to check the board's connectivity.

10:51.960 --> 10:54.900
Sometimes you might order a part and you're like, does this really work?

10:54.900 --> 10:58.720
So we have our multimeters here to make sure that it actually does.

10:58.720 --> 11:05.240
So we want to locate voltage and ground, identify our power and ground pins, and then do a continuity trace.

11:05.440 --> 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.

11:13.680 --> 11:16.060
So it's important to sometimes check this.

11:17.340 --> 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.

11:27.140 --> 11:32.860
So first step is to look at the back of the Arduino board and see the soldered traces.

11:33.200 --> 11:36.480
Choose a single line to trace like I have here.

11:38.060 --> 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.

11:48.160 --> 11:51.040
I also have the video as well.

11:52.820 --> 11:57.200
And so for this one, our Arduino is not plugged in yet, so we're all good there.

11:57.200 --> 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.

12:14.980 --> 12:19.400
And then once it's on, you're automatically going to see a zero L, and that means open loop.

12:20.060 --> 12:26.600
And then... okay, I hear beep, so that means that somebody might have it working.

12:29.100 --> 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.

12:43.220 --> 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.

12:52.580 --> 12:58.440
But I'll just stop for like a minute or maybe two and just have everyone do the test.

12:59.420 --> 13:04.080
For those doing the continuity test, is it going okay so far?

13:08.850 --> 13:10.930
All right, I think we're all good there.

13:15.460 --> 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.

13:30.900 --> 13:38.300
Sometimes this is very important as well because we want to make sure that it's actually functioning as expected.

13:38.540 --> 13:44.020
So what I did was I had a... I hear something working, so that's good.

13:44.880 --> 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.

13:52.920 --> 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.

14:03.260 --> 14:09.060
All right, so now that we've done that, we're also going to locate our diagnostic ports.

14:09.060 --> 14:11.740
This is another step to hardware reverse engineering.

14:12.500 --> 14:16.500
This provides direct access to the device's internal systems.

14:16.860 --> 14:21.960
Many times you'll have UART, JTAG that allow you to read your system memory.

14:23.180 --> 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.

14:29.640 --> 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.

14:39.800 --> 14:42.340
And in our Arduino board, that's our focus for this one.

14:42.340 --> 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.

14:51.660 --> 14:56.640
So now that we've done that, we've completed our hardware part.

14:56.640 --> 15:01.640
Just like Ash, we actually want to collect all the possible firmware extraction.

15:06.970 --> 15:08.170
All right.

15:08.170 --> 15:09.530
It sounds like y'all got it.

15:09.530 --> 15:10.330
That's good.

15:11.750 --> 15:14.770
We want to collect all the possible firmware extraction.

15:19.590 --> 15:27.570
But instead of Ash collecting Pokemon, we want to pull all the different firmware and binaries as possible.

15:27.670 --> 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.

15:34.410 --> 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.

15:48.550 --> 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.

16:03.030 --> 16:05.170
Now, in our case, I've made this very easy for us.

16:05.170 --> 16:08.450
I already have the ELF file ready for download.

16:08.450 --> 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.

16:18.170 --> 16:20.970
But this is a very important step overall.

16:21.270 --> 16:27.170
Once we have our binary file, we're then going to do flash analysis.

16:27.770 --> 16:33.170
First we're going to extract the embedded files using tools like Flash ROM.

16:33.170 --> 16:37.350
Then we would use Binwalk to identify the file structure and format.

16:37.350 --> 16:40.850
It's going to tell me do I have an ELF file or an EXE file.

16:40.930 --> 16:45.590
Then we're going to analyze any systems present using Ghidra.

16:45.590 --> 16:49.150
We might find strings, we might find passwords, stuff like that.

16:50.190 --> 16:55.490
And then also we could use tools like Floss or GREP to find more sensitive data.

16:59.280 --> 17:01.720
And we will walk through like this process.

17:01.720 --> 17:03.800
We're actually going to walk through this later on.

17:05.700 --> 17:10.580
Another important discussion to have is to talk about our different binary formats.

17:10.700 --> 17:14.100
So for us, we're looking at an Arduino and it has an ELF format.

17:14.360 --> 17:17.460
That stands for executable and linkable format.

17:17.720 --> 17:21.500
And that is because Arduino is more like a Linux based system.

17:21.500 --> 17:23.180
It's also open source.

17:24.300 --> 17:30.760
And these type of files could be analyzed using Abijay Jump and GDB.

17:31.480 --> 17:34.020
But also EXEs are important as well.

17:34.020 --> 17:36.080
And these are more Windows based systems.

17:36.520 --> 17:40.240
All tools will still work, but Ghidra and IDA Pro are more popular.

17:44.170 --> 17:47.010
So we also got to discuss disassembly.

17:47.270 --> 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.

17:53.250 --> 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.

18:00.050 --> 18:02.510
Like it's a whole different ballgame.

18:02.510 --> 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.

18:14.350 --> 18:20.510
So it's the same file, but it's in three different formats as it is on your system.

18:21.750 --> 18:26.110
And I will also show a quick example of this.

18:30.130 --> 18:37.030
So for this example, I actually wrote a C code, just something very, very simple.

18:37.810 --> 18:42.030
And I'm using Nano just to open up the C code that I wrote.

18:42.070 --> 18:44.950
And so all this code is doing is adding two numbers together.

18:44.950 --> 18:47.590
It's adding 5 plus 12 and getting 17.

18:47.590 --> 18:49.330
And then it's printing it out.

18:49.370 --> 18:50.950
Very chill, right?

18:54.290 --> 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.

19:02.250 --> 19:07.130
This is what it is when I executed the code just to show that it does work, no errors.

19:11.360 --> 19:18.900
And then this is the assembly instructions that go with that same code.

19:18.900 --> 19:23.240
But even looking at this, although it is a lot, it's not so bad.

19:23.240 --> 19:29.980
We still see that there's two functions that are declared called EAX and EBX.

19:30.180 --> 19:32.280
We see that they're added together.

19:32.780 --> 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.

19:42.340 --> 19:46.520
So even though it's slightly more complicated, it's still somewhat.

19:47.060 --> 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.

19:57.700 --> 20:01.440
Then we're going to look at our binary instructions as well for this.

20:08.540 --> 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.

20:21.300 --> 20:23.260
But we still see a lot of the same stuff.

20:23.260 --> 20:27.400
We see like a lot of the same add and move components of it.

20:27.580 --> 20:32.240
And then this is a picture of the hex dump of that same file.

20:32.440 --> 20:35.160
And this is more of the binary representation of it.

20:35.360 --> 20:38.100
But as we see, this is not as useful to us.

20:39.860 --> 20:42.320
So what happens is a lot of time we get this one.

20:42.320 --> 20:43.500
We get the binary.

20:43.500 --> 20:47.720
But we need to go back and try to get the C of that same code.

20:47.720 --> 20:49.220
And it's not easy to do that.

20:50.460 --> 20:56.000
But I hope that this was just good to see the different representations of one file that we have.

20:56.940 --> 21:01.520
So now that we've done that, we also want to do code analysis.

21:01.520 --> 21:07.380
There is static analysis of code that allows us to understand the code without executing it.

21:07.380 --> 21:13.120
And then there's dynamic analysis that allows us to run the program to observe behavior.

21:18.820 --> 21:24.340
And that dynamic analysis involves executing and watching the code of what it does.

21:24.340 --> 21:28.760
That's when we were able to see the print and the add, the 5 plus 17.

21:28.940 --> 21:33.840
And our goal whenever we do code analysis is always to understand what the program is doing.

21:33.840 --> 21:36.600
And we construct the logic and the architecture.

21:38.380 --> 21:41.480
But we also have to stop and talk about documentation.

21:43.100 --> 21:47.980
I had this meme because it's like so many times we skip documentation.

21:47.980 --> 21:51.720
But documentation is actually the thing that makes this process easier.

21:51.720 --> 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.

22:07.620 --> 22:11.880
Common tools are flowcharts like is here or a memory map.

22:12.040 --> 22:16.200
We also have diagrams and pseudocode that we write.

22:19.440 --> 22:26.660
So, we're going into the next exercise where we're going to flash software onto the Arduino.

22:29.220 --> 22:33.200
And for this, we will download files and then

22:37.320 --> 22:39.980
first download all the INO files.

22:40.040 --> 22:45.580
And then this is the steps and process as to how to flash that onto your boards.

22:45.580 --> 22:48.140
And I also have a video showing how to do that too.

22:49.300 --> 22:50.940
So, we can do this.

22:50.940 --> 22:56.160
If you do have everything in front of you, you can do this live or watch the video to see.

23:01.300 --> 23:05.820
So, first we're gonna go to our Arduino cloud platform.

23:06.860 --> 23:12.020
This actually, this video assumes that you already have all the INO files.

23:12.020 --> 23:16.220
The first one that I go into, I named this one blink of an eye.

23:16.220 --> 23:22.020
And the purpose of that is just because I have a light blinking on the board.

23:22.140 --> 23:24.160
So, that's the function of the code.

23:25.980 --> 23:30.660
Another important thing is there's always drivers associated with hardware.

23:30.700 --> 23:36.160
So, I must download the Arduino driver to my computer before it can communicate.

23:37.220 --> 23:39.540
So, that's what I'm showing here.

23:40.200 --> 23:43.200
I need to install the Arduino cloud agent.

23:45.940 --> 23:49.900
So, once I do that, then I'm able to talk to the board with no problem.

24:06.080 --> 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.

24:14.220 --> 24:20.480
And so, once it verifies, you get a notification or it shows you everything that happens here.

24:21.520 --> 24:23.540
And this code is actually very simple.

24:23.540 --> 24:32.260
It just blinks the LED for half a minute in 200 millisecond intervals.

24:34.040 --> 24:36.560
Sometimes uploading does take a little while.

24:45.190 --> 24:47.670
Okay, I did not show it actually.

24:47.910 --> 24:51.010
It was uploaded, but I didn't show the end of it being uploaded.

24:51.710 --> 24:55.760
And then once you have that, the main point of it is to see the...

24:56.950 --> 25:00.010
once you upload the code, you'll see your Arduino light blink.

25:03.560 --> 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.

25:17.870 --> 25:24.310
So, does everybody have the INO files downloaded from GitHub that is following along?

25:28.020 --> 25:29.240
Okay.

25:29.240 --> 25:30.400
All right, that's cool.

25:30.400 --> 25:30.960
No, it's good.

25:30.960 --> 25:32.040
It's good that I'm like...

25:32.040 --> 25:36.920
I don't want to race past things or not fully explain.

25:40.890 --> 25:44.190
But I'll actually... I can do the same with my computer too.

25:48.910 --> 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.

26:01.110 --> 26:02.470
I call this one give me the addr...

26:02.470 --> 26:03.490
give me the addy.

26:03.590 --> 26:07.550
But the point really is because I'm... the addy is not a location like a house.

26:07.550 --> 26:12.230
It's like a... it's actually a location in memory that I'm like referencing.

26:12.270 --> 26:15.130
So, that's why I use that as the name.

26:15.450 --> 26:27.850
But this is the code that is currently a part of the... so, this is the header file also.

26:28.070 --> 26:31.670
And this is the INO file that I mentioned downloading.

26:32.370 --> 26:36.330
And once this is uploaded, it's going to do two things.

26:36.330 --> 26:41.310
It's going to add two integers together, but it's also going to print out the user credentials.

26:41.470 --> 26:44.510
And I show that in the video of how this works.

26:46.750 --> 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.

27:03.850 --> 27:12.670
So, this secret header file, it actually contains... it contains a username for Alice and a password called password.

27:12.850 --> 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.

27:25.770 --> 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.

27:37.030 --> 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.

27:46.770 --> 27:51.930
And then after that, we're going to jump into the Ghidra reverse engineering process more.

27:52.070 --> 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.

28:03.000 --> 28:12.040
Okay, so now that we've successfully flashed to our board, we saw different codes running.

28:12.200 --> 28:18.540
We're now going to go to the actual tutorial of analyzing our C code in Ghidra.

28:18.680 --> 28:23.060
So, as part of this, we have three objectives.

28:23.060 --> 28:26.420
We want to locate the main function in the decompiler.

28:26.420 --> 28:30.820
We want to observe how variables are mapped to registers or memory.

28:30.900 --> 28:38.160
And then lastly, we want to identify the username and password that we saw in the header file from before.

28:39.400 --> 28:46.300
I also had a short tutorial on getting up and running with Ghidra for trying to install.

28:46.520 --> 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.

29:00.740 --> 29:02.200
It's launching right now.

29:02.200 --> 29:04.120
Just give it a second.

29:06.380 --> 29:07.300
All right.

29:07.300 --> 29:13.500
So, this is the main... when you first launch Ghidra, this is what it looks like.

29:16.700 --> 29:19.520
And the text is very small.

29:22.630 --> 29:27.370
But the first thing I did is I opened up the...

29:30.350 --> 29:36.490
this is what the... so, this ELF file is available on my GitHub.

29:36.830 --> 29:42.290
And this is the ELF file of the C file that we saw before.

29:42.290 --> 29:43.730
Or the INO file.

29:43.890 --> 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.

29:54.490 --> 29:57.350
Ghidra went in and analyzed it for us.

29:59.250 --> 30:04.590
So, on the right side of the screen... or on this side of the screen, we have...

30:05.990 --> 30:09.570
I want to make the font bigger because it is kind of hard to see.

30:11.810 --> 30:12.150
All right.

30:12.150 --> 30:15.210
So, unfortunately, I'm not going to be able to zoom in.

30:15.210 --> 30:19.630
So, I'm just going to have to go and try to explain the best with the font being little.

30:20.630 --> 30:25.490
But on this side of the screen, this is all of my assembly.

30:25.570 --> 30:27.510
Assembly is good.

30:27.510 --> 30:30.730
But we're not going to spend a lot of time looking at that.

30:31.350 --> 30:36.330
Instead, we want to spend more of our time looking at our decompiled code.

30:38.290 --> 30:39.050
All right.

30:39.050 --> 30:40.490
So, yeah.

30:40.490 --> 30:42.870
I did not mean for that to be that difficult.

30:42.870 --> 30:44.990
But this is actually the view that we want.

30:48.450 --> 30:51.750
This on the left side is our assembly.

30:51.790 --> 30:58.610
And on the right side is our other part of the code, the disassembled code.

30:59.730 --> 31:05.210
And I do appreciate everyone for just kind of, like, being there with me.

31:05.330 --> 31:06.890
There's going to be a lot going on in the screen.

31:06.890 --> 31:08.710
I do have notes up here, too.

31:09.430 --> 31:10.530
But it's fine.

31:10.530 --> 31:12.310
You guys can see them as well.

31:12.950 --> 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.

31:22.210 --> 31:28.670
Because it already tells us, like... I was trying to do too much.

31:28.670 --> 31:30.070
But I think this is fine.

31:31.070 --> 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.

31:37.890 --> 31:38.510
All right.

31:38.510 --> 31:39.770
I'm sorry about that.

31:39.950 --> 31:45.230
So, first, we have our two different ways of seeing our code.

31:45.830 --> 31:52.830
And in our source code, we have four integers that we wanted to that we want to try to locate.

31:53.270 --> 31:56.590
The first objective was try to locate the main function.

31:56.610 --> 31:59.570
Although it's really small, you can see that.

32:00.050 --> 32:03.550
And it also is there here.

32:03.810 --> 32:10.070
When we go to ELF and we go to... this is really small, but it says functions.

32:10.290 --> 32:12.690
And these are all the functions that's there.

32:13.050 --> 32:15.610
And I believe one of these is main.

32:15.870 --> 32:17.450
This is main there.

32:17.450 --> 32:21.810
It allows you to jump directly to main in the assembly code.

32:22.130 --> 32:29.310
From there, we now want to observe and understand how the variables are mapped together in memory.

32:29.310 --> 32:32.530
The four variables that we have are A, B, C, and D.

32:32.530 --> 32:33.770
A is 5.

32:33.770 --> 32:36.390
B is 12 from our previous tutorial.

32:36.630 --> 32:40.270
And then we have D and E, which are two hexadecimal values.

32:40.310 --> 32:42.970
And I'm actually going to go and search for those.

32:43.290 --> 32:46.970
So, to do that, I'm just going to do control F.

32:47.390 --> 32:52.210
And this allows me to search for them.

32:52.210 --> 32:53.590
One of them was called BD.

32:53.590 --> 32:54.970
So, I type it in.

32:54.970 --> 32:59.010
You also need to hit all fields.

32:59.010 --> 33:05.110
Because just the comments, that's not actually where that variable is found.

33:05.290 --> 33:07.370
So, I search all.

33:07.710 --> 33:10.330
And it highlights it multiple times.

33:11.270 --> 33:23.970
So, from there, I was able to find that whenever I saw this location in memory, I was seeing R24.

33:23.970 --> 33:32.130
And I was able to find some relationship between this hexadecimal value and these assembly lines.

33:33.490 --> 33:41.490
So, I was able to see that... see a relationship between that.

33:42.370 --> 33:50.470
I find that in Ghidra, our value is called also when you search and find...

33:50.470 --> 33:57.870
when I do the control F command and I look at my hexadecimal value, it also gives me search results.

33:58.110 --> 34:01.390
So, these search results are good because you don't have to go and look at all the code.

34:01.390 --> 34:04.010
You're only looking at your search results that you care about.

34:04.710 --> 34:12.070
And I find that my hexadecimal value of BD is R24 on their code.

34:12.250 --> 34:13.730
And I do that for all of them.

34:13.730 --> 34:15.590
I also do that for the other one.

34:15.590 --> 34:21.930
And what I was able to find is I was able to break down where addition was happening.

34:21.930 --> 34:25.250
So, our other code that we're looking for is A1.

34:25.730 --> 34:30.310
So, I search for that and then search all.

34:30.530 --> 34:32.770
It will give me some results.

34:33.290 --> 34:35.530
It is case sensitive as well.

34:35.790 --> 34:38.950
So, searching it out.

34:40.750 --> 34:47.850
And then from there, you'll see all of the different lines where it happens.

34:57.970 --> 35:02.750
So, now I'm going to go to trying to find the user credentials.

35:04.970 --> 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.

35:15.150 --> 35:22.950
So, for there... so, I go to search and I go to four strings.

35:26.550 --> 35:31.410
And this is going to find every single string that is in my code at all.

35:31.410 --> 35:34.170
I don't have to go through any more work for that.

35:34.190 --> 35:36.830
And these are all of my string values here.

35:38.610 --> 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.

35:54.270 --> 36:00.510
So, because of that, Ghidra is very easily able to track that, even though it only had the binary.

36:00.570 --> 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.

36:13.330 --> 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.

36:24.930 --> 36:28.390
But when I do search it,

36:34.080 --> 36:37.080
I have to... first, you need to click on this one.

36:46.740 --> 36:55.140
And what this shows is these are all of the different letters or characters of the password broken up.

36:56.900 --> 37:00.740
And this is all of the locations in memory where it's actually stored.

37:00.740 --> 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.

37:14.420 --> 37:19.520
So, this is my very simple and very easy Guidra tutorial here.

37:19.940 --> 37:23.320
It wasn't supposed to be anything too crazy or anything too much.

37:23.320 --> 37:29.660
I kind of just wanted to show some relationship between C code, assembly code, and binary code.

37:30.040 --> 37:33.440
I'm gonna hop back to the slides to close us out.

37:36.610 --> 37:38.650
So, we completed that.

37:38.890 --> 37:41.710
These slides actually also will be available on GitHub.

37:41.710 --> 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.

37:49.050 --> 37:51.390
And I definitely highly recommend doing that.

37:51.390 --> 37:55.450
I also even have a little video of how to install Guidra and do all that stuff.

37:56.350 --> 38:00.910
So, for our tips and takeaways, I have my Naruto here.

38:00.950 --> 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.

38:12.630 --> 38:16.630
It can feel overwhelming at first, but you don't need to know everything to start.

38:16.630 --> 38:22.730
Focus on learning a few core tools like Guidra, Binwalk, and ObjectDump.

38:22.730 --> 38:27.330
They're all available on Kali Linux, which is free.

38:27.330 --> 38:30.850
And then use this to build your experience.

38:31.150 --> 38:34.150
And you will definitely gain the skills that's needed.

38:34.350 --> 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.

38:47.190 --> 38:49.970
And then lastly, practice makes patterns.

38:49.970 --> 38:52.330
The more you do this, the better it'll get.

38:52.670 --> 39:01.030
Some future learning resources are these two YouTube, one YouTube page, and then one of this GitHub IO.

39:01.110 --> 39:02.950
This one is really good for me.

39:02.950 --> 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.

39:08.670 --> 39:12.170
These helped me a lot to gain a lot of skills and experience here as well.

39:13.150 --> 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.

39:24.350 --> 39:30.910
Also, I even had the Guidra exported on my GitHub, so that that will be really good as well.

39:31.110 --> 39:32.670
So, this is my page.

39:33.250 --> 39:35.830
Well, actually, my page is shown on the slide.

39:35.830 --> 39:38.230
So, I'll let you go through that as well.

39:38.450 --> 39:42.210
And then this is my LinkedIn also, if you would like to connect with me later.

39:42.570 --> 39:44.370
But I definitely appreciate it.

39:44.370 --> 39:49.290
I appreciate you all attending and taking your time to spend time with me for the last hour or so.

39:50.530 --> 39:51.190
Yeah.

39:51.190 --> 39:56.410
And then if there's any questions, I am welcome to answer them.

40:06.090 --> 40:12.350
You said, have I thought about doing reverse engineering on stuff that I know has known vulnerabilities?

40:12.830 --> 40:14.230
A little bit.

40:15.150 --> 40:15.810
Somewhat.

40:15.810 --> 40:17.250
I would say, yeah.

40:17.250 --> 40:18.470
I mean, it's very helpful.

40:18.470 --> 40:21.730
Especially, let's say you have a binary that has a known vulnerability.

40:22.130 --> 40:24.590
I would say looking at it that way.

40:24.750 --> 40:30.910
Also looking at malware and different executables that I know cause vulnerabilities.

40:32.170 --> 40:32.530
Yeah.

40:32.530 --> 40:33.290
Definitely.

40:34.510 --> 40:35.170
All right.

40:35.170 --> 40:35.830
Yes?

40:36.470 --> 40:37.270
Okay.

40:37.270 --> 40:44.420
That is... that is here.

40:54.700 --> 40:55.200
Yes.

40:55.200 --> 40:57.560
And again, thank you all for just attending the talk.

40:57.560 --> 40:59.000
And I hope you all enjoyed it.

