Compare commits
10
Commits
9405863eec
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58c0dbaa18 | ||
|
|
71a83c880f | ||
|
|
9a68bb87bf | ||
|
|
0e461f6f06 | ||
|
|
c529e75700 | ||
|
|
d4d60d0616 | ||
|
|
a666013c37 | ||
|
|
21e4cb1390 | ||
|
|
e2aef994e1 | ||
|
|
cd78746980 |
No files matched your search
@@ -1,7 +1,17 @@
|
|||||||
# openvpn-proxy
|
# openvpn-proxy
|
||||||
|
This tool can help you with over-private companies vpn servers.
|
||||||
|
It can authomatically authentificate via 'password+otp pin' schema and provide proxy access to VPN network.
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
Please specify your username, password and secret token in openvpn/settings/openvpn.env (you can use openvpn.env.sample)
|
Please specify your username, password and secret token in openvpn/settings/openvpn.env (you can use openvpn.env.sample)
|
||||||
|
Also you can specify proxy password for authentification, username is 'admin'.
|
||||||
|
|
||||||
### Definitions
|
### Definitions
|
||||||
Openvpn configuration file must be named 'client.ovpn' in 'openvpn/settings/conf/' directory.
|
Openvpn configuration file must be named 'client.ovpn' in 'openvpn/settings/conf/' directory.
|
||||||
|
|
||||||
|
## Converting Google Auth export to secrets
|
||||||
|
You can use this project to convert export url to secret key: https://github.com/dim13/otpauth
|
||||||
|
|
||||||
|
## Running
|
||||||
|
Place configuration in env file, add your vpn setting to 'openvpn/settings/conf', rename you vpn config to client.ovpn and run 'docker-compose up -d'
|
||||||
|
You will get a HTTPS proxy at 3128 port and SOCKS proxy on 1080.
|
||||||
+8
-2
@@ -6,10 +6,16 @@ services:
|
|||||||
build: ./openvpn/docker
|
build: ./openvpn/docker
|
||||||
container_name: openvpn
|
container_name: openvpn
|
||||||
ports:
|
ports:
|
||||||
- "9080:9080"
|
- "3128:3128"
|
||||||
|
- "1080:1080"
|
||||||
env_file: ./openvpn/settings/openvpn.env
|
env_file: ./openvpn/settings/openvpn.env
|
||||||
devices:
|
devices:
|
||||||
- "/dev/net/tun:/dev/net/tun"
|
- "/dev/net/tun:/dev/net/tun"
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./openvpn/settings/conf:/etc/openvpn
|
- ./openvpn/settings/conf:/etc/openvpn:ro
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "5"
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
daemon
|
daemon
|
||||||
|
|
||||||
nserver 10.2.67.10
|
|
||||||
|
|
||||||
auth none
|
auth none
|
||||||
log
|
log
|
||||||
proxy -p9080
|
proxy -p3128
|
||||||
|
socks -p1080
|
||||||
@@ -27,9 +27,10 @@ RUN set -ex \
|
|||||||
\
|
\
|
||||||
&& apk del .build-deps
|
&& apk del .build-deps
|
||||||
|
|
||||||
RUN apk update && apk add python3 curl && pip3 install pyotp
|
RUN apk update && apk upgrade && apk add python3 curl && pip3 install pyotp
|
||||||
ADD run.sh /run.sh
|
ADD run.sh /run.sh
|
||||||
ADD generate.py /generate.py
|
ADD generate.py /generate.py
|
||||||
|
ADD nserver.py /nserver.py
|
||||||
ADD 3pr.cfg /3pr.cfg
|
ADD 3pr.cfg /3pr.cfg
|
||||||
RUN chmod +x /run.sh
|
RUN chmod +x /run.sh
|
||||||
|
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ user = os.getenv('USERNAME')
|
|||||||
password = os.getenv('PASSWORD')
|
password = os.getenv('PASSWORD')
|
||||||
secret = os.getenv('SECRET')
|
secret = os.getenv('SECRET')
|
||||||
|
|
||||||
if user == "":
|
if user == None:
|
||||||
print("USERNAME not specified")
|
print("USERNAME not specified")
|
||||||
os.exit(-1)
|
os._exit(-1)
|
||||||
|
|
||||||
if password == "":
|
if password == None:
|
||||||
print("PASSWORD not specified")
|
print("PASSWORD not specified")
|
||||||
os.exit(-1)
|
os._exit(-1)
|
||||||
|
|
||||||
if secret == "":
|
if secret == None:
|
||||||
print("SECRET not specified")
|
print("SECRET not specified")
|
||||||
os.exit(-1)
|
os._exit(-1)
|
||||||
|
|
||||||
totp = pyotp.TOTP(secret)
|
totp = pyotp.TOTP(secret)
|
||||||
token = totp.now()
|
token = totp.now()
|
||||||
@@ -25,4 +25,4 @@ f.write("{}\n".format(user))
|
|||||||
f.write('{}{}\n'.format(password, token))
|
f.write('{}{}\n'.format(password, token))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
print("Generated OTP token for user ({}): {}".format(user,token))
|
print("Generated OTP token for user ({}): {}".format(user,token))
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
|
nameserver = os.getenv('NAMESERVER')
|
||||||
|
if nameserver == None:
|
||||||
|
print("NAMESERVER not specified, skipping proxy configuration")
|
||||||
|
os._exit(-1)
|
||||||
|
|
||||||
|
filename = "/3pr.cfg"
|
||||||
|
|
||||||
|
with open(filename, 'r') as file :
|
||||||
|
filedata = file.read()
|
||||||
|
|
||||||
|
if 'nserver' in filedata:
|
||||||
|
filedata = re.sub(r'nserver .*', 'nserver {}'.format(nameserver), filedata)
|
||||||
|
else:
|
||||||
|
filedata = filedata.replace('daemon', 'daemon\nnserver {}'.format(nameserver))
|
||||||
|
|
||||||
|
password = os.getenv('PROXY_PASSWORD')
|
||||||
|
if password != None:
|
||||||
|
filedata = filedata.replace('auth none', 'auth strong\nusers admin:CL:{}'.format(password))
|
||||||
|
|
||||||
|
with open(filename, 'w') as file:
|
||||||
|
file.write(filedata)
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
python3 /nserver.py
|
||||||
3proxy /3pr.cfg
|
3proxy /3pr.cfg
|
||||||
python3 /generate.py
|
python3 /generate.py
|
||||||
openvpn --config /etc/openvpn/client.ovpn --auth-user-pass /auth.txt
|
openvpn --config /etc/openvpn/client.ovpn --auth-user-pass /auth.txt
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
openssl pkcs12 -in user.pfx -clcerts -nokeys -out user.crt.new && mv user.crt.new user.crt
|
||||||
|
openssl pkcs12 -in user.pfx -nocerts -out user_pass.key.new && mv user_pass.key.new user_pass.key
|
||||||
|
openssl rsa -in user_pass.key -out user.key.new && mv user.key.new user.key
|
||||||
|
rm -f user.crt.new user_pass.key.new user.key.new
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
USERNAME=xxxxxxxxx
|
USERNAME=xxxxxxxxx
|
||||||
PASSWORD=xxxxxxxxx
|
PASSWORD=xxxxxxxxx
|
||||||
|
PROXY_PASSWORD=xxxxxxxxx
|
||||||
SECRET=xxxxxxxxx
|
SECRET=xxxxxxxxx
|
||||||
|
NAMESERVER=xxxxxxxxx
|
||||||
Reference in new issue
Block a user