Exploiting Java Tomcat With a Crazy JSP Web Shell - Real World CTF 2022

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • This was a hard web CTF challenge involving a JSP file upload with very restricted character sets. We had to use the Expression Language (EL) to construct useful primitives and upload an ascii-only .jar file.
    Alternative writeups: github.com/voi...
    Fuzzing log4j with Jazzer: • Fuzzing Java to Find L...
    =[ ❤️ Support ]=
    → per Video: / liveoverflow
    → per Month: / @liveoverflow
    =[ 🐕 Social ]=
    → Twitter: / liveoverflow
    → Instagram: / liveoverflow
    → Blog: liveoverflow.com/
    → Subreddit: / liveoverflow
    → Facebook: / liveoverflow

КОМЕНТАРІ • 117

  • @TheThirdPrice
    @TheThirdPrice 2 роки тому +294

    Wow! What a crazy technique, mad props to the folks who wrote the ASCII only jar, that's mental

    • @logiciananimal
      @logiciananimal 2 роки тому +9

      Indeed - that's incredible. We could have had fun with that 25 years ago and not worried about uuencode! :)

  • @PaulFisher
    @PaulFisher 2 роки тому +123

    I can explain part of this! The reason that your uploaded jar got corrupted is because of the way String works in Java. Unlike a string in e.g. C++ or Go, String in Java represents a sequence of Unicode codepoints, much like the str class in Python. When you uploaded your jar, the bytes of your query had to be converted to a String at some point before the «GARBAGE BEFORE + data + GARBAGE AFTER» step. So your input bytes got interpreted as UTF-8 sequences, but because most binary data is just going to be invalid UTF-8, it all got replaced with � (which is then encoded back to UTF-8 as EFBFBD when the file is written). The pure-ASCII zipfile is an ingenious workaround.

  • @ismailcotton913
    @ismailcotton913 2 роки тому +115

    AHA! FINALLY afters years understanding nothing but "Bahnhof" of your videos, I as a java dev, understand a tiny bit. Feels good.

  • @saketsrv9068
    @saketsrv9068 2 роки тому +24

    What a genius guy,wish one day i could get even close to you

  • @MeriaDuck
    @MeriaDuck 2 роки тому +46

    As a java developer, just ❤️ this one.
    My first thought for that replace chat was that neck slash wasn't excluded, so maybe \u123 like tricks could play a role.
    Did not see the ASCII only zip file coming. Just how do you create that... Magic 🤣

    • @MeriaDuck
      @MeriaDuck 2 роки тому +2

      Auto correct and late night commenting made a mess of that, meant char and backslash.

  • @cauhxmilloy7670
    @cauhxmilloy7670 2 роки тому +20

    10:16 "..and it was private static final anyways." This shouldn't be a problem.
    First, the `final` only protects the reference to the array from changing, not the array itself. In C++ terms, `final` is the equivalent of `T * const`, Java has no concept of `T const *` or `T const * const` unless T is defined to be always immutable. Sure Strings are immutable in Java, but arrays are fair game.
    Next, the fact that it's `static` could be helpful, not a hindrance. This means that there is no overall object reference for `ParamUtil` to find, there is only one instance of the `SPECIAL_CHARS` in the whole program. This should be findable with reflection.
    Lastly, the `private` should be no problem if you're using reflection. Reflection does not care about member visibility.
    I'm not sure what reflection you could have pulled off, given the challenge's constrained jsp; so maybe this would still end up being a dead end. I just wanted to share some Java technicalities. 😎

  • @MarcoZanon
    @MarcoZanon 2 роки тому +5

    I have to watch your video multiple times just to appreciate all the details you give to audience. It's fenomenal

  • @DawnnDusk-k4n
    @DawnnDusk-k4n 2 роки тому +44

    How are you creating content that will forcefully put the viewer to watch the whole video without skipping any part? Its 100% amazing. Superior content btw. Loved it😍

    • @secureitmania
      @secureitmania 2 роки тому +2

      It took me an hour to complete this video 😂😂

    • @DawnnDusk-k4n
      @DawnnDusk-k4n 2 роки тому +1

      @@secureitmania ha ha😁

  • @crlfff
    @crlfff 2 роки тому +8

    insane, i would not figure this out in my entire life if you gave me that time

  • @wouterr6063
    @wouterr6063 2 роки тому +7

    CTF challenge vids are one of my favorite types of videos on this channel!

  • @_DeProgrammer
    @_DeProgrammer 2 роки тому +2

    this video was dope. thanks for taking the time to make this content, much love!

  • @akshaymall6462
    @akshaymall6462 2 роки тому +3

    This is the kind of cyber security expert I aspire to become......just so much dedication

  • @blizzy78
    @blizzy78 2 роки тому +24

    So what do we learn from this? Tomcat's applicationScope object is read-write instead of read-only, which is a bad idea.

    • @kebien6020
      @kebien6020 2 роки тому +11

      Also, don't implement file upload in Java because Java will dynamically load code for any reason at all

  • @gerardmarquinarubio9492
    @gerardmarquinarubio9492 2 роки тому +1

    This was the most interesting CTF video I've ever seen. Normally, I don't understand shit, but you explained everything so well.

  • @ndm13
    @ndm13 2 роки тому +9

    Beautiful solution. I genuinely don't understand why Apache regularly does stupidly insecure things with class loading.

  • @0x2a1A4
    @0x2a1A4 Рік тому

    solving this must feel great, but creating such a challenge.... you must be a wizard...

  • @_xzvf2557
    @_xzvf2557 2 роки тому +2

    That is a crazy exploit, well done!

  • @oblivion_2852
    @oblivion_2852 2 роки тому +1

    The ascii only zip is really interesting

  • @eamonmulholland3159
    @eamonmulholland3159 2 роки тому

    A bunch of this flew over my head but I loved it. Props to you and your team for the great work!

  • @Myzreal92
    @Myzreal92 2 роки тому +1

    Just a note on the URL class and the "fix it plz java" note - there's nothing to fix, that's an immutable object and it's supposed to be like that. You want a new URL - you create a new instance of that class.

  • @mgetommy
    @mgetommy 2 роки тому +13

    So cool…. As a web dev this scares me lol

  • @bertrahm3104
    @bertrahm3104 2 роки тому +5

    13:11 Stupid Question: Couldn't you have just made a StringInterpreter Compatible class and then call do your arbitrary code execution from the constructor since its instantiated immediatly?

    • @LiveOverflow
      @LiveOverflow  2 роки тому +2

      sure could have done that as well. But makes no difference if we execute the code in static section or in the constructor. Wouldn't have changed much.

    • @bertrahm3104
      @bertrahm3104 2 роки тому

      @@LiveOverflow yeah, it just seemed easier to me at the moment

  • @vectoralphaSec
    @vectoralphaSec 2 роки тому +3

    love the new glasses.

  • @c14n_
    @c14n_ 2 роки тому +3

    Hey what about the STÖK glasses? haha

  • @saranshjain5391
    @saranshjain5391 Рік тому

    the thing is i dont know any bit of coding , still I am watching it and having fun , and can safely say yeah this field is for me I need to take it in colleague as majours even if I need to compromise a better colleague for the subject.

  • @konfushon
    @konfushon 2 роки тому +2

    This guy's a genius

  • @FVT-tn8ji
    @FVT-tn8ji 2 роки тому

    I don't understand anything at all but this is interesting af! Thanks for uploading

  • @Azulath.
    @Azulath. 2 роки тому +1

    Nice video - quick comment from my side: I have found JADX being superior to JD-GUI, since the latter has issues with a few class files and the other has not.

  • @constexprDuck
    @constexprDuck 2 роки тому +1

    Why did you put angle brackets on your head and disable your glasses for the thumbnail? I'm confused. But great video!

  • @triularity
    @triularity 2 роки тому

    Just wondering if the start was anything like that early scene in Blue Streak where he says "What is the first thing you do? You check if it's open." Only, in this case, you check if it's log4j vulnerable. ;)

  • @ripplerxeon
    @ripplerxeon 2 роки тому

    I just know basics programming stuff but the video made me watch this like I knew everything what he said ... Magic ✨

  • @FUTUREPES
    @FUTUREPES 2 роки тому +2

    On glasses in a stream nicee

  • @michaeldprovenzano9936
    @michaeldprovenzano9936 2 місяці тому

    Thats insane!!!

  • @rapid2950
    @rapid2950 2 роки тому

    *me just nodding to everything he says with a wistful expression, whilst trying to understand it*

  • @realkorgo
    @realkorgo 2 роки тому

    Great video!

  • @EER0000
    @EER0000 2 роки тому +1

    About halfway through, my approach would be to upload a .class or jar file with remote shell in perhaps a static initializer field, then change the class path and execute the code from there. Let’s see if that’s the way you did it :D

    • @EER0000
      @EER0000 2 роки тому +1

      Close! Nice find and very creative solution!

  • @club6525
    @club6525 2 роки тому

    3:47 I thought the top file said something else for a second...

  • @0x150
    @0x150 2 роки тому +3

    glassesOverflow

  • @dhruvvanawat6562
    @dhruvvanawat6562 2 роки тому

    Thats a nice video.
    Can you please make a video on exploitation on vulnerable version of jetty.

  • @ichbins7203
    @ichbins7203 2 роки тому +1

    Very interesting video! I really like to watch your CTF videos. Aaaand ive got a question: how is your vscode theme called?

    • @lebit01
      @lebit01 2 роки тому +1

      Pretty sure it's Solarized Dark

    • @ichbins7203
      @ichbins7203 2 роки тому

      @@lebit01 thanks

  • @Jan.-
    @Jan.- 2 роки тому +1

    im waiting for the minecraft log4j vid xd

  • @gokhansahin7872
    @gokhansahin7872 2 роки тому +1

    Could you please describe how you make valid jar file with ascii-zip?

  • @quangvo4563
    @quangvo4563 2 роки тому

    Java web challenges are always good !!!!

  • @Nevermore101
    @Nevermore101 2 роки тому

    what a rollercoaster :D

  • @FUTUREPES
    @FUTUREPES 2 роки тому +1

    Well done sir

  • @abdulrahmanfaisal288
    @abdulrahmanfaisal288 2 роки тому

    If you click the number it will display on your video that video ended is ended like 51 minutes why ? Please can you explain and thanks

  • @LiEnby
    @LiEnby 2 роки тому +2

    ASCII ONLY JAR?
    WHAT.
    HOW IS THAT POSSIBLE

    • @blizzy78
      @blizzy78 2 роки тому

      compression dictionary

    • @fitmotheyap
      @fitmotheyap 2 роки тому

      Some souls were consumed in the making

  • @tristandostaler8953
    @tristandostaler8953 2 роки тому +1

    Maybe a dumb question, but would using a "
    " worked to remove the garbage on the beginning of the string?
    "GARBAGE" + "
    something else" + "GARBAGE" ?

    • @LiveOverflow
      @LiveOverflow  2 роки тому +2

      not a dumb question :)

      only affects how text is displayed. It tells the computer "now move the cursor back at the start". And so in reality, that garbage at the start is still there, it was just overwritten when it was displayed. And so it has no effect for when the computer tries to read this data as a file.

    • @tristandostaler8953
      @tristandostaler8953 2 роки тому

      @@LiveOverflow thanks! Makes sense!

  • @lopo8000
    @lopo8000 2 роки тому

    looking closer and closer to vitalik buterin by the day.

  • @aha6593
    @aha6593 2 роки тому

    I know little about the Java wepapp world. Decompille a class is regularly needed because the documentation is bad or fix a bug of a used software. A servlet to upload files gives actually control of OS running tomcat. What I dont understand how you get access to the .war file from a running Webapp in the net?

  • @DARKBRAIN90
    @DARKBRAIN90 2 роки тому

    Ooh no. Jemes kittle explain how to exploit this bug in his template injection talk

  • @randomguy3784
    @randomguy3784 2 роки тому

    Crazyyy technique! 😵

  • @nirshaashua6436
    @nirshaashua6436 2 роки тому

    Thanks for the video

  • @louisalakazam738
    @louisalakazam738 2 роки тому

    It's an amazing ctf!

  • @huhwhatwho7895
    @huhwhatwho7895 2 роки тому +2

    How did you work out 0xfffff number of hashes ?

    • @lepsycho3691
      @lepsycho3691 2 роки тому +2

      Okay, took me a little bit to figure this out, but it all come down to this:
      A md5 hash is 32 hex characters.
      One hex characters has 16 possible value [0-9] [a-f].
      So if the hash has to start with 5 specific characters, the total possible variation of 5 hex characters is 16^5 or 1,048,576.
      Now to explain what the python script does:
      We are generating random md5 hashes keeping only the first 5 char and putting them in a dictionary as the key and the seed as the value. The top loop will run until we have generated all possible combinations.

  • @kiwiwelch3620
    @kiwiwelch3620 2 роки тому

    Love your work but I fear your arms are going to snap in half

  • @IBITZEE
    @IBITZEE 2 роки тому

    Dude,,, I understand only parts of what you were explaining... but I couldn't stop seeing....
    great job.... and avoid Java!!!
    ;-)

  • @warker_de
    @warker_de 2 роки тому

    this ascii-zip crafting made me cry ... #ctflife I think

  • @modmah7191
    @modmah7191 2 роки тому

    all in >

  • @A00ii
    @A00ii 2 роки тому +1

    I understand 1% of this, i think i learning 🌭

  • @NoNameAtAll2
    @NoNameAtAll2 2 роки тому

    dark lighting makes you sad old dev, not the bright excited mind you were before

  • @anassbougazzoul5405
    @anassbougazzoul5405 2 роки тому

    new video lets goo

  • @venkatesangovindarajan863
    @venkatesangovindarajan863 2 роки тому

    Stupid question : In these CTF's do they provide the web-app source codess ? for you guys to figure the prblm on local machine.

    • @kebien6020
      @kebien6020 2 роки тому +1

      In this video it looks like they provided just the compiled .class files. But decompilers work really well on Java (as long as it is not intentionally obfuscated) so the decompiled code was pretty ok. They were also using an open-source library so you can just grab the source code for that from github.

  • @abdulrahmanfaisal288
    @abdulrahmanfaisal288 2 роки тому

    Hello please can you explain the doc exploit other thing I discover thing before when you type a

  • @manuyel4845
    @manuyel4845 2 роки тому +1

    welcome to the blind gang

  • @captainsalazar7166
    @captainsalazar7166 2 роки тому

    You are amazing

  • @sookmaideek
    @sookmaideek 2 роки тому

    DO U USING KALE LUNIX BRO❓

  • @syrrithplayz3824
    @syrrithplayz3824 2 роки тому

    You Joined My MC server without the web address or ip how did you do that ?

  • @zackenbaron6773
    @zackenbaron6773 2 роки тому

    What system do you run in this video?

  • @abdulrahmanfaisal288
    @abdulrahmanfaisal288 2 роки тому

    Video minute that it is even not in the video it display for you in example

  • @n1ghtmar3_orin
    @n1ghtmar3_orin 2 роки тому

    🔥🔥🔥

  • @thatcrockpot1530
    @thatcrockpot1530 2 роки тому

    badass

  • @lattaio2855
    @lattaio2855 2 роки тому +1

    Hey man. Someone recently logged onto my Minecraft server under the name Zaafir_Zuberi. He ran some long command, apologized for spam, then left. He linked his channel which led me here. What exactly did you do, and should I be concerned? I tried to find the acc but they must have changed the name or deleted it. Would appreciate a response.

    • @LiEnby
      @LiEnby 2 роки тому

      minecraft doenst use JSP

    • @lattaio2855
      @lattaio2855 2 роки тому

      @@LiEnby I know Minecraft doesn't. It was just his most recent video, so, I thought it would be more likely that he sees the comment.

    • @LiveOverflow
      @LiveOverflow  2 роки тому +7

      it was me, sorry for the spam. you don't need to be concerned. It's for an upcoming video series :) if you have any more questions, write me an email or DM me on twitter. sorry again!

    • @benasin1724
      @benasin1724 2 роки тому

      @@LiveOverflow lol

    • @fitmotheyap
      @fitmotheyap 2 роки тому

      @@LiveOverflow what are you doing to the poor guy lmao

  • @esra_erimez
    @esra_erimez 2 роки тому

    Does this mean that Tomcat is not secure?

    • @ltxr9973
      @ltxr9973 2 роки тому +2

      Not really. The way it's configured in the video is almost painful to watch as a Java dev. But Tomcat won't stop you from shooting yourself in your own foot either. There's so much stuff you can do in Java, there's a feature for everything. This kind of complexity can be dangerous.

  • @shurgars
    @shurgars 2 роки тому

    Nice

  • @mohittirkey7889
    @mohittirkey7889 2 роки тому

    Is it just me or is he really looking like Ed-Sheeran :D

  • @secureitmania
    @secureitmania 2 роки тому

    🔥🤯🤯🤯🤯😱

  • @goodtoot3145
    @goodtoot3145 2 роки тому

    on yaaaa

  • @topsovs839
    @topsovs839 2 роки тому

    Let's fix what broken for 5 years now.

  • @bibabutzemann4640
    @bibabutzemann4640 2 роки тому +1

    That’s for all genius hackers - you‘re the heros right now 🇺🇦❤️

  • @StorageESP
    @StorageESP 2 роки тому

    uh oh

  • @siddharthchhetry4218
    @siddharthchhetry4218 2 роки тому +1

    Nice i couldn't understand a shit:)

  • @btno222
    @btno222 2 роки тому

    Yu gained weight! Good yu look gewd!

  • @JustSomeAussie1
    @JustSomeAussie1 2 роки тому

    The way you pronounce "interpreter" drives me crazy

  • @spreen_co
    @spreen_co 2 роки тому

    first?

  • @XenoContact
    @XenoContact 2 роки тому

    thumbnail makes me not want to watch this video sorry

  • @senjuchidori9448
    @senjuchidori9448 2 роки тому +1

    bro use vim to sort, instead of VS code,

  • @SlashedSucks
    @SlashedSucks 2 роки тому

    56 secs ago???