Executing an arbitrary function from a PHP file on pfSense

I accidentally overwrote the bind service’s startup script in /usr/local/etc/rc.d/. I had no backup, and I couldn’t remember the contents of the file. I had a look at the pfSense github packages repository and had a look through the bind section. I found bind.inc which had a function called bind_write_rcfile(). I toyed around with the idea of copying and pasting the code by hand, replacing the variables with their values (or what I thought were the values). I remembered that pfSense has a developer shell which allows you to execute PHP code. You type in the PHP and then type exec and press enter. The code gets executed. Yay. I required_once('bind.inc') and then pressed enter, then typed exec and again pressed enter. I jumped into the shell and checked the contents of the file, and hey presto! it was fixed.

This post is for my future reference. I hope it helps you too!


What say you?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.