Posted on Tuesday, 31st August 2010 by Michael

Facebook Bot: FBCbot.pl

FBCbot is a bot written in Perl to interface with Facebook on the users behalf. The bot is still in its infant stage and could definitely be improved upon. Currently FBCbot was developed on Linux though since it is written in Perl it can be modified to run on Windows as well. The FBCbot was developed in a way to allow for quick writing and adding of additional modules to it. Side note I am pretty new to programming in Perl, so if you see something that could be improved please let me know.

FBCbot works by checking all your friends status updates for key words that are predefined as commands in the bot. By default FBCbot comes with two modules. The “nmap” module allows users to post the command nmap xxx.xxx.xxx.xxx , where the xxx.xxx.xxx.xxx is the IP to NMAP. Once it is done scanning the IP it will post the results back to the wall of the user that issued the command. The “ping” module allows users to post the command pingpong xxx.xxx.xxx.xxx, where the xxx.xxx.xxx.xxx is the IP to PING. Once it is done pinging the IP it will post the results back to the wall of the user that issued the command.

To use FBCbot you will need to have a Perl interpreter installed on your operating system. I am currently using the default one that comes with Linux. You will need a way to schedule the bot to run, I currently use the cron to have it check every x amount of minutes. You will also need the Facebook command line application that was written by Dave Tompkins over at http://fbcmd.dtompkins.com/. This allows you to send commands via command line to Facebook as well as craft custom Facebook queries like you would do in SQL. Facebook command line runs on both Linux and Windows as well. Once you have this application you will need to overwrite the original fbcmd.php with my modified one. The modified one is provided in the zip along with FBCbot.pl: http://www.digitaloffensive.com/files/fbcbot.zip

I altered the original fbcmd.php file to add a common delimiter to the “fstatus” output to make separating the username and the command easier since the white space between the username and status is never the same. To do this I added “::” to be printed out right before the actual status

To add additional modules to FBCbot you can use the “elsif” syntax in Perl. Basically you would say

If $command = “x” then do “y” elsif $command =”a” then do “b” and so on. Just make sure to use proper syntax and close everything you open.

The current limitations to FBCbot are that it can only do 10 wall posts day. More than that will have it blocked for 48 hours. I am currently thinking of implementing a way that a user can provide an email address to have the results mailed to but that is a future though if more development is done FBCbot. I also need to take into consideration how to handle people leaving commands in their status over long periods of time.

Posted in Code | Comments (0)

Leave a Reply

*