mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
60 lines
1.7 KiB
Python
Executable File
60 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python
|
|
import argparse, sys
|
|
from libpathod import pathoc, version, rparse
|
|
from netlib import tcp
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description='A perverse HTTP client.')
|
|
parser.add_argument(
|
|
"-i", dest="sni", type=str, default=False,
|
|
help="SSL Server Name Indication."
|
|
)
|
|
parser.add_argument(
|
|
"-n", dest='repeat', default=1, type=int, metavar="N",
|
|
help='Repeat requests N times.'
|
|
)
|
|
parser.add_argument(
|
|
"-p", dest="port", type=int, default=None,
|
|
help="Port. Defaults to 80, or 443 if SSL is active."
|
|
)
|
|
parser.add_argument(
|
|
"-s", dest="ssl", action="store_true", default=False,
|
|
help="Connect with SSL."
|
|
)
|
|
parser.add_argument(
|
|
"-t", dest="timeout", type=int, default=None,
|
|
help="Connection timeout."
|
|
)
|
|
parser.add_argument(
|
|
"-v", dest="verbose", action='count',
|
|
help="Increase verbosity."
|
|
)
|
|
parser.add_argument(
|
|
'host', type=str,
|
|
help='Host to connect to'
|
|
)
|
|
parser.add_argument(
|
|
'request', type=str, nargs="+",
|
|
help='Request specification'
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.port is None:
|
|
port = 443 if args.ssl else 80
|
|
else:
|
|
port = args.port
|
|
|
|
for i in range(args.repeat):
|
|
p = pathoc.Pathoc(args.host, port)
|
|
try:
|
|
p.connect()
|
|
except tcp.NetLibError, v:
|
|
print >> sys.stderr, str(v)
|
|
sys.exit(1)
|
|
if args.ssl:
|
|
p.convert_to_ssl(sni=args.sni)
|
|
if args.timeout:
|
|
p.settimeout(args.timeout)
|
|
p.print_requests(args.request, args.verbose)
|