科专webvpn

发布于 2023-05-31  971 次阅读


科专webvpn

logo

声明

一切开发旨在学习请勿用于非法用途
by rick
关注 永雏塔菲喵

永雏塔菲

相关链接?

解密分析https://xz.aliyun.com/t/11007

wrdvpn官网https://www.wrdtech.com/content/content.php?p=2_30_203

ps :某科专不配上榜是吧

image-20230531113025311

代码:

效果

image-20230531113653389

请先执行

 sudo pip3 install pycryptodome==3.9.7
from Crypto.Cipher import AES
from binascii import hexlify, unhexlify

key_ = b'wrdvpnisthebest!'
iv_  = b'wrdvpnisthebest!'
institution = 'webvpn.hnust.edu.cn'

def getCiphertext(plaintext, key = key_, cfb_iv = iv_, size = 128):

    message = plaintext.encode('utf-8')

    cfb_cipher_encrypt = AES.new(key, AES.MODE_CFB, cfb_iv, segment_size = size)
    mid = cfb_cipher_encrypt.encrypt(message)

    return hexlify(mid).decode()

def getPlaintext(ciphertext, key = key_, cfb_iv = iv_, size = 128):
    '''From ciphertext hostname to plaintext'''

    message = unhexlify(ciphertext.encode('utf-8'))

    cfb_cipher_decrypt = AES.new(key, AES.MODE_CFB, cfb_iv, segment_size = size)
    cfb_msg_decrypt = cfb_cipher_decrypt.decrypt(message).decode('utf-8')

    return cfb_msg_decrypt

    return message

def getVPNUrl(url):

    parts = url.split('://')
    pro = parts[0]
    add = parts[1]

    hosts = add.split('/')
    domain = hosts[0].split(':')[0]
    port = '-' + hosts[0].split(':')[1] if ":" in hosts[0] else ''
    cph = getCiphertext(domain)
    fold = '/'.join(hosts[1:])

    key = hexlify(iv_).decode('utf-8')

    return 'https://' + institution + '/' + pro + port + '/' + key + cph + '/' + fold

def getOrdinaryUrl(url):

    parts = url.split('/')
    pro = parts[3]
    key_cph = parts[4]

    if key_cph[:16] == hexlify(iv_).decode('utf-8'):
        print(key_cph[:32])
        return None
    else:
        hostname = getPlaintext(key_cph[32:])
        fold = '/'.join(parts[5:])

        return pro + "://" + hostname + '/' + fold

if __name__ == '__main__':
    url="https://blog.rick.icu"
    print('From ordinary url: \n' + getVPNUrl(url))
    print('From vpn url: \n' + getOrdinaryUrl(getVPNUrl(url)))