From 0c1d1fb78e77f0edb6528d604c50a4441510e7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoren=20Gr=C3=BCttemeier?= Date: Fri, 17 May 2024 08:11:11 +0200 Subject: [PATCH 1/5] support personal lua plugin path, v1.3.1 --- .github/workflows/build.yml | 2 +- Installer/InstallerScript.iss | 715 +++++++++++++------------ V2G_Libraries/CertificateInfos/main.rc | 8 +- V2G_Libraries/V2GDecoder/main.rc | 8 +- Wireshark/plugins/v2gmsg.lua | 63 ++- Wireshark/plugins/v2gsdp.lua | 3 +- Wireshark/plugins/v2gshared.lua | 10 + Wireshark/plugins/v2gtlssecret.lua | 19 +- Wireshark/plugins/v2gtp.lua | 25 +- update_version.bat | 8 +- 10 files changed, 456 insertions(+), 405 deletions(-) create mode 100644 Wireshark/plugins/v2gshared.lua diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e9a97e..57cbc6d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: - name: Upload Win64 Files uses: actions/upload-artifact@v4 with: - name: dsV2Gshark_Files_Win_x64 + name: dsV2Gshark_Files_Win_x86_64 path: artifact_dir/* build-linux: diff --git a/Installer/InstallerScript.iss b/Installer/InstallerScript.iss index e876ea4..4b55036 100644 --- a/Installer/InstallerScript.iss +++ b/Installer/InstallerScript.iss @@ -1,357 +1,358 @@ -// DO NOT CHANGE VERSION HERE! Run update_version.bat -#define AppVer "1.3.0" -#define AppId "dsV2Gshark" - -[Setup] -AppId={#AppId} -AppName=dSPACE V2Gshark Wireshark Plugin -DefaultGroupName=dSPACE V2Gshark Wireshark Plugin -AppVersion={#AppVer} -VersionInfoVersion={#AppVer} -AppPublisher=dSPACE GmbH -AppCopyright=Copyright 2024, dSPACE GmbH. All rights reserved. -WizardStyle=modern -DefaultDirName=C:\Program Files\Wireshark -Compression=lzma2 -SolidCompression=yes -ChangesEnvironment=no -DisableDirPage=no -PrivilegesRequiredOverridesAllowed=dialog -UsePreviousPrivileges=no -OutputBaseFilename=dsV2Gshark_{#AppVer}_Setup -DirExistsWarning=no -DisableWelcomePage=no -LanguageDetectionMethod=none -AppendDefaultDirName=no -UsePreviousAppDir=no -UsedUserAreasWarning=no - -[Languages] -Name: "dsV2Gshark_strings"; MessagesFile: "strings.isl" - -[Types] -Name: "full"; Description: "Full installation" -Name: "custom"; Description: "Custom installation"; Flags: iscustom - -[CustomMessages] -Linebreak=%n - -[Components] -Name: "plugin"; Description: "Plugin files"; Types: full custom; Flags: fixed -Name: "plugin/dissectors"; Description: "V2G dissectors"; Types: full custom; Flags: fixed -Name: "plugin/decoder"; Description: "EXI decoder (powered by chargebyte cbexigen)"; Types: full custom; Flags: fixed -Name: "plugin/decoder/din"; Description: "DIN 70121 support"; Types: full custom; Flags: fixed -Name: "plugin/decoder/iso2"; Description: "ISO 15118-2 support"; Types: full custom; Flags: fixed -Name: "plugin/decoder/iso20"; Description: "ISO 15118-20 support (experimental)"; Types: full custom; Flags: fixed -Name: "plugin/autoschema"; Description: "Automatic schema detection"; Types: full custom; Flags: fixed -Name: "plugin/autodecrypt"; Description: "Live TLS decryption with disclosed master secret from UDP packet"; Types: full custom; -Name: "buttons"; Description: "Add filter buttons to Wireshark (current user only)"; Types: full -Name: "colorfilters"; Description: "Highlight V2G messages in Wireshark (current user only)"; Types: full -Name: "iograph"; Description: "Prepare Wireshark I/O Graphs for V2G messages{cm:Linebreak}(current user only, may override I/O Graph preferences)"; Types: full - -[Files] -Source: "..\Wireshark\plugins\v2gmsg.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/dissectors -Source: "..\Wireshark\plugins\v2gtp.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/dissectors -Source: "..\Wireshark\plugins\v2gsdp.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/dissectors -Source: "..\Wireshark\plugins\v2gtlssecret.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/autodecrypt -Source: "..\Wireshark\*.dll"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: plugin/decoder -Source: "..\LICENSE"; DestDir: "{app}"; DestName: "dsV2Gshark_LICENSE.txt"; Flags: ignoreversion; -Source: "..\OSSAcknowledgements.txt"; DestDir: "{app}"; DestName: "dsV2Gshark_OSSAcknowledgements.txt"; Flags: ignoreversion recursesubdirs; -Source: "dsV2Gshark_README.txt"; DestDir: "{app}"; DestName: "dsV2Gshark_README.txt"; Flags: ignoreversion; - -[InstallDelete] -Type: filesandordirs; Name: "{app}\luaV2Gdecoder.dll" -Type: filesandordirs; Name: "{app}\X509CertInfos.dll" -Type: filesandordirs; Name: "{app}\plugins\v2gmsg_generic.lua" - -[Code] -function HasWriteAccessToApp: Boolean; -var - FileName: string; -begin - FileName := AddBackslash(WizardDirValue) + 'writetest.tmp'; - Result := SaveStringToFile(FileName, 'test', False); - if Result then - begin - Log(Format( - 'Have write access to the last installation path [%s]', [WizardDirValue])); - DeleteFile(FileName); - end - else - begin - Log(Format('Does not have write access to the last installation path [%s]', [ - WizardDirValue])); - end; -end; - -function GetWiresharkConfigPath: string; -begin - if FileExists(ExpandConstant('{app}\..\..\WiresharkPortable64.exe')) then - Result := ExpandConstant('{app}\..\..\Data\') - else - Result := ExpandConstant('{userappdata}\Wireshark\'); - - if not DirExists(Result) then - CreateDir(Result); -end; - -function RemoveFromFile(FileName: string; LinesToRemove: array of string): Boolean; -var - LinesFile: TArrayOfString; - i, j: Integer; -begin - if LoadStringsFromFile(FileName, LinesFile) then - begin - for i := GetArrayLength(LinesFile) - 1 downto 0 do - begin - for j := GetArrayLength(LinesToRemove) - 1 downto 0 do - begin - if Pos(LinesToRemove[j], LinesFile[i]) > 0 then - LinesFile[i] := ''; - end; - end; - - if SaveStringsToFile(FileName, LinesFile, False) then - begin - Result := True; - end - else - Result := False; - end - else - begin - Result := False; - end; -end; - -function PrependStringsToFile(const FileName: string; const Strings: TArrayOfString): boolean; -var - Lines: TArrayOfString; - Count, NewLinesCount, i: Integer; -begin - Result := True; - if LoadStringsFromFile(FileName, Lines) then - begin - Count := GetArrayLength(Lines); - NewLinesCount := GetArrayLength(Strings); - SetArrayLength(Lines, Count + NewLinesCount); - for i := Count - 1 downto 0 do - Lines[i + NewLinesCount] := Lines[i]; - for i := 0 to NewLinesCount - 1 do - Lines[i] := Strings[i]; - if not SaveStringsToFile(FileName, Lines, False) then - Result := False; - end - else - Result := False; -end; - -function CheckLines(const FileName: string; const LinesToCheck: TArrayOfString): TArrayOfString; -var - FileLines: TStringList; - MissingLines: TStringList; - i: Integer; -begin - if not FileExists(FileName) then - begin - Result := LinesToCheck; - end - else - begin - FileLines := TStringList.Create; - MissingLines := TStringList.Create; - try - FileLines.LoadFromFile(FileName); - - for i := 0 to High(LinesToCheck) do - begin - if not FileLines.IndexOf(LinesToCheck[i]) >= 0 then - MissingLines.Add(LinesToCheck[i]); - end; - - SetLength(Result, MissingLines.Count); - for i := 0 to MissingLines.Count - 1 do - Result[i] := MissingLines[i]; - finally - FileLines.Free; - MissingLines.Free; - end; - end; -end; - -function NextButtonClick(PageId: Integer): Boolean; -begin - Result := True; - if (PageId = wpSelectDir) and not DirExists(ExpandConstant('{app}')) then - begin - MsgBox('The selected directory does not exist!', mbError, MB_OK); - Result := False; - exit; - end; - if (PageId = wpSelectDir) and not HasWriteAccessToApp then - begin - MsgBox('You do not have write access to this directory. Please run the installer as admin or select another directory!', mbError, MB_OK); - Result := False; - exit; - end; - if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}\Wireshark.exe')) then - begin - MsgBox('Wireshark does not seem to be installed in the selected folder. Note: For Wireshark Portable, select (...)\WiresharkPortable64\App\Wireshark\', mbError, MB_OK); - Result := False; - exit; - end; -end; - -function InitializeSetup(): boolean; -var - StringVersionPrefix, stringVersionSuffix: string; - VersionOfPlugin: string; - StartPos, endPos: Integer; - Lines: TArrayOfString; - i: Integer; -begin - // check version of lua files - StringVersionPrefix := 'DS_V2GSHARK_VERSION = "'; - stringVersionSuffix := '" -- DO NOT CHANGE'; - ExtractTemporaryFile('v2gmsg.lua'); - if LoadStringsFromFile(ExpandConstant('{tmp}\v2gmsg.lua'), Lines) then - begin - for i := 0 to GetArrayLength(Lines) - 1 do - begin - if (Copy(Lines[i], 1, Length(StringVersionPrefix)) = StringVersionPrefix) then - begin - StartPos := Length(StringVersionPrefix) + 1; - endPos := Pos(stringVersionSuffix, Lines[i]); - VersionOfPlugin := Copy(Lines[i], StartPos, endPos - StartPos); - Log('Version found in v2gmsg.lua is: ' + VersionOfPlugin); - Break; - end; - end; - end; - - if CompareText(VersionOfPlugin, '{#AppVer}') <> 0 then - begin - MsgBox('This setup seems to be faulty! Plugin version (' + VersionOfPlugin +') mismatch installer version ('+'{#AppVer}' +')!', mbError, MB_OK); - end; - Result := True; -end; - -procedure CleanupConfigs; -var - LinesToRemove: TArrayOfString; - FileName: string; -begin - // remove colorfilters - FileName := GetWiresharkConfigPath + 'colorfilters'; - LinesToRemove := ['@Homeplug@homeplug-av@[26214,26214,26214][65535,65535,65535]', - '@V2G Warning@v2gtp and _ws.expert@[52685,65535,51657][54484,0,0]', - '@V2G Default@v2gtp@[52685,65535,51657][0,0,0]', - '@V2G TLS Secret@v2gtlssecret@[0,29555,2056][65535,65535,65535]']; - RemoveFromFile(FileName, LinesToRemove); - - // remove buttons - FileName := GetWiresharkConfigPath + 'dfilter_buttons'; - LinesToRemove := [ - // v1.0.0 buttons - '"TRUE","[V2G ext]","v2gtp or v2gtlssecret or tls.handshake or tls.alert_message or tcp.flags.syn == 1 or tcp.flags.fin == 1 or homeplug or homeplug-av ",""', - '"TRUE","[V2G]","v2gtp or v2gtlssecret",""', - - // current buttons - '"TRUE","[V2G ext]","v2gtp or v2gtlssecret or tls.handshake or tls.alert_message or tls.change_cipher_spec or tcp.flags.syn == 1 or tcp.flags.fin == 1 or homeplug or homeplug-av ","Filter V2G messages, SLAC messages and additional TCP packets"', - '"TRUE","[V2G]","v2gtp or v2gtlssecret","Filter V2G messages"']; - RemoveFromFile(FileName, LinesToRemove); - - FileName := GetWiresharkConfigPath + 'io_graphs' - LinesToRemove := ['v2gtp', 'v2gmsg', 'CP State'] - RemoveFromFile(FileName, LinesToRemove); -end; - -procedure CurStepChanged(CurStep: TSetupStep); -var - FileName: string; - Lines: TArrayOfString; - StringsToCheck, StringsToAdd: TArrayOfString; -begin - // add wireshark filter buttons after installation - if (CurStep = ssPostInstall) then - begin - CleanupConfigs; // cleanup old configs on update - if WizardIsComponentSelected('buttons') then - begin - FileName := GetWiresharkConfigPath + 'dfilter_buttons' - StringsToCheck := ['"TRUE","[V2G ext]","v2gtp or v2gtlssecret or tls.handshake or tls.alert_message or tls.change_cipher_spec or tcp.flags.syn == 1 or tcp.flags.fin == 1 or homeplug or homeplug-av ","Filter V2G messages, SLAC messages and additional TCP packets"', - '"TRUE","[V2G]","v2gtp or v2gtlssecret","Filter V2G messages"'] - StringsToAdd := CheckLines(FileName, StringsToCheck) - if Length(StringsToAdd) > 0 then - if not SaveStringsToFile(FileName, StringsToAdd, True) then - MsgBox('Failed to add buttons to Wireshark', mbError, MB_OK); - end; - - if WizardIsComponentSelected('colorfilters') then - begin - // add wireshark colorfilters after installation - FileName := GetWiresharkConfigPath + 'colorfilters' - StringsToCheck := [ '@Homeplug@homeplug-av@[26214,26214,26214][65535,65535,65535]', - '@V2G Warning@v2gtp and _ws.expert@[52685,65535,51657][54484,0,0]', - '@V2G Default@v2gtp@[52685,65535,51657][0,0,0]', - '@V2G TLS Secret@v2gtlssecret@[0,29555,2056][65535,65535,65535]']; - StringsToAdd := CheckLines(FileName, StringsToCheck) - if not FileExists(FileName) then - begin - // copy standard colorfilters to $FileName - if not LoadStringsFromFile(ExpandConstant('{app}\colorfilters'), Lines) then - begin - MsgBox('Failed to add colorfilters to Wireshark. Default filter settings not found!', mbError, MB_OK); - end - else - begin - SaveStringsToFile(FileName, Lines, True); - end; - end; - if Length(StringsToAdd) > 0 then - if not PrependStringsToFile(FileName, StringsToAdd) then - MsgBox('Failed to add colorfilters to Wireshark!', mbError, MB_OK); - end; - - if WizardIsComponentSelected('iograph') then - begin - // add graph io presets after installation - FileName := GetWiresharkConfigPath + 'io_graphs' - StringsToAdd := [ '"Enabled","#V2G-Packets/Interval","v2gtp","#D3D3D3","Square","Packets","v2gtp","None","1"', - '"Enabled","Target Voltage EV","","#AA0000","Cross","AVG(Y Field)","v2gmsg.xml.iograph.EVTargetVoltage","None","1"', - '"Enabled","Present Voltage EVSE","","#AA0000","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEPresentVoltage","None","1"', - '"Enabled","[ISO20] Present Voltage EV","","#AA6262","Circle","AVG(Y Field)","v2gmsg.xml.iograph.EVPresentVoltage","None","1"', - '"Enabled","Target Current EV","","#0000FF","Cross","AVG(Y Field)","v2gmsg.xml.iograph.EVTargetCurrent","None","1"', - '"Enabled","Present Current EVSE","","#0000FF","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEPresentCurrent","None","1"', - '"Enabled","[ISO20] Present SOC","","#AAFF00","Line","AVG(Y Field)","v2gmsg.xml.iograph.PresentSOC","None","1"', - '"Enabled","[DIN/ISO2] Present SOC","","#AAFF00","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVRESSSOC","None","1"', - '"Disabled","[DIN/ISO2] Max Voltage EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumVoltageLimit","None","1"', - '"Disabled","[DIN/ISO2] Max Voltage EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumVoltageLimit","None","1"', - '"Disabled","[DIN/ISO2] Max Current EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumCurrentLimit","None","1"', - '"Disabled","[DIN/ISO2] Max Current EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumCurrentLimit","None","1"', - '"Disabled","[ISO20] Max Voltage EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumVoltage","None","1"', - '"Disabled","[ISO20] Min Voltage EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMinimumVoltage","None","1"', - '"Disabled","[ISO20] Max Current EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumChargeCurrent","None","1"', - '"Disabled","[ISO20] Max Voltage EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumVoltage","None","1"', - '"Disabled","[ISO20] Max Current EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumChargeCurrent","None","1"', - '"Disabled","CP State","","#2E3436","Dot","AVG(Y Field)","homeplug_av.st_iotecha.cpstate.state","None","20"']; - if FileExists(FileName) then - begin - if not PrependStringsToFile(FileName, StringsToAdd) then - MsgBox('Failed to add I/O Graph presets to Wireshark!', mbError, MB_OK); - end - else - begin - if not SaveStringsToFile(FileName, StringsToAdd, True) then - begin - MsgBox('Failed to add I/O Graph presets to Wireshark!', mbError, MB_OK); - end; - end; - end; - end; -end; - -procedure DeinitializeUninstall; -begin - CleanupConfigs; -end; +// DO NOT CHANGE VERSION HERE! Run update_version.bat +#define AppVer "1.3.1" +#define AppId "dsV2Gshark" + +[Setup] +AppId={#AppId} +AppName=dSPACE V2Gshark Wireshark Plugin +DefaultGroupName=dSPACE V2Gshark Wireshark Plugin +AppVersion={#AppVer} +VersionInfoVersion={#AppVer} +AppPublisher=dSPACE GmbH +AppCopyright=Copyright 2024, dSPACE GmbH. All rights reserved. +WizardStyle=modern +DefaultDirName=C:\Program Files\Wireshark +Compression=lzma2 +SolidCompression=yes +ChangesEnvironment=no +DisableDirPage=no +PrivilegesRequiredOverridesAllowed=dialog +UsePreviousPrivileges=no +OutputBaseFilename=dsV2Gshark_{#AppVer}_Win64_Setup +DirExistsWarning=no +DisableWelcomePage=no +LanguageDetectionMethod=none +AppendDefaultDirName=no +UsePreviousAppDir=no +UsedUserAreasWarning=no + +[Languages] +Name: "dsV2Gshark_strings"; MessagesFile: "strings.isl" + +[Types] +Name: "full"; Description: "Full installation" +Name: "custom"; Description: "Custom installation"; Flags: iscustom + +[CustomMessages] +Linebreak=%n + +[Components] +Name: "plugin"; Description: "Plugin files"; Types: full custom; Flags: fixed +Name: "plugin/dissectors"; Description: "V2G dissectors"; Types: full custom; Flags: fixed +Name: "plugin/decoder"; Description: "EXI decoder (powered by chargebyte cbexigen)"; Types: full custom; Flags: fixed +Name: "plugin/decoder/din"; Description: "DIN 70121 support"; Types: full custom; Flags: fixed +Name: "plugin/decoder/iso2"; Description: "ISO 15118-2 support"; Types: full custom; Flags: fixed +Name: "plugin/decoder/iso20"; Description: "ISO 15118-20 support (experimental)"; Types: full custom; Flags: fixed +Name: "plugin/autoschema"; Description: "Automatic schema detection"; Types: full custom; Flags: fixed +Name: "plugin/autodecrypt"; Description: "Live TLS decryption with disclosed master secret from UDP packet"; Types: full custom; +Name: "buttons"; Description: "Add filter buttons to Wireshark (current user only)"; Types: full +Name: "colorfilters"; Description: "Highlight V2G messages in Wireshark (current user only)"; Types: full +Name: "iograph"; Description: "Prepare Wireshark I/O Graphs for V2G messages{cm:Linebreak}(current user only, may override I/O Graph preferences)"; Types: full + +[Files] +Source: "..\Wireshark\plugins\v2gshared.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/dissectors +Source: "..\Wireshark\plugins\v2gmsg.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/dissectors +Source: "..\Wireshark\plugins\v2gtp.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/dissectors +Source: "..\Wireshark\plugins\v2gsdp.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/dissectors +Source: "..\Wireshark\plugins\v2gtlssecret.lua"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs; Components: plugin/autodecrypt +Source: "..\Wireshark\*.dll"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: plugin/decoder +Source: "..\LICENSE"; DestDir: "{app}"; DestName: "dsV2Gshark_LICENSE.txt"; Flags: ignoreversion; +Source: "..\OSSAcknowledgements.txt"; DestDir: "{app}"; DestName: "dsV2Gshark_OSSAcknowledgements.txt"; Flags: ignoreversion recursesubdirs; +Source: "dsV2Gshark_README.txt"; DestDir: "{app}"; DestName: "dsV2Gshark_README.txt"; Flags: ignoreversion; + +[InstallDelete] +Type: filesandordirs; Name: "{app}\luaV2Gdecoder.dll" +Type: filesandordirs; Name: "{app}\X509CertInfos.dll" +Type: filesandordirs; Name: "{app}\plugins\v2gmsg_generic.lua" + +[Code] +function HasWriteAccessToApp: Boolean; +var + FileName: string; +begin + FileName := AddBackslash(WizardDirValue) + 'writetest.tmp'; + Result := SaveStringToFile(FileName, 'test', False); + if Result then + begin + Log(Format( + 'Have write access to the last installation path [%s]', [WizardDirValue])); + DeleteFile(FileName); + end + else + begin + Log(Format('Does not have write access to the last installation path [%s]', [ + WizardDirValue])); + end; +end; + +function GetWiresharkConfigPath: string; +begin + if FileExists(ExpandConstant('{app}\..\..\WiresharkPortable64.exe')) then + Result := ExpandConstant('{app}\..\..\Data\') + else + Result := ExpandConstant('{userappdata}\Wireshark\'); + + if not DirExists(Result) then + CreateDir(Result); +end; + +function RemoveFromFile(FileName: string; LinesToRemove: array of string): Boolean; +var + LinesFile: TArrayOfString; + i, j: Integer; +begin + if LoadStringsFromFile(FileName, LinesFile) then + begin + for i := GetArrayLength(LinesFile) - 1 downto 0 do + begin + for j := GetArrayLength(LinesToRemove) - 1 downto 0 do + begin + if Pos(LinesToRemove[j], LinesFile[i]) > 0 then + LinesFile[i] := ''; + end; + end; + + if SaveStringsToFile(FileName, LinesFile, False) then + begin + Result := True; + end + else + Result := False; + end + else + begin + Result := False; + end; +end; + +function PrependStringsToFile(const FileName: string; const Strings: TArrayOfString): boolean; +var + Lines: TArrayOfString; + Count, NewLinesCount, i: Integer; +begin + Result := True; + if LoadStringsFromFile(FileName, Lines) then + begin + Count := GetArrayLength(Lines); + NewLinesCount := GetArrayLength(Strings); + SetArrayLength(Lines, Count + NewLinesCount); + for i := Count - 1 downto 0 do + Lines[i + NewLinesCount] := Lines[i]; + for i := 0 to NewLinesCount - 1 do + Lines[i] := Strings[i]; + if not SaveStringsToFile(FileName, Lines, False) then + Result := False; + end + else + Result := False; +end; + +function CheckLines(const FileName: string; const LinesToCheck: TArrayOfString): TArrayOfString; +var + FileLines: TStringList; + MissingLines: TStringList; + i: Integer; +begin + if not FileExists(FileName) then + begin + Result := LinesToCheck; + end + else + begin + FileLines := TStringList.Create; + MissingLines := TStringList.Create; + try + FileLines.LoadFromFile(FileName); + + for i := 0 to High(LinesToCheck) do + begin + if not FileLines.IndexOf(LinesToCheck[i]) >= 0 then + MissingLines.Add(LinesToCheck[i]); + end; + + SetLength(Result, MissingLines.Count); + for i := 0 to MissingLines.Count - 1 do + Result[i] := MissingLines[i]; + finally + FileLines.Free; + MissingLines.Free; + end; + end; +end; + +function NextButtonClick(PageId: Integer): Boolean; +begin + Result := True; + if (PageId = wpSelectDir) and not DirExists(ExpandConstant('{app}')) then + begin + MsgBox('The selected directory does not exist!', mbError, MB_OK); + Result := False; + exit; + end; + if (PageId = wpSelectDir) and not HasWriteAccessToApp then + begin + MsgBox('You do not have write access to this directory. Please run the installer as admin or select another directory!', mbError, MB_OK); + Result := False; + exit; + end; + if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}\Wireshark.exe')) then + begin + MsgBox('Wireshark does not seem to be installed in the selected folder. Note: For Wireshark Portable, select (...)\WiresharkPortable64\App\Wireshark\', mbError, MB_OK); + Result := False; + exit; + end; +end; + +function InitializeSetup(): boolean; +var + StringVersionPrefix, stringVersionSuffix: string; + VersionOfPlugin: string; + StartPos, endPos: Integer; + Lines: TArrayOfString; + i: Integer; +begin + // check version of lua files + StringVersionPrefix := 'v2gshared.DS_V2GSHARK_VERSION = "'; + stringVersionSuffix := '" -- DO NOT CHANGE'; + ExtractTemporaryFile('v2gshared.lua'); + if LoadStringsFromFile(ExpandConstant('{tmp}\v2gshared.lua'), Lines) then + begin + for i := 0 to GetArrayLength(Lines) - 1 do + begin + if (Copy(Lines[i], 1, Length(StringVersionPrefix)) = StringVersionPrefix) then + begin + StartPos := Length(StringVersionPrefix) + 1; + endPos := Pos(stringVersionSuffix, Lines[i]); + VersionOfPlugin := Copy(Lines[i], StartPos, endPos - StartPos); + Log('Version found in v2gmsg.lua is: ' + VersionOfPlugin); + Break; + end; + end; + end; + + if CompareText(VersionOfPlugin, '{#AppVer}') <> 0 then + begin + MsgBox('This setup seems to be faulty! Plugin version (' + VersionOfPlugin +') mismatch installer version ('+'{#AppVer}' +')!', mbError, MB_OK); + end; + Result := True; +end; + +procedure CleanupConfigs; +var + LinesToRemove: TArrayOfString; + FileName: string; +begin + // remove colorfilters + FileName := GetWiresharkConfigPath + 'colorfilters'; + LinesToRemove := ['@Homeplug@homeplug-av@[26214,26214,26214][65535,65535,65535]', + '@V2G Warning@v2gtp and _ws.expert@[52685,65535,51657][54484,0,0]', + '@V2G Default@v2gtp@[52685,65535,51657][0,0,0]', + '@V2G TLS Secret@v2gtlssecret@[0,29555,2056][65535,65535,65535]']; + RemoveFromFile(FileName, LinesToRemove); + + // remove buttons + FileName := GetWiresharkConfigPath + 'dfilter_buttons'; + LinesToRemove := [ + // v1.0.0 buttons + '"TRUE","[V2G ext]","v2gtp or v2gtlssecret or tls.handshake or tls.alert_message or tcp.flags.syn == 1 or tcp.flags.fin == 1 or homeplug or homeplug-av ",""', + '"TRUE","[V2G]","v2gtp or v2gtlssecret",""', + + // current buttons + '"TRUE","[V2G ext]","v2gtp or v2gtlssecret or tls.handshake or tls.alert_message or tls.change_cipher_spec or tcp.flags.syn == 1 or tcp.flags.fin == 1 or homeplug or homeplug-av ","Filter V2G messages, SLAC messages and additional TCP packets"', + '"TRUE","[V2G]","v2gtp or v2gtlssecret","Filter V2G messages"']; + RemoveFromFile(FileName, LinesToRemove); + + FileName := GetWiresharkConfigPath + 'io_graphs' + LinesToRemove := ['v2gtp', 'v2gmsg', 'CP State'] + RemoveFromFile(FileName, LinesToRemove); +end; + +procedure CurStepChanged(CurStep: TSetupStep); +var + FileName: string; + Lines: TArrayOfString; + StringsToCheck, StringsToAdd: TArrayOfString; +begin + // add wireshark filter buttons after installation + if (CurStep = ssPostInstall) then + begin + CleanupConfigs; // cleanup old configs on update + if WizardIsComponentSelected('buttons') then + begin + FileName := GetWiresharkConfigPath + 'dfilter_buttons' + StringsToCheck := ['"TRUE","[V2G ext]","v2gtp or v2gtlssecret or tls.handshake or tls.alert_message or tls.change_cipher_spec or tcp.flags.syn == 1 or tcp.flags.fin == 1 or homeplug or homeplug-av ","Filter V2G messages, SLAC messages and additional TCP packets"', + '"TRUE","[V2G]","v2gtp or v2gtlssecret","Filter V2G messages"'] + StringsToAdd := CheckLines(FileName, StringsToCheck) + if Length(StringsToAdd) > 0 then + if not SaveStringsToFile(FileName, StringsToAdd, True) then + MsgBox('Failed to add buttons to Wireshark', mbError, MB_OK); + end; + + if WizardIsComponentSelected('colorfilters') then + begin + // add wireshark colorfilters after installation + FileName := GetWiresharkConfigPath + 'colorfilters' + StringsToCheck := [ '@Homeplug@homeplug-av@[26214,26214,26214][65535,65535,65535]', + '@V2G Warning@v2gtp and _ws.expert@[52685,65535,51657][54484,0,0]', + '@V2G Default@v2gtp@[52685,65535,51657][0,0,0]', + '@V2G TLS Secret@v2gtlssecret@[0,29555,2056][65535,65535,65535]']; + StringsToAdd := CheckLines(FileName, StringsToCheck) + if not FileExists(FileName) then + begin + // copy standard colorfilters to $FileName + if not LoadStringsFromFile(ExpandConstant('{app}\colorfilters'), Lines) then + begin + MsgBox('Failed to add colorfilters to Wireshark. Default filter settings not found!', mbError, MB_OK); + end + else + begin + SaveStringsToFile(FileName, Lines, True); + end; + end; + if Length(StringsToAdd) > 0 then + if not PrependStringsToFile(FileName, StringsToAdd) then + MsgBox('Failed to add colorfilters to Wireshark!', mbError, MB_OK); + end; + + if WizardIsComponentSelected('iograph') then + begin + // add graph io presets after installation + FileName := GetWiresharkConfigPath + 'io_graphs' + StringsToAdd := [ '"Enabled","#V2G-Packets/Interval","v2gtp","#D3D3D3","Square","Packets","v2gtp","None","1"', + '"Enabled","Target Voltage EV","","#AA0000","Cross","AVG(Y Field)","v2gmsg.xml.iograph.EVTargetVoltage","None","1"', + '"Enabled","Present Voltage EVSE","","#AA0000","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEPresentVoltage","None","1"', + '"Enabled","[ISO20] Present Voltage EV","","#AA6262","Circle","AVG(Y Field)","v2gmsg.xml.iograph.EVPresentVoltage","None","1"', + '"Enabled","Target Current EV","","#0000FF","Cross","AVG(Y Field)","v2gmsg.xml.iograph.EVTargetCurrent","None","1"', + '"Enabled","Present Current EVSE","","#0000FF","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEPresentCurrent","None","1"', + '"Enabled","[ISO20] Present SOC","","#AAFF00","Line","AVG(Y Field)","v2gmsg.xml.iograph.PresentSOC","None","1"', + '"Enabled","[DIN/ISO2] Present SOC","","#AAFF00","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVRESSSOC","None","1"', + '"Disabled","[DIN/ISO2] Max Voltage EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumVoltageLimit","None","1"', + '"Disabled","[DIN/ISO2] Max Voltage EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumVoltageLimit","None","1"', + '"Disabled","[DIN/ISO2] Max Current EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumCurrentLimit","None","1"', + '"Disabled","[DIN/ISO2] Max Current EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumCurrentLimit","None","1"', + '"Disabled","[ISO20] Max Voltage EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumVoltage","None","1"', + '"Disabled","[ISO20] Min Voltage EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMinimumVoltage","None","1"', + '"Disabled","[ISO20] Max Current EV","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVMaximumChargeCurrent","None","1"', + '"Disabled","[ISO20] Max Voltage EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumVoltage","None","1"', + '"Disabled","[ISO20] Max Current EVSE","","#2E3436","Line","AVG(Y Field)","v2gmsg.xml.iograph.EVSEMaximumChargeCurrent","None","1"', + '"Disabled","CP State","","#2E3436","Dot","AVG(Y Field)","homeplug_av.st_iotecha.cpstate.state","None","20"']; + if FileExists(FileName) then + begin + if not PrependStringsToFile(FileName, StringsToAdd) then + MsgBox('Failed to add I/O Graph presets to Wireshark!', mbError, MB_OK); + end + else + begin + if not SaveStringsToFile(FileName, StringsToAdd, True) then + begin + MsgBox('Failed to add I/O Graph presets to Wireshark!', mbError, MB_OK); + end; + end; + end; + end; +end; + +procedure DeinitializeUninstall; +begin + CleanupConfigs; +end; diff --git a/V2G_Libraries/CertificateInfos/main.rc b/V2G_Libraries/CertificateInfos/main.rc index 18f978f..96cb39e 100644 --- a/V2G_Libraries/CertificateInfos/main.rc +++ b/V2G_Libraries/CertificateInfos/main.rc @@ -1,11 +1,11 @@ #include -#define VER_FILEVERSION 1,3,0,0 -#define VER_FILEVERSION_STR "1.3.0.0\0" +#define VER_FILEVERSION 1,3,1,0 +#define VER_FILEVERSION_STR "1.3.1.0\0" #define VER_COMPANYNAME_STR "dSPACE GmbH" #define VER_PRODUCTNAME_STR "V2gCertificateInfos" -#define VER_PRODUCTVERSION 1,3,0,0 -#define VER_PRODUCTVERSION_STR "1.3.0.0\0" +#define VER_PRODUCTVERSION 1,3,1,0 +#define VER_PRODUCTVERSION_STR "1.3.1.0\0" VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION diff --git a/V2G_Libraries/V2GDecoder/main.rc b/V2G_Libraries/V2GDecoder/main.rc index 93cfe4d..898ead2 100644 --- a/V2G_Libraries/V2GDecoder/main.rc +++ b/V2G_Libraries/V2GDecoder/main.rc @@ -1,11 +1,11 @@ #include -#define VER_FILEVERSION 1,3,0,0 -#define VER_FILEVERSION_STR "1.3.0.0\0" +#define VER_FILEVERSION 1,3,1,0 +#define VER_FILEVERSION_STR "1.3.1.0\0" #define VER_COMPANYNAME_STR "dSPACE GmbH" #define VER_PRODUCTNAME_STR "V2gDecoder" -#define VER_PRODUCTVERSION 1,3,0,0 -#define VER_PRODUCTVERSION_STR "1.3.0.0\0" +#define VER_PRODUCTVERSION 1,3,1,0 +#define VER_PRODUCTVERSION_STR "1.3.1.0\0" VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION diff --git a/Wireshark/plugins/v2gmsg.lua b/Wireshark/plugins/v2gmsg.lua index f7649c7..c79bdfa 100644 --- a/Wireshark/plugins/v2gmsg.lua +++ b/Wireshark/plugins/v2gmsg.lua @@ -10,11 +10,45 @@ -- -- See license file (dsV2Gshark_LICENSE.txt) -- -DS_V2GSHARK_VERSION = "1.3.0" -- DO NOT CHANGE + +-- do OS specific stuff, required to load v2g libs +if package.config:sub(1, 1) == "\\" then + local plugins_path = debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])") or "./" -- path of this lua script + local wireshark_path = plugins_path .. "../" + + -- extend path (where to load .lua files) + if not string.find(plugins_path, package.path) then + package.path = package.path .. ";" .. plugins_path .. "?.lua" + end + + -- extend cpath (where to load .so files) + if not string.find(wireshark_path, package.cpath) then + package.cpath = package.cpath .. ";" .. wireshark_path .. "?.dll;" .. plugins_path .. "?.dll" + end +else + -- UNIX + local global_plugins_path = debug.getinfo(1, "S").source:sub(2):match("(.*/)") or "./" -- path of this lua script + local wireshark_path = global_plugins_path .. "../" + local personal_plugins_path = os.getenv("HOME") .. "/.local/lib/wireshark/" + + -- extend path (where to load .lua files) + if not string.find(global_plugins_path, package.path) then + package.path = package.path .. ";" .. global_plugins_path .. "?.lua" + end + + -- extend cpath (where to load .so files) + if not string.find(wireshark_path, package.cpath) then + package.cpath = + package.cpath .. + ";" .. personal_plugins_path .. "?.so;" .. wireshark_path .. "?.so;" .. global_plugins_path .. "?.so" + end +end + +local v2gshared = require("v2gshared") p_v2gmsg = Proto("v2gmsg", "V2G Message") local p_v2gmsg_info = { - version = DS_V2GSHARK_VERSION, + version = v2gshared.DS_V2GSHARK_VERSION, author = "dSPACE GmbH", description = "Dissector for V2G Messages (DIN 70121, ISO15118-2, ISO15118-20)" } @@ -25,27 +59,6 @@ local v2g_decoder = require("v2gLuaDecoder") v2g_decoder.initValidator() local cert_info_extractor = require("v2gX509CertInfos") --- Settings -p_v2gmsg.prefs["infotext"] = Pref.statictext("dSPACE V2Gshark Wireshark Plugin") -p_v2gmsg.prefs["additionalinfo"] = Pref.statictext("powered by chargebyte cbExiGen") -p_v2gmsg.prefs["additionalinfo2"] = Pref.statictext("") -p_v2gmsg.prefs["portrange_tlssecret"] = - Pref.range( - "TLS secret UDP port(s)", - "49152-65535", - "UDP source ports of TLS secret disclosure packets.\n\nDefault: '49152-65535'", - 65535 -) -p_v2gmsg.prefs["portrange_v2g"] = - Pref.range( - "V2G message TCP port(s)", - "49152-65535", - "TCP source ports of V2G request and response messages.\n\nDefault: '49152-65535'", - 65535 -) -p_v2gmsg.prefs["additionalinfo3"] = Pref.statictext("") -p_v2gmsg.prefs["versioninfo"] = Pref.statictext("Version " .. DS_V2GSHARK_VERSION) - -- Buffer for all decoded messages. Maps packetID -> xml string (or nil) local xml_buffer = {} @@ -128,10 +141,6 @@ function p_v2gmsg.init() decoded_with_auto_schema_detection = {} decoded_with_schema_namespace = {} decoded_error_code = {} - - -- register v2g ports - DissectorTable.get("tls.port"):add(p_v2gmsg.prefs["portrange_v2g"], p_v2gtp) - DissectorTable.get("tcp.port"):add(p_v2gmsg.prefs["portrange_v2g"], p_v2gtp) end local function decode_v2g_message(schema, exi_string, packet_number) diff --git a/Wireshark/plugins/v2gsdp.lua b/Wireshark/plugins/v2gsdp.lua index be21e82..90acffb 100644 --- a/Wireshark/plugins/v2gsdp.lua +++ b/Wireshark/plugins/v2gsdp.lua @@ -4,11 +4,12 @@ -- -- See license file (dsV2Gshark_LICENSE.txt) -- +local v2gshared = require("v2gshared") p_sdpreq = Proto("v2gsdp-req", "V2G SECC Discovery Protocol Request") p_sdpres = Proto("v2gsdp-res", "V2G SECC Discovery Protocol Response") local p_v2gsdp_info = { - version = DS_V2GSHARK_VERSION, + version = v2gshared.DS_V2GSHARK_VERSION, author = "dSPACE GmbH" } set_plugin_info(p_v2gsdp_info) diff --git a/Wireshark/plugins/v2gshared.lua b/Wireshark/plugins/v2gshared.lua new file mode 100644 index 0000000..487a4f6 --- /dev/null +++ b/Wireshark/plugins/v2gshared.lua @@ -0,0 +1,10 @@ +-- +-- Copyright 2024, dSPACE GmbH. All rights reserved. +-- +-- See license file (dsV2Gshark_LICENSE.txt) +-- +local v2gshared = {} + +v2gshared.DS_V2GSHARK_VERSION = "1.3.1" -- DO NOT CHANGE + +return v2gshared diff --git a/Wireshark/plugins/v2gtlssecret.lua b/Wireshark/plugins/v2gtlssecret.lua index 22beee7..bcacb98 100644 --- a/Wireshark/plugins/v2gtlssecret.lua +++ b/Wireshark/plugins/v2gtlssecret.lua @@ -5,14 +5,29 @@ -- -- See license file (dsV2Gshark_LICENSE.txt) -- +local v2gshared = require("v2gshared") p_v2gtlssecret = Proto("v2gtlssecret", "V2G TLS secret") local p_v2gtlssecret_info = { - version = DS_V2GSHARK_VERSION, + version = v2gshared.DS_V2GSHARK_VERSION, author = "dSPACE GmbH" } set_plugin_info(p_v2gtlssecret_info) +-- Settings +p_v2gtlssecret.prefs["infotext"] = Pref.statictext("dSPACE V2Gshark Wireshark Plugin") +p_v2gtlssecret.prefs["additionalinfo"] = Pref.statictext("powered by chargebyte cbExiGen") +p_v2gtlssecret.prefs["additionalinfo2"] = Pref.statictext("") +p_v2gtlssecret.prefs["portrange_tlssecret"] = + Pref.range( + "TLS secret UDP port(s)", + "49152-65535", + "UDP source ports of TLS secret disclosure packets.\n\nDefault: '49152-65535'", + 65535 +) +p_v2gtlssecret.prefs["additionalinfo3"] = Pref.statictext("") +p_v2gtlssecret.prefs["versioninfo"] = Pref.statictext("Version " .. v2gshared.DS_V2GSHARK_VERSION) + local min_wireshark_version = "3.5.0" local f_cr = ProtoField.string("v2gtlssecret.clientrandom", "NSS Key Log", base.ASCII) @@ -204,6 +219,6 @@ end -- end function 'p_v2gtlssecret.dissector' -- initialization routine function p_v2gtlssecret.init() -- register tls secret ports - DissectorTable.get("udp.port"):add(p_v2gmsg.prefs["portrange_tlssecret"], p_v2gtlssecret) + DissectorTable.get("udp.port"):add(p_v2gtlssecret.prefs["portrange_tlssecret"], p_v2gtlssecret) frame_numbers = {} end diff --git a/Wireshark/plugins/v2gtp.lua b/Wireshark/plugins/v2gtp.lua index c13d6d9..88e62df 100644 --- a/Wireshark/plugins/v2gtp.lua +++ b/Wireshark/plugins/v2gtp.lua @@ -4,14 +4,29 @@ -- -- See license file (dsV2Gshark_LICENSE.txt) -- +local v2gshared = require("v2gshared") p_v2gtp = Proto("v2gtp", "V2G Transfer Protocol") local p_v2gtp_info = { - version = DS_V2GSHARK_VERSION, + version = v2gshared.DS_V2GSHARK_VERSION, author = "dSPACE GmbH" } set_plugin_info(p_v2gtp_info) +-- Settings +p_v2gtp.prefs["infotext"] = Pref.statictext("dSPACE V2Gshark Wireshark Plugin") +p_v2gtp.prefs["additionalinfo"] = Pref.statictext("powered by chargebyte cbExiGen") +p_v2gtp.prefs["additionalinfo2"] = Pref.statictext("") +p_v2gtp.prefs["portrange_v2g"] = + Pref.range( + "V2G message TCP port(s)", + "49152-65535", + "TCP source ports of V2G request and response messages.\n\nDefault: '49152-65535'", + 65535 +) +p_v2gtp.prefs["additionalinfo3"] = Pref.statictext("") +p_v2gtp.prefs["versioninfo"] = Pref.statictext("Version " .. v2gshared.DS_V2GSHARK_VERSION) + local V2GTP_HDR_LENGTH = 8 local f_pv = ProtoField.uint8("v2gtp.protoversion", "Protocol Version", base.HEX) @@ -158,8 +173,8 @@ end -- initialization routine function p_v2gtp.init() - -- register protocol - DissectorTable.get("udp.port"):add(15118, p_v2gtp) - DissectorTable.get("tcp.port"):add(15118, p_v2gtp) - DissectorTable.get("tls.port"):add(15118, p_v2gtp) + -- register v2g ports + DissectorTable.get("udp.port"):add(p_v2gtp.prefs["portrange_v2g"], p_v2gtp) + DissectorTable.get("tls.port"):add(p_v2gtp.prefs["portrange_v2g"], p_v2gtp) + DissectorTable.get("tcp.port"):add(p_v2gtp.prefs["portrange_v2g"], p_v2gtp) end diff --git a/update_version.bat b/update_version.bat index 46af0fa..8c24f01 100644 --- a/update_version.bat +++ b/update_version.bat @@ -29,15 +29,15 @@ for /F delims^=^ eol^= %%A in ('%SystemRoot%\System32\findstr.exe /N "^" "%FileN ) >>"%TempFile%" move /y %TempFile% %FileName% -:: update v2gmsg.lua -set "FileName=.\Wireshark\plugins\v2gmsg.lua" +:: update v2gshared.lua +set "FileName=.\Wireshark\plugins\v2gshared.lua" del "%TempFile%" 2>nul for /F delims^=^ eol^= %%A in ('%SystemRoot%\System32\findstr.exe /N "^" "%FileName%"') do ( set "Line=%%A" setlocal EnableDelayedExpansion - if not "!Line:DS_V2GSHARK_VERSION=!" == "!Line!" ( + if not "!Line:v2gshared.DS_V2GSHARK_VERSION=!" == "!Line!" ( if not "!Line:DO NOT CHANGE=!" == "!Line!" ( - echo DS_V2GSHARK_VERSION = "%newVersion%" -- DO NOT CHANGE + echo v2gshared.DS_V2GSHARK_VERSION = "%newVersion%" -- DO NOT CHANGE ) else echo(!Line:*:=! ) else echo(!Line:*:=! endlocal From 09d34fae54b35a87cd28981ca0a8984e892d8c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoren=20Gr=C3=BCttemeier?= Date: Fri, 17 May 2024 08:41:47 +0200 Subject: [PATCH 2/5] cleanup --- Wireshark/plugins/v2gmsg.lua | 41 +++++++++++++----------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/Wireshark/plugins/v2gmsg.lua b/Wireshark/plugins/v2gmsg.lua index c79bdfa..ac837da 100644 --- a/Wireshark/plugins/v2gmsg.lua +++ b/Wireshark/plugins/v2gmsg.lua @@ -11,37 +11,26 @@ -- See license file (dsV2Gshark_LICENSE.txt) -- --- do OS specific stuff, required to load v2g libs +-- do OS specific stuff, required to properly load v2g libs +local plugins_path -- path to the plugins directory of this script +local lib_pattern if package.config:sub(1, 1) == "\\" then - local plugins_path = debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])") or "./" -- path of this lua script - local wireshark_path = plugins_path .. "../" - - -- extend path (where to load .lua files) - if not string.find(plugins_path, package.path) then - package.path = package.path .. ";" .. plugins_path .. "?.lua" - end - - -- extend cpath (where to load .so files) - if not string.find(wireshark_path, package.cpath) then - package.cpath = package.cpath .. ";" .. wireshark_path .. "?.dll;" .. plugins_path .. "?.dll" - end + -- WINDOWS + plugins_path = debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])") or "./" + lib_pattern = "?.dll" else -- UNIX - local global_plugins_path = debug.getinfo(1, "S").source:sub(2):match("(.*/)") or "./" -- path of this lua script - local wireshark_path = global_plugins_path .. "../" - local personal_plugins_path = os.getenv("HOME") .. "/.local/lib/wireshark/" - + plugins_path = debug.getinfo(1, "S").source:sub(2):match("(.*/)") or "./" + lib_pattern = "?.so" +end +local wireshark_path = plugins_path .. "../" +if not string.find(plugins_path, package.path) then -- extend path (where to load .lua files) - if not string.find(global_plugins_path, package.path) then - package.path = package.path .. ";" .. global_plugins_path .. "?.lua" - end - + package.path = package.path .. ";" .. plugins_path .. "?.lua" +end +if not string.find(wireshark_path, package.cpath) then -- extend cpath (where to load .so files) - if not string.find(wireshark_path, package.cpath) then - package.cpath = - package.cpath .. - ";" .. personal_plugins_path .. "?.so;" .. wireshark_path .. "?.so;" .. global_plugins_path .. "?.so" - end + package.cpath = package.cpath .. ";" .. wireshark_path .. lib_pattern .. ";" .. plugins_path .. lib_pattern end local v2gshared = require("v2gshared") From 8b83c8792a5d226af2da076f5a60c6699a945cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoren=20Gr=C3=BCttemeier?= Date: Fri, 17 May 2024 10:07:22 +0200 Subject: [PATCH 3/5] updated linux hints --- .github/workflows/build.yml | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57cbc6d..5d48cae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: mkdir artifact_dir/plugins cp ./Wireshark/plugins/* ./artifact_dir/plugins/ echo "dSPACE V2Gshark Wireshark Plugin" > ./artifact_dir/README - echo "Please copy these files to your Wireshark installation." >> ./artifact_dir/README + echo "Please copy the .so files and the 'plugins' directory into your Wireshark installation or into your personal plugin directory (%appdata%/wireshark)." >> ./artifact_dir/README - name: Upload Win64 Files uses: actions/upload-artifact@v4 @@ -61,7 +61,7 @@ jobs: mkdir artifact_dir/plugins cp ./Wireshark/plugins/* ./artifact_dir/plugins/ echo "dSPACE V2Gshark Wireshark Plugin" > ./artifact_dir/README - echo "Please copy these files to your Wireshark installation." >> ./artifact_dir/README + echo "Please copy the .so files and the 'plugins' directory into your Wireshark installation or into your personal plugin directory (~/.local/lib/wireshark)." >> ./artifact_dir/README - name: Upload Linux Files uses: actions/upload-artifact@v4 diff --git a/README.md b/README.md index 4a06b8f..903a108 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Click on a packet in the graph to inspect it in the Wireshark main window. Press - ISO 15118-20 is not fully supported yet - please let us know if you encounter incorrectly decoded packets - Linux - - no installer + - no installer, please copy the files manually into your Wireshark installation or into your personal plugin directory (~/.local/lib/wireshark) - filter buttons and color filters must be added manually - I/O graph must be configured manually From 56ad0d6fdd32f5aa6af24ac2cd1e3d8f14dbc75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoren=20Gr=C3=BCttemeier?= Date: Fri, 17 May 2024 10:07:47 +0200 Subject: [PATCH 4/5] (re-)added port 15118 for v2gtp --- Wireshark/plugins/v2gtp.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Wireshark/plugins/v2gtp.lua b/Wireshark/plugins/v2gtp.lua index 88e62df..c92210c 100644 --- a/Wireshark/plugins/v2gtp.lua +++ b/Wireshark/plugins/v2gtp.lua @@ -174,7 +174,9 @@ end -- initialization routine function p_v2gtp.init() -- register v2g ports - DissectorTable.get("udp.port"):add(p_v2gtp.prefs["portrange_v2g"], p_v2gtp) + DissectorTable.get("udp.port"):add(15118, p_v2gtp) + DissectorTable.get("tcp.port"):add(15118, p_v2gtp) + DissectorTable.get("tls.port"):add(15118, p_v2gtp) DissectorTable.get("tls.port"):add(p_v2gtp.prefs["portrange_v2g"], p_v2gtp) DissectorTable.get("tcp.port"):add(p_v2gtp.prefs["portrange_v2g"], p_v2gtp) end From eeb8533d165e730623a3ed3119c178a325050827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoren=20Gr=C3=BCttemeier?= Date: Fri, 17 May 2024 14:20:04 +0200 Subject: [PATCH 5/5] updated README --- .github/workflows/build.yml | 8 ++++---- OSSAcknowledgements.txt | 4 ++-- README.md | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d48cae..8294886 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,8 +33,8 @@ jobs: cp ./V2G_Libraries/V2GDecoder/bin/* ./artifact_dir/ mkdir artifact_dir/plugins cp ./Wireshark/plugins/* ./artifact_dir/plugins/ - echo "dSPACE V2Gshark Wireshark Plugin" > ./artifact_dir/README - echo "Please copy the .so files and the 'plugins' directory into your Wireshark installation or into your personal plugin directory (%appdata%/wireshark)." >> ./artifact_dir/README + cp ./LICENSE ./artifact_dir/dsV2Gshark_LICENSE.txt + cp ./README.md ./artifact_dir/dsV2Gshark_README.txt - name: Upload Win64 Files uses: actions/upload-artifact@v4 @@ -60,8 +60,8 @@ jobs: cp ./V2G_Libraries/V2GDecoder/bin/* ./artifact_dir/ mkdir artifact_dir/plugins cp ./Wireshark/plugins/* ./artifact_dir/plugins/ - echo "dSPACE V2Gshark Wireshark Plugin" > ./artifact_dir/README - echo "Please copy the .so files and the 'plugins' directory into your Wireshark installation or into your personal plugin directory (~/.local/lib/wireshark)." >> ./artifact_dir/README + cp ./LICENSE ./artifact_dir/dsV2Gshark_LICENSE.txt + cp ./README.md ./artifact_dir/dsV2Gshark_README.txt - name: Upload Linux Files uses: actions/upload-artifact@v4 diff --git a/OSSAcknowledgements.txt b/OSSAcknowledgements.txt index 3a90136..2e9250a 100644 --- a/OSSAcknowledgements.txt +++ b/OSSAcknowledgements.txt @@ -141,7 +141,7 @@ cbExiGen The license text of the 'Apache License Version 2.0' can be found in APPENDIX A. -Wireshark 4.2.4 +Wireshark 4.2.5 Copyright: Copyright 1998-2024 Gerald Combs and contributors Repository: https://gitlab.com/wireshark/wireshark @@ -149,7 +149,7 @@ Wireshark 4.2.4 The license text of the 'GNU GENERAL PUBLIC LICENSE v2.0' can be found in APPENDIX A. -GnuTLS 3.8.3 +GnuTLS 3.8.4 URL: https://www.gnutls.org/ License: GnuTLS License diff --git a/README.md b/README.md index 903a108..98691d8 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Click on a packet in the graph to inspect it in the Wireshark main window. Press ## Installation notes - The installer can be downloaded from [GitHub Releases](https://github.com/dspace-group/dsV2Gshark/releases/latest) +- To use the plugin without installer, download the zipped files from [GitHub Releases](https://github.com/dspace-group/dsV2Gshark/releases/latest) and copy its content manually into your Wireshark installation or into your personal plugin directory (Windows: %appdata%/wireshark/, Linux: ~/.local/lib/wireshark/). The filter buttons, color filter and I/O Graph configuration must be added manually in this case. - When updating Wireshark, please reinstall the plugin to avoid any warnings - Not compatible with other V2G dissector plugins. Please uninstall these plugins before installing dsV2Gshark. - Not compatible with 32 bit versions of Wireshark. @@ -60,8 +61,8 @@ Click on a packet in the graph to inspect it in the Wireshark main window. Press - ISO 15118-20 is not fully supported yet - please let us know if you encounter incorrectly decoded packets - Linux - - no installer, please copy the files manually into your Wireshark installation or into your personal plugin directory (~/.local/lib/wireshark) - - filter buttons and color filters must be added manually + - No installer, see [Installation Notes](#installation-notes). Make sure you have read permissions for all files. + - Filter buttons and color filters must be added manually - I/O graph must be configured manually ## Support @@ -71,7 +72,7 @@ Click on a packet in the graph to inspect it in the Wireshark main window. Press ## Further notes - When sniffing V2G communication, lost packets may occur, which cause corrupted TCP/TLS sessions. In that case, it may help to activate the option to ignore Message Authentication Code (MAC) check failures in the Wireshark TLS protocol settings. This option can be found under Wireshark Preferences - Protocols - TLS -- This plugin was built and tested with Wireshark 4.2.4 +- This plugin was built and tested with Wireshark 4.2.5 - The EXI decoding is based on [cbExiGen](https://github.com/EVerest/cbexigen)