Commit Graph

455 Commits

Author SHA1 Message Date
John Thacker 3c22bc0d0b dpauxmon: Flush after pcap header
Flush after writing the pcap header for the same reasons as
in udpdump (see commit 9ad1ec1651)
2023-08-11 20:05:10 +00:00
John Thacker 9ad1ec1651 extcap: Flush after writing the pcap header
Call fflush in udpdump and ciscodump after writing the pcap header
so that it is actually written out even if no packets have arrived yet.

By doing so, dumpcap no longer blocks in cap_pipe_open_live waiting
for the pcap header from the extcap pipe until the first packet is
captured, but instead goes on to (attempt to) open its output.

This means that if we capture no packets that a capture file with
a header but no packet records will be created (and, if not a temp
file, will have to be cleaned up), but that is consistent with tshark
and Wireshark behavior otherwise.

This means you can no longer do a capture to a FIFO or Named Pipe
in this order:

1) Start dumpcap
2) Create the FIFO or Named Pipe
3) Start the flow of packets to the UDP port

which only worked when not dissecting packets. It was broken if tshark
also needed to dissect packets, but evaded the checks for if we were
writing to a FIFO or Named Pipe resulting in behavior mysterious to
users, such as only writing to one of the Named Pipe readers on Windows
(or failing if there aren't enough instances), or having tshark and
the other pipe reader compete for the pipe input and eventually failing
on UN*X.

Instead, the FIFO or Named Pipe needs to be created before launching
dumpcap, or else an ordinary file will be created (on UN*X), or an
error about not being able to open the output (on Windows, since
Named Pipes have a magic prefix, and you can't create an ordinary
file with a named pipe filename.)

Fix #17900.
2023-08-03 22:03:07 -04:00
Gerald Combs 3c2fa2b61a Falcodump: Partially revert c8accef14c
sinsp::get_plugin_manager is usable again, so switch back to using it.
2023-07-31 14:22:37 -07:00
Gerald Combs c8accef14c Falcodump + Falco bridge: libsinsp API updates
Update to match recent libsinsp 0.11 API changes.
2023-07-04 14:42:29 +00:00
Gerald Combs c068948610 Falcodump: Update our AWS region list 2023-06-28 14:00:57 -07:00
Gerald Combs 347f3ab1a6 Falcodump: Fix our data source settings
Change the data source label to "Log data URL". Fix a tooltip typo.
2023-06-28 11:24:59 -07:00
Guy Harris f8d1525b17 Get rid of unnecessary casts.
snprintf(), sensibly, takes a size_t argument specifying the size of the
buffer. g_snprintf(), bogusly, takes a gulong argument specifying the
size of the buffer, so we had to do casts to avoid narrowing complaints,
but we're just using snprintf() now (as we require C11 or later), and
don't need the casts any more.
2023-06-18 16:07:35 -07:00
Gerald Combs a265aa4bc2 Convert writecap to C99 types
Convert writecap to C99 types. Add maximum and minimum values to
convert-glib-types.py.

Ping #19116
2023-06-16 15:34:44 +00:00
Gerald Combs 978f62a805 Convert our extcaps to C99 types
Convert our extcaps to C99 types. Try to preserve padding in
convert-glib-types.py and add globbing support on Windows.

Ping #19116
2023-06-15 01:14:59 +00:00
John Thacker 1cdebcd80c randpkt: Support different capture formats, default to pcapng
Related to #18009 - Have randpkt default to pcapng, allow selecting
a different capture file format via the common -F option that other
command line tools use, and document it.

For the randpktdump extcap, just use pcapng.

This fixes --all-random, because --all-random requires different
encapsulation per packet. It also fixes the related -r option to
randpkt (though note that picking a file format that doesn't support
ENCAP_PER_PACKET with -r causes problems.)

Document -r in the randpkt man page.

Fix #18944
2023-06-03 13:45:20 -04:00
João Valverde 41b8f07c86 CMake+Windows: Try to fix NSIS installer with Ninja 2023-06-01 19:27:55 +01:00
João Valverde 9f7f472f49 androiddump: Fix warning [-Wdiscarded-qualifier]
wireshark/extcap/androiddump.c:573:48: warning: passing argument 5 of 'select' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  573 |             if ((select(0, NULL, &fdset, NULL, &timeout) != 0) && (FD_ISSET(sock, &fdset))) {
      |                                                ^~~~~~~~
2023-05-26 01:16:59 +01:00
Jaap Keuter eea848bf5e sshdump: Trying to get closer to setting intended rem. capture filter
Closes #18874
2023-05-16 09:17:40 +00:00
John Thacker 5f08477bba etwdump: Try to fix the build
At least one version of MSVC seems not to like a trailing
comma at the end of variadic arguments.
2023-04-26 18:45:14 -04:00
Kevin Schoonover bdac10e25e add ProcessorNumber to packet comments 2023-04-26 18:09:27 +00:00
Gerald Combs f01f81b87d falcodump: Catch exceptions when loading plugins
Consolidate some duplicate code.
2023-04-20 23:00:18 +00:00
Jaap Keuter 512a1ca2b3 sshdump: allow dumpcap capture config without remote interface
Closes #18904
2023-03-23 11:25:41 +00:00
Gerald Combs 84d3aefa1b Falcodump: Update to match the current libsinsp/libscap. 2023-03-13 16:06:06 -07:00
Jaap Keuter 455b9a470f sshdump: add capability to use doas on remote host 2023-02-19 13:41:24 +00:00
João Valverde 0cea64a632 Move ui/cmdarg_err.[ch] to wsutil 2023-02-10 20:59:22 +00:00
João Valverde 71cfbd81b3 Remove wspcap.h and use config.h instead
Forcing the use of a dedicated header to replace pcap.h is
unnecessary code and mental overhead in this case. We can
use config.h instead for the same purpose of defining a
macro symbol before including pcap.h.
2023-02-06 15:05:36 +00:00
João Valverde d70e174ca0 Remove wsutil/netlink.h workaround 2023-02-06 15:04:46 +00:00
João Valverde b07ab25a1c CMake: Cleanup unnecessary linking with shared libraries 2023-02-06 15:04:46 +00:00
Gerald Combs 24ab9c0aaa Falco bridge+falcodump: Scan for personal plugins 2023-01-19 00:17:08 +00:00
João Valverde cdff6da68e MinGW: Cast away a -Wincompatible-pointer-types warning
extcap/androiddump.c:1712:36: warning: passing argument 2 of 'ws_inet_pton4' from incompatible pointer type [-Wincompatible-pointer-types]
 1712 |         ws_inet_pton4(bt_local_ip, &(server.sin_addr.s_addr));
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                    |
      |                                    u_long * {aka long unsigned int *}
2023-01-14 14:52:53 +00:00
João Valverde f3152af8a0 MinGW: Fix -Wsign-compare 2023-01-13 22:41:04 +00:00
Alexis La Goutte f908bfa821 ciscodump(.c): Fix Null pointer passed to 1st parameter expecting 'nonnull' 2023-01-13 08:06:02 +00:00
Gerald Combs 11983087ed Falcodump: More scap event code handling fixes
We don't need to do anything special for timeouts.
2023-01-12 02:36:41 +00:00
Gerald Combs 809b34455e Falcodump: Improve scap event code handling
Check timeouts and filtered events.
2023-01-11 22:04:41 +00:00
Jakub Pawlowski c95e8bd38a androiddump: btsnoop support on android T and onwards
After android T, BT process might be called i.e.
com.google.android.bluetooth, instead of com.android.bluetooth

It depends on what APEX version is installed.
2023-01-05 06:52:02 +00:00
Gerald Combs bf17e3260e CMake: Set a default output directory for log-based extcaps 2022-12-22 19:30:17 +00:00
Gerald Combs f2caa6a0cc Extcap: Fix falcodump gcc warnings and errors.
Fix warnings and errors reported by gcc 11.3.
2022-12-15 01:46:03 +00:00
Dario Lombardo f2eb97e910 Fix ciscodump CID 2022-12-13 20:05:59 +00:00
j.novak@netsystem.cz 212b196bee ciscodump: Added support for IOS XE 17.x 2022-12-12 19:49:17 +00:00
Gerald Combs 9581085430 Falcodump: Open our fifo directly.
Just open our fifo directly using our sinsp dumper. Add a couple of
missing regions.
2022-12-12 18:36:52 +00:00
j.novak@netsystem.cz 2e22eb8357 ciscodump: Added noisy messages for troubleshooting 2022-12-12 07:50:46 +00:00
Alexis La Goutte 8aa55eb2ba etwudmp: fix typo
parmeters => parameters
2022-11-17 14:53:02 +00:00
Adrian Granados 420ec1511d extcap: fix missing control frames from wifidump capture
Normally, 'control' and 'otherbss' flags are set when
using monitor mode, but certain Wi-Fi drivers (e.g. MT7921)
need to explicitly have these flags set in order to capture
control frames.
2022-10-31 13:20:06 +00:00
Gerald Combs f10538a102 falcodump: Fix our credential and config file parsing. 2022-10-13 16:32:43 +00:00
Gerald Combs 7896f4b292 falcodump: Fixup our default profile and region.
Make sure we fetch AWS_PROFILE if it exists. Don't add AWS_PROFILE or
AWS_REGION if they're already in the profile and region lists. Fix our
default values.
2022-10-11 00:40:54 +00:00
João Valverde 3949d289d1 Add log init message to main() 2022-10-08 15:33:47 +00:00
Uli Heilmeier a471aa7628 sshdump: Add '-f ' for capture filter
Fixes #18420
2022-10-08 12:27:30 +00:00
Gerald Combs a1ec850894 falcodump: Prefill the Cloudtrail profile and region fields.
Make the cloudtrail-aws-profile and cloudtrail-aws-region settings
prefilled selection lists. Make them editable as well.
2022-10-07 17:01:17 +00:00
Gerald Combs ca0843f168 falcodump: Fixup our help output. 2022-10-03 15:09:55 -07:00
Gerald Combs b5b1949c5e falcodump: Updates for libsinsp and the cloudtrail plugin.
The libsinsp plugin API recently changed the way plugins are opened.
Update falcodump to match.

Plugins might return a nested and "$ref"ed config schema. Update our
parsing code to match.
2022-10-03 14:24:24 -07:00
j.novak@netsystem.cz e091e8755a extcap: Fixed end application loop logic 2022-10-03 10:16:57 +00:00
Gerald Combs 28a26096fb falcodump: Add support for selection options.
If a plugin has an "enum" + array in its configuration, convert it to a
selector option.

Start adding plugin sections to the falcodump man page.
2022-09-29 16:44:21 +00:00
Mikael Kanstrup b7066e0819 sshdump: Fix remote-capture-command option
The remote-capture-command option does not work when selecting
remote capture command selection 'other' from the extcap capture
options dialog. Fix strcmp statement to actually check for 'other'.

Fixes: #18381
2022-09-26 20:25:18 +02:00
Alexis La Goutte 2d22f72d4d ciscodump(extcap): Fix DeadStore 2022-09-20 06:27:46 +00:00
Guy Harris e5951765d8 Dissector names are not protocol names.
A given protocol's packet format may depend, for example, on which
lower-level protocol is transporting the protocol in question.  For
example, protocols that run atop both byte-stream protocols such as TCP
and TLS, and packet-oriented protocols such as UDP or DTLS, might begin
the packet with a length when running atop a byte-stream protocol, to
indicate where this packet ends and the next packet begins in the byte
stream, but not do so when running atop a packet-oriented protocol.

Dissectors can handle this in various ways:

For example, the dissector could attempt to determine the protocol over
which the packet was transported.

Unfortunately, many of those mechanisms do so by fetching data from the
packet_info structure, and many items in that structure act as global
variables, so that, for example, if there are two two PDUs for protocol
A inside a TCP segment, and the first protocol for PDU A contains a PDU
for protocol B, and protocol B's dissector, or a dissector it calls,
modifies the information in the packet_info structure so that it no
longer indicates that the parent protocol is TCP, the second PDU for
protocol A might not be correctly dissected.

Another such mechanism is to query the previous element in the layers
structure of the packet_info structure, which is a list of protocol IDs.

Unfortunately, that is not a list of earlier protocols in the protocol
stack, it's a list of earlier protocols in the dissection, which means
that, in the above example, when the second PDU for protocol A is
dissected, the list is {...,TCP,A,B,...,A}, which means that the
previous element in the list is not TCP, so, again, the second PDU for
protocol A will not be correctly dissected.

An alternative is to have multiple dissectors for the same protocol,
with the part of the protocol that's independent of the protocol
transporting the PDU being dissected by common code.  Protocol B might
have an "over a byte-stream transport" dissector and an "over a packet
transport" dissector, with the first dissector being registered for use
over TCP and TLS and the other dissector being registered for use over
packet protocols.  This mechanism, unlike the other mechanisms, is not
dependent on information in the packet_info structure that might be
affected by dissectors other than the one for the protocol that
transports protocol B.

Furthermore, in a LINKTYPE_WIRESHARK_UPPER_PDU pcap or pcapng packet for
protocol B, there might not be any information to indicate the protocol
that transports protocol B, so there would have to be separate
dissectors for protocol B, with separate names, so that a tag giving the
protocol name would differ for B-over-byte-stream and B-over-packets.

So:

We rename EXP_PDU_TAG_PROTO_NAME and EXP_PDU_TAG_HEUR_PROTO_NAME to
EXP_PDU_TAG_DISSECTOR_NAME and EXP_PDU_TAG_HEUR_DISSECTOR_NAME, to
emphasize that they are *not* protocol names, they are dissector names
(which has always been the case - if there's a protocol with that name,
but no dissector with that name, Wireshark will not be able to handle
the packet, as it will try to look up a dissector given that name and
fail).

We fix that exported PDU dissector to refer to those tags as dissector
names, not protocol names.

We update documentation to refer to them as DISSECTOR_NAME tags, not
PROTO_NAME tags.  (If there is any documentation for this outside the
Wireshark source, it should be updated as well.)

We add comments for calls to dissector_handle_get_dissector_name() where
the dissector name is shown to the user, to indicate that it might be
that the protocol name should be used.

We update the TLS and DTLS dissectors to show the encapsulated protocol
as the string returned by dissector_handle_get_long_name(); as the
default is "Application Data", it appeaers that a descriptive name,
rather than a short API name, should be used.  (We continue to use the
dissector name in debugging messages, to indicate which dissector was
called.)
2022-09-10 22:37:11 -07:00