Monthly Archives: May 2011

Mechanics of Facebook Spamming

You’ve no doubt by now come across the spam posts posts on your profile by some of your other friends. I came across one such post today and I wanted to dissect and analyze how they do it. I was really also curious as to whether if it was a security issue with Facebook, or they’re playing on the user’s mentality to click on anything that seems mildly interesting.

Facebook Spam example

Facebook spam post step 1

The basics of such spamming methods are simple:

  • Post something that invokes the curiosity of the user
  • Personalize it
  • Make them click on it and spread it so more people see it

Because the above post says “hey kailash you look so stupid” I would be enticed into clicking and finding out more about it. And when I click on it, the URL (



&length=2%3A52&action_name=&payload_url=&buttonText=Play&gwid=1013 ) loads a swf file and I am guessing there’s a bug in Facebook which allows a flash file in a remote URL to execute. (I am yet to verify this with a POC)

Facebook Spam Example Step 2

Facebook spam post step 2

Then, the swf file takes over. When you click on the play button above, it autoloads the clipboard with a piece of escaped javascript, which all curious people copy and paste on their browser address bar and that leads to posts being made to their friends’ profiles.

Facebook Spam Example Step 3

Facebook Spam post step 3

Let’s take a closer look

javascript: (function () {

The above block of code is exactly what users copy and paste in their browser (url-escaped version of it) and the scripts listed there do their thing. The first function is used to append a tracking script (Analytics FTW!) to the DOM. The url ( loads a widget for tracking purposes and then comes the code where they load ( 25% of the time and ( 75% of time (Split-Testing FTW!)

Code inside

Code inside

Code inside

Brief explanation of code in the above two js files: When the user runs the javascript from their clipboard, it appends either of the two scripts. The script gets a bunch of the users’ friends and posts an enticing message to their walls. These messages are being formed by spinning one some the strings like ‘hey’, ‘HEY’, ‘WTF’, ‘OMG’, ‘ROTFL’, ‘YO’, ‘yo’, ‘YO!’, ‘omg!’, ‘omg’, ‘wtf’, ‘wtf!!’, ‘WTF!!’,’OMG!!’, ‘why are you’, ‘what are you doing’, ‘I can\’t believe you\’re’, ‘you look so stupid’, ‘i cant believe youre tagged’, ‘why are you tagged’,’you should untag yourself’, ‘in this video’, ‘in this vid’ and personalizes it with the friend’s name so it looks legit. The messages also contains a link to one of the malicious swf files from one of these domains ‘’, ‘’,’’ and it leads to the viral cycle.

For what it’s worth, Facebook seems to have taken action and deleted the actual application with the id 6628568379 so the actual intent of the spammers was never satisfied.

Why take so much trouble? The money involved. The spammers make money from CPA (Cost Per Action). Both these pieces of js embed two different CPA offers from the CPA network which looks to be an affiliate of, which I presume was going to be posted to the application page. Even though the page was deleted, the spreading is still on and I think it will not stop until users realize that it’s spam or the domains are seized.

Simple advice to avoid all such spam (TL;DR): DON’T COPY PASTE STUFF ON YOUR BROWSER’S URL BAR!