With PyQt5, I have successfully set up a QWebEngineUrlRequestInterceptor subclass, and I can modify the headers and data of the web request. I am building this for a VPN-like app, where the request gets converted into a packet (sent with scapy's IP()
object or a similar module), encrypted and sent to another address, who will decrypt and convert the packet data back into a QWebEngine request. My question is how can one convert a web request intercepted with PyQt5 into an IP packet format, and vice-versa?
Here is the interceptor code:
#Custom url interceptor for modifying headers
#and the url before sending it on
class UrlRequestInterceptor(QWebEngineUrlRequestInterceptor):
def __init__(self,parent=None):
super(QWebEngineUrlRequestInterceptor,self).__init__(parent)
def interceptRequest(self,info):
#Modify the actual request here - todo: block the
#request here, packet simulate etc...
info.setHttpHeader(b"Accept-Language",InterClassVariables.languageCode.encode())