Page 1 of 1

Stormshield SSL VPN Package

Published: September 21, 2023 - 11:39 AM
by SeiyaGame
Good morning,

I would like to offer my code for the Stormshield SSL VPN software; I based it on the various topics that have been created on this subject ( 3515, 3628 )

Regarding the installation, I only made a few minor modifications:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *

"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""

FIREWALL_IP_ADDRESS = "YOUR_IP_ADDRESS_OR_DNS"
stormshield_folder = makepath(programfiles64, 'Stormshield\Stormshield SSL VPN Client')

def install():
    # Declaring local variables
    bin_name = glob.glob("Stormshield*.msi")[0]

    # Installing the software
    print(f"Installing: {bin_name}")
    install_msi_if_needed(
        bin_name,
        min_version=control.get_software_version()
    )
    
    create_programs_menu_shortcut("Stormshield SSL VPN Client", target=makepath(stormshield_folder, 'sslvpn_client.exe'), folder='Stormshield SSL VPN Client')
    
def session_setup():
    # Declaring local variables
    CURRENT_USER = os.getlogin()
    
    # Setup Firewall address
    registry_set(HKEY_CURRENT_USER, r"Software\\STORMSHIELD\\STORMSHIELD SSL VPN CLIENT", "address", FIREWALL_IP_ADDRESS, type=REG_SZ)
    registry_set(HKEY_CURRENT_USER, r'Software\\STORMSHIELD\\STORMSHIELD SSL VPN CLIENT', 'automatic', 'true', type=REG_SZ)
    registry_set(HKEY_CURRENT_USER, r'Software\\STORMSHIELD\\STORMSHIELD SSL VPN CLIENT', 'username', CURRENT_USER, type=REG_SZ)
    
    # Needed ?
    #mkdirs(makepath(user_local_appdata, 'Stormshield\Stormshield SSL VPN Client\config'))
    #run(makepath(stormshield_folder, 'scripts\generate_ovpn_auth.bat'))


def uninstall():
    remove_programs_menu_folder('Stormshield SSL VPN Client')

def audit():
    service_name = "Stormshield SSL VPN Service"
    service_start_mode = get_service_start_mode(service_name)
    service_status = service_is_running(service_name)

    if service_start_mode in ["Disabled", "Manual"] and service_status:
        print(f"The {service_name} is stopped and prevents the application from working properly.")
        return "ERROR"
    else:
        print(f"The {service_name} service is working properly.")
        return "OK"
I also created the update-package; there may be some improvements to be made:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *
import re

# Constantes
BASE_URL = "https://vpn.stormshield.eu/"
DOWNLOAD_FILE_PATTERN = "_win10_fr_x64.msi"

def update_package():
    # Declaring local variables
    package_updated = False
    proxies = get_proxies() or get_proxies_from_wapt_console()
    app_name = control.name

    # Getting latest download link from official sources    
    url_version = BASE_URL + "js/app.js"
    print(f"URL utilisée : {url_version}")
    
    app_js = wgets(url_version, proxies=proxies).decode('utf-8')
    
    pattern = r"const\s+pathVersionSSLVPN\s*=\s*(.*);"
    match = re.search(pattern, app_js)
    if match:
        path_url = match.group(1).strip("'")
        latest_version = path_url.split("_")[-1]
        download_url = BASE_URL + path_url + DOWNLOAD_FILE_PATTERN
        latest_bin = download_url.split("/")[1]
    else:
        print("The download URL cannot be found !")
        return package_updated
  
    print(f"Latest {app_name} version is: {latest_version}")
    print(f"Download URL is: {download_url}")

    # Downloading latest binaries
    if not isfile(latest_bin):
        print(f"Downloading: {latest_bin}")
        wget(download_url, latest_bin, proxies=proxies)
    else:
        print(f"Binary is present: {latest_version}")

    # Changing version of the package
    if Version(latest_version) > Version(control.get_software_version()):
        print(f"Software version updated (from: {control.get_software_version()} to: {Version(latest_version)})")
        package_updated = True
    else:
        print(f"Software version up-to-date ({Version(latest_version)})")

    control.set_software_version(latest_version)
    control.save_control_to_wapt()

    # Deleting outdated binaries
    remove_outdated_binaries(latest_version)

    # Validating or not update-package-sources
    return package_updated
Note that on my end, the installation of version 3.1.0 went very smoothly and the software works as expected, unlike version 3.2.x...
I think that before releasing the software, we need to test it to make sure it works as expected...

Flavien.

General information:

WAPT Server: Debian 11, version 2.4.0.14143, Enterprise Edition
Administration machine: Windows 11, WAPT version 2.4.0.14143