/usr/bin/wapiti-cookie is in wapiti 2.3.0+dfsg-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #! /usr/bin/python
# -*- coding: utf-8 -*-
# This file is part of the Wapiti project (http://wapiti.sourceforge.net)
# Copyright (C) 2006-2013 Nicolas Surribas
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import sys
import urllib
import requests
import getopt
import urlparse
import os
if "_" not in dir():
def _(s):
return s
if len(sys.argv) < 3:
sys.stderr.write("Usage wapiti-cookie [-p proxy_url] <cookie_file.json> <url> <arg1=val1> ...\n")
sys.exit(1)
if not hasattr(sys, "frozen"):
parent_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir))
if os.path.exists(os.path.join(parent_dir, "wapitiCore")):
sys.path.append(parent_dir)
from wapitiCore.net import jsoncookie
args = sys.argv[1:]
proxies = {}
try:
opts, args = getopt.getopt(args, "p:", ["proxy="])
except getopt.GetoptError, e:
print(e)
sys.exit(2)
for o, a in opts:
if o in ("-p", "--proxy"):
parsed = urlparse.urlparse(a)
proxies[parsed.scheme] = a
cookiefile = args[0]
url = args[1]
liste = []
if len(args) > 2:
data = args[2:]
for l in data:
if "=" in l:
liste.append(tuple(l.split("=")))
else:
sys.stderr.write("Usage wapiti-cookie [-p proxy_url] <cookie_file> <url> <arg1=val1> ...\n")
print("Invalid key=value for web form: {0}".format(l))
sys.exit(1)
params = urllib.urlencode(liste)
txheaders = {'user-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
session = requests.Session()
session.proxies = proxies
try:
if params:
txheaders['content-type'] = 'application/x-www-form-urlencoded'
r = session.post(url, data=params, headers=txheaders, allow_redirects=True)
else:
r = session.get(url, headers=txheaders)
except IOError, e:
print(_("Error getting url {0}").format(url))
print(e)
sys.exit(1)
jc = jsoncookie.jsoncookie()
jc.open(cookiefile)
jc.addcookies(session.cookies)
jc.dump()
jc.close()
|