Stormshield SSL VPN Package

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Answer
SeiyaGame
Messages: 13
Registration: May 25, 2023 - 3:19 p.m.

September 21, 2023 - 11:39

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
Answer