konomae / lastpass-python Goto Github PK
View Code? Open in Web Editor NEWLastPass Python API
Home Page: https://pypi.python.org/pypi/lastpass-python
License: MIT License
LastPass Python API
Home Page: https://pypi.python.org/pypi/lastpass-python
License: MIT License
While they're present in the API response, it seems like the "Notes" field of accounts is silently discarded. It would be nice if that was preserved.
Similarly, I don't understand why only certain types of notes are supported... the API responses clearly include even "Generic" free-form notes entries, but they're silently discarded...
We're getting a 420 response error (empty response content) from /login.php endpoint
We're able to login using the lastpass web interface correctly. Are you getting similar issues on login?
('Unexpected error:', <class 'lastpass.exceptions.NetworkError'>)
There is a major issue in the repository that causes the application to crash when calling open_remote on a vault due to Lastpass beginning to encrypt the URL field of sites. https://www.bleepingcomputer.com/news/security/lastpass-is-now-encrypting-urls-in-password-vaults-for-better-security/
lastpass.Vault.open_remote(username, password)
The open_remote call should not throw a TypeError
The open_remote call throws a TypeError
Pull request to attempt a decrypt else decode
#54
I got the following error on opening valut:
Traceback (most recent call last):
File "./main.py", line 76, in <module>
deploy(args)
File "./main.py", line 36, in deploy
service_deployer.deploy(docker_registry.get_project_image_name(project_config))
File "./lib/service_deployer.py", line 13, in deploy
self._fetch_credentials()
File "./lib/service_deployer.py", line 17, in _fetch_credentials
self._lastpass.fetch_all_credentials()
File "./lib/lastpass_client.py", line 34, in fetch_all_credentials
vault = Vault.open(blob, self._username, self._password)
File "./venv/lib/python3.6/site-packages/lastpass/vault.py", line 21, in open
return cls(blob, blob.encryption_key(username, password))
File "./venv/lib/python3.6/site-packages/lastpass/vault.py", line 38, in __init__
account = parser.parse_ACCT(i, key)
File "./venv/lib/python3.6/site-packages/lastpass/parser.py", line 73, in parse_ACCT
url, username, password = parse_secure_note_server(notes)
File "./venv/lib/python3.6/site-packages/lastpass/parser.py", line 131, in parse_secure_note_server
key, value = i.split(b':', 1)
ValueError: not enough values to unpack (expected 2, got 1)
From what I understand it failed to parse multiline note - when I print(i.split(b':', 1))
I get something like:
[b'Notes', b'* NOTE_TITLE']
[b'NOTE FIRST LINE']
It may be relevant that this is an enterprise shared forlder note.
I have been running an old version of lastpass-python (76d6e98 from May 2014) for a long time without any problems to access both "Sites" and "Secure notes" in my lastpass account (via vault.accounts). Today, I decided that I wanted to access the Notes-field for accounts, so I upgraded to lastpass-python master. I can now see the Notes-field, but ufortunately I can't seem to access the Secure notes any more. I can't seem to find them anywhere when looping through all accounts.
Is it possible to access the Secure notes somehow with a recent lastpass-python?
Hi,
I am using lastpass-python in my projects, but today morning stopped working and I am unable get credentials from lastpass.
Looks like they changed something in lastpass ...
I tried this with more accounts, with more computers, within more networks...
Thanks
Hi,
I looked at this code and ran over it with 2to3, which got it mostly working. I noticed some circular dependencies, which I got rid of, but ended up with a bit of a roadblock with the make_hash function:
In [1]: import lastpass
In [2]: vault = lastpass.Vault.open_remote('foo', 'goo')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-3a326fc22f5d> in <module>()
----> 1 vault = lastpass.Vault.open_remote('foo', 'goo')
/Users/nfaggian/Desktop/development/lastpass-python/lastpass/vault.py in open_remote(cls, username, password, multifactor_password)
10 @classmethod
11 def open_remote(cls, username, password, multifactor_password=None):
---> 12 return cls.open(cls.fetch_blob(username, password, multifactor_password), username, password)
13
14 # Creates a vault from a locally stored blob
/Users/nfaggian/Desktop/development/lastpass-python/lastpass/vault.py in fetch_blob(cls, username, password, multifactor_password)
26 @classmethod
27 def fetch_blob(cls, username, password, multifactor_password=None):
---> 28 return fetcher.Fetcher.fetch(fetcher.Fetcher.login(username, password, multifactor_password))
29
30 # This more of an internal method, use one of the static constructors instead
/Users/nfaggian/Desktop/development/lastpass-python/lastpass/fetcher.py in login(cls, username, password, multifactor_password)
36 def login(cls, username, password, multifactor_password=None):
37 key_iteration_count = cls.request_iteration_count(username)
---> 38 return cls.request_login(username, password, key_iteration_count, multifactor_password)
39
40 @classmethod
/Users/nfaggian/Desktop/development/lastpass-python/lastpass/fetcher.py in request_login(cls, username, password, key_iteration_count, multifactor_password, web_client)
71 'xml': 1,
72 'username': username,
---> 73 'hash': cls.make_hash(username, password, key_iteration_count),
74 'iterations': key_iteration_count,
75 }
/Users/nfaggian/Desktop/development/lastpass-python/lastpass/fetcher.py in make_hash(cls, username, password, key_iteration_count)
139 def make_hash(cls, username, password, key_iteration_count):
140 if key_iteration_count == 1:
--> 141 return hashlib.sha256(cls.make_key(username, password, 1).encode('hex') + password).hexdigest()
142 else:
143 return pbkdf2.pbkdf2_hex(
AttributeError: 'bytes' object has no attribute 'encode'
Do you want to get a python 3 version working together? I think it might be useful.
Cheers,
Nathan
Hi Konomae,
We (Costas and I) work at Schuberg Philis and we took inspiration from your repository to write a library for LastPass.
Since then our company has moved away from LastPass and we are wondering if you want to take over our code since we won't maintain it anymore, or reference it here.
Kind regards
Yorick Hoorneman
Please add a copy of the License into the repo.
It would be awesome if there was a way to get the password history of an item.
Maybe there is already a way and I didn't see it?
When I run the example script, I get the following back
Traceback (most recent call last):
File "example/example.py", line 18, in <module>
vault = Vault.open_remote(username, password)
File "build/bdist.macosx-10.9-x86_64/egg/lastpass/vault.py", line 10, in open_remote
File "build/bdist.macosx-10.9-x86_64/egg/lastpass/vault.py", line 21, in open
File "build/bdist.macosx-10.9-x86_64/egg/lastpass/vault.py", line 38, in __init__
File "build/bdist.macosx-10.9-x86_64/egg/lastpass/parser.py", line 73, in parse_ACCT
File "build/bdist.macosx-10.9-x86_64/egg/lastpass/parser.py", line 130, in parse_secure_note_server
ValueError: need more than 1 value to unpack
Any thoughts as to whats going wrong there?
Thanks
Alex
I used the example in this project and tested with a hardcoded string in my py script, but get this error. I'm running it on a mac OSx.
Traceback (most recent call last):
File "lp.py", line 29, in <module>
vault = Vault.open_remote(username, password, None, DEVICE_ID)
File "/Library/Python/2.7/site-packages/lastpass/vault.py", line 12, in open_remote
return cls.open(blob, username, password)
File "/Library/Python/2.7/site-packages/lastpass/vault.py", line 23, in open
return cls(blob, blob.encryption_key(username, password))
File "/Library/Python/2.7/site-packages/lastpass/vault.py", line 41, in __init__
self.accounts = self.parse_accounts(chunks, encryption_key)
File "/Library/Python/2.7/site-packages/lastpass/vault.py", line 62, in parse_accounts
key = parser.parse_SHAR(i, encryption_key, rsa_private_key)['encryption_key']
File "/Library/Python/2.7/site-packages/lastpass/parser.py", line 108, in parse_SHAR
key = decode_hex(rsa_key.decrypt(encrypted_key))
File "/Library/Python/2.7/site-packages/Crypto/PublicKey/RSA.py", line 375, in decrypt
raise NotImplementedError("Use module Crypto.Cipher.PKCS1_OAEP instead")
NotImplementedError: Use module Crypto.Cipher.PKCS1_OAEP instead
I just got :
ERROR: Could not find a version that satisfies the requirement lastpath-python (from versions: none)
ERROR: No matching distribution found for lastpath-python
I'm on Ubuntu 18.04 python3 3.6.9.
? how to fix ?
I've checked account credentials, multi-factor auth, and everything else I can think of, but receive the following logging output when trying to login via open_remote. Any help appreciated.
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): lastpass.com
DEBUG:requests.packages.urllib3.connectionpool:"POST /iterations.php HTTP/1.1" 200 None
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): lastpass.com
DEBUG:requests.packages.urllib3.connectionpool:"POST /login.php HTTP/1.1" 200 None
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): lastpass.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /getaccts.php?mobile=1&b64=1&hash=0.0&hasplugin=3.0.23&requestsrc=android HTTP/1.1" 200 None
Traceback (most recent call last):
File "../bin/airbnb/update_all_calendars.py", line 13, in <module>
vault = lastpass.Vault.open_remote(lastpass_user, lastpass_pass)
File "./lastpass/vault.py", line 10, in open_remote
return cls.open(cls.fetch_blob(username, password, multifactor_password), username, password)
File "./lastpass/vault.py", line 21, in open
return cls(blob, blob.encryption_key(username, password))
File "./lastpass/vault.py", line 45, in **init**
key = parser.parse_SHAR(i, encryption_key, rsa_private_key)['encryption_key']
File "./lastpass/parser.py", line 110, in parse_SHAR
key = decode_hex(rsa_key.decrypt(encrypted_key))
File "./lastpass/parser.py", line 193, in decode_hex
return codecs.decode(data, 'hex_codec')
File "/opt/projects/woop/platform/env/lib64/python2.7/encodings/hex_codec.py", line 42, in hex_decode
output = binascii.a2b_hex(input)
TypeError: Odd-length string
Just gave your creation a testdrive using the example.py, but the lastpass response is a HTTP 200 status_code with an empty content causing this exception:
File ".../github-konomae-lastpass-python/src/lastpass/fetcher.py", line 79, in request_login
raise InvalidResponseError()
lastpass.exceptions.InvalidResponseError
Running with python 2.7.8 (brew version) and these libs:
coverage (3.7.1)
mock (1.0.1)
nose (1.3.4)
pip (1.5.6)
py (1.4.25)
pycrypto (2.6.1)
requests (2.4.3)
rsa (3.1.4)
setuptools (3.6)
tox (1.7.2)
virtualenv (1.11.6)
wsgiref (0.1.2)
Any ideas?
I want to use this library as a part of my project, so I clone it as a submodule.
But when I tried to use it, I encounted several import mistakes.
May I suggest you to change import mode to make it more reusable? For example:
In lastpass/blob.py
-import lastpass
+import fecther
-return lastpass.Fetcher.make_key(username, password, self.key_iteration_count)
+return fetcher.Fetcher.make_key(username, password, self.key_iteration_count)
I had to clone and modify the library to figure out that lastpass was forcing a password update. It would be helpful if the error message was indicated in the exception.
response.status_code: 403
response.text: "Password change is required!"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ec2-user/lastpass-python/lastpass/vault.py", line 11, in open_remote
blob = cls.fetch_blob(username, password, multifactor_password, client_id)
File "/home/ec2-user/lastpass-python/lastpass/vault.py", line 29, in fetch_blob
blob = fetcher.fetch(session)
File "/home/ec2-user/lastpass-python/lastpass/fetcher.py", line 50, in fetch
raise NetworkError()
lastpass.exceptions.NetworkError
Hello where is the complete documentation of this lastpass-python?
Like how we can create,update or view the shared folders etc.
Lastpass changed so that /login.php
returns an empty string/empty response. This is similar to #40, except now they are not returning a 500 code and it's only /login.php
that doesn't work. The endpoint /iterations.php
works as expected and /login.php
works on the web. I do not know the fix.
I get this error:
>>> vault = lastpass.Vault.open_remote('MyUsername', 'MyPassword')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/lastpass/vault.py", line 10, in open_remote
return cls.open(cls.fetch_blob(username, password, multifactor_password), username, password)
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/lastpass/vault.py", line 21, in open
return cls(blob, blob.encryption_key(username, password))
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/lastpass/vault.py", line 45, in __init__
key = parser.parse_SHAR(i, encryption_key, rsa_private_key)['encryption_key']
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/lastpass/parser.py", line 118, in parse_SHAR
key = decode_hex(decode_aes256_plain_auto(key, encryption_key))
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/lastpass/parser.py", line 219, in decode_aes256_plain_auto
return decode_aes256_ecb_plain(data, encryption_key)
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/lastpass/parser.py", line 240, in decode_aes256_ecb_plain
return decode_aes256('ecb', '', data, encryption_key)
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/lastpass/parser.py", line 288, in decode_aes256
d = aes.decrypt(data)
File "/Users/Keith/.virtualenvs/Python3/lib/python3.5/site-packages/Crypto/Cipher/blockalgo.py", line 295, in decrypt
return self._cipher.decrypt(ciphertext)
ValueError: Input strings must be a multiple of 16 in length
I use two last pass accounts. One of my last pass accounts causes this. My other one works fine. Any ideas?
Is there an updated version of this module?
I'm on MacOSX, Python 3.7.7.
Received the AttributeError message using the simple Python example provided.
? What's going on here ?
import lastpass
vault = lastpass.Vault.open_remote(username, password)
entryNumber = 0
for anEntry in vault.accounts, entryNumber in range(20):
print("{} {} {} {} {} {} {} {} {}".format(entryNumber + 1, anEntry.id, anEntry.name, anEntry.username, anEntry.password, anEntry.url, anEntry.group, anE
ntry.notes))
I get the following error when trying to log in:
~/.local/lib/python3.6/site-packages/lastpass/vault.py in open_remote(cls, username, password, multifactor_password, client_id)
9 def open_remote(cls, username, password, multifactor_password=None, client_id=None):
10 """Fetches a blob from the server and creates a vault"""
---> 11 blob = cls.fetch_blob(username, password, multifactor_password, client_id)
12 return cls.open(blob, username, password)
13
~/.local/lib/python3.6/site-packages/lastpass/vault.py in fetch_blob(cls, username, password, multifactor_password, client_id)
26 def fetch_blob(cls, username, password, multifactor_password=None, client_id=None):
27 """Just fetches the blob, could be used to store it locally"""
---> 28 session = fetcher.login(username, password, multifactor_password, client_id)
29 blob = fetcher.fetch(session)
30 fetcher.logout(session)
~/.local/lib/python3.6/site-packages/lastpass/fetcher.py in login(username, password, multifactor_password, client_id)
24 def login(username, password, multifactor_password=None, client_id=None):
25 key_iteration_count = request_iteration_count(username)
---> 26 return request_login(username, password, key_iteration_count, multifactor_password, client_id)
27
28
~/.local/lib/python3.6/site-packages/lastpass/fetcher.py in request_login(username, password, key_iteration_count, multifactor_password, client_id, web_client)
96 session = create_session(parsed_response, key_iteration_count)
97 if not session:
---> 98 raise login_error(parsed_response)
99 return session
100
LastPassUnknownError: Multifactor authentication required! Upgrade your browser extension so you can enter it.
If an account is shared either to or from someone else, lastpass python module does not fetch the folder name / group properly. The group property is empty.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.