mbehr1 / vsc-webshark

Visual Studio Code extension to open pcap / network capture files using wireshark/sharkd.
GNU General Public License v2.0
27 stars 11 forks source link

about settings #29

Closed chen-ran-mo closed 2 months ago

chen-ran-mo commented 1 year ago

I installed the wirehark in C:\Wireshark\wireshark. But it till has the problem: Assertion Failed: argument is undefined or null. I don't know how to do it.

mbehr1 commented 1 year ago

can you run sharkd from command line? Search for sharkd.exe in your install folder.

mbehr1 commented 1 year ago

(once found please post the output of

sharkd --version
actanta commented 1 year ago

Your work is exciting. I'd like to try your plugin.But I got the same tip.(Assertion Failed: argument is undefined or null)

Copyright 1998-2023 Gerald Combs gerald@wireshark.org and contributors. Licensed under the terms of the GNU General Public License (version 2 or later). This is free software; see the file named COPYING in the distribution. There is NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiled (64-bit) using Microsoft Visual Studio 2022 (VC++ 14.32, build 31332), with GLib 2.72.3, with PCRE2, with zlib 1.2.12, with Lua 5.2.4, with GnuTLS 3.6.3 and PKCS #11 support, with Gcrypt 1.10.1, with Kerberos (MIT), with MaxMind, with nghttp2 1.46.0, with brotli, with LZ4, with Zstandard, with Snappy, with libxml2 2.9.14, with libsmi 0.4.8, with binary plugins.

Running on 64-bit Windows 10 (22H2), build 19045, with Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz (with SSE4.2), with 16206 MB of physical memory, with GLib 2.72.3, with PCRE2 10.40 2022-04-14, with c-ares 1.18.1, with GnuTLS 3.6.3, with Gcrypt 1.10.1, with nghttp2 1.46.0, with brotli 1.0.9, with LZ4 1.9.3, with Zstandard 1.5.2, with LC_TYPE=C, binary plugins supported.

actanta commented 1 year ago
  1. Developer Tools -> console image
  2. sharkd.exe - Looks fine. image
mbehr1 commented 1 year ago

@actanta which version of the extension are you using?

hababy commented 2 months ago

Attempt to modify the src code,windows11, Sharkd (Wireshark) 4.2.6 (v4.2.6-0-g2acd1a854bab). 1. this._proc = spawn(sharkdPath, spawnArgs); image 2. image

Then the plugin works image

mbehr1 commented 2 months ago

hmm. interesting. So you did 3 changes: a) removing the stdio:['pipe', 'pipe', 'pipe']] from spawn options b) removing shell:true c) setting loadReq['prevFrame'] to 1 instead of false

Can you tell whether really all 3 are necessary? So if you e.g. add a) does it still work? (then same for b) and c))

mbehr1 commented 2 months ago

According to node.js spec e.g. a) should anyhow be the default value (so removing it should be fine per se but it should help to fix the issue ;-) https://nodejs.org/docs/latest-v20.x/api/child_process.html#optionsstdio

mbehr1 commented 2 months ago

For c) this is interesting as well. The wireshark wiki doesn't help a lot: https://wiki.wireshark.org/sharkd-JSON-RPC-Request-Syntax#frame Checking the wireshark/sharkd source from 4.0. branch "prev_frame" is defined as: https://gitlab.com/wireshark/wireshark/-/blame/release-4.0/sharkd_session.c#L396

 {"frame",      "prev_frame", 2, JSMN_PRIMITIVE,    SHARKD_JSON_BOOLEAN,  OPTIONAL},

Can you try whether c) still works if you change it to true instead of 1? (this would at least fit to the SHARKD_JSON_BOOLEAN definition.)

mbehr1 commented 2 months ago

Ah. now I understand: you do use wireshark 4.2 (not 4.0..). There is was actually changed: https://gitlab.com/wireshark/wireshark/-/blob/release-4.2/sharkd_session.c#L406

 {"frame",      "prev_frame", 2, JSMN_PRIMITIVE,    SHARKD_JSON_UINTEGER, SHARKD_OPTIONAL},
// commented as  *   (o) prev_frame - previously displayed frame number

So yes, c) seems needed to wireshark 4.2 (need to check when the version was added and change semantics depending on the version). Will do this as a PR.

Would still be nice if a) and b) are really necessary to fix your issue.

mbehr1 commented 2 months ago

@hababy see above. could you check my questions? thx!

hababy commented 2 months ago

@mbehr1 b) save shell:true image a) No abnormalities,You're right

mbehr1 commented 2 months ago

@hababy I fixed this in v2.1.1. Can you check? Works for me on mac with wireshark v4.0.10, v4.2.7 and v4.4.0.

hababy commented 2 months ago

@hababy I fixed this in v2.1.1. Can you check? Works for me on mac with wireshark v4.0.10, v4.2.7 and v4.4.0.

Sharkd (Wireshark) 4.4.0 (v4.4.0-0-g009a163470b5) Windows11, Unable to work in v2.1.1 or V2.2.0;

When I block 'shell: true', it can work

mbehr1 commented 2 months ago

ok. will take a look at the shell:true today

mbehr1 commented 2 months ago

@hababy can you help me with debugging. I cannot reproduce it (but I admit I have no win11 machine... only win10). Could you change that line:

console.log(`SharkdProcess(${this.id}) closed with: ${code}`);

to output additionally

data='${this._notReadyErrData}, partResp='${this._partialResponse?.toString()}'

thx!

mbehr1 commented 2 months ago

and can you print your %COMSPEC% env variable?

mbehr1 commented 2 months ago

I can reproduce it on a freshly installed win11 arm in a vm on a mac :-)

If wireshark/sharkd is installed in a path with a ' ' (space) then it does not work. E.g. using as sharkd full path (on a german language win11)

c:\Programme\Wireshark\sharkd.exe

works but

c:\Program Files\Wireshark\sharkd.exe

does not work. I'll try to find a fix for that.

mbehr1 commented 2 months ago

Found a way which seems best fitting to the nodes child_process.spawn api: spawn expects the command as first argument (and somewhat not the command with full path). So I'll split the fullPath to the dir/base and use the dir as options.cwd and the base as command.

hababy commented 2 months ago

%COMSPEC%

C:\Windows\system32\cmd.exe

hababy commented 2 months ago

I can reproduce it on a freshly installed win11 arm in a vm on a mac :-)

If wireshark/sharkd is installed in a path with a ' ' (space) then it does not work. E.g. using as sharkd full path (on a german language win11)

c:\Programme\Wireshark\sharkd.exe

works but

c:\Program Files\Wireshark\sharkd.exe

does not work. I'll try to find a fix for that.

That's true,I can use it normally when using “D:\Wireshark\sharkd.exe” instead of “D:\Program Files\Wireshark\sharkd.exe”

mklink /D "D:\Wireshark" "D:\Program Files\Wireshark\",

image image

mbehr1 commented 2 months ago

@hababy does version 2.2.1 fixes the issue?

hababy commented 2 months ago

version 2.2.1 fixes the issue @mbehr1 image image ![Uploading image.png…]()