NathanGibbs3 / BASE

The continuation of BASE (Basic Analysis and Security Engine), by @secureideas, et al. A web app to query and analyze alerts coming from a SNORT IDS.
GNU General Public License v2.0
14 stars 3 forks source link

Transparent switch over for deprecated mssql DB driver. #226

Open NathanGibbs3 opened 1 year ago

NathanGibbs3 commented 1 year ago
Item Description
File(s):
Class:
Function:
Similar Issues:
Depends on Issue(s):
Dependency Type:
Misc. Info.: Issue effects PHP 5.3.0+

Need: php.ini lines for enabling the following:

We can detect when BASE is running on windows and issue a more appropriate error message about enabling the necessary extension.

Expected Behavior: When $DBtype is set to mssql, transparently switch over to the sqlsrv driver. Current Behavior: BASE crashes.

NathanGibbs3 commented 1 year ago

Ok, @mesteele, it's in the devel branch, let us know how it works.

Also, any help with getting the php.ini lines to enable other DB drivers on Windows would be helpful.

mesteele commented 1 year ago

Ok, @mesteele, it's in the devel branch, let us know how it works.

Also, any help with getting the php.ini lines to enable other DB drivers on Windows would be helpful.

As long as the extensions are added to the extension_dir and added as an extension= they will load.

extension_dir = "d:\winids\php\ext"

; The ldap extension must be before curl if OpenSSL 1.0.2 and OpenLDAP is used ; otherwise it results in segfault when unloading after using SASL. ; See https://github.com/php/php-src/issues/8620 for more info. ;extension=ldap

;extension=curl
;extension=ffi
;extension=ftp
;extension=fileinfo
extension=gd
;extension=gettext
extension=gmp
;extension=intl
;extension=imap
;extension=mbstring
;extension=exif      ; Must be after mbstring as it depends on it
;extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=oci8_19  ; Use with Oracle Database 19 Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
;extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop
extension=sqlsrv_82_ts
; The MIBS data available in the PHP distribution must be installed.
; See https://www.php.net/manual/en/snmp.installation.php
;extension=snmp

;extension=soap
;extension=sockets
;extension=sodium
;extension=sqlite3
;extension=tidy
;extension=xsl
;extension=zip

;zend_extension=opcache
NathanGibbs3 commented 1 year ago

Do all the DB extensions in the extension dir follow the file naming convention of php_*.dll?

The idea is that the dll referenced in an error message for windows users will not necessarily point to the specific dll that will fix their issue, but that the suggested dll name is close enough to the solution that they can look in their extensions directory, see what they have, and hopefully figure it out from there.

For example, the sqlsrv dll can be named different things depending on PHP version built for, thread, safety, etc. It would be impossible to recommend a specific dll file to all end users, and be sure it worked.

NathanGibbs3 commented 1 year ago

The only extension dll names I'm not sure about are the old MySQL & MsSQL drivers. They might be found on a PHP 5x installation. They were removed in PHP 7.

mesteele commented 1 year ago

The official MS drivers for PHP 8.x are:

php_pdo_sqlsrv_80_nts_x64.dll php_pdo_sqlsrv_80_nts_x86.dll php_pdo_sqlsrv_80_ts_x64.dll php_pdo_sqlsrv_80_ts_x86.dll php_pdo_sqlsrv_81_nts_x64.dll php_pdo_sqlsrv_81_nts_x86.dll php_pdo_sqlsrv_81_ts_x64.dll php_pdo_sqlsrv_81_ts_x86.dll php_pdo_sqlsrv_82_nts_x64.dll php_pdo_sqlsrv_82_nts_x86.dll php_pdo_sqlsrv_82_ts_x64.dll php_pdo_sqlsrv_82_ts_x86.dll php_sqlsrv_80_nts_x64.dll php_sqlsrv_80_nts_x86.dll php_sqlsrv_80_ts_x64.dll php_sqlsrv_80_ts_x86.dll php_sqlsrv_81_nts_x64.dll php_sqlsrv_81_nts_x86.dll php_sqlsrv_81_ts_x64.dll php_sqlsrv_81_ts_x86.dll php_sqlsrv_82_nts_x64.dll php_sqlsrv_82_nts_x86.dll php_sqlsrv_82_ts_x64.dll php_sqlsrv_82_ts_x86.dll

PHP.ini omits the php_ and the .dll - So the extension for Windows x64 PHP 8.2 and Apache would be:

extension=sqlsrv_82_ts_x64

NathanGibbs3 commented 1 year ago

Thanks, that helped me refine the error message a bit more. It won't point end users to the exact dll they need for their installation, but it will get them close enough to figure it out from there.

Better than compile time options for building PHP from source, which most of the time doesn't apply to the situation, especially on windows.

mesteele commented 1 year ago

php-5.6.40-Win32-VC11-x64 php_mysql.dll php_mysqli.dll php_pgsql.dll

php-5.6.40-nts-Win32-VC11-x64 php_mysql.dll php_mysqli.dll php_pgsql.dll

php-5.0.0-Win32 php_mysql.dll php_mysqli.dll php_pgsql.dll php_mssql.dll