-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfacebook_post.py
87 lines (63 loc) · 1.78 KB
/
facebook_post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import mechanize
import cookielib
import sys
import getpass
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
url = 'https://m.facebook.com/login.php'
def post_msg():
br.select_form(nr=1)
print "The message will get updated from your facebook profile, post carefully\n"
message = raw_input("Enter the post: ")
br.form['xc_message'] = message
br.submit(name='view_post')
print "[+] Post updated successfully.\n"
r = raw_input("Do you want to post something again? (y/n): ")
if r=='y':
post_msg()
elif(r=='n'):
print "Exiting. . ."
br.close()
sys.exit(0)
else:
print "Enter correct value\n"
sys.exit(0)
def fb_login():
email = raw_input("Enter your username: ")
pwd = getpass.getpass()
br.select_form(nr=0)
br.form['email'] = email
br.form['pass'] = pwd
br.submit()
login_url = br.geturl()
error_login = 'https://m.facebook.com/login.php?'
s = login_url.find(error_login)
if(s==-1):
print "\n[+] Login successful!\n"
check_url = br.geturl()
checkpoint = 'https://m.facebook.com/checkpoint/?'
c = check_url.find(checkpoint)
if(c==-1):
post_msg()
else:
print "Checkpoint Found. . ."
br.select_form(nr=0)
br.submit(name='submit[Continue]')
print "[+]Checkpoint bypassed.\n"
post_msg()
elif(s!=-1):
print "\n[+] Wrong credentials entered!"
print "Try again. . .\n"
fb_login()
br.open(url)
fb_login()