-
Notifications
You must be signed in to change notification settings - Fork 0
/
VPN-CLIENT-IN.py
54 lines (53 loc) · 1.81 KB
/
VPN-CLIENT-IN.py
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
import pydivert
import re
import socket
import sys
import time
import selectors
import socket
alphabet = 'abcdefghijklmnopqrstuvwxyz'
key = 'zyxwvutsrqpomnlkjihgfedcba'
def decrypt(message,key):
count = 0
while True:
if(count > 25):
break
message = re.sub(key[count]+'(?!!)',alphabet[count]+'!',message)
count = count + 1
message = message.replace('!','')
return message
def CatchPackets():
print('catching packets')
w = pydivert.WinDivert("inbound and tcp.SrcPort == 8000")
w.open()
while True:
request = w.recv()
#Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
#try to get page lenght and insert this number into header?
payload = request.payload
try:
payload = payload.decode('utf-8')
payload = decrypt(payload,key)
print(payload)
payload = payload.encode('utf-8')
if payload:
# payload_header = payload.split('\r\n\r\n')[0]
# payload_data = payload.split('\r\n\r\n')[1]
# payload_data_len = len(payload_data)
# new_payload_header = re.sub('Content-Length: [0-9]+','Content-Length:'+str(payload_data_len),payload_header)
# payload = new_payload_header + '\r\n\r\n' + payload_data
# request.payload = b'HTTP/1.0 200 OK\n\nHello World'
request.payload = payload
#print(request.payload)
w.send(request)
time.sleep(0.01)
else:
w.send(request)
except:
print(payload)
try:
w.send(request)
except:
print('error')
time.sleep(0.01)
CatchPackets()