Python Scripting Modular Arithmetic - PicoCTF 2022 #02 basic-mod1

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ก.ย. 2024
  • New MicroCenter customer? Get a free 128 GB USB & microSD! j-h.io/microce... // Check out what MicroCenter has to offer! j-h.io/microce... // Build a new workstation or server with MicroCenter! j-h.io/microce...
    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...
    🐶Snyk ➡ j-h.io/snyk
    🌎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

ความคิดเห็น • 92

  • @_JohnHammond
    @_JohnHammond  2 ปีที่แล้ว +14

    ♥ Huge thanks to MicroCenter for sponsoring this video! ♥ New MicroCenter customer? Get a free 128 GB USB & microSD! j-h.io/microcenter-new // Check out what MicroCenter has to offer! j-h.io/microcenter // Build a new workstation or server with MicroCenter! j-h.io/microcenter-builder

  • @joeymelo2882
    @joeymelo2882 2 ปีที่แล้ว +24

    Hey John. I’ve been following you for over a year now. It’s crazy that I remember watching your videos and being bombarded with knowledge. So much I didn’t understand or never considered.
    Now, moving forward to today, I was able to switch careers and get a pentesting job, and I’ve grown so much. And now that I’m watching your video on picoCTF I’m thinking: “man, that’s such a basic/easy challenge”. I almost can’t believe these types of challenges would take me forever a year ago and I had to look up writeups constantly.
    My point is, I wanna thank you for taking the time and go over the details in these beginner-friendly videos. Things like explaining what “ls” is doing or the difference between “int” and “str”. That’s gold for those who are beginning. I can see how much I’ve grown professionally and I’m certain this will also be of help to so many students out there.
    You rock!

    • @1ronman1
      @1ronman1 2 ปีที่แล้ว

      Dang how’d you get a pen test job in a year from 0

    • @charlieisacatwithseizures
      @charlieisacatwithseizures 2 ปีที่แล้ว

      @@1ronman1 right? Unless he did some really intense 24/7 cybersecurity bootcamp or has some magic secret to absorbing all that information in such a short time bc im 4 years in and im still overwhelmed with how much i still dont know

  • @JeffNoel
    @JeffNoel 2 ปีที่แล้ว +3

    The fact that you explain all your keyboard shortcuts is worth its weight in gold.
    I love how you say out loud what you're thinking, showing a basic way and then simplify/optimize the code.
    Thanks a lot for publishing all these PicoCTF videos.

  • @seanvinsick5271
    @seanvinsick5271 2 ปีที่แล้ว +13

    Avoid ifs if you can. Strings are char arrays, so create a string of all the characters you want to map. Use its index to look up the value.
    Table = "ABCD ... _"
    encodedvalue = table[value % 36]

  • @franktejeda669
    @franktejeda669 2 ปีที่แล้ว +17

    I have never 110% understood a Python video in my life before until now, Everything made so much sense and was beautifully explained (I'm a noob btw) I would absolutely love to see more Python videos with these explanations in the future

    • @wtfanupam
      @wtfanupam 2 ปีที่แล้ว +1

      Keep grinding

  • @arandomboredindividual7855
    @arandomboredindividual7855 2 ปีที่แล้ว +15

    Been loving this series. Keep it up man!

  • @_CryptoCat
    @_CryptoCat 2 ปีที่แล้ว +1

    curly braces with mv command 😮 learn something new every day 👌

  • @renanzinx
    @renanzinx 2 ปีที่แล้ว +3

    Josh, you content is so good.. such a pitty that I'm not studying for security jobs. I wish I knew someone in devops world with a quality of content like yours

  • @guydht1
    @guydht1 2 ปีที่แล้ว +37

    That f-string didn't work because the inner string quotations you used for the join ("".join()) is the same as the outer f-string quotations. If you had written down f'picoCTF{{{"".join(flag)}}}' it would've worked

    • @LordTails
      @LordTails 2 ปีที่แล้ว +4

      I was about to say that. Single quotes work as well as double quotes. In sublime the colour changes too.

    • @fordorth
      @fordorth 2 ปีที่แล้ว +1

      You took the words right out of my fingers :)

    • @lariojaalta890
      @lariojaalta890 2 ปีที่แล้ว

      Using 3 curly brackets is the key here. I did it a little differently:
      3 x { }
      flag = ''.join(map(str, alpha_num_list))
      print(f'picoCTF{{{flag}}}')
      returns:
      picoCTF{R0UND_N_R0UND_B6B25531}
      2 x { }
      flag = ''.join(map(str, alpha_num_list))
      print(f'picoCTF{{flag}}')
      returns:
      picoCTF{flag}

  • @dtvdavid
    @dtvdavid ปีที่แล้ว

    Thank you for teaching these things, it really helpful for beginners!

  • @fjr2go
    @fjr2go 2 ปีที่แล้ว +1

    Thanks for explaining the python code for the non programmers! Appreciate it.

  • @jekyll11111
    @jekyll11111 ปีที่แล้ว

    I wish I had 10% of your capacity of explaining the technical concepts so clear

  • @BehradJi
    @BehradJi 2 ปีที่แล้ว +1

    You're an amazing teacher!

  • @drewzilla1263
    @drewzilla1263 2 ปีที่แล้ว

    Great series! I am attempting each challenge myself first and then coming here to watch the video on it. Love the outro music as well.

  • @KramerEspinoza
    @KramerEspinoza 2 ปีที่แล้ว +3

    Why not add string.ascii_uppercase + string.digits + ‘_’ use that as your map and get rid of the if then else otherwise

  • @FVT-tn8ji
    @FVT-tn8ji 2 ปีที่แล้ว +1

    Thank you for explaining all of this in such detail! Really interesting as always :)

  • @karenruvalcaba6974
    @karenruvalcaba6974 2 ปีที่แล้ว

    I cannot thank you enough for explaining the little things. For once I'm really understanding the material.

  • @jpierce2l33t
    @jpierce2l33t 2 ปีที่แล้ว

    Libraries to the rescue again! I tried to use this whole fancy match-case thing that came with python 3.10, but apparently I need to read up more on the syntax. Yours is way cleaner, and better! Thanks for the lesson once again John, these are *GREAT!*

  • @EricSondermann
    @EricSondermann 2 ปีที่แล้ว

    Great video John, I love the way you show everything and make it easy to digest.

  • @sasakanjuh7660
    @sasakanjuh7660 2 ปีที่แล้ว +1

    Hey John, really not trying to be that guy who comments how things could be done better, just want to point out you could use += sign to concatenate string to the variable rather than using list and join method :) Keep up an amazing work, as always!! :)

    • @_JohnHammond
      @_JohnHammond  2 ปีที่แล้ว +1

      From what I understand the list and join method to concatenate strings is significantly faster and more performant than just slapping strings together with +=... but I could be wrong! :)

    • @sasakanjuh7660
      @sasakanjuh7660 2 ปีที่แล้ว +1

      @@_JohnHammond Hm, interesting, good to know.. Intuitively it sounds like doing it in constant time should be more efficient than traversing the list to join elements ( which is O(n)), but there certainly may be something I'm missing, and, to your point, since I don't know it for a fact, I might be way off as well :D

  • @vincenzo3292
    @vincenzo3292 2 ปีที่แล้ว

    Thanks for the clear step by step breakdown with the code, that is very helpful.

  • @viv_2489
    @viv_2489 2 ปีที่แล้ว

    Really liked the extensive explanation of basics

  • @joeyshi2114
    @joeyshi2114 2 ปีที่แล้ว +3

    I find it's often simpler to define a string with the character set like CHAR_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".
    Then, mapping a single `val` becomes as simple as CHAR_MAP[int(val) % len(CHAR_MAP)].
    - I use len(CHAR_MAP) here because this makes things easier if we ever wanted to extend our character set.

    • @rasraster
      @rasraster ปีที่แล้ว

      Amen, brother! The ascii route seemed overly complex.

  • @masudrahman253
    @masudrahman253 2 ปีที่แล้ว

    Love this tutorial. Thanks John . Grad to find your youtube channel.

  • @TheDutchisGaming
    @TheDutchisGaming 2 ปีที่แล้ว

    13:10 seems like I learned something today. Never knew such for statements were a thing.

  • @m2585r
    @m2585r 2 ปีที่แล้ว

    Awesome! Thanks for the vid, John, looking forward to more CTF content!

  • @Hlrguitar
    @Hlrguitar 2 ปีที่แล้ว +4

    Great one, keep these capture the flag videos coming

  • @avadhootsachingharat5312
    @avadhootsachingharat5312 2 ปีที่แล้ว

    Felt like a Python Class
    Loved it !!

  • @soniablanche5672
    @soniablanche5672 2 ปีที่แล้ว

    cool way to convert a string array to an int array
    int_array = list(map(int, string_array))
    you can also omit list() if you're not planning on grabbing a specific value from the array

  • @badmashito4059
    @badmashito4059 2 ปีที่แล้ว

    Wow !!!
    I didnt thought that python would help us in our ctf challenges . thanks a lot sir for bring such a QUALITY Content ❤️❤️❤️😌

  • @abulaman8713
    @abulaman8713 2 ปีที่แล้ว +2

    Nice one, simple but nice

  • @Colaholiker
    @Colaholiker 2 ปีที่แล้ว +2

    It would probably be too high of a python level for the intended audience, but I would have started building a combined string of string.ascii_uppercase + ascii.digits + '_',, and then generated the characters in a single instruction inside the list comprehension
    translate = string.ascii_uppercase + string.digits + '_' # Todo: Find better name for this ;-)
    # (...) Read file into variable named content
    characters = [translate[int(x) % 37] for x in content.split()]
    Now all that is left to do is join the items of the list "characters" into the flag string.
    The benefit is that we don't need to go through the if/else statements and we don't need to worry about getting the index straight for the digits.

    • @vHawkeyev
      @vHawkeyev 2 ปีที่แล้ว +1

      I was thinking the same thing. It greatly decreases the amount of lines needed and is easier to read IMO.

    • @Colaholiker
      @Colaholiker 2 ปีที่แล้ว

      @@vHawkeyev Absolutely! But like I said, maybe he wanted to keep things simpler for people with less programming experience. (In which case I would have not used list comprehension at all, as this takes a moment to get your head wrapped around. At least it did for me, despite having a ton of experience programming in many different languages before learning Python.)

  • @rajeshsagar3912
    @rajeshsagar3912 2 ปีที่แล้ว

    your programming skills are amazing....anyways thnx for the video

  • @narasimha6736
    @narasimha6736 2 ปีที่แล้ว

    Thank you John

  • @thelegomas9301
    @thelegomas9301 2 ปีที่แล้ว +1

    Simple but well done, great explanations as usual, as a side-note, the string.digits is unnecessary since all the (values -26) are already exactly the digits you are indexing, as an example: string.digits[0] = 0, could have simply used the indexing-variable but keep up the great content!!

    • @pavelprchal8625
      @pavelprchal8625 2 ปีที่แล้ว

      You’re thinking in same way. str = “abcdef” str[n]

  • @wimnanoe5887
    @wimnanoe5887 2 ปีที่แล้ว +1

    Thank you John, still hope on a python course of you

  • @beyahbruce
    @beyahbruce 2 ปีที่แล้ว

    Yeah I gotta work on my python you did steps that made me think I was doing it the hard way. My reality atm lol thanks for that walk through.

  • @SunDevilThor
    @SunDevilThor 2 ปีที่แล้ว

    I really need to start learning and incorporating modules from the Python Standard Library in my scripts.

  • @georgehammond867
    @georgehammond867 2 ปีที่แล้ว

    great teaching in python3.

  • @Tkeechy
    @Tkeechy 2 ปีที่แล้ว +1

    John, Can you do a python only course? I learnt more in this video than I ever did trying to follow other python vids

    • @rajeshsagar3912
      @rajeshsagar3912 2 ปีที่แล้ว +1

      that's a nice idea.....yes john we need a python only course from you!

  • @greg_NL
    @greg_NL 2 ปีที่แล้ว +1

    John more such videos. Super cool.👍👍👍👍👍👍👍👍👍

  • @doc_ineeda_win5834
    @doc_ineeda_win5834 2 ปีที่แล้ว

    love the python tutorial real world use here on ctf hope to see more of that , thanks for all the vids your , awesome at teaching, ps what video is it you install subl in kali?

  • @Talyzeni
    @Talyzeni 2 ปีที่แล้ว

    Awesome content again... Really enjoy the python 101 tutorial. xD

  • @masudrahman253
    @masudrahman253 2 ปีที่แล้ว

    with open("message.txt") as file_object:
    contents = file_object.read()
    numbers = [ int(val) for val in contents.split() ]
    for number in numbers:
    modulus = number % 37
    if modulus in range(26):
    flag.append(string.ascii_uppercase[modulus])
    elif modulus in range(26,36):
    flag.append(string.digits[modulus-26])
    else:
    flag.append("_")

  • @learnwithshahzebb
    @learnwithshahzebb 7 หลายเดือนก่อน

    I’m learning python and I can bet if you start doing python challenges videos, you’ll have a developer fan base along with cyber geeks

  • @rickm1427
    @rickm1427 2 ปีที่แล้ว

    Yes!

  • @cheikhdione2895
    @cheikhdione2895 2 ปีที่แล้ว

    Keep going god job !

  • @yurilsaps
    @yurilsaps 2 ปีที่แล้ว

    Thanks for the video

  • @diabate6929
    @diabate6929 2 ปีที่แล้ว

    ALRIGHT!!!!

  • @chrochodilmociarny1342
    @chrochodilmociarny1342 2 ปีที่แล้ว

    Great video

  • @0xkavish
    @0xkavish 2 ปีที่แล้ว

    Keep it up

  • @AndrewFalgout
    @AndrewFalgout 2 ปีที่แล้ว

    Mr. Hammond. Can you share your bash command prompt setup? Loving it.

  • @7onysWorld
    @7onysWorld 2 ปีที่แล้ว

    I love it. Thank you so much

  • @lindanancy2728
    @lindanancy2728 2 ปีที่แล้ว +1

    Cool

  • @learnwithshahzebb
    @learnwithshahzebb 7 หลายเดือนก่อน

    John, here when if statement is true, why it’s showing the else statement output here? I’m learning python and cannot find a better teacher than you

  • @ashish6895
    @ashish6895 2 ปีที่แล้ว +1

    For the TH-cam algo❤️

  • @MattDeDuck
    @MattDeDuck 2 ปีที่แล้ว +1

    Having literally just done this challenge yesterday this made me feel dumb 😅

  • @Sqwince23
    @Sqwince23 2 ปีที่แล้ว

    would have concat the alpha chars + digits + "_" all into one string then take the index of taht long look up string directly without having to deal with all of the offsets.

  • @lukajeliciclux3074
    @lukajeliciclux3074 2 ปีที่แล้ว +2

    Great video. F string doesn’t work because you’re put three pairs of curly braces instead of two.

  • @angrybirds2472
    @angrybirds2472 3 หลายเดือนก่อน

    i knew all that mirc scripting would pay off with something i actually want to learn again......

  • @guilherme5094
    @guilherme5094 2 ปีที่แล้ว

    Geat👍!

  • @masudrahman253
    @masudrahman253 2 ปีที่แล้ว

    what does the flag.append(string.digits[modulus-26]) mean

  • @joerivandenabeele6707
    @joerivandenabeele6707 ปีที่แล้ว

    thx!

  • @PhrosstBite
    @PhrosstBite 2 ปีที่แล้ว

    What terminal is that?? I love the color changes and layout, tried setting it up with zsh and p10k but it doesn't look nearly that good

  • @teqnify63
    @teqnify63 2 ปีที่แล้ว

    Are you doing writeups for all of them?

  • @tylercoombs1
    @tylercoombs1 2 ปีที่แล้ว

    You should throw together a Udemy course John, you would make a killing bro

  • @Krewz
    @Krewz 2 ปีที่แล้ว

    I watched the ad and bought 10 computers

  • @rango099
    @rango099 10 หลายเดือนก่อน

    The moment i got the error on 20:44 i would have just generated a list from 26- whatever I wanted to use it to index with😂

  • @0xr1kk07
    @0xr1kk07 2 ปีที่แล้ว

    Alright!

  • @codywohlers2059
    @codywohlers2059 2 ปีที่แล้ว

    elif = else if

  • @jaswanthbsp
    @jaswanthbsp 2 ปีที่แล้ว

    Bro do buffer overflow 3, and flag leak from picoctf 2022

  • @masudrahman253
    @masudrahman253 2 ปีที่แล้ว

    2:43
    +

  • @OfficialSlippedHalo
    @OfficialSlippedHalo 2 ปีที่แล้ว

    This was definitely cryptography - maybe because it was so simple and most of the video was actually spent teaching python it didnt feel like it, but you decrypted a substitute cypher with a known key.

  • @kraemrz
    @kraemrz 2 ปีที่แล้ว

    Yt algo

  • @davsyl94
    @davsyl94 2 ปีที่แล้ว

    You're an awesome teacher!

  • @KramerEspinoza
    @KramerEspinoza 2 ปีที่แล้ว

    Great videos

  • @WathsalaDewmina
    @WathsalaDewmina 2 ปีที่แล้ว

    great video thanks