forked from web20suicide/cgi-bin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suicide_linkedin.py
235 lines (227 loc) · 8.01 KB
/
suicide_linkedin.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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import random,time
import csv, logging, urllib
import re, sys, os
import settings,MySQLdb
import sendkillermail
#*******************************************************
# global settings
dbconn = settings.connect_db()
cursor = dbconn.cursor(MySQLdb.cursors.DictCursor)
#*******************************************************
def delLinkedIn(sel,amount):
try:
sel.open("http://www.linkedin.com/connections?trk=hb_side_connections")
except:
pass
try:
logging.info("[ok] will try to kill " + str(amount) + " business links")
for i in range(0,int(amount)):
try:
sel.click("link=Remove Connections")
logging.info("[ok] follow link Remove Connections")
except:
sel.open("http://www.linkedin.com/connections?displayBreakConnections=&goback=%2Ecnt_false_0_0")
logging.info("[ok] follow link hardcoded Remove Connections")
random_wait = random.randint(4,8)
time.sleep(random_wait)
try:
sel.click("connectionChooser")
logging.info("[ok] selected checkbox connectionChooser")
random_wait = random.randint(1,3)
time.sleep(random_wait)
sel.click("breakConnections")
logging.info("[ok] click button breakConnections")
random_wait = random.randint(1,3)
time.sleep(random_wait)
try:
sel.click("//input[@name='breakConnections' and @value='Yes, remove them']")
logging.info("[ok] answered dialog with yes")
except:
logging.warning("[failed] answering dialog with yes")
sel.click("id=break-connection-link")
logging.info("[ok] clicked a href with id break-connection-link")
random_wait = random.randint(1,3)
time.sleep(random_wait)
pass
random_wait = random.randint(2,6)
time.sleep(random_wait)
logging.info("[ok] one business link deleted!")
except:
logging.warning("[failed] account deletion faild")
except:
logging.info("[failed] business link couldn't be deleted!")
pass
return sel
def getInfo(sel,lastwords,command,email):
sel.open("http://www.linkedin.com/home")
capturepath = "/var/www/profiles/img/"
filename = str(int(time.time())) + ".png"
capture = capturepath + filename
# get profile name and friends amount with regex-vodoo
websource = sel.get_html_source()
try:
# regex to catch profile image
sel.open("http://www.linkedin.com/myprofile?trk=hb_tab_pro")
websource2 = sel.get_html_source()
m = re.search('<a href="\/myprofile\?trk=nus_stat_photo&goback=%2Ehom"><img src="(.*?)shrink_40_40\/(.*?)"',websource2,re.IGNORECASE)
profile_picture = m.group(1) + m.group(2)
logging.info("[ok] got the profile picture " + profile_picture)
except:
profile_picture = "http://static03.linkedin.com/img/icon/icon_no_photo_80x80.png"
logging.warning("[failed] 2nd profile picture regex failed, using default one!!!")
logging.error(websource2)
pass
try:
logging.info("[ok] url of profile picture is " + profile_picture)
urllib.urlretrieve(profile_picture, capture)
logging.info("[ok] image moved to " + capture)
except:
logging.warning("[failed] profile picture download failed!!!")
pass
try:
# modifying pciture so it fits on our wall of fame
cropme = "convert %s -resize '200' %s" %(capture,capture)
os.system(cropme)
print cropme
logging.info("[ok] image cropped to 200px width")
except:
logging.error("[failed] image not cropped")
pass
try:
# regex to catch username
m = re.search('<span class="given-name">(.*)</span>\n',websource,re.IGNORECASE)
g = re.search('<span class="family-name">(.*)</span>\n',websource,re.IGNORECASE)
username = m.group(1) + " " + g.group(1)
logging.info("[ok] username logged in as " + username)
logging.info("[ok] " + username + " last words are " + lastwords)
except:
logging.warning("[failed] username regex failed!!!")
logging.error(websource)
try:
m = re.search('<a href="\/myprofile\?trk=hb_pro" title="Edit profile">(.*?)</a>',websource,re.IGNORECASE)
username = m.group(1)
logging.info("[ok] " + username + " last words are " + lastwords)
except:
logging.warning("[failed] 2nd username regex failed!!!")
pass
pass
try:
sel.open("http://www.linkedin.com/connections?trk=hb_side_connections")
websource = sel.get_html_source()
time.sleep(2)
m = re.search('<strong id="count-showing">(.*?)</strong>',websource,re.IGNORECASE)
friends = m.group(1)
logging.info("[ok] " + username + " has " + friends + " friends!")
except:
logging.error(websource)
logging.warning("[failed] friendsamount regex failed!!!")
friends = "0"
pass
# sql query
try:
# q = "INSERT INTO web20suicide.users(`id`,`username`,`friends`,`picture`,`lastwords`,`command`,`t_create`,`email`,) VALUES (NULL,%s,%s,%s,%s,%s,CURRENT_TIMESTAMP,%s)"
#cursor.execute(q, (username,friends,filename,lastwords,command,email))
sendkillermail(capture,username,friends,lastwords,command)
logging.info("[ok] user " + username + " added to mysql")
try:
q2 = "SELECT id FROM web20suicide.users WHERE command='" + command + "' ORDER BY id DESC LIMIT 1"
cursor.execute(q2)
user_id = cursor.fetchone()
user_id = str(user_id.values())
user_id = user_id.strip("[]L")
logging.info("fetching last row ID: " + str(user_id))
except:
logging.warning("[failed] to catch last user id")
pass
except:
logging.warning("[failed] mysql insert failed!!")
pass
return friends,user_id
def changePicture(sel,filename):
logging.info("[ok] changing picture now")
sel.open("http://www.linkedin.com/memberPicture?display=&goback=.prf_en*4US")
#sel.open("http://www.linkedin.com/myprofile?trk=hb_upphoto")
#random_wait = random.randint(6,9)
#time.sleep(random_wait)
#sel.click("//div[@id='content']/div[1]/div/div[1]/p/span/a")
random_wait = random.randint(6,10)
time.sleep(random_wait)
try:
sel.type("//input[@name='file']", filename)
except:
random_wait = random.randint(8,12)
time.sleep(random_wait)
sel.type("//input[@name='file']", filename)
pass
random_wait = random.randint(1,3)
time.sleep(random_wait)
sel.click("bt-upload-submit")
random_wait = random.randint(1,3)
time.sleep(random_wait)
sel.click("bt-save-photo")
random_wait = random.randint(1,3)
time.sleep(random_wait)
sel.open("http://www.linkedin.com/home")
random_wait = random.randint(1,3)
time.sleep(random_wait)
return sel
def changePassword(sel,password,newpassword):
logging.info("[ok] changing language now")
sel.open("https://www.linkedin.com/secure/settings?goback=%2Eaas&trk=hb_acc")
random_wait = random.randint(3,5)
time.sleep(random_wait)
try:
sel.click("link=Sprache")
sel.click("link=English")
sel.click("//ul[@id='lang-list']/li[1]/a/strong")
logging.info("[ok] language was set to german")
except:
try:
sel.click("link=Langue")
sel.click("link=English")
sel.click("//ul[@id='lang-list']/li[1]/a/strong")
logging.info("[ok] language was set to french")
except:
try:
sel.click("link=Idioma")
sel.click("link=English")
sel.click("//ul[@id='lang-list']/li[1]/a/strong")
logging.info("[ok] language was set to spanish")
except:
logging.info("[ok] language was set to english")
pass
try:
sel.click("//ul[@id='lang-list']/li[1]/a/strong")
except:
try:
sel.click("link=English")
logging.info("[ok] changed language to English")
except:
pass
random_wait = random.randint(2,5)
time.sleep(random_wait)
logging.info("[ok] changing password now")
try:
sel.open("https://www.linkedin.com/secure/settings?pass=&goback=%2Eaas")
except:
logging.warning("couldn't click the change Password button")
sel.click("link=Change Password")
pass
random_wait = random.randint(4,7)
time.sleep(random_wait)
sel.type("old_password-changePassword", password)
sel.type("new_password-new_password-changePassword", newpassword)
random_wait = random.randint(1,3)
time.sleep(random_wait)
sel.type("new_password_again-new_password-changePassword", newpassword)
random_wait = random.randint(1,3)
time.sleep(random_wait)
sel.click("updpass")
random_wait = random.randint(4,8)
time.sleep(random_wait)
def logout(sel):
random_wait = random.randint(1,3)
time.sleep(random_wait)
sel.click("link=Sign Out")
random_wait = random.randint(5,9)
time.sleep(random_wait)