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

Add support for FreeBSD #496

Open
pythononedog opened this issue Jul 4, 2023 · 5 comments
Open

Add support for FreeBSD #496

pythononedog opened this issue Jul 4, 2023 · 5 comments

Comments

@pythononedog
Copy link

I found image_ Build without freebsd.why does s2e not support freebsd?What do I need to do if I want it to support freebsd?

@pythononedog
Copy link
Author

I want to use s2e to analyze freebsd.

@vitalych vitalych changed the title S2E Question about freebsd Add support for FreeBSD Jul 4, 2023
@vitalych
Copy link
Member

vitalych commented Jul 4, 2023

The S2E engine shouldn't have any issues running FreeBSD or any other x86 OS. However, all the tooling around S2E only supports Linux and Windows. Here's what you could do to get started:

  • Build a VM image with BSD using vanilla QEMU, e.g., image.raw (it is important to have a raw image, not vmdk or something else).
  • Rename image.raw to image.raw.s2e. The s2e suffix will tell S2E that this should be handled with S2E image handler.
  • Boot the image in S2E mode using libs2e.so, save a "ready" snapshot (savevm ready command in QEMU console).
  • Resume the image.

s2e image_build builds Linux and Windows images in such a way that when they are resumed by launch-s2e.sh, they fetch a bootstrap script from the host. See [1] for details. Note that fetching files from the host requires the s2ecmd binary to be built for FreeBSD. Please check the guest/ folder, you may need to cross-compile it.

[1] https://s2e.systems/docs/ImageInstallation.html

Once you have guest tools built, you can technically start symbolic execution. Use that tool to create symbolic files in a ramdisk.

You may want to study the Linux tooling and tweak that for FreeBSD (e.g., s2e image_build, s2e new_project, etc).

To have full plugin support, you will need to create a FreeBSDMonitor plugin, similar to LinuxMonitor and WindowsMonitor. This may require instrumenting the kernel in order to provide the monitor all the required information to implement the OSMonitor interface.

@pythononedog
Copy link
Author

thanks,i'll give it a try.

@pythononedog
Copy link
Author

When I customize the freebsd VM image,I am unable to save the snapshot.

Screenshot from 2023-07-31 04-56-30
image

@vitaly-cyberhaven
Copy link

That's because qemu thinks it's a raw image. Those don't support snapshots.
You need to use something like this: -drive if=ide,index=0,file=image.raw.s2e,format=s2e,cache=writeback

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

No branches or pull requests

3 participants