 Hello everyone, my name is John Hammond doing a little bit more TAMU CTF The game that's been going on the past couple days. I will jump over to my screen and we will get started I think I want to showcase this RSA Pone challenge in the miscellaneous category because it's kind of cool Just a simple thing that actually has a module that I really want to showcase to you guys So let's get a terminal open and ready I'll hop over to that TAMU directory that I've been working in let's make a directory for RSA Pone So inside of RSA Pone Let's make a simple connect script just so we can keep track of that host important number in case the CTF goes down Or in case we ever want to get back to it. I just always think that's a good practice And I try and enforce that in a lot of my videos So it says we must train future hackers to break RSA quickly. I realize my face is in the ways Let's bring that up. Here's how it'll work I'll multiply together two big primes less than whatever that number is Giving you the results and you must reply to me in less than two seconds telling me what primes I multiplied Press enter when you're ready. So if I enter we have this number and that is what we need to go ahead and supply values for In this case, okay, it looks like it's going to be using just the split function So that will determine that we needed supply a delimiter with a space character because that's the default delimiter with split But obviously in this case, I didn't enter numbers so it wind about these not being integers If we were to go ahead and supply something else I will Supply something like let's use 12 and 34. That'll tell me hey, I was too slow That was sorry 12 and 34. And yeah, I was either wrong or hit it too quickly Hit the enter button 1234 and that tells me I'm too slow So we need to automate this somehow we need to be able to factor this somehow a lot of times when you're doing RSA Challenge you might hop on over to factor db.com. I will need to factor db Goodness gracious Wow, I can't type. I don't know why my chrome is being super slow Factor db.com you could do that there You could automate kind of connecting to this and then supplying that value here And I did not copy that this video is going really well And we could supply these values, but we need to automate that process What I want to show you is that prime fact There is a module in python that has gone ahead and added support for this This is actually a fork of the original prime fact where it did add support for Connecting to factory db and being able to use this That's kind of nice because it's also a little bit faster. It has firm not factorization the prime fact module is pretty great and I'm getting YouTube notifications fantastic video guys. We're really doing well here Anyway, it has a factor int function and you can do that all programmatically within python So that is what I want to do and showcase that for you go ahead and check this out Go download this module and we'll use that to solve this challenge. So let me go ahead and create a script for this I'll call it ape.py and let's use our classic shebang line user bin environment python I'll say python 3 because I just like to be explicit and let's go ahead and frompon import all We can check out our connect script just to kind of grab this host and port number So let me go ahead and throw that in the script Grab our host grab our port number and let's go ahead and say s can equal remote of that host and port So quick and easy. We'll just burn through that We will verify that we have a valid prompt and now let's run that script Okay, it looks like it connects. It needs us to hit the enter key So s dot send line New line or I guess we don't really need anything in that case because we'll let's receive until the new line new line Because we know that there was one and that said please press enter when you're ready. So we'll do an s dot receive Until another new line. Is that right? There we go press enter when you're ready, which we've just sent So now we can go ahead and receive until the new line character again to get that number out And let's actually drop the new line there and let's say that that is going to be a Decoded value because you can see we're getting getting bytes So I'll use Latin one just to kind of safely get that and we probably also want that as an integer So let's save that as a variable and mark that as an integer Okay, I don't need any extra because I had some parentheses already when I was using the print function now We can determine that we have successfully extracted that number There we go. So let's go ahead and grab that Prime fact module. I have it installed already You can install it through the GitHub repository if you're using that fork and we should be able to now run our factors Can equal prime fact dot factor int on that number? So let's check out what we have here. What was it able to factor for us? There we go. So we have these values and they're kind of denoted actually is a little bit of an interesting dictionary What I'm going to do is I'm going to convert that into a list And if you verify that now you'll see that they're still in this kind of MPZ format for what I ended up using To go ahead and do that factoring. I'm going to actually convert those into integers I'm just going to say int of x for x in that list just some quick dirty list comprehension and Now we have those as actual numbers fantastic So we can go ahead and send that because it just needs it as the line s dot send line So I will join these together Factors here But I also need those to be string so I will use some list comprehension So I'll use for x in those list of factors And then we don't know what's going to come after this so we'll go interactive and Now let's send that along Okay, looks like that is literally just that challenge That's all that task was asking for us that it will give us the flag just like that Just supplying the factors of this value and that value would change every single time So we wouldn't be able to like okay Keep track of it not connected and then connect to it and send that within two seconds It's going to be just this random value and we need to factor it prime fact We'll let us do that and that's pretty awesome and pretty great. So there's our flag. That's it Let's uh, note that as a flag dot text and then mark this challenge As solved with my little finish script and command. So that's that that is literally all that we need to do for that challenge I just kind of wanted to use that as an opportunity to showcase that prime fac a module to you guys I I think it's awesome. I honestly think it's awesome That's pretty handy and because for some cryptography stuff, they're gonna do maybe a little bit of rsa Well now you can do that kind of programmatically in your python script and that's fantastic So hey, thank you guys so much for watching if you guys like the video Please do hit that like button hit the subscribe button Hit the bell hit the comment box and then type things and hit the enter key Fantastic, you're the best. Love to see you guys on discord patreon paypal linkedin facebook twitter, etc. All right Let's stop the video. Thank you. Take care You