mirror of
https://github.com/vysecurity/LinkedInt.git
synced 2025-12-06 17:02:19 +01:00
fixed login
This commit is contained in:
parent
e654a9ae16
commit
9688ffd739
1 changed files with 21 additions and 36 deletions
47
LinkedInt.py
47
LinkedInt.py
|
|
@ -7,7 +7,6 @@
|
||||||
# --- Constrain to company filters
|
# --- Constrain to company filters
|
||||||
# --- Addition of Hunter for e-mail prediction
|
# --- Addition of Hunter for e-mail prediction
|
||||||
|
|
||||||
|
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -42,44 +41,30 @@ username = config.get('CREDS', 'linkedin_username')
|
||||||
password = config.get('CREDS', 'linkedin_password')
|
password = config.get('CREDS', 'linkedin_password')
|
||||||
|
|
||||||
def login():
|
def login():
|
||||||
cookie_filename = "cookies.txt"
|
URL = 'https://www.linkedin.com'
|
||||||
cookiejar = cookielib.MozillaCookieJar(cookie_filename)
|
s = requests.Session()
|
||||||
opener = urllib2.build_opener(urllib2.HTTPRedirectHandler(),urllib2.HTTPHandler(debuglevel=0),urllib2.HTTPSHandler(debuglevel=0),urllib2.HTTPCookieProcessor(cookiejar))
|
rv = s.get(URL + '/uas/login?trk=guest_homepage-basic_nav-header-signin')
|
||||||
page = loadPage(opener, "https://www.linkedin.com/")
|
p = BeautifulSoup(rv.content, "html.parser")
|
||||||
parse = BeautifulSoup(page, "html.parser")
|
|
||||||
|
|
||||||
csrf = parse.find(id="loginCsrfParam-login")['value']
|
csrf = p.find(attrs={'name' : 'loginCsrfParam'})['value']
|
||||||
|
csrf_token = p.find(attrs={'name':'csrfToken'})['value']
|
||||||
login_data = urllib.urlencode({'session_key': username, 'session_password': password, 'loginCsrfParam': csrf})
|
sid_str = p.find(attrs={'name':'sIdString'})['value']
|
||||||
page = loadPage(opener,"https://www.linkedin.com/uas/login-submit", login_data)
|
|
||||||
|
|
||||||
parse = BeautifulSoup(page, "html.parser")
|
|
||||||
cookie = ""
|
|
||||||
|
|
||||||
|
postdata = {'csrfToken':csrf_token,
|
||||||
|
'loginCsrfParam':csrf,
|
||||||
|
'sIdString':sid_str,
|
||||||
|
'session_key':username,
|
||||||
|
'session_password':password,
|
||||||
|
}
|
||||||
|
rv = s.post(URL + '/checkpoint/lg/login-submit', data=postdata)
|
||||||
try:
|
try:
|
||||||
cookie = cookiejar._cookies['.www.linkedin.com']['/']['li_at'].value
|
cookie = requests.utils.dict_from_cookiejar(s.cookies)
|
||||||
|
cookie = cookie['li_at']
|
||||||
except:
|
except:
|
||||||
print "[!] Cannot log in"
|
print "[!] Cannot log in"
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
cookiejar.save()
|
|
||||||
os.remove(cookie_filename)
|
|
||||||
return cookie
|
return cookie
|
||||||
|
|
||||||
def loadPage(client, url, data=None):
|
|
||||||
try:
|
|
||||||
response = client.open(url)
|
|
||||||
except:
|
|
||||||
print "[!] Cannot load main LinkedIn page"
|
|
||||||
try:
|
|
||||||
if data is not None:
|
|
||||||
response = client.open(url, data)
|
|
||||||
else:
|
|
||||||
response = client.open(url)
|
|
||||||
return ''.join(response.readlines())
|
|
||||||
except:
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def get_search():
|
def get_search():
|
||||||
|
|
||||||
body = ""
|
body = ""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue