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

Поделиться
HTML-код
  • Опубликовано: 2 окт 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! :)

  • @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.

  • @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.

  • @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.

  • @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

  • @saketsrv9068
    @saketsrv9068 2 года назад +24

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

  • @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!

  • @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. 😎

  • @crlfff
    @crlfff 2 года назад +8

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

  • @vectoralphaSec
    @vectoralphaSec 2 года назад +3

    love the new glasses.

  • @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😁

  • @konfushon
    @konfushon 2 года назад +2

    This guy's a genius

  • @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

  • @ndm13
    @ndm13 2 года назад +9

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

  • @FVT-tn8ji
    @FVT-tn8ji 2 года назад

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

  • @akshaymall6462
    @akshaymall6462 2 года назад +3

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

  • @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!

  • @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

  • @quangvo4563
    @quangvo4563 2 года назад

    Java web challenges are always good !!!!

  • @mgetommy
    @mgetommy 2 года назад +13

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

  • @rapid2950
    @rapid2950 2 года назад

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

  • @0x150
    @0x150 2 года назад +3

    glassesOverflow

  • @c14n_
    @c14n_ 2 года назад +3

    Hey what about the STÖK glasses? haha

  • @gokhansahin7872
    @gokhansahin7872 2 года назад +1

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

  • @_xzvf2557
    @_xzvf2557 2 года назад +2

    That is a crazy exploit, well done!

  • @randomguy3784
    @randomguy3784 2 года назад

    Crazyyy technique! 😵

  • @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.

  • @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.

  • @manuyel4845
    @manuyel4845 2 года назад +1

    welcome to the blind gang

  • @_DeProgrammer
    @_DeProgrammer 2 года назад +2

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

  • @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

  • @Jan.-
    @Jan.- 2 года назад +1

    im waiting for the minecraft log4j vid xd

  • @oblivion_2852
    @oblivion_2852 2 года назад +1

    The ascii only zip is really interesting

  • @FUTUREPES
    @FUTUREPES 2 года назад +2

    On glasses in a stream nicee

  • @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.

  • @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.

  • @anassbougazzoul5405
    @anassbougazzoul5405 2 года назад

    new video lets goo

  • @wouterr6063
    @wouterr6063 2 года назад +7

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

  • @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?

  • @0x2a1A4
    @0x2a1A4 Год назад

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

  • @A00ii
    @A00ii 2 года назад +1

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

  • @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

  • @siddharthchhetry4218
    @siddharthchhetry4218 2 года назад +1

    Nice i couldn't understand a shit:)

  • @XenoContact
    @XenoContact 2 года назад

    thumbnail makes me not want to watch this video sorry

  • @NoNameAtAll2
    @NoNameAtAll2 2 года назад

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

  • @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.

  • @abdulrahmanfaisal288
    @abdulrahmanfaisal288 2 года назад

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

  • @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!

  • @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. ;)

  • @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!

  • @michaeldprovenzano9936
    @michaeldprovenzano9936 2 месяца назад

    Thats insane!!!

  • @IBITZEE
    @IBITZEE 2 года назад

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

  • @dhruvvanawat6562
    @dhruvvanawat6562 2 года назад

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

  • @realkorgo
    @realkorgo 2 года назад

    Great video!

  • @FUTUREPES
    @FUTUREPES 2 года назад +1

    Well done sir

  • @DARKBRAIN90
    @DARKBRAIN90 2 года назад

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

  • @syrrithplayz3824
    @syrrithplayz3824 2 года назад

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

  • @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

  • @lopo8000
    @lopo8000 2 года назад

    looking closer and closer to vitalik buterin by the day.

  • @modmah7191
    @modmah7191 2 года назад

    all in >

  • @ripplerxeon
    @ripplerxeon 2 года назад

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

  • @abdulrahmanfaisal288
    @abdulrahmanfaisal288 2 года назад

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

  • @club6525
    @club6525 2 года назад

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

  • @sookmaideek
    @sookmaideek 2 года назад

    DO U USING KALE LUNIX BRO❓

  • @kiwiwelch3620
    @kiwiwelch3620 2 года назад

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

  • @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

  • @mohittirkey7889
    @mohittirkey7889 2 года назад

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

  • @btno222
    @btno222 2 года назад

    Yu gained weight! Good yu look gewd!

  • @warker_de
    @warker_de 2 года назад

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

  • @topsovs839
    @topsovs839 2 года назад

    Let's fix what broken for 5 years now.

  • @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.

  • @nirshaashua6436
    @nirshaashua6436 2 года назад

    Thanks for the video

  • @zackenbaron6773
    @zackenbaron6773 2 года назад

    What system do you run in this video?

  • @Nevermore101
    @Nevermore101 2 года назад

    what a rollercoaster :D

  • @thatcrockpot1530
    @thatcrockpot1530 2 года назад

    badass

  • @captainsalazar7166
    @captainsalazar7166 2 года назад

    You are amazing

  • @goodtoot3145
    @goodtoot3145 2 года назад

    on yaaaa

  • @spreen_co
    @spreen_co 2 года назад

    first?

  • @louisalakazam738
    @louisalakazam738 2 года назад

    It's an amazing ctf!

  • @secureitmania
    @secureitmania 2 года назад

    🔥🤯🤯🤯🤯😱

  • @shurgars
    @shurgars 2 года назад

    Nice

  • @n1ghtmar3_orin
    @n1ghtmar3_orin 2 года назад

    🔥🔥🔥

  • @StorageESP
    @StorageESP 2 года назад

    uh oh

  • @bibabutzemann4640
    @bibabutzemann4640 2 года назад +1

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

  • @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.

  • @JustSomeAussie1
    @JustSomeAussie1 2 года назад

    The way you pronounce "interpreter" drives me crazy

  • @senjuchidori9448
    @senjuchidori9448 2 года назад +1

    bro use vim to sort, instead of VS code,

  • @SlashedSucks
    @SlashedSucks 2 года назад

    56 secs ago???