text
stringlengths
0
2.35k
[1327.54 --> 1329.80] Which is the spiritual parent of Go.
[1329.98 --> 1331.24] Yeah, I suppose.
[1331.36 --> 1336.36] And also a spiritual parent of many other languages because like it came from the 80s, maybe the 70s, right?
[1336.50 --> 1343.44] I remember learning Pascal or at least the basics when I was in school, something like 15 years ago now.
[1343.94 --> 1344.22] Same.
[1344.36 --> 1349.00] It was my high school graduation project had to be in Pascal.
[1349.42 --> 1350.04] So there you go.
[1350.36 --> 1352.46] Like, I probably wrote a little bit of Pascal myself.
[1352.66 --> 1355.62] Probably never actual projects that did anything meaningful.
[1355.62 --> 1360.06] But I did have to look at some APT malware, like real life APT.
[1360.20 --> 1361.28] What does APT stand for?
[1361.68 --> 1362.14] Oh, sorry.
[1362.22 --> 1364.38] It means advanced persistent threat.
[1364.72 --> 1370.52] So APTs are one of the categories of hackers that we track in our daily work.
[1370.52 --> 1376.48] So you have on one end the attackers that are financially motivated, cybercrime, ransomware groups, and all the like.
[1377.16 --> 1389.18] And on the other end of the spectrum, you have what we call the APTs, which basically are the state-sponsored actors or the mercenary actors, all the groups that are focused on cyber espionage.
[1389.18 --> 1395.06] Now, initially, the name APT was, I think, proposed by a mendiant.
[1395.40 --> 1398.58] It's probably around 2010 or something like this with their first report.
[1398.68 --> 1406.24] And back then, I think it made sense to say, you know, on one end, we have the low-skilled cybercriminals that are doing run-of-the-mill crimeware.
[1406.46 --> 1411.38] And on the other end of the spectrum, you have those state-sponsored attackers that are doing very sophisticated things.
[1411.38 --> 1417.56] I think that today, trying to separate attackers between levels of sophistication doesn't make that much sense anymore.
[1417.68 --> 1423.72] We do have extremely skilled ransomware groups that use very cutting-edge pen-testing methodologies.
[1423.80 --> 1426.24] And we do have APTs that are extremely bad.
[1426.46 --> 1428.30] I would say they have a poor OPSEC.
[1428.52 --> 1430.20] They don't know how to use their tools and so on.
[1430.32 --> 1436.44] So at this stage, I think, in 2022, when you hear APT, you just have to think about espionage.
[1436.60 --> 1439.18] I think this is going to be the way to understand this.
[1439.18 --> 1450.52] But in any case, yeah, this week I was working on another APT case taking place in some of the STAN countries in the CIS, Commonwealth Independent States, I think.
[1450.98 --> 1455.44] Anyway, and one of the malware implants that we found there was actually written in Pascal.
[1455.74 --> 1461.12] And so it was kind of a trip down the memory lane to, one, figure out what Pascal was again.
[1461.48 --> 1466.44] And also trying to understand what kind of assembly was generated by this Pascal compiler.
[1466.44 --> 1469.94] It wasn't that bad, actually, way less bad than having to discover the Go language.
[1470.66 --> 1478.10] That's interesting to know, because there is a lot of similarity between Go and Pascal, but knowing that the translation of that is different.
[1478.76 --> 1479.04] Oh, yeah.
[1479.08 --> 1485.70] I can tell you, even though I'm not an expert in any of the language, that even though you might have some similarities on the code level,
[1485.92 --> 1488.70] and maybe the constructs and the way that you declare things and so on,
[1489.14 --> 1492.96] when it comes to assembly, like the languages could not be more different from one another.
[1492.96 --> 1498.82] I thought that if they're conceptually similar, they might have a similar structure, but I guess not.
[1499.10 --> 1503.64] No, I suppose they took inspiration when it comes to how to write the code.
[1504.06 --> 1508.88] But then when it comes to what the compiler does, then yeah, the Go compiler really does its own thing.
[1509.22 --> 1513.80] And when you say that each language has their own different thing in the assembly representation,
[1514.12 --> 1517.58] or even when you reverse engineer that into like a visual representation,
[1517.86 --> 1519.74] how many different ways can you have?
[1519.74 --> 1522.82] Is it really, can it be like every time completely different?
[1523.26 --> 1527.78] It's not always completely, completely different, but there are some meaningful differences.
[1528.14 --> 1536.30] I would say that C language, maybe it's a misconception I have because C language is traditionally what you learn reverse engineering on.
[1536.72 --> 1540.38] So C language to me is going to be the language that is closest to the CPU.
[1540.38 --> 1547.96] When you compile a C program, then there's going to be a kind of direct translation from your C code to the assembly language.
[1548.80 --> 1551.84] Like the compiler isn't going to be too smart about things.
[1552.18 --> 1557.92] When you do something in C, then when you write it in code, then it kind of shows in the assembly language.
[1558.06 --> 1563.28] Of course, you can have some compiler optimizations for speed, for space and so on.
[1563.28 --> 1570.20] But overall, the translation is going to be pretty, I wouldn't say it's easily reversible, but I think it's pretty direct.
[1570.50 --> 1573.88] Like you really find your bearings from the C code to the assembly language.
[1574.20 --> 1583.14] And I think it's actually not that much of a surprise that decompiler tools such as Ghidra or such as the one sold with Ida Pro
[1583.14 --> 1588.22] do take the assembly and convert it back to C language because I think this is the closest.
[1588.22 --> 1595.24] And then when you go to languages that have, I would say, higher levels of conceptual complexity,
[1596.06 --> 1599.88] then this is where the compiler starts doing a lot of things on its own.
[1600.26 --> 1605.08] And this is where the code that you write ends up being super different from the assembly that you read.
[1605.44 --> 1610.52] When it comes to C++ and when you use an STD string, it seems like a very simple thing, right?
[1610.52 --> 1619.74] But under the hood, the STD string class is actually a template instantiation of like a very, very complex series of nested templates.
[1620.24 --> 1623.28] And you end up with, how can I explain this?
[1623.36 --> 1630.24] You end up with a weird structure that has a first a table that contains a pointer to methods,
[1630.56 --> 1632.00] which is something you never wrote in C.
[1632.30 --> 1637.68] You end up with methods calling each other nested methods that come from the template library,
[1637.68 --> 1640.06] from the C++ standards library, and so on.
[1640.12 --> 1641.58] And things just get crazy from here.
[1642.06 --> 1646.02] Taking the example of Pascal, and again, I don't write that much Pascal code,
[1646.10 --> 1649.40] but it's very obvious to me that when I look at the assembly code
[1649.40 --> 1653.18] and I see reference counters being incremented and decremented automatically,
[1653.74 --> 1654.68] and all that kind of stuff,
[1654.74 --> 1657.40] then this is something that was automatically added by the compiler.
[1657.90 --> 1661.60] And it's, I guess, useful as far as the running the program goes.
[1661.72 --> 1664.00] But when it comes to me understanding the program,
[1664.00 --> 1667.38] making sure that reference counts are handled properly
[1667.38 --> 1671.26] and that the objects are going to be freed when there are no more references to them
[1671.26 --> 1672.74] is something that I really don't care about.
[1672.86 --> 1676.40] And it's just cluttering my window, really.
[1676.52 --> 1679.64] It's just code added by the compiler that has no meaning,
[1679.90 --> 1681.94] at least when it comes to what the program is supposed to be doing.
[1682.00 --> 1684.88] It doesn't add any intelligence to the program.
[1684.96 --> 1686.12] It's just something that gets in the way.
[1686.94 --> 1690.42] And Go is probably one of the far extremes of this,
[1690.42 --> 1696.30] right there with C++ because the Go compiler is really doing a lot of stuff under the hood.
[1697.30 --> 1700.10] Like it really, how can I put this?
[1701.04 --> 1701.48] Optimizations?
[1702.06 --> 1703.02] Yeah, optimizations.
[1703.26 --> 1707.42] It inlines anything that is not worth a function call.
[1708.00 --> 1710.54] The calling convention is its own thing.
[1711.08 --> 1715.06] It's really, oh, you also have a garbage collection mechanism.
[1715.06 --> 1718.50] When you write a simple hello world program in Go language,
[1718.62 --> 1722.38] it ends up being an executable that's something like one megabyte big or something like this.
[1722.70 --> 1726.70] Like I get that today storage space isn't that expensive.
[1726.90 --> 1728.62] Like we don't care about one megabyte of code.
[1729.10 --> 1731.46] Like what's the difference between this and seven kilobytes?
[1731.54 --> 1733.88] I think not that much when it comes to hard drives.
[1734.64 --> 1737.82] But when you are a reverse engineer and you have to look at one megabyte of code
[1737.82 --> 1741.46] instead of seven kilobytes and it's actually a big deal, right?
[1741.46 --> 1745.50] And this is the kind of thing that the Go compiler does to you,
[1745.96 --> 1747.94] along with a number of optimizations,
[1748.52 --> 1752.70] along with this very weird calling convention that they have, etc.