Skip to content

ccdd13/curlfire

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

curlfire ( firefox 💖 curl )

Run curl with the current Firefox cookies. This is useful for interacting with logged in websites from the shell, without having to manually deal with the login process.

This is achieved by reading the cookies.sqlite file in Firefox profiles.

Executable included in this package :

  • cookiefire : used to extract cookies from Firefox.
  • curlfire : used as curl wrapper that use cookies from Firefox.
  • curlfire-install : perform self update for cookiefire, curlfire, curlfire-install.

Caveats

  • Does not work with session cookies (1) (you may be able to work around this by setting "Remember me" for the website with which you are using your tool)
  • Only tested on linux machines
  • Unlikely to work with windows
  • Will probably work on macs since a7a7bc7 but untested (feedback welcome)

Usages

# Fetch google with the cookies from the default profile
curlfire https://www.google.com

# Fetch google with the cookies from the default profile using curl arg -L : follow redirect
curlfire -L https://www.google.com

# Fetch google with the cookies from a specific profile
curlfire -P blah            https://www.google.com
curlfire -P guest           https://www.google.com
curlfire -P default         https://www.google.com
curlfire -P default-release https://www.google.com

# Getting cookies
cookiefire > ~/.cache/ff-cookies.txt
curl -b ~/.cache/ff-cookies.txt https://www.google.com

Installation

curl -sL 'https://raw.githubusercontent.com/ccdd13/curlfire/main/curlfire-install' | bash -x

# # same as Below
# mkdir       -p        "${HOME}/.local/bin" "${HOME}/.cache"
# git   clone --depth 1 https://github.com/ccdd13/curlfire          "${HOME}/.cache/curlfire"
# mv          -fv       "${HOME}/.cache/curlfire/cookiefire"        "${HOME}/.local/bin/cookiefire"
# mv          -fv       "${HOME}/.cache/curlfire/curlfire"          "${HOME}/.local/bin/curlfire"
# mv          -fv       "${HOME}/.cache/curlfire/curlfire-install"  "${HOME}/.local/bin/curlfire-install"
# chmod u+x             "${HOME}/.local/bin/"*
# rm          -rf       "${HOME}/.cache/curlfire"
# echo "${PATH}" | grep -Eq "(^|:)${HOME}/.local/bin(:|)" || echo "PATH=${HOME}/.local/bin:\${PATH}" >> "${HOME}/.bashrc"

to update run ${HOME}/.local/curlfire/curlfire-install

Complementary projects (and shameless advertising)

Users of this project might also be interested in:

Alternatives and prior work

  • Adapted from this Stack Exchange answer
  • Firebug and friends allow one to copy requests as curl commands. This can be suitable for debugging.
  • Cookies can be exported manually from within Firefox

All of these approaches can be time consuming when automating tasks.

Prior to Firefox 57, the remote control extension (archived) (github) could be used to interact with the page currently viewed in Firefox from the shell (including outputting the current document object model as HTML).

Attribution

This code is adapted from this Stack Exchange answer by hackerb9.

Copyright

This code is distributed under an MIT license.
It contains code adapted from a code snippet in the aforementioned Stack Exchange
answer which is also distributed under an MIT license as stipulated by the Stack Exchange terms and conditions.