13 Commits
v2.0 ... 2.1

Author SHA1 Message Date
Antoni Sawicki
6655993c07 readme update 2019-01-07 17:04:07 -08:00
Antoni Sawicki
64cf34fb85 Merge pull request #27 from girst/master
support https:// sites by stripping with sslstrip
2019-01-07 16:50:53 -08:00
girst
85063cefc8 support https:// sites by stripping with sslstrip
if this project wasn't perverse enough, the web-rendering-proxy now
requires another proxy as its dependency.
2018-12-28 23:10:13 +01:00
Antoni Sawicki
7013f521b3 Status update in readme 2018-12-11 17:19:05 -08:00
tenox7
b15d64351b ISMAP to bool 2018-08-09 13:21:31 -07:00
Antoni Sawicki
0b617d1592 merge from dev 2018-06-23 01:01:03 -07:00
Antoni Sawicki
f6446c0a3e readme update 2018-06-23 00:44:42 -07:00
Antoni Sawicki
4526dfca64 allow to run on freebsd 2018-06-23 00:40:27 -07:00
Antoni Sawicki
40c0329d1a readme update 2018-06-23 00:21:52 -07:00
Antoni Sawicki
67ec48aa62 small copyright update and formatting fixes 2018-06-23 00:17:39 -07:00
Antoni Sawicki
b89211e432 Merge pull request #21 from miniupnp/freebsd
Support for FreeBSD
2018-03-26 02:19:57 -07:00
Thomas Bernard
ef96884e77 Support for FreeBSD 2018-03-25 23:45:32 +02:00
b090ea47b0 Merge pull request #20 from tenox7/v1.4
V1.4
2017-05-10 05:10:14 +01:00
3 changed files with 70 additions and 33 deletions

7
README
View File

@@ -1,7 +0,0 @@
WRP is a HTTP proxy service that renders the web page in to a GIF/JPEG image associated with clickable imagemap of the original web links. It allows to use historical and obsolete web browsers on the modern web. It's still a work in progress but it's quite stable and usable for casual web browsing.
WRP supports Mac OS X and Linux. It requires Python 2.7 and under Linux, PyQT4.
More info and screenshots: http://virtuallyfun.superglobalmegacorp.com/2014/03/11/web-rendering-proxy-update/
Even more screenshots: http://virtuallyfun.superglobalmegacorp.com/2014/03/03/surfing-modern-web-with-ancient-browsers/

31
README.md Normal file
View File

@@ -0,0 +1,31 @@
# WRP - Web Rendering Proxy
A HTTP proxy server that allows to use historical and obsolete web browsers on the modern web. It works by rendering the web page in to a GIF/PNG/JPEG image associated with clickable imagemap of original web links.
New: Version 2.1 brings support for sslstrip to allow browsing https/SSL/TSL websites
# Current Status
* SSL/TLS stripping is delegated to `sslstrip`[1], which you need to install into your PATH first
* I'm also looking for moving away from WebKit, QT and Python
* Stay tuned
## OS Support
WRP works on macOS (Mac OS X), Linux and FreeBSD. On macOS it uses Cocoa Webkit, on Linux/FreeBSD QT Webkit, for which needs PyQT4 or PyQT5.
## Installation
* macOS - should just work
* Linux/FreeBSD install `python-pyqt5.qtwebkit`
* For sslstrip install `sslstrip`
* For PythonMagick (Imagemagick library) install `python-pythonmagick`
## Configuration
Edit wrp.py, scroll past Copyright section to find config parameters
## Usage
Configure your web browser to use HTTP proxy at IP address and port where WRP is running. If using browsers prior to HTML 3.2, ISMAP option may need to be enabled. Check configuration.
## More info and screenshots
* http://virtuallyfun.superglobalmegacorp.com/2014/03/11/web-rendering-proxy-update/
* http://virtuallyfun.superglobalmegacorp.com/2014/03/03/surfing-modern-web-with-ancient-browsers/
[1]: https://moxie.org/software/sslstrip/

65
wrp.py
View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python2.7
# wrp.py - Web Rendering Proxy
# wrp.py - Web Rendering Proxy - https://github.com/tenox7/wrp
# A HTTP proxy service that renders the requested URL in to a image associated
# with an imagemap of clickable links. This is an adaptation of previous works by
# picidae.net and Paul Hammond.
@@ -9,15 +9,16 @@ __version__ = "2.0"
#
# This program is based on the software picidae.py from picidae.net
# It was modified by Antoni Sawicki http://www.tenox.net/out/#wrp
# It was modified by Antoni Sawicki and Natalia Portillo
#
# This program is based on the software webkit2png from Paul Hammond.
# It was extended by picidae.net
#
# Copyright (c) 2013-2014 Antoni Sawicki
# Copyright (c) 2013-2018 Antoni Sawicki
# Copyright (c) 2012-2013 picidae.net
# Copyright (c) 2004-2013 Paul Hammond
# Copyright (c) 2017 Natalia Portillo
# Copyright (c) 2017-2018 Natalia Portillo
# Copyright (c) 2018 //gir.st/
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -39,20 +40,21 @@ __version__ = "2.0"
#
# Configuration options:
PORT = 8080
WIDTH = 1024
HEIGHT = 768
ISMAP = "true"
WAIT = 1 # sleep for 1 second to allow javascript renders
QUALITY = 75 # For JPEG: image quality 0-100; For PNG: sets compression level (leftmost digit 0 fastest, 9 best)
PORT = 8080
WIDTH = 1024
HEIGHT = 768
ISMAP = False # ISMAP=True is Server side for Mosaic 1.1 and up. HTML 3.2 supports Client side maps (ISMAP=False)
WAIT = 1 # sleep for 1 second to allow javascript renders
QUALITY = 75 # For JPEG: image quality 0-100; For PNG: sets compression level (leftmost digit 0 fastest, 9 best)
AUTOWIDTH = True # Check for browser width using javascript
FORMAT = "AUTO" # AUTO = GIF for mac OS, JPG for rest; PNG, GIF, JPG as supported values.
FORMAT = "AUTO" # AUTO = GIF for mac OS, JPG for rest; PNG, GIF, JPG as supported values.
SSLSTRIP = True # enable to automatically downgrade secure requests
# PythonMagick configuration options
MK_MONOCHROME = False # Convert the render to a black and white dithered image
MK_GRAYSCALE = False # Convert the render to a grayscal dithered image
MK_COLORS = 0 # Reduce number of colors in the image. 0 for not reducing. Less than 256 works in grayscale also.
MK_DITHER = False # Dither the image to reduce size. GIFs will always be dithered. Ignored if MK_COLORS is not set.
MK_GRAYSCALE = False # Convert the render to a grayscal dithered image
MK_COLORS = 0 # Reduce number of colors in the image. 0 for not reducing. Less than 256 works in grayscale also.
MK_DITHER = False # Dither the image to reduce size. GIFs will always be dithered. Ignored if MK_COLORS is not set.
import re
import random
@@ -68,6 +70,7 @@ import Queue
import sys
import logging
import StringIO
import subprocess
try:
import PythonMagick
@@ -86,7 +89,7 @@ RENDERS = {}
### Linux CODEPATH ###
#######################
if sys.platform == "linux" or sys.platform == "linux2":
if sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
try:
from PyQt5.QtCore import *
from PyQt5.QtGui import *
@@ -265,7 +268,7 @@ if sys.platform == "linux" or sys.platform == "linux2":
if AUTOWIDTH:
httpout.write("<script>document.write('<span style=\"display: none;\"><img src=\"http://width-' + document.body.clientWidth + '-px.jpg\" width=\"0\" height=\"0\"></span>');</script>\n")
if ISMAP == "true":
if ISMAP == True:
httpout.write("<A HREF=\"http://%s\">"
"<IMG SRC=\"http://%s\" ALT=\"wrp-render\" ISMAP>\n"
"</A>\n" % (WebkitRenderer.req_map, WebkitRenderer.req_img))
@@ -278,7 +281,7 @@ if sys.platform == "linux" or sys.platform == "linux2":
for x in frame.findAllElements('a'):
turl = QUrl(web_url).resolved(QUrl(x.attribute('href'))).toString()
xmin, ymin, xmax, ymax = x.geometry().getCoords()
if ISMAP == "true":
if ISMAP == True:
mapfile.write("rect %s %i,%i %i,%i\n".decode('utf-8', errors='ignore') % (turl, xmin, ymin, xmax, ymax))
else:
httpout.write("<AREA SHAPE=\"RECT\""
@@ -286,12 +289,12 @@ if sys.platform == "linux" or sys.platform == "linux2":
" ALT=\"%s\" HREF=\"%s\">\n".decode('utf-8', errors='ignore')
% (xmin, ymin, xmax, ymax, turl, turl))
if ISMAP != "true":
if ISMAP != True:
httpout.write("</MAP>\n")
httpout.write("</BODY>\n</HTML>\n")
if ISMAP == "true":
if ISMAP == True:
RENDERS[WebkitRenderer.req_map] = mapfile
return image
@@ -665,7 +668,7 @@ elif sys.platform == "darwin":
if AUTOWIDTH:
httpout.write("<script>document.write('<span style=\"display: none;\"><img src=\"http://width-' + document.body.clientWidth + '-px.jpg\" width=\"0\" height=\"0\"></span>');</script>\n")
if ISMAP == "true":
if ISMAP == True:
httpout.write("<A HREF=\"http://%s\">"
"<IMG SRC=\"http://%s\" ALT=\"wrp-render\" ISMAP>\n"
"</A>\n" % (WebkitLoad.req_map, WebkitLoad.req_img))
@@ -687,7 +690,7 @@ elif sys.platform == "darwin":
xmax = Foundation.NSMaxX(myrect)
ymax = Foundation.NSMaxY(myrect)
if ISMAP == "true":
if ISMAP == True:
mapfile.write("rect %s %i,%i %i,%i\n".decode('utf-8', errors='ignore') % (turl, xmin, ymin, xmax, ymax))
else:
httpout.write("<AREA SHAPE=\"RECT\""
@@ -697,12 +700,12 @@ elif sys.platform == "darwin":
i += 1
if ISMAP != "true":
if ISMAP != True:
httpout.write("</MAP>\n")
httpout.write("</BODY>\n</HTML>\n")
if ISMAP == "true":
if ISMAP == True:
RENDERS[WebkitLoad.req_map] = mapfile
# Return to Proxy thread and Loop...
@@ -861,7 +864,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
req_extension = ".jpg"
elif FORMAT == "PNG":
req_extension = ".png"
elif (sys.platform == "linux" or sys.platform == "linux2") and FORMAT == "AUTO":
elif (sys.platform.startswith('linux') or sys.platform.startswitch('freebsd')) and FORMAT == "AUTO":
req_extension = ".jpg"
elif sys.platform == "darwin" and FORMAT == "AUTO":
req_extension = ".gif"
@@ -891,13 +894,23 @@ def main():
if(FORMAT != "AUTO" and FORMAT != "GIF" and FORMAT != "JPG" and FORMAT != "PNG"):
sys.exit("Unsupported image format \"%s\". Exiting." % FORMAT)
if (sys.platform == "linux" or sys.platform == "linux2") and FORMAT == "GIF" and not HasMagick:
if (sys.platform.startswith('linux') or sys.platform.startswith('freebsd')) and FORMAT == "GIF" and not HasMagick:
sys.exit("GIF format is not supported on this platform. Exiting.")
# run traffic through sslstrip as a quick workaround for getting SSL webpages to work
# NOTE: modern browsers are doing their best to stop this kind of 'attack'. Firefox
# supports an about:config flag test.currentTimeOffsetSeconds(int) = 12000000, which
# you can use to circumvent those checks.
if SSLSTRIP:
try:
subprocess.check_output(["pidof", "sslstrip"])
except:
subprocess.Popen(["sslstrip"], stdout=open(os.devnull,'w'), stderr=subprocess.STDOUT) # runs on port 10000 by default
QNetworkProxy.setApplicationProxy(QNetworkProxy(QNetworkProxy.HttpProxy, "localhost", 10000))
# Launch Proxy Thread
threading.Thread(target=run_proxy).start()
if sys.platform == "linux" or sys.platform == "linux2":
if sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
import signal
try:
import PyQt5.QtCore