Add Golang_For_Hackers__LDAP_Injector_-_Episode_02_-_Dependency_Injection.jsonl
Browse files
Golang_For_Hackers__LDAP_Injector_-_Episode_02_-_Dependency_Injection.jsonl
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"text": "What's going on, YouTube? This is IPSC and welcome to episode two of our Golang for hacker series where we're building an LDAP injector. This episode's all about dependency injection, which is definitely one of the more technical topics we'll cover. So, you may be thinking, why are we diving into something so technical this early, which of course is a fair question. But here's the thing, dependency injection shows up everywhere in Go, much more than other languages because Go doesn't really give us an easy way to avoid it. I can't count how many times I ran back to Python or C just in frustration thinking why can't I pass some optional arguments like a normal person. The answer to that, at least in my case, was stop being lazy and learn dependency injection. I find it's a lot like trying to beat an incredibly challenging boss", "start": 0.08, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 2 |
+
{"text": "in a video game without understanding their mechanics. It's really easy to quit the game or go in this case if you don't understand how it expects you to solve the challenge. So, let's get to the point. Dependency injection is just passing objects, not just simple variables, into our functions, which helps us decouple parts of the code, helping it us make it easier to test, read, and scale. If that doesn't click yet, don't worry. I'm going to show a demo in Python first, then we'll repeat the definition, apply it to our LDAP injector, so hopefully it makes a lot more sense the second or even third time around. And yes, you heard that right.", "start": 40.239, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 3 |
+
{"text": "In Golink for Hackers episode 2, we're going to start with Python. Why? because I know that's where a lot of you are coming from. So hopefully it helps make this concept stick. Additionally, Go doesn't have optional arguments or function overloading. So it's really easy to hit a wall if you're trying to write Go the same way you'd write Python, which is why I quit um Go so many times trying to learn it and went back to Python because I was just trying to write my Go code just like I'd write Python, which does not work. Let's take a simple example. Imagine we want to upload a file to an SFTP server. The solution you or AI would come up with probably looks something like this.", "start": 74.72, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 4 |
+
{"text": "Nothing fancy, just a quick function passing some arguments and call it a day. But over time, we want to support more destinations. Maybe S3, Azure, Webdave, a binary protocol. Who knows what we need to add? So you start adding flags, conditionals, and optional parameters. And this is when things get messy. The function works. So obviously it's not horrible. But putting all this conflicting logic will make it difficult to maintain or attest. If we added Azure, we have to change the arguments up here which could break our code elsewhere. Right? So it's not easy to modify this without modifying just how the program works overall. If we try this approach in Go, the language is just like nope. But that's not really a bad thing. That's Go guiding us towards the better way, which is dependency injection. So what do I mean about", "start": 110.079, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 5 |
+
{"text": "conflicting logic? Well, S3 and SFTP are transports, and the upload is an action.", "start": 156.48, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 6 |
+
{"text": "All the unique variables are coming from the transport, not the action. So, ideally, we'd have an upload function that just takes a source and destination path. Then, we can inject the transport dependency into that function. So, the logic on how to transport data isn't actually in the upload function. So, let's take a look how this might look in Python. And it's a little bit intimidating at first, but let's go over it. I'm sure it will make some sense after we go through it. Right? We start off with an abstractbased class and all this has is the upload function that just takes in a path and a destination and then we have objects for SFTP and S3 and in this init function this were having all the unique variables and then the upload is all the unique code right so the same thing looks like it does for", "start": 162.56, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 7 |
+
{"text": "S3 and then we have the upload of course that's just taking it in we have this upload data function that takes in the storage handler because all these objects are based off of this. So the only real requirement is we have the upload function that's shared with the I guess child classes and it just takes in the same parameters, right? So if we wanted to go use this, we could then just create an object. So I'm going to do con is equal to let's do SFTP handler if I can spell that correctly. We're going to put the destination because if we look at the arguments it needs, we need the host username and password. So, let's go put in um ipsseack.rocks because I want to copy a file there. Um my user is going to be IPSC and of course the password is going to be please subscribe with a bang because we", "start": 212.44, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 8 |
+
{"text": "have to have a little bit complexity there, right? Maybe we need a number two. Um and then if we wanted to use this all we do is call upload data and then um data and then pass in our object which is going to be con and then the source and destination which is going to be let's do data set.json because we're going to update that file and that exists in var dubdubdub html data set.json right and that's it. Um in python you may also do like con.upload upload and do it like this. But Golang really likes it um the pency injection where we pass the whole object in.", "start": 261.199, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 9 |
+
{"text": "There's no conditionals, no optional optional flags, just clean, predictable behavior. Not only does it make it easier to use the library, but the function tells you exactly what it needs. So it's easier to write unit tests for additional transports and maintain. So let's go back to this function, right? If we wanted to add Azure, we'd have to do like if server type is equal to um let's do Azure or bucket. I don't know what it calls it, but again, if we cause an error here, it just changes everything. If we wanted to use this function, I'm sure right after we wrote it, it would make sense to us.", "start": 297.12, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 10 |
+
{"text": "But if we're just calling it like weeks later when we don't really know what it is, we call upload peak at the like definitions and it's just giving us so many parameters. How do we use this?", "start": 331.12, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 11 |
+
{"text": "It's not very clear. If we're doing AWS, do we need the username password? I don't know. So, I have to go look at the code and see exactly what it is. It's just so much cleaner to do it with dependency injection. If we wanted to do um S3 again, we do con is equal to S3 handler and then we can just look at exactly what it needs. Oh, we just need the access key, the secret key, and the region. So, um let's go over the definition again. Dependency injection is just passing objects, not simple variables, into our functions, which helps us decouple parts of a code, making it easier to test, read, and scale. And when we get to unit testing, I'm sure the concepts really going to stick. But essentially, think about how you'd write a test case, right? We just want to test the smallest piece possible. We write a test case for", "start": 342.08, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 12 |
+
{"text": "upload data, and that's very easy. We can just easily create a mock or something like that. And then testing each S3 and SFTP becomes easy because we just have to think about how to connect to this service and how to upload specifically to this service. The testing logic here would just be all over the place because there's so much logic in this function even though at first glance it may not look like that.", "start": 389.44, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 13 |
+
{"text": "Um there's one last thing I wanted to talk about, but um oh um if we wanted to add like Azure handlers to this, like we just create a new object and there's no way that can cause an error because our upload data doesn't really have any additional logic. So if we just added a new class here, it's not changing the code flow or anything else in our program until we use that Azure handler.", "start": 412.0, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 14 |
+
{"text": "So it's a much more reliable way to be able to edit this code without risking breaking something else. So, um, hopefully I've convinced you that dependency injection's a good thing. So, now let's go take a look at it in our LDAP injector. Opening up zed, we can get to where we left off in the last episode. Now, think about what you know about dependency injection. Now, what of this code are we going to start isolating? If you said the net http client, that is correct. So, we're mainly going to be focused on this test password thing, turning this into a um dependency of our LDAP injector. So, let's start creating a new strct or implementation for the net HTTP client.", "start": 434.96, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 15 |
+
{"text": "And then afterwards, we're going to create another one and use a different way to um talk to HTTP, probably the fast HTTP thing to see if um it goes any quicker. Right? So let's do a new type and I'm going to call this net http brute imple for implementation. That's of course going to be a strct and I'm going to get a little bit more granular here than we did in the LDAP injector just so it's um flexible. I'm going to start with the method which is going to be the HTTP verb like a get post put whatever. Um and then of course we need the URL still so I'm going to give that as a string. Um, I'm going to put the username in here. And I don't love hard coding the username. Um, I would probably like do a payload and then uh make it like a can we do that or just do a uh slice of string like that. That's probably how", "start": 478.479, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 16 |
+
{"text": "I would approach this. But we haven't gone over like vetic functions and things like that to make this really easy. Um, what I'm talking about there would be if we had let's just create a new function real quick. Um, I'll call it print lines. And then we can say lines dot dot dot string or maybe we'll do line, right? And then all this line is is going to be a slice of string. And then we could do like um for L range line like this. and then fmt print line l. And this makes it really easy for us to just use this function. So if we wanted to do print lines, we could do like line one and then um line two and just pass them this way. Right? If I look at it, uh expected declaration found print lines. Oh, because we're not in like a function. But that's what that does. If we It's pretty much the same", "start": 533.2, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 17 |
+
{"text": "thing as this. Hold on. Like this because that's what the line gets treated as. But if we had it as a slice, then we don't have all like these commas. So we'd have to specify it by defining a slice of string. So it' kind of look like this, which makes calling the argument more messy. I say this because I'd like the payload to be able to be a list because that would just be like a print f string. So we could have like a um we could pass in the payload and then have it be what? Like username is equal to percent s and then um password is equal to percent s and then just like check if the um number of payloads is equal to the number of percent s's and then be really flexible. We wouldn't have to hardcode the username. But um that sounds simple.", "start": 598.16, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 18 |
+
{"text": "It's actually going to be somewhat challenging to code in a good way to make it really flexible. So, I'm going to hold that for a future episode. Um, so let's get rid of the payload. We'll just hardcode the username, keep the logic kind of the same how we have been.", "start": 649.92, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 19 |
+
{"text": "Um, if you want to try to make it flexible, that can be a challenge for you to do on your own and maybe I'll um create that episode. Um, let me know in the comments. So, we have the username.", "start": 663.519, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 20 |
+
{"text": "What else do we need? Oh, we need the headers because I don't want to hard code all the headers. And this is going to be a little bit um different if you're not used to like how to define things and just depend on Python's dynamic typing. We're going to do a map of a slice of string of string. And this is looking confusing, but really it's just a key value. So then we can pass in like user agent and then that's going to be uh Firefox, right? So that's all that definition is doing. And man, can I not type um let's see. I think that's it. Oh no, we probably want one more thing.", "start": 672.56, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 21 |
+
{"text": "Let's do expected um status code. And that'll be an integer because in this case, uh 303 is what we have for valid password. But maybe in the future like 200's a valid password and 500's invalid or something like that. So I definitely want to have like expected status code.", "start": 706.72, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 22 |
+
{"text": "And once we go into like functional option patterns, we may have more things like expected string, expected status code. But since we don't know how to do optional arguments yet, um it would be really messy to call this function. So now that we have that, let's go ahead and create our new object to create this. So I'm going to do funk new http brute implementation. And then uh AI will be able to handle creating most of this.", "start": 725.279, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 23 |
+
{"text": "Right? This is how it's passing. We have method URL and username as a string.", "start": 753.12, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 24 |
+
{"text": "Expected status code as an int and headers looks fine. Now the only thing I'm going to change here is the method.", "start": 757.44, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 25 |
+
{"text": "I'm going to call strings.2 upper on the method because I'm used to HTTP verbs always being uppercase. Um I'm not sure if that's the case, but it just makes sense in my mind to do that there. So that way if we passed in post as lowerase, it still will be uppercase there. And now we have to add this to the Ljap injector. And we can't just add this implementation because if we did um we'd just be hard- coding LDAP injector to use our net http brute implementation. So we're going to use a interface. And what the interface is going to allow us to do it's like the um abstract base class in Python. So I'm going to call this uh we'll just call it injector. And this is going to be a interface. And then we're gonna have one function that's going to be do. And this is essentially our test password function. I'm gonna have do pass in the", "start": 764.72, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 26 |
+
{"text": "password of a string. And then I really wish we could just pass in error, but we haven't gone over error handling yet. So we're going to do um bull error as the return. So what this interface allows us to do is use any implementation as long as it contains all the methods in the interface. So for this LDAP injector, we can remove the URL and username and then just say uh client is now going to be an injector like that. So if this implementation implements the do method, then it can be used as part of this LDAP injector. And then if we created a different implementation using like the fast HTTP brute implementation or a binary protocol maybe gRPC brute implementation as long it has that do function the code will just magically work right. So now let's go ahead and um update this new LDAP injector and we", "start": 816.399, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 27 |
+
{"text": "don't have a URL anymore. We just have the client which is going to be an injector. And then we can do um client is equal to client here. And that should be good. And the function we're going to play with is this test password. So I'm going to rename this to do. And then this is also going to be part of the injector. So I'm going to do C for client. And then I'm just going to leave it as um net hp brute implementation.", "start": 876.88, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 28 |
+
{"text": "It's actually not the interface. we have to do one for each implementation because all this logic is unique to the net http client. So this new request um this is no longer lil. This is now um curl. Uh payload looks fine. This is going to be C do username. Let's just do C do username like that. And then we also have the request. This is going to be the um method. So we'll do C do method here.", "start": 905.839, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 29 |
+
{"text": "Maybe I should code that verb, but I think method makes sense as well. Um the headers, I'm going to just move these down at the bottom of the code so we can deal with them later. But we want to make our code dynamic. So let's go back to do and we're going to do a for key value and range of C do headers. And then we would want to go request um header. And we can either do add or set. I think add will just add it. So you can have a duplicate header. Um set will just replace it I think. And I'm going to use set because I don't think we're ever want a duplicate header because this is going to be like content type. So if our library had a content type already, we don't want to duplicate it. We just want it to um replace. So that's going to add all the headers we pass in. Uh we still of course um want", "start": 943.6, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 30 |
+
{"text": "to leave the redirect there. That's making the request. And then this is going to be um we have now expected status code. There we go. So now we can easily change the status code that we're looking for.", "start": 999.199, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 31 |
+
{"text": "And now we just have to update these functions. And this um ldap injector.test password is now like what?", "start": 1012.079, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 32 |
+
{"text": "LDAP.client.do, right? Yep. That's how we now reference this. So now the test character doesn't have any like HTTP logic. LDAP injector overall has no HTTP logic. All it knows how to do is send payloads. So it knows, oh, I'm going to do first like a star to see if a password begins with a star. It doesn't know the whole how to send it over HTTP. So this becomes super handy in other things. So um since this is a for hackers course, think you're making a C2 program, right? A lot of people probably have made them in the past and you just kind of hardcode everything to curl because that's the easiest thing to do over HTTP and you have part of your like um internal logic of how the agent runs command tied in with your curl. So if you had dependency injection all your routing logic of your C2 agent needs", "start": 1022.68, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 33 |
+
{"text": "something like get file and then etsy pass WD right that's all the agent needs to read. you'd have a dependency injection that does HTTP and that makes it easier to add other transports to your C2, right? So, if we wanted our C2 to magically instead of doing HTTP to pull it from Slack, Discord, uh, Google Drive documents, anything we want, we can easily just use dependency injection to um, skip out on that piece of code to our agent routing logic. It also makes it really easy to change crypto things like that because again you just have to focus on the agent routing logic and then you can think about the transports completely differently. So dependency injection helps a lot there. Um we'll go into more examples at the end of this video but let's get back to updating this. So we had lilient.do there. I", "start": 1077.44, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 34 |
+
{"text": "think we have it in a few other places.", "start": 1128.64, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 35 |
+
{"text": "I'm just going to quickly do um a search and replace to replace this. So we'll do li.est past password and we'll replace it with what was it?", "start": 1130.799, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 36 |
+
{"text": "LII.client.do like this. And there we go. It's been replaced. And I think that is pretty much it. So let's go ahead and use this function now. So I'm going to create HTTP client and that's going to be a new HTTP brute implementation. And then the method is going to be a post request. The URL this is going to be HTTP internet ghost HTTP port 808 login.", "start": 1140.039, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 37 |
+
{"text": "The username of course is gett temp principle. And then what else do we need? I'm going to delete everything here. Um I'm just going to peek at the definition real quick. Uh let's see. We did method URL username expected status code. So that's going to be a 303. And then the headers. This is going to be where it gets a little messy. Uh let's It's definitely easier once we do functional option patterns, but uh let's do this here. So, we want to pass in a map of string string. And then we have two things. So, we'll put both of these in. Uh let's fix up the indentation.", "start": 1169.36, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 38 |
+
{"text": "There we go. And we don't need this. We change this to be a colon, comma, like that. Let's go back to this and again change that to be a colon. So it's just key value and then we close that out and I think do a parenthesy, right? Yes, that is good. Um, yeah, that looks fine. So now in our LDAP injector, we don't want to pass the username or URL. We just pass our HTTP client. And that should work.", "start": 1212.72, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 39 |
+
{"text": "Um, let's see. I just want to peek at LDAP injector here because we did not change the username. So let's delete that because we no longer have that in our function. And I think this is good. So let's test this out. So, I'm going to save this. We can do a gor run dot and just see if it works. It's probably going to take around um a minute to run.", "start": 1255.039, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 40 |
+
{"text": "Maybe it's a little quicker. I guess while it runs, we can start um changing things up because what I want to do is put all this logic in its own file. Um we'll wait for this to run and then start Oh, there we go. It's done. So, we found a partial password because um we limited the character set and removed one of the valid characters. So, that's good. Everything looks good.", "start": 1283.28, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 41 |
+
{"text": "Um so, uh let's make a new file. I'll call it net http.go. And then we're going to start moving all the unique logic in that file. It's going to make it easier to have other implementations. So, let's uh let's see.", "start": 1307.0, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 42 |
+
{"text": "We need to move this first.", "start": 1323.76, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 43 |
+
{"text": "So let's open the file net http that's package main. We'll put that line there.", "start": 1327.12, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 44 |
+
{"text": "There we go. Let's go back to main and let's see the next thing we have is this implementation. So we can move this go to net http put that and then the final piece is going to be the do. So let's take this Yank that out. Put it down. Save. And I think everything should still work. I'm just going to do save. There we go. Go run dot.", "start": 1334.559, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 45 |
+
{"text": "Everything looks like it's working. So now we have the implementation isolated into this net http file, which is going to let me cheat a little bit. I'm going to go over to AI. I'm gonna give it the file of net http.go and I'm gonna say um can you replace the net http with fast http which is just another um golen http client. And since it has fast in the name, I'm thinking maybe it's going to speed up my program a little bit. So that's why I want to try this out. So let's go ahead and take the code it gave us and we'll just see if it's good.", "start": 1371.44, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 46 |
+
{"text": "So, I'm going to go up here. Uh, let's see. Package main. Yank all that. Let's go here. Touch fast http.go. Uh, we can close the AI out.", "start": 1411.84, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 47 |
+
{"text": "Close that. Fast http put. And let's see. Uh, we probably have to rename this. It's no longer new http brute.", "start": 1427.039, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 48 |
+
{"text": "It's probably new fat h fast http brute.", "start": 1436.88, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 49 |
+
{"text": "And I don't see any syntax errors. Let's see. Are we still doing things? Yep, we're using fast HTTP now. We can see the code's a little bit different than net HTTP. We're setting up pools and stuff. Uh setting the method, the payload, setting Yep, everything looks good. So, what do we need to do here? Um Oh, we need to download this library. So let's go ahead and copy this and then do a go get paste that in. So now we're going to add that dependency to our project and everything should work. So let's do um I'm going to delete this line real quick. We'll save this and I'm going to do a go build- net http. So we're going to build it using the net http And then we can just change this client out. And this is going to be new fast HTTP. So now we have it using two different libraries. That was easy,", "start": 1442.12, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 50 |
+
{"text": "right? I just um changed the client and we're now injecting the fast HTTP client in a LDAP injector. So that's um super easy to now be changing things out. I know that was not a good explanation. So let's do a echo net http run that and then echo fast http and run that. So um normally we probably wouldn't have to port two different HTTP clients, but that's just the easiest way to do this since um my target server only accepts LDAP over HTTP. But if it was like gRPC, if it was a binary protocol, then having these implementations makes a lot more sense.", "start": 1508.4, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 51 |
+
{"text": "Also, um, thinking about it like if this wasn't LDAP, think about like if we wanted to send notifications, right? If you wanted to send notifications, you could have a giant if then logic saying if it's a text message, if it's SMTP, if it's Mailchimp, if it's a push message.", "start": 1557.44, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 52 |
+
{"text": "You don't want to go through and have all the logic there. It would be just nice having all the transports as objects and then injecting them into your notification function. So it just decides how to send that message. It's just a lot more um cleaner way to deal with it. So I'm going to pause the video and we'll come back after this runs so we can see if there's any performance improvement. Okay, it is done and we can see um something odd. I did not expect this honestly. We have net HTTP taking a minute and 12 seconds and fast HTTP only taking 40 seconds. These should be the same. I didn't think there would be a performance improvement, so I'm going to run it again just to make sure it's not a fluke while we talk about just um the program overall, right? Uh the other thing we could use these objects for or", "start": 1574.48, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 53 |
+
{"text": "the um other dependencies is if we had other HTB machines, right? It's very easy to just add different ways to do the payload and then inject that in. So all our functions here doesn't really change because all the um LDAP injector needs to know is how to perform the LDAP injection. It doesn't need to know how to get the data to the client, right? It doesn't really help us that much in LDAP because there's not a lot of um complex logic here. But if we had other things like uh divide and conquer or things like that in our injector, if this was like SQL and we could support a lot of things, then you wouldn't want to code all that logic every time you change the um server you're talking to. So this just makes it really easy to keep the same type of logic on how you perform things without changing it up when you", "start": 1620.64, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 54 |
+
{"text": "um have to change the transport or like change how the HTTP request is formatted. Additionally, when we write unit testing, we can just test this logic individually. We don't have to test the logic along with the transport.", "start": 1672.48, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 55 |
+
{"text": "So again, it's just going to make it a lot easier to keep robust, reliable code. We have net HTTP finishing. How long did that take? A minute and 13 seconds. So net HTTP took around the same time. I'm curious if fast HTTP again will just take under a minute. But I really expected fast HTTP to be about the same as net HTTP. But maybe it's actually faster, maybe it's not. But uh I guess we'll find out in one minute.", "start": 1686.08, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 56 |
+
{"text": "I'm going to pause the video just so um I don't have to kill dead time. And there we have it. Fast HTTP yet again was just a little bit quicker. Um I'm not exactly sure why, but it's still getting the password correct. So, I think fast HTTP may have some type of um performance improvement over that net HTTP client. I'm really baffled right now of that going faster. I did not think it would, but it just goes to show um how nice this dependency injection is. I've never used this library before.", "start": 1714.32, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 57 |
+
{"text": "I don't know exactly what it's doing under the hood, but um having this isolated that just let me like say, \"Hey AI, take what I did. Use this updated library that's supposed to go faster.\" It did and we had a performance improvement. So, um I guess that's cool.", "start": 1747.76, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|
| 58 |
+
{"text": "I did not expect that. I wish I did so I could have prepared to talk about why it's faster, but that's going to be the video. Um hope you guys enjoyed dependency injection. Let me know in the comments what you thought and then we'll do another video. So stay tuned.", "start": 1763.919, "duration": 0.0, "meta": {"video_id": "BhLpqRev80s", "title": "Golang For Hackers: LDAP Injector - Episode 02 - Dependency Injection", "url": "https://www.youtube.com/watch?v=BhLpqRev80s"}}
|