Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished impl for CVE-2023-0386 #17

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

747745124
Copy link

No description provided.

@olegbck
Copy link
Collaborator

olegbck commented Nov 18, 2024

Everything seems to be working, but:

Please run the exploit from the "command" parameter in cvex.yml. Do not run it from the Ansible playbook. This way the playbook only installs the vulnerable service, CVEX takes a screenshot of the VM with it, and only then CVEX runs the exploit.

@747745124
Copy link
Author

I pushed the new changes, there might be ssh connection problem since it requires reboot.

For local testing, I add a function named _reconnect for src/cvex/ssh.py, and modify the apis to something simiilar to this.

    def upload_file(self, local: str, dest: str):
        """
        Upload a file to the remote server. Retry on connection loss.
        """
        self.log.info("Uploading %s -> %s...", local, dest)
        try:
            self.ssh.put(local, dest)
        except (paramiko.SSHException, OSError) as e:
            if "Socket is closed" in str(e):
                self.log.warning("SSH connection lost during upload. Attempting to reconnect...")
                self._reconnect()
                self.upload_file(local, dest)
            else:
                raise

    def download_file(self, local: str, dest: str):
        """
        Download a file from the remote server. Retry on connection loss.
        """
        self.log.info("Downloading %s -> %s...", dest, local)
        try:
            self.ssh.get(dest, local)
        except (paramiko.SSHException, OSError) as e:
            if "Socket is closed" in str(e):
                self.log.warning("SSH connection lost during download. Attempting to reconnect...")
                self._reconnect()
                self.download_file(local, dest)
            else:
                raise

playbook: ubuntu.yml
command:
- "cd /usr/local/bin && ./exp"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary empty lines

args:
executable: /bin/bash

- name: Output instructions for CVEX
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this command. The intention is to have a clean Ansible playbook that could be shared.

@olegbck
Copy link
Collaborator

olegbck commented Nov 19, 2024

Having binaries is not great. Can we have the source code and then build it during the Ansible run? Or, if it is super long and tedious process, could you at least add the source code of the binaries to the data folder?

Thank you for the SSH _reconnect() function, I believe I had encountered it sporadically as well. Could you please create a pull request with these changes on https://github.com/ucsb-seclab/CVEX/?

ubuntu:
playbook: ubuntu.yml
command:
- "cd /usr/local/bin && ./exp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gives me this:

2024-11-20 12:33:22,381 - INFO - [ubuntu] Executing 'cd /usr/local/bin && ./exp'...
2024-11-20 12:33:22,474 - INFO - [ubuntu] [+] exploit success!

2024-11-20 12:33:22,474 - INFO - [ubuntu] exp: mkdir ./ovlcap: Permission denied
sh: 1: ./ovlcap/upper/file: not found

Why do we see "Permission denied" after "exploit success!"? Is it OK?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my local test without ansible, it gives "exploit success!", followed by: sh: ... (waiting for prompt), i'll look into this

@olegbck
Copy link
Collaborator

olegbck commented Nov 20, 2024

I just thought... is it really that hard to build the source code? Shouldn't it be a simple gcc run, no? Could you please try to build it in the Ansible playbook and then use that version during execution?

@747745124
Copy link
Author

I just thought... is it really that hard to build the source code? Shouldn't it be a simple gcc run, no? Could you please try to build it in the Ansible playbook and then use that version during execution?

yes i'll do that. previously it was troublesome to do on a different ubuntu version, you'll have to modify the package source, since the ubuntu version might be no longer supported. I'll modify to compile locally.

@olegbck
Copy link
Collaborator

olegbck commented Jan 7, 2025

To install gcc, we need to add build-essential to the Install dependencies task of ubuntu.yml.

Building exp.c:

gcc exp.c -lcap -o exp

Building fuse.c:

gcc fuse.c -o fuse -D_FILE_OFFSET_BITS=64 -lfuse

What is the gc binary? Is it shellops.c?

Also, "Permission denied" still remains. exp tries to execute ./ovlcap/upper/file and fails to do so because the file is empty:

sh: 1: ./ovlcap/upper/file: Permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants