text stringlengths 0 2.35k |
|---|
[682.80 --> 690.18] Then, second very good reason for using Go as an offensive language is going to be that |
[690.18 --> 694.96] reverse engineering is difficult, which I will get back to, but also all these standard |
[694.96 --> 700.32] tools that we, as defenders, tend to use in order to figure out quickly if a program is |
[700.32 --> 703.28] malicious or is not, tend to kind of break with Go language. |
[703.66 --> 708.10] The reason for this, and it ties into the discussion of why reverse engineering Go is annoying for |
[708.10 --> 713.16] us is that Go tends to really do its own thing, like the assembly it generates really does not |
[713.16 --> 714.78] look like any other assembly. |
[714.90 --> 719.96] It's not like C or it's not like C++ or Delphi that kind of tend to like look like distant |
[719.96 --> 721.78] cousins or even brothers in some cases. |
[722.52 --> 729.64] Go really does things its own way and all the automated methods for analyzing code statically |
[729.64 --> 735.92] or all the maybe signatures you can recreate for Go language, et cetera, but all the tools |
[735.92 --> 740.80] that would try to recognize specific patterns in code are not going to work because the code |
[740.80 --> 743.52] generated by Go just looks like nothing you've seen before. |
[743.52 --> 745.12] So that's one reason. |
[745.12 --> 747.68] And the final reason is reverse engineering. |
[747.68 --> 754.40] It's really difficult for us because the constructs that are generated by the Go compiler tend to be |
[754.40 --> 755.76] very unfamiliar to us. |
[755.76 --> 758.56] And so the learning curve, I would not say it's that steep. |
[758.56 --> 762.72] Like you mentioned, Natalie, that I had released a few videos about it. |
[762.72 --> 766.56] I think, you know, by the end of the videos, you can have like a rough idea of how to approach those |
[766.56 --> 766.96] programs. |
[766.96 --> 771.28] So it's not that like, it's not like an obstacle that is insurmountable. |
[771.28 --> 773.36] It's something that eventually you will be able to figure out. |
[773.36 --> 780.80] But when you've been working on C or like similar looking code as C for 10 years, and |
[780.80 --> 786.16] sometimes learning something new is not something that you are easily going to do because you are, |
[786.16 --> 790.32] you have your comfort zone and then you have to like discover something different. |
[790.32 --> 793.52] And maybe you don't like to do this and maybe you have, you know, 10 easy malware |
[793.52 --> 795.60] return C that are waiting in the, in the test list. |
[795.60 --> 799.52] And maybe you're going to work on those first because it will allow you to end your day earlier |
[799.52 --> 800.08] next Friday. |
[800.08 --> 800.40] Right. |
[800.40 --> 805.12] So you, you kind of mentioned that there's assembly differences that make it hard to recognize. |
[805.12 --> 808.88] Are there any like specific things that you've learned about Go under the hood from that, |
[808.88 --> 815.20] you know, like that differ from C like how functions are called in the assembly or something like that? |
[815.20 --> 816.56] Yeah, absolutely. |
[816.56 --> 820.72] So one of the major differences, it's not really about the assembly itself. |
[820.72 --> 825.28] It's about, you know, the static aspect of the executables is the fact that all the |
[825.84 --> 828.32] functions are pulled inside the final binary. |
[828.32 --> 832.72] And then you have this big program that's two megabytes or three megabytes big just for a |
[832.72 --> 833.04] print. |
[833.04 --> 834.08] Hello world. |
[834.08 --> 836.16] And now it's getting a bit better. |
[836.16 --> 841.76] I think IDA pro has made significant improvements in its later versions, but maybe two to three years |
[841.76 --> 845.20] ago when you were opening a Go program, you would have nothing recognized at all. |
[845.20 --> 851.04] Maybe you would be able to pull a few plugins here and there or Python scripts that may or may not |
[851.04 --> 851.28] work. |
[851.92 --> 856.16] And in that case, if you were lucky, you might have been able to create signatures for the |
[856.16 --> 859.92] well-known functions and maybe start from there, but it was really a huge ordeal. |
[859.92 --> 861.28] Now it's a bit better. |
[861.28 --> 867.36] So at least you are starting to get pretty reliably all the references to all the known functions. |
[867.36 --> 871.52] Beyond this, the calling convention is, well, I'm not going to say it's weird because like, |
[871.52 --> 873.52] it's, I mean, it's as valid as any other one. |
[873.52 --> 875.76] It's just not the same one that we are used to seeing. |
[876.48 --> 881.36] The main difference is that considering that Go can return multiple return values, |
[881.92 --> 886.72] then you cannot, you know, have the same system as we had to, as we had before. |
[886.72 --> 890.32] Like for instance, in the C program, the return value goes into EAX and that's it, right? |
[890.32 --> 891.28] No difference. |
[891.28 --> 893.76] I mean, the AX register of your CPU. |
[893.76 --> 897.84] When it comes to Go language, if you have three, four, or, you know, maybe more return values, |
[897.84 --> 902.24] you know, typically one return value and also some error objects, if I'm not mistaken, |
[903.12 --> 906.48] then you cannot put all that into a single CPU register. |
[906.48 --> 907.36] It just doesn't work. |
[907.36 --> 912.40] And so you tend to get values that, well, in the past, you would have all the arguments being |
[912.40 --> 917.84] passed through the stack, not through pushes, but direct moves from the, you know, from the |
[917.84 --> 919.68] value into the stack directly. |
[919.68 --> 924.40] So the instruction was not push, which are these assemblers, they are, you know, automated analysis |
[924.40 --> 924.64] tools. |
[924.64 --> 926.88] They just like to see push, push, push, and then call that. |
[926.88 --> 929.60] That's something that is easy for them to recognize. |
[929.60 --> 933.76] But Go would just do move this on the stack at this place, move this on the stack at this place, |
[933.76 --> 935.04] and then you go into another function. |
[935.04 --> 937.84] It knows because the compiler knows where the stuff ends up. |
[937.84 --> 938.64] So it figures it out. |
[938.64 --> 941.44] But you know, the Ida Pro looks at this and is like, what the hell is this? |
[941.44 --> 943.36] This memory has never been initialized before. |
[943.36 --> 944.24] I cannot show this to you. |
[944.88 --> 945.76] That was an issue. |
[945.76 --> 948.40] And then the return values were given back exactly the same. |
[948.40 --> 952.64] So the program would just move back all the return values onto the stack as well, |
[952.64 --> 955.36] at places that it would be able to figure out later. |
[955.36 --> 958.96] But then when you look at Ida Pro, then, you know, it sees, okay, values being moved on the |
[958.96 --> 959.20] stack. |
[959.20 --> 963.68] You go back into the calling function, and then you see references to the stack as well. |
[963.68 --> 966.96] But you know, the offsets are going to be different because since you are returning from a function, |
[966.96 --> 968.88] you know, things have shifted a little bit. |
[968.88 --> 971.44] And so the offsets are not well, do not work well anymore. |
[971.44 --> 975.68] And so this is like another issue that you have to face, like figuring out where your return values go. |
[975.68 --> 978.08] It still is, by the way, a terrible nightmare. |
[978.80 --> 983.12] And finally, there is this other key difference. |
[983.12 --> 989.04] And this difference is the fact that usually the C compiler and other similar compilers will tend to |
[990.00 --> 994.24] reserve some space on the stack for specific local variables. |
[994.24 --> 996.48] And this tends to be very reliable. |
[996.48 --> 997.84] It doesn't move too much. |
[997.84 --> 1001.52] So when you have some variable in C, you know, it gets used some part of the program. |
[1001.52 --> 1003.28] It's at one place on the stack, and then that's it. |
[1003.28 --> 1007.68] And if the program needs another local variable later on, then there's just another space located |
[1007.68 --> 1008.80] for this in the stack. |
[1008.80 --> 1011.52] And the Go compiler tends to be very smart about these things. |
[1012.08 --> 1016.08] And what it does is if it sees that, you know, there used to be a variable at some place on the |
[1016.08 --> 1021.04] stack and it's not used anymore, then it will feel like it's totally okay to reuse the same space |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.