-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoBOOMB.py
More file actions
196 lines (131 loc) · 4.77 KB
/
Copy pathnoBOOMB.py
File metadata and controls
196 lines (131 loc) · 4.77 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import requests
from bs4 import BeautifulSoup
def beauti4(res):
soup = BeautifulSoup(res.text, 'html.parser')
last_page = soup.find('form', id='mbasic-composer-form', href=True)['action']
title = soup.find('h1', class_='entry-title').text
return title, int(last_page)
def req(u, cookie):
s = requests.Session()
s.headers.update({'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0',
'Cookie':cookie})
res = s.get(u)
return res
def reqp(u, cookie, body):
s = requests.Session()
s.headers.update({'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0',
'Cookie':cookie})
res = s.post(u, data=body)
return res
def req_img(u, cookie, body, img):
s = requests.Session()
s.headers.update({'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0',
'Cookie':cookie})
res = s.post(u, data=body, files={'file':open(img, 'rb')})
return res
def load_cookie(fn):
with open(fn, 'r') as f:
return f.read()
def get_payload(res):
body = {}
base = 'https://mbasic.facebook.com'
soup = BeautifulSoup(res.text, 'html.parser')
form = soup.find('form', id='composer_form')
url = base + form['action']
inps = form.find_all('input', type="hidden")
print(form)
for inp in inps:
try:
#print(inp['name'], inp['value'])
body[inp['name']] = inp['value']
except:
body[inp['name']] = ''
body['send'] = '傳送'
body['body'] = ''
return url, body
def get_img_payload(res):
body = {}
soup = BeautifulSoup(res.text, 'html.parser')
form = soup.find('form', action=True, method='post')
url = form['action']
inps = form.find_all('input')
print(form)
for inp in inps:
try:
#print(inp['name'], inp['value'])
body[inp['name']] = inp['value']
except:
try:
body[inp['name']] = ''
except:
pass
# body['send'] = '傳送'
body['body'] = ''
#print('777777777777777', url)
return url, body
def send_msg(to, msg, cookie):
base = 'https://mbasic.facebook.com'
u = 'https://mbasic.facebook.com/messages/read/?fbid=' + to
res = req(u, cookie)
url, body = get_payload(res)
body['body'] = msg
print(body)
print(url)
#body='fb_dtsg=AQGwcg_x6a1JB5Y%3A8%3A1641554647&jazoest=21930&body=999&send=%E5%82%B3%E9%80%81&tids=cid.c.100003609124739%3A100076970858707&wwwupp=C3&ids%5B100003609124739%5D=100003609124739&referrer=&ctype=&cver=legacy&csid=057ee8c8-5ee1-4b45-8807-201b2f799798'
res = reqp(url, cookie, body)
print(res)
def send_like(to, cookie):
base = 'https://mbasic.facebook.com'
u = 'https://mbasic.facebook.com/messages/read/?fbid=' + to
res = req(u, cookie)
url, body = get_payload(res)
body['like'] = "讚"
print(body)
print(url)
#body='fb_dtsg=AQGwcg_x6a1JB5Y%3A8%3A1641554647&jazoest=21930&body=999&send=%E5%82%B3%E9%80%81&tids=cid.c.100003609124739%3A100076970858707&wwwupp=C3&ids%5B100003609124739%5D=100003609124739&referrer=&ctype=&cver=legacy&csid=057ee8c8-5ee1-4b45-8807-201b2f799798'
res = reqp(url, cookie, body)
print(res)
def send_stk(to, sticker, cookie):
base = 'https://mbasic.facebook.com'
u = 'https://mbasic.facebook.com/messages/read/?fbid=' + to
res = req(u, cookie)
url, body = get_payload(res)
body['sticker_id'] = sticker
print(body)
print(url)
#body='fb_dtsg=AQGwcg_x6a1JB5Y%3A8%3A1641554647&jazoest=21930&body=999&send=%E5%82%B3%E9%80%81&tids=cid.c.100003609124739%3A100076970858707&wwwupp=C3&ids%5B100003609124739%5D=100003609124739&referrer=&ctype=&cver=legacy&csid=057ee8c8-5ee1-4b45-8807-201b2f799798'
res = reqp(url, cookie, body)
print(res)
def send_img(to, img, cookie):
base = 'https://mbasic.facebook.com'
u = 'https://mbasic.facebook.com/messages/read/?fbid=' + to
res = req(u, cookie)
url, body = get_payload(res)
body["send_photo"] = "新增相片"
#print(body)
url = 'https://mbasic.facebook.com/messages/photo/?%s=%s&%s=%s&%s=%s'%('ids', to, 'tids[0]', body['tids'], 'cancel', u)
print(body)
print(url)
res = reqp(url, cookie, body)
print(res)
url, body = get_img_payload(res)
print(url)
print(body)
res = req_img(url, cookie, body, img)
print(res)
url = "https://mbasic.facebook.com/groups/143704482352660"
url = ' /home.php?ref_component=mbasic_home_header&ref_page=%2Fwap%2Fhome.php&refid=7'
img = 'C:\\Users\\User\\Pictures\\funny\\photo.php.jpg'
cookie = load_cookie("cookie.txt")
print(cookie)
send_img('100000852003681', img, cookie)
#send_img('100003609124739', img, cookie)
#send_stk('100000852003681', '144885185685748', cookie) # sky
#send_like('100000852003681', cookie) # sky
#send_msg('100000852003681', '不告訴你~~', cookie) # sky
#send_msg('100003609124739', '吃飯啦', cookie)
'''
res = req(url, cookie)
with open('skyyyy.html', 'wb') as f:
f.write(res.content)
'''