text stringlengths 0 2.35k |
|---|
So this is something that makes running programs very easy on victim machines, where you do not control the environment. A long time ago, maybe 10 years ago, it was kind of a problem, because you cannot send binaries that are two or three megabytes big to victims; if your attack vector is an infected PDF or infected Wo... |
Then the second very good reason for using Go as an offensive language is going to be that reverse-engineering is difficult, which I will get back to, but also, all the standard tools that we as defenders tend to use in order to figure out quickly if a program is malicious or not tend to kind of break with Go language.... |
So that's one reason... And then the final reason reverse-engineering is really difficult for us is because the constructs that are generated by the Go compiler tend to be very unfamiliar to us. And so the learning curve - I wouldn't say it's that steep... You mentioned, Natalie, that I had released a few videos about ... |
**Ian Lopshire:** So you kind of mentioned that there's assembly differences that make it hard to recognize... Are there any specific things that you've learned about Go under the hood from that? ...that differ from C, like how functions are called in the assembly, or something like that. |
**Ivan Kwiatkowski:** Yeah, absolutely. So one of the major differences -- it's not really about the assembly itself, it's about the static aspect of the executables. It's the fact that all the functions are pulled inside the final binary, and then you have this big program that's two megabytes or three megabytes big j... |
So at least you are starting to get pretty reliably all the references to all the unknown functions. Beyond this, the Golang convention is -- well, I'm not going to it's weird, because it's as valid as any other one, it's just not the same one that we are used to seeing. The main difference is that considering that Go ... |
So the instruction was not pushed, which these assemblers or automated analysis tools - they just like to see push, push, push, and then call. That's something that is easy for them to recognize. But Go would just do "Move this on the stack, at this place, move this on the stack, at this place", and then when you go to... |
\[16:18\] And finally, there is this other key difference... And this difference is the fact that usually the C compiler and other similar compilers will tend to reserve some space on the stack for specific local variables... And this tends to be very reliable; it doesn't move too much. So when you have some variable i... |
So this is like a very, very difficult thing for us, trying to track down variables and return values, even arguments, is something extremely complex... And basically, this is the normal flow of how you analyze a program - you try to figure out what the variables are, you try to look at the functions and how they are c... |
Now, the last thing I can mention is that since version probably 16.1 or something like this, or 1.16, I guess, in Go, the Golang convention actually changed, and they do things even smarter now, which is pass some arguments through the registers and not through the stack. For me, it doesn't change that much. Actually,... |
And then when it comes to the quick and easy mode, which is getting my super-expensive IDA Pro license that comes with a decompiler, then I just open a program, press F5, and hopefully I can read whatever is going on in the program - well, that just doesn't work, because the constructs that are generated by the Go comp... |
**Natalie Pistunovich:** \[19:53\] For anybody who didn't watch the video or is not familiar with how to do reverse-engineering, I can in simple words say that roughly you look at the instructions, and then you try to kind of see - the entry point is usually main, so this is probably function main, this is one thing th... |
**Ivan Kwiatkowski:** Yeah. Actually, maybe I can say a few words about what reverse-engineering is for people that might not be familiar with it. The general idea is that we try to understand what a program does, even though we do not have access to the source code. But this is the typical case for malware, because we... |
**Natalie Pistunovich:** Especially when the tooling is not even there for you. |
**Ivan Kwiatkowski:** Yes. |
**Ian Lopshire:** Just for some reference, the ratio between lines of, say, Go, to assembly - do you know what that ratio is? Just roughly... 1 to 100, 1 to 1,000? |
**Ivan Kwiatkowski:** It's a good question; it would depend on the complexity of the line. In Go I'm pretty sure that you can do function calls that are chained together in long lines. I'm not sure if it's compliant to the official Go styling code, or something like this... But if you were to do this, then you would ha... |
**Ian Lopshire:** Okay. Yeah, that gives me a good idea. |
**Natalie Pistunovich:** What does it for other languages? Is it a lot more? Is it a lot less? Is it roughly the same? |
**Ivan Kwiatkowski:** I would say it's probably going to be mostly the same. C++ tends to be very \[unintelligible 00:23:09.17\] it's very comparable to to Go. C might be a bit more direct, like the translation between C and assembly is going to be a bit more -- how would I say it in English...? The correspondence betw... |
**Natalie Pistunovich:** Interesting to see if in one or two years from now it will be more supported and more pattern recognition working... |
**Ivan Kwiatkowski:** Well, that's the thing, right? It kind of depends on the attackers. If we do end up seeing more and more Go tools out there in the wild, then there's going to be pressure on the tool authors, like either IDA, Ghidra etc. to implement better detection, and better support for those languages. I'm pr... |
\[24:16\] We will still have to figure out how the Go assembly works, especially if it changes again in the future... But overall, at least the support in the last years has improved tremendously, and I think it will continue to do so also in the future, if there is a need to. And I would guess that Go is only going to... |
**Natalie Pistunovich:** Because of all the reasons that you mentioned. |
**Ivan Kwiatkowski:** Yeah, exactly. |
**Natalie Pistunovich:** Some specific questions... You mentioned that -- you were kind of thinking out loud about the behavior you see in IDA Pro when you were looking at the Go code that you loaded there, or the binary of it that you loaded there... So some -- I'm gonna describe two things that you mentioned, and tel... |
**Ivan Kwiatkowski:** Yeah, exactly. So this is something that was super-surprising to me, which is when I reverse-engineer programs so we can look at it statically in IDA Pro, which means you display the instructions and you read them like a book... Or there is another approach, which is not like opposite, but maybe m... |
And eventually, by doing some Google searches, etc. I figured out that it is actually the -- I don't know if it's the Go scheduler that is involved in there, probably it is, But there is a garbage collector that is in charge of freeing the variables that are not used anymore. And sometimes it takes priority and starts ... |
Now, once I was able to figure out what was going on and understand that I just have to get out of this garbage collector function - and it will take me back exactly where I used to be, and things were fine, but initially, it was another one of Go's idiosyncrasies that felt super-alien to me. I wasn't happy about it at... |
**Natalie Pistunovich:** So that means it's not a behavior that you see often in other languages... |
**Ivan Kwiatkowski:** Oh, no, it's something I had never seen before. I know that other languages, they do have their own garbage collectors, but when it comes to Java, we don't really have to look at the instructions, because Java is compiled to bytecode. So we just read the code disassembled or decompiled maybe, and ... |
**Natalie Pistunovich:** \[28:05\] And then one more question about another behavior that was peculiar, that you pointed out... That at some point, when you had two following instructions, and they were using the same variable, you didn't see the return, but because it was right the one after or before. |
**Ivan Kwiatkowski:** I'm not sure if I remember exactly the part that you refer to... But what I noticed is - yeah, this might be one of the other ways that the compiler in Go is being very smart, which is that if you have chained function calls, it turns out I think that the way that arguments from one functions are ... |
So one of these other things that we are used to seeing, like we see a function call, we look at the input -- we look at what goes in and what goes out, basically; this helps us understand what is going on. And with Go, sometimes you just don't see that, because it's hidden from you. The complexity tends to be -- well,... |
**Natalie Pistunovich:** It's very interesting to hear about this from the perspective of somebody who's kind of poking this out from the outside... |
**Ian Lopshire:** No, that's this makes me want to dive more into the reverse-engineering just to learn more about the internals. |
**Break:** \[30:48\] |
**Ian Lopshire:** So let's maybe move to a bit of a higher level now. Go's community is kind of big on consistency; we have like the linters, that keep everything consistent, go format keeps everything consistent... Does that actually helped with reverse-engineering at all? ...just the only one way to do thing. Or at t... |
**Ivan Kwiatkowski:** It's a good question. I have to say, I don't know that much about the linter itself. I have written a bit of C code myself. When I was trying to like look at assembly code and write Go at the same time, that would generate the same thing. So this is my extent of the experience with the language, a... |
For us, it doesn't matter too much, in the sense that those checks are enforced at the compiler level, right? It's something that if the code is not compliant, then you will not get a binary at the end. So it does not add additional stuff inside the binary, And also, if there were some variable that is unused inside th... |
\[34:01\] So for us, it doesn't really change that much, although knowing about those guarantees kind of allows us to make more informed guesses about what is going on in the program. Like, for instance, when I do you see a function that returns multiple return values, then I am not a Go developer, but still, I am alwa... |
**Natalie Pistunovich:** So would you say that Go is a good language to pick up for a hacker, or for a researcher in security? |
**Ivan Kwiatkowski:** Well, I'm not really in the business of helping attackers new being more efficient at varying offensive tools... But if I were to, then yes, I would guess that Go is probably a good language to pick up. Basically, anything that is away from the traditional languages is going to be more annoying fo... |
**Ian Lopshire:** So if those are kind of the new school ones, Go and Rust, historically, what languages has everyone used on the hacking side and on the research side? |
**Ivan Kwiatkowski:** Well, historically, everything has been used. You know Murphy's law, which says that if there is a way to misuse something, then it's going to be misused, right? And programming languages have proven time and again that law. The thing is, we are recipients of whatever the hackers are doing, right?... |
So the thing is, this is our bane as reverse-engineers, which is that we receive malware, and whatever it is, we have to work on it... Because at the end of the day, our job is to figure out what was going on in that specific incident. And so whether it's C, or C++, or it's Go, or Delphi, or Pascal, whatever... Erlang ... |
**Ian Lopshire:** So you just mentioned right there, your research is on whatever hackers leave behind, let that be malware, or whatever. What other things do people leave behind? Is it just the actual binaries? Or like, are you digging into logs, and other things? |
**Ivan Kwiatkowski:** Yeah, so in a typical incident scenario, then you would have people that go into what we call forensics mode; they will collect all the logs, they will collect all the hard drives and try to figure out exactly what happened inside the network. They will collect not just machine logs with DNS logs,... |
\[38:23\] So you would see that, you know, at this time, you had some suspicious request on some web frontend, and then you'd see that there was a file created at a later date on the same web server, and then you would maybe see some weird, suspicious request to the Active Directory server, with some golden ticket with... |
**Ian Lopshire:** You said the incident response teams are the ones that collect all that data, and all of that... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.