-
Notifications
You must be signed in to change notification settings - Fork 18
/
nuclearpokebot.py
143 lines (127 loc) · 5.97 KB
/
nuclearpokebot.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/python
import os
import pycurl
import cStringIO
import re
import time
username = "username"
password = "password"
returnpoke = True
newpoke = True
def login():
try:
os.remove("pycookie.txt")
except:
pass
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://www.facebook.com")
c.setopt(pycurl.COOKIEFILE, "pycookie.txt")
c.setopt(pycurl.COOKIEJAR, "pycookie.txt")
c.setopt(pycurl.WRITEFUNCTION, buf.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.ENCODING, "")
c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)")
c.perform()
curlData = buf.getvalue()
buf.close()
charsettest = re.findall(ur"name=\"charset_test\" value=\"([^\"]*)",curlData)
lgnrnd = re.findall(ur"name=\"lgnrnd\" value=\"([^\"]*)",curlData)
locale = re.findall(ur"name=\"locale\" value=\"([^\"]*)",curlData)
lsd = re.findall(ur"name=\"lsd\" value=\"([^\"]*)",curlData)
persistent = 1
default_persistent = 1
timezone = 480
lgnjs = time.time()
lgnjs = int(lgnjs)
postdata = 'charset_test='+charsettest[0]+'&locale='+locale[0]+'&email='+username+'&pass='+password+'&lsd='+lsd[0]+'&default_persistent='+str(default_persistent)+'&lgnjs='+str(lgnjs)+'&lgnrnd='+lgnrnd[0]+'&persistent='+str(persistent)+'&timezone='+str(timezone)
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL, "https://login.facebook.com/login.php?login_attempt=1")
c.setopt(pycurl.COOKIEFILE, "pycookie.txt")
c.setopt(pycurl.COOKIEJAR, "pycookie.txt")
c.setopt(pycurl.WRITEFUNCTION, buf.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.ENCODING, "")
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)")
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS, postdata)
c.setopt(pycurl.POSTFIELDSIZE, len(postdata))
#c.setopt(pycurl.VERBOSE, True)
c.perform()
curlData = buf.getvalue()
buf.close()
#print curlData
def poke():
#enter infinite poke loop
while True:
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(pycurl.URL, "https://www.facebook.com/pokes?notif_t=poke")
c.setopt(pycurl.COOKIEFILE, "pycookie.txt")
c.setopt(pycurl.COOKIEJAR, "pycookie.txt")
c.setopt(pycurl.WRITEFUNCTION, buf.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.ENCODING, "")
c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)")
c.perform()
curlData = buf.getvalue()
buf.close()
#print curlData
pokebackdata = re.findall(ur"<div class=\"pokeHeader fsl fwb fcb\"><a href=\"(.*?)\" data-hovercard=\"\/ajax\/hovercard\/user.php\?id=([0-9]*)\">([^<]*)<\/a> has poked you.<\/div>",curlData)
pokesuggestdata = re.findall(ur"<div class=\"userSuggestionName\"><span class=\"fwb\"><a href=\"https:\/\/www.facebook.com\/(.*?)\" data-hovercard=\"\/ajax\/hovercard\/user.php\?id=([0-9]*)\">([^<]*)<\/a><\/span><\/div>",curlData)
#print pokebackdata
userid = re.findall(ur"\"user\":\"([0-9]*)\"",curlData)
fb_dtsg = re.findall(ur"name=\"fb_dtsg\" value=\"([^\"]*)",curlData)
if len(pokesuggestdata)>0 and newpoke:
for victim in pokesuggestdata:
victimid = victim[1]
postdata = '__a=1&nctr[_mod]=pagelet_pysp&suggestion=1&__user='+str(userid[0])+'&fb_dtsg='+fb_dtsg[0]+'&uid='+str(victimid)
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL, "https://www.facebook.com/ajax/pokes/poke_inline.php")
c.setopt(pycurl.COOKIEFILE, "pycookie.txt")
c.setopt(pycurl.COOKIEJAR, "pycookie.txt")
c.setopt(pycurl.WRITEFUNCTION, buf.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.ENCODING, "")
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)")
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS, postdata)
c.setopt(pycurl.POSTFIELDSIZE, len(postdata))
#c.setopt(pycurl.VERBOSE, True)
c.perform()
curlData = buf.getvalue()
buf.close()
print "You poked "+victim[2]+"!"
if len(pokebackdata)>0 and returnpoke:
for victim in pokebackdata:
victimid = victim[1]
postdata = '__a=1&nctr[_mod]=pagelet_pokes&pokeback=1&__user='+str(userid[0])+'&fb_dtsg='+fb_dtsg[0]+'&uid='+str(victimid)
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL, "https://www.facebook.com/ajax/pokes/poke_inline.php")
c.setopt(pycurl.COOKIEFILE, "pycookie.txt")
c.setopt(pycurl.COOKIEJAR, "pycookie.txt")
c.setopt(pycurl.WRITEFUNCTION, buf.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.ENCODING, "")
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)")
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.POSTFIELDS, postdata)
c.setopt(pycurl.POSTFIELDSIZE, len(postdata))
#c.setopt(pycurl.VERBOSE, True)
c.perform()
curlData = buf.getvalue()
buf.close()
print "You return poked "+victim[2]+"!"
else:
time.sleep(3)
def main():
login()
poke()
if __name__ == "__main__":
main()