Modular Inverses in Python 3 (PicoCTF 2022 #03 basic-mod2)
ฝัง
- เผยแพร่เมื่อ 17 ก.ย. 2024
- Help the channel grow with a Like, Comment, & Subscribe!
❤️ Support ➡ j-h.io/patreon ↔ j-h.io/paypal ↔ j-h.io/buymeac...
Check out the affiliates below for more free or discounted learning!
🖥️ Zero-Point Security ➡ Certified Red Team Operator j-h.io/crto
💻Zero-Point Security ➡ C2 Development with C# j-h.io/c2dev
👨🏻💻7aSecurity ➡ Hacking Courses & Pentesting j-h.io/7asecurity
📗Humble Bundle ➡ j-h.io/humbleb...
🌎Follow me! ➡ j-h.io/discord ↔ j-h.io/twitter ↔ j-h.io/linkedin ↔ j-h.io/instagram ↔ j-h.io/tiktok
📧Contact me! (I may be very slow to respond or completely unable to)
🤝Sponsorship Inquiries ➡ j-h.io/sponsor...
🚩 CTF Hosting Requests ➡ j-h.io/ctf
🎤 Speaking Requests ➡ j-h.io/speaking
💥 Malware Submission ➡ j-h.io/malware
❓ Everything Else ➡ j-h.io/etc
For the sake of learning , RSA uses the multiplicative inverse in order to generate the private key (For extra info you know what to do ). John you are a beast , Greetings from Greece !
The "Extended Euclidean Algorithm" is well worth a look, since it is one of the most fundamental algorithms in computer algebra and cryptography, and in particular it is the key to understanding and computing modular inverses.
### Since the gcd of two numbers a,b (suppose a>=b, otherwise swap) is computed step-by-step via the ordinary Euclidean algorithm,
a_0 = a, b_0 = b
for n = 0,1,2... until r_n = 0:
(1) q_n = a_n div b_n
(2) r_n = a_n - b_n * q_n (which implies 0
Rhanks
Hello from Brazil, thank you so much. Awesome video!
Thanks John. It’s good to see you’re still learning too. I think it’s helps us feel that it’s ok to always be learning and you can’t know everything. Thanks again for the time and energy you put in.
Another golden video from John. He makes looks thing easy and interesting. But the video doesn't show thousand of hours spent learning these skills, approach and thought process.
I like what you did here. I just imported mod_invers from smypy then used modulasinv = mod_inverse(number, 41)
great approach John!
Awesome, Thanks John.
John Hammond's channel: come for the infosec lessons & news; stay for the word "shenanigans". 😊
This is so awesome and valuable :DD
Thks !
since 41 is a prime number, you could use Fermats little theorem to compute the modular inverse of x by calling pow(x, 39, 41), which works for older python versions as well.
Nice Nazaré Tedesco image........ Brazil dude!! hahahahahaha love u John...
Yeah...I love the math...I do the math all the time, I'm the best at math. Thank you for your video, kind sir.
Awesome John!
loving this series
Dude it such a relief to see that I was not alone crossing my eyes when reading about reverse modulo. I though I was ultra dumb to not getting it right away
def modular_inverse(a, c):
for n in range(c):
if (a * n) % c == 1:
return n
return -1
Hello from Brazil 🇧🇷 🖖🏼
Short but perfect
Best example of understanding a modular inverse i could find (that actually was my google answer, i just did the search a bit differently lol):
The multiplicative inverse of “a modulo m” exists if and only if a and m are relatively prime (i.e., if gcd(a, m) = 1).
Input: a = 3, m = 11 Output("pow(3, -1, 11)"): 4 Since (4*3) mod 11 = 1, 4 is modulo inverse of 3(under 11)
And not to be confused with 1/3 mod11 (or "(3 to the power of -1) mod11"). I think python did it this way just to simplify it for us. I tried to get a calculator to reproduce the result, to no avail.
Thank you so much for doing this. I massively over thought this challenge as simple and straightforward as it turned out to be! I got so frustrated when I couldn't do it but I knew trusty Hohn Jammond would save the day!
Brother beard looks cool
Great job John👊💜
hoping that you solve all that pico ctf challenges...thanq
beautiful
When you encrypt a file, does the algorithm apply to the binary directly or other values are used (as shown in the challenge)?
RSA is not a stream cypher like AES. The encrypted part is always the size of the modulus. So if your mod is 16 bit you need 2 bytes to save the value.
seeing the Extended Euclidean Algorithm brought back trauma from a few months ago when i first learned about rsa encryption and tried to compute my own keys, it still not working btw
It boggles my mind how hackers of yesteryear plied their trade without internet search engines. The accumulative knowledge they had to seek (and remember) wasn't a mouse click away!
I just want to know how to execute the code and the result shows on the right side of the screen and not the bottom!
What about @John Hammond using Nazare Tedesco's meme. lol
Python tutorial when?
It would help us if you provide the python script
Seeing that you don't understand the definition of this inverse in your native language makes me feel less bad about not understanding it when reading the definition in a foreign language. ;-)
comment
Hi John
I want you help??
This meme is Brazilian lol