Enough with the applaud to the company coz they were great already.
I'm not here to lecture about hacking, but how to submit facebook status right? so, just follow the steps below and you can have a BOT that will send facebook status without human intervention.
1. First thing you have to do is to know the structure of the wap site, this time the facebook wap site http://m.facebook.com
2. Since we are using PERL, we have to install some libraries for sending HTTP request and cookies. install the libraries below:
- LWP::UserAgent
- HTTP::Cookies
3. After installing the 2 libraries into your server, we are now ready to do the coding. The code below is just a standard coding that we do in PERL.
#!/usr/bin/perl
require LWP::UserAgent;
use strict;
use warnings;
use HTTP::Cookies;
4. After we require the libraries, we need to initialize the variables we need.
my $lwpua = LWP::UserAgent->new;
5. Set your facebook username/email, password, and your status. please see below.
my $strUser = "<your facebook username/email>";
my $strPass = "<your facebook password>";
my $strStatus = "<your facebook status>";
6. Set up user agent that we will use to send HTTP request.
my $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ( 'Referer' => 'http://m.facebook.com/','User-Agent' => $user_agent);
7. Set up cookie file and jar.
my $cookie_file = "cookies.dat";
my $cookie_jar = HTTP::Cookies->new(
file => $cookie_file,
autosave => 1,
ignore_discard => 1);
$lwpua->cookie_jar($cookie_jar);
8. Setup the code for log-in to facebook. Please take note that you should know the link of the login page of the site which is http://m.facebook.com/login.php. The important thing here is to look for the FORM element in which the site is submitting the credentials. You also have to get all the important INPUT parameters for submission to the FORM. I pasted here the FORM element of the login page source as of today as reference. Below also are the ONLY details you need to login.
=begin
<form method="post" action="https://login.facebook.com/login.php?m=m&refsrc=http%3A%2F%2Fm.facebook.com%2login.php&fbb=rac4881b1&refid=9">
<input class="input" name="email" value="" type="text"/>
<input class="input" name="pass" type="password"/>
<input type="submit" value="Log In" class="btn btnC" name="login"/>
</form>
=cut
# logging in to facebook
my $response = $lwpua->post('http://m.facebook.com/login.php',
['email' => $strUser,
'pass' => $strPass,
'login' => 'Login'], @header);
9. After logging in, we have to extract the COOKIES and use it on our next SESSION or PAGE.
$cookie_jar->extract_cookies( $response );
$cookie_jar->save;
10. After saving the COOKIES, accessing the facebook home page should direct you to the home page where in you can send your STATUS. You can check that if you print the $response->content. I also pasted the code snippet of the content below as reference.
$response = $lwpua->get('http://m.facebook.com/home.php', @header);
my $form_data = $response->content;
=begin
<form method="post" id="composer_form" action="/a/home.php?fbb=r488fb708&refid=7"><input type="hidden" name="fb_dtsg" value="DdtLy" autocomplete="off" /><input type="hidden" name="post_form_id" value="726fdf3c15403500a70f64960565e305" /><input type="hidden" name="charset_test" value="€,´,€,´,水,Д,Є" /><div>What's on your mind?<br /><textarea class="composerInput" name="status" rows="2" onfocus="" onblur=""></textarea></div><input type="submit" value="Share" class="btn btnC" name="update" /></form>
=cut
11. Same thing here with the login page but this time, we need to know how the page sends a status message. find the FORM that submits STATUS. please take note that the site is frequently changing so you should know how to do the REGEX to catch all the PARAMETERS you need and for the benefit of this post, the above content is the updated content as of today and my REGEX below should be able to catch parameters such as: FORM ACTION, FB_DTSG, and POST_FORM_ID.
$form_data =~ s/\n//g;
$form_data =~ /form method="post" id="composer_form" action="(.*?)"(.*?)name="fb_dtsg" value="(.*?)"(.*?)name="post_form_id" value="(.*?)"/ig;
my $form_action = $1;
my $form_fbdtsg = $3;
my $form_id = $5;
12. Send now the STATUS message with the PARAMETERS needed below.
@header = ('Referer' => 'http://m.facebook.com/',
'User-Agent' => $user_agent);
$response = $lwpua->post('http://m.facebook.com'.$form_action,
['fb_dtsg' => $form_fbdtsg,
'post_form_id' => $form_id,
'status' => $strStatus,
'update' => 'Share'], @header);
$form_data = $response->content;
unlink($cookie_file);
1;
13. And, that's it!! below is the whole script. hope you were able to get it. next will be in PHP. yeah men!!
#!/usr/bin/perl
require LWP::UserAgent;
use strict;
use warnings;
use HTTP::Cookies;
my $lwpua = LWP::UserAgent->new;
my $strUser = "<your facebook username>";
my $strPass = "<your facebook password>";
my $strStatus = "<your facebook status>";
my $user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6";
my @header = ( 'Referer' => 'http://m.facebook.com/','User-Agent' => $user_agent);
my $cookie_file = "cookies.dat";
my $cookie_jar = HTTP::Cookies->new(
file => $cookie_file,
autosave => 1,
ignore_discard => 1);
$lwpua->cookie_jar($cookie_jar);
my $response = $lwpua->post('http://m.facebook.com/login.php',
['email' => $strUser,
'pass' => $strPass,
'login' => 'Login'], @header);
$cookie_jar->extract_cookies( $response );
$cookie_jar->save;
$response = $lwpua->get('http://m.facebook.com/home.php', @header);
my $form_data = $response->content;
$form_data =~ s/\n//g;
$form_data =~ /form method="post" id="composer_form" action="(.*?)"(.*?)name="fb_dtsg" value="(.*?)"(.*?)name="post_form_id" value="(.*?)"/ig;
my $form_action = $1;
my $form_fbdtsg = $3;
my $form_id = $5;
@header = ('Referer' => 'http://m.facebook.com/',
'User-Agent' => $user_agent);
$response = $lwpua->post('http://m.facebook.com'.$form_action,
['fb_dtsg' => $form_fbdtsg,
'post_form_id' => $form_id,
'status' => $strStatus,
'update' => 'Share'], @header);
$form_data = $response->content;
unlink($cookie_file);
1;
nice... very nice.. keep up the good work sir. :D i might use this on my future projects.. :D
ReplyDeleteanyway sir, you can embed \\<\/code\> on the code portion of your blog so to have unique font and visibility in your blog.
thanks.. just new here.. i will post all the codes i know to make my blog informative to everyone.. hehehe!!
ReplyDeleteplease check out my new post - http://paulgonzaga.blogspot.com/2010/12/how-to-submit-facebook-status-via-back_24.html
ReplyDeleteplease check the revised version of this post using oauth the "legay way" - http://paulgonzaga.blogspot.com/2011/01/posting-facebook-status-using-oauth-via.html
ReplyDelete