pax_global_header 0000666 0000000 0000000 00000000064 14743162762 0014526 g ustar 00root root 0000000 0000000 52 comment=192b3aba82460fe887a9fb6b0125e3794de87a4b
natlog-3.01.00/ 0000775 0000000 0000000 00000000000 14743162762 0013153 5 ustar 00root root 0000000 0000000 natlog-3.01.00/CLASSES 0000664 0000000 0000000 00000000404 14743162762 0014171 0 ustar 00root root 0000000 0000000 rotatingstreambuf
rotatingstream
nic
options
storage
showseconds
record
ipbase
tcp
udp
icmp
producer
producersignals
pcaprecord
pcap
pcapfilter
devicesproducer
conntrackrecord
conntrackproducer
tcpdumprecord
tcpdumpproducer
connectionsconsumer
natfork
natlog-3.01.00/INSTALL 0000664 0000000 0000000 00000007503 14743162762 0014211 0 ustar 00root root 0000000 0000000 To install natlog by hand instead of using a binary distribution perform
the following steps:
0. natlog and its construction depends, in addition to the normally
standard available system software on specific software and versions
which is documented in the file `required'.
(If you compile the bobcat library yourself, note that natlog does
not use the SSL, Milter and Xpointer classes; they may --as far as
natlog is concerned-- be left out of the library by running
'./build light')
1. It is expected you use icmake for the package construction. For this a
top-level script (build) and support scripts in the ./icmake/
directory are available. By default, the 'build' script echoes the
commands it executes to the standard output stream. By specifying the
option -q (e.g., ./build -q ...) this is prevented, significantly
reducing the output generated by 'build'.
2. Inspect the values of the variables in the file INSTALL.im Modify these
when necessary.
3. Run
./build program [strip]
to compile natlog. The argument `strip' is optional and strips
symbolic information from the final executable.
4. If you installed Yodl then you can create the documentation:
./build man
builds the man-page.
5. Before installing the components of natlog, consider defining the
environment variable NATLOG, defining its value as the (preferably
absolute) filename of a file on which installed files and directories
are logged.
Defining the NATLOG environment variable as ~/.natlog usually
works well.
6. Run (probably as root)
./build install 'what' 'base'
to install. Here, 'what' specifies what you want to install.
Specify:
x, to install all components,
or specify a combination of:
b (binary program),
d (standard documentation),
m (man-pages)
E.g., use
./build install bm 'base'
if you only want to be able to run natlog, and want its man-page to
be installed below 'base'.
./build install's last argument 'base' is optional: the base directory
below which the requested files are installed. This base directory is
prepended to the paths #defined in the INSTALL.im file. If 'base' is
not specified, then INSTALL.im's #defined paths are used as-is.
When requesting non-existing elements (e.g., './build install x' was
requested, but the man-pages weren't constructed) then these
non-existing elements are silently ignored by the installation
process.
If the environment variable NATLOG was defined when issuing the
`./build install ...' command then a log of all installed files is
written to the file indicated by the NATLOG environment variable
(see also the next item).
Defining the NATLOG environment variable as ~/.natlog usually
works well.
7. Uninstalling previously installed components of natlog is easy
if the environment variable NATLOG was defined before issuing the
`./build install ...' command. In that case, run the command
./build uninstall logfile
where 'logfile' is the file that was written by ./build install.
Modified files and non-empty directories are not removed, but the
logfile itself is removed following the uninstallation.
8. Following the installation nothing in the directory tree which contains
this file (i.e., INSTALL) is required for the proper functioning of
natlog, so consider removing it. If you only want to remove
left-over files from the build-process, just run
./build distclean
natlog-3.01.00/INSTALL.im 0000664 0000000 0000000 00000003041 14743162762 0014606 0 ustar 00root root 0000000 0000000 #define PROGRAM "natlog"
#define CXX "ccache g++"
#define CXXFLAGS "-Wall -Werror -O2 -pthread "\
"-fdiagnostics-color=never"
#define LDFLAGS ""
// The following /bin/cp option is used to keep, rather than follow
// symbolic references. If your installation doesn't support these flags,
// then change them into available ones.
// -P, --no-dereference
// never follow symbolic links in SOURCE
// --preserve[=ATTR_LIST]
// preserve the specified attributes (default:
// mode,ownership,timestamps), if possible additional
// attributes: context, links, all
// -d same as --no-dereference --preserve=links
#define CPOPTS "-d"
// COMPONENTS TO INSTALL
// =====================
// For an operational non-Debian installation, you probably must be
// `root'.
// If necessary, adapt DOC, HDR, LIB and MAN (below) to your situation.
// The provided locations are used by Debian Linux.
// With 'build install' you can dynamically specify a location to prepend
// to the locations configured here, and select which components you want
// to install
// ONLY USE ABSOLUTE DIRECTORY NAMES:
// the final program
#define BINARY "/usr/bin/"${PROGRAM}
// the directory where the standard documentation is stored
#define DOC "/usr/share/doc/"${PROGRAM}
// the directory whre the manual page is stored
#define MAN "/usr/share/man/man1"
natlog-3.01.00/LICENSE 0000664 0000000 0000000 00000104515 14743162762 0014166 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
natlog-3.01.00/README 0000664 0000000 0000000 00000001446 14743162762 0014040 0 ustar 00root root 0000000 0000000 IP packet related enum and struct definitions are in
iptypes/iptypes.h
------------------------------------------------------------------------------
The organization of the program's flow is described in
documentation/README.flow
An annotated example of tcp communication is available in
documentation/README.tcp
Information describing the format of the file written by tcpdump is found in
documentation/README.tcpdump
An annotated example of udp communication and the instructions of how to set
up a demo-udp connection is available in documentation/README.udp
The organization of pcap packets is described in documentation/README.packet
An example of the information made available by the conntrack program for tcp,
udp, and icmp connections is available in documentation/README.conntrack
natlog-3.01.00/README.signals 0000664 0000000 0000000 00000003764 14743162762 0015504 0 ustar 00root root 0000000 0000000 When NatLog runs it starts the ConnectionConsumer and either the
ConntrackProducer or the DevicesProducer.
Ending the program:
===================
The ConntrackProducer starts conntrack as a separate process which is killed
when the program ends, either (non-daemon) via ^C or (daemon) via option
--terminate.
The DevicesProducer uses threads which are ended when its mutex 'd_signaled'
is notified by the signalHandler member when SIGTERM (or SIGKILL) is received.
ProducerSignals: both ConntrackProducer and DevicesProducer are derived from
ProducerSignals, which is derived from Producer and
FBB::SignalHandler. ProducerSignals adds signals for SIGINT and SIGTERM, and
ConntrackProducer and DevicesProducer override the
FBB::SignalHandler::signalHandler member to terminate either 'conntrack' or
the DevicesProducer's threads.
Rotating log files (see also natfork/README.logging)
==================
classes UDP, TCP and ICMP receive the logDataStream
NatFork::childProcess defines 'ConnectionsConsumer connections' It remains in
existence for as long as NatLog runs (either as daemon or as forground
program).
The stream receiving the std log messages is d_stdMsg, additional msg are
inserted by imsg, when -V is specified.
ConnectionConsumer's constructor defines RotatingStream d_logDataStream, and
opens it, opening RotatingStreambuf::open. The RotatingStreambuf object is
assigned to s_dataRotate.rotationStreambuf.
The standard log stream's RotatingStreambuf is assigned to
s_stdRotate.rotationStreambuf when NatFork::setupStdMsg is called from
NatFork's constructor.
When calling 'natfork --rotate' the signal SIGHUP is sent to the running
natlog process. When calling 'natfork --rotate-data' the signal SIGALRM is
sent to the running natlog process.
These signals are recognized by NatFork::childProcess, and are received by
NatFork::signalHandler. At SIGHUP RotatingStreambuf::logRotate is called,
rotating the standard log file, At SIGALRM RotatingStreambuf::dataRotate is
called, rotating the log-data file,
natlog-3.01.00/VERSION 0000664 0000000 0000000 00000000155 14743162762 0014224 0 ustar 00root root 0000000 0000000 #define AUTHOR "Frank B. Brokken (f.b.brokken@rug.nl)";
#define VERSION "3.01.00"
#define YEARS "2012-2025"
natlog-3.01.00/VERSION.h 0000664 0000000 0000000 00000000104 14743162762 0014444 0 ustar 00root root 0000000 0000000 #include "VERSION"
SUBST(_CurVers_)(VERSION)
SUBST(_CurYrs_)(YEARS)
natlog-3.01.00/build 0000775 0000000 0000000 00000006732 14743162762 0014210 0 ustar 00root root 0000000 0000000 #!/usr/bin/icmake -t.
#define LOGENV "NATLOG"
string
g_logPath = getenv(LOGENV)[1],
g_cwd = chdir(""); // initial working directory, ends in /
int g_echo = ON;
#include "icmconf"
#include "icmake/cuteoln"
#include "icmake/backtick"
#include "icmake/setopt"
#include "icmake/run"
#include "icmake/md"
#include "icmake/findall"
#include "icmake/logfile"
#include "icmake/logzip"
#include "icmake/uninstall"
#include "icmake/loginstall"
#include "icmake/special"
#include "icmake/pathfile"
#include "icmake/clean"
#include "icmake/manpage"
#include "icmake/install"
#include "icmake/gitlab"
void main(int argc, list argv)
{
string option;
int idx;
int strip = 0;
for (idx = listlen(argv); idx--; )
{
if (argv[idx] == "-q")
{
g_echo = OFF;
argv -= (list)"-q";
}
}
echo(g_echo);
option = argv[1];
if (option == "clean")
clean(0);
if (option == "distclean")
clean(1);
if (option != "")
special();
if (option == "install")
install(argv[2], argv[3]);
if (option == "uninstall")
uninstall(argv[2]);
if (option == "gitlab")
gitlab();
if (option == "man")
manpage();
if ("VERSION" younger "version/version.h")
system("touch version/version.h `grep -l Icmbuild:: *.cc`");
if (option == "library")
{
system("icmbuild library");
exit(0);
}
if (argv[2] == "strip") // in preparation for 9.03.00:
strip = 1; // changed strip-handling
if (option == "program")
{
system("icmbuild program");
if (strip)
system("strip " TMP_DIR "/bin/binary");
exit(0);
}
if (option == "xref")
{
system("icmbuild program");
run("oxref -r replacements -t main -fxs tmp/lib"
LIBRARY ".a tmp/main.o > " PROGRAM ".xref");
exit(0);
}
printf("Usage: build [-q -P] what\n"
"Where\n"
" [-q]: run quietly, do not show executed commands\n"
"`what' is one of:\n"
" clean - clean up remnants of previous "
"compilations\n"
" distclean - clean + fully remove tmp/\n"
" library - build " PROGRAM "'s library\n"
" man - build the man-page (requires Yodl)\n"
" program - build " PROGRAM "\n"
" xref - same a `program', also builds xref file\n"
" using oxref\n"
" install selection [base] - to install the software in the \n"
" locations defined in the INSTALL.im file,\n"
" optionally below base\n"
" selection can be\n"
" x, to install all components,\n"
" or a combination of:\n"
" b (binary program),\n"
" d (documentation),\n"
" m (man-page)\n"
" uninstall logfile - remove files and empty directories listed\n"
" in the file 'logfile'\n"
" gitlab - prepare gitlab's web-pages update\n"
" (internal use only)\n"
"\n"
);
exit(1);
}
natlog-3.01.00/build-depends 0000664 0000000 0000000 00000000272 14743162762 0015616 0 ustar 00root root 0000000 0000000 Build-Depends:
g++ (>= 4.7.1),
icmake (>= 7.19.00),
libbobcat-dev (>= 3.01.00),
libpcap-dev,
yodl (>= 3.00.0)
natlog-3.01.00/changelog 0000664 0000000 0000000 00000030345 14743162762 0015032 0 ustar 00root root 0000000 0000000 natlog (3.01.00)
* Requires bobcat >= 6.07.00 and icmake >= 13.00,03.
* Changed ArgConfig::None into ArgConfig::NoArg.
* Building uses a SPCH and multi-compilation.
* The compiler is called using the value of the ${ICMAKE_CPPSTD} environment
variable specifying the C++ standard to use.
* Calling natlog without arguments or with the --help option provides usage
info, with the --version option the current version is written to the
std. output stream
-- Frank B. Brokken Sun, 19 Jan 2025 12:17:43 +0100
natlog (3.00.01)
* Ready for libbobcat6
* Added 'c++std' defining the c++ standard to use for
compilation. Compilation commands also use -Werror
-- Frank B. Brokken Mon, 12 Sep 2022 08:36:37 +0200
natlog (3.00.00)
* With mode 'conntrack' natlog writes 1 to
/proc/sys/net/netfilter/nf_conntrack_acct unless `no-bytes' was specified.
* --verbose does not imply --stdout anymore.
* conntrack supports protocol subselections (e.g., tcp:udp).
* added option --no-dst suppressing destination entries in the log-files.
* added option --rotate to force log file rotation.
* added option --rotate-data to force log-data file rotation.
* added class ProducerSignals as common baseclass for ConntrackProducer and
DevicesProducer providing the Producer class and the signals required for
--terminate.
* All class-specific icmconf files are now soft-links to the base
directory's icmconf.lib file.
-- Frank B. Brokken Tue, 07 Jun 2022 12:59:20 +0200
natlog (2.04.02)
* Added missing option entries to the etc/natlog.conf file
* Included options S and terminate in the manpage's list of options that
cannot be specified in the natlog.conf file.
-- Frank B. Brokken Fri, 15 Apr 2022 21:09:32 +0200
natlog (2.04.01)
* Changed the std version c++2a to c++20.
-- Frank B. Brokken Thu, 21 Oct 2021 12:00:05 +0200
natlog (2.04.00)
* Added option --no-via to suppress 'via' entries in the log files.
* Added option --no-bytes to suppress the sent/received counts in the log
files.
* Fixed several flaws in the default configuration file
* Updated the man-page; added information about how to use Natlog if
source-natting is not used.
* Repaired flaw in icmake/findall: it now checks for 'backtick' returning a
single, empty element.
-- Frank B. Brokken Mon, 06 Sep 2021 20:15:17 +0200
natlog (2.03.00)
* Fixed erroneously thrown 'bool' value in ipbase/destroy.cc when observing
a DESTROY action of an unknown record.
* Fixed missing sent/receive counts in mode conntrack
* Fixed handling stripping in 'build'
* Added main's call-tree to oxref's output
* Added cross reference listing (natlog.xref)
* Added icmconf files for internal use to natlog's directories
-- Frank B. Brokken Tue, 07 Jan 2020 20:50:34 +0100
natlog (2.02.00)
* Requires bobcat >= 5.00.00
-- Frank B. Brokken Wed, 24 Apr 2019 12:15:01 +0200
natlog (2.01.01)
* Migrated from Github to Gitlab
-- Frank B. Brokken Mon, 25 Jun 2018 11:44:12 +0200
natlog (2.01.00)
* Simplified ConnectionsConsumer, added classes IPbase, TCP, UDP, and ICMP.
* Redefined the RecordMap key handling, now using 64-bit keys. This should
solve the incorrect handling of TCP connections observed with version
2.00.00.
* Commas instead of colons are used to separate IP-addresses from port
numbers with TCP and UDP connections.
* Using detached Pcap threads, to avoid long waiting times caused by
pcap_loop's waiting for one additional packet after calling
pcap_breakloop.
* Repaired flaws in the byte-counting procedures
* The Storage now contains pointers to Records. Once retrieved they are
handled by unique_ptrs, guaranteeing their eventual destructions.
* Using C++-17 attributes ([[maybe_unused]]) where applicable.
* The file documentation/simplified.def relates types used by objdump(1) to
types used in natlog's source files. E.g., objdump reports
std::__cxx11::basic_string,
std::allocator > while std::string is used in natlog's source
files. This information can be used by other programs, like oxref(1) to
improve the readability of their output.
* Added option -S to be used as natlog's first argument in systemd's
natlog.service file's ExecStart= specifications.
* Added option --debug writing information about memory consumption to the
log file
-- Frank B. Brokken Thu, 22 Mar 2018 16:38:24 +0100
natlog (2.00.00)
* Added mode tcpdump processing captured tcpdump files
* Modes tcpdump, conntrack and device (formerly known as mode pcap) log
files show numbers of bytes that were sent and received.
* To use byte-accounting in mode conntrack the following command must have
been issued (after starting iptables):
/bin/echo "1" > /proc/sys/net/netfilter/nf_conntrack_acct
* Added option --contrack-device, by default set to /proc/net/nf_conntrack.
Older systems may still use /proc/net/ip_conntrack, which may be selected
using this option.
* Added option --ip-header-size, correcting for the IP header sizes which
are added by conntrack to its logs.
* Added option --log, replacing the former --no-syslog option. --log can be
used to specify a log-file instead of using syslog facilities.
* Added option --log-data, specifying a path to a log file to contain a
table that can be used by statistical software.
* Added option --log-rotate, specifying time-interval between log-file
rotations and number of log-files to rotate.
* Option --protocol can be used to process tcp, udp, and/or icmp protocols
for all three modes. To process all three protocols '--protocol all' can
be specified. With mode conntrack only a single protocol or 'all' can be
used.
* Added option --terminate terminating a running natlog daemon process.
* Added option --ttl for udp/icmp and/or tcp connections
-- Frank B. Brokken Thu, 08 Feb 2018 19:36:39 +0100
natlog (1.03.00)
* Fixed bug when setting syslog-facility in options/setSyslogFacility:
instead of using the assignment operator (=) to set the facility
the comparison operator (==) was written... :-(
* The --verbose option can be abbreviated to -V. When specified twice, the
actual configuration parameters are shown. When specified more often,
natlog ends after showing the configuration parameters.
-- Frank B. Brokken Thu, 26 Jan 2017 12:27:40 +0100
natlog (1.02.03)
* Adapted natlog's build scripts to icmake >= 8.00.03
-- Frank B. Brokken Fri, 11 Dec 2015 17:17:43 +0100
natlog (1.02.02)
* Kevin Brodsky observed that the installation scripts used 'chdir' rather
than 'cd'. Fixed in this release.
* Kevin Brodsky also observed that the combined size of all precompiled
headers might exceed some disks capacities. The option -P was added to the
./build script to prevent the use of precompiled headers.
-- Frank B. Brokken Mon, 05 Oct 2015 21:06:54 +0200
natlog (1.02.01)
* Standardized the (de)installation procedures. See INSTALL for details.
-- Frank B. Brokken Sun, 04 Oct 2015 16:09:21 +0200
natlog (1.02.00)
* Conntrack(8) has two modes: when -p is specified conntrack shows
connections of protocol . When -p is not specified connections of
all protocols are shown. When multiple -p options are specified only the
last specified protocol is selected. Conntrack commands generated by
natlog before 1.02.00 erroneously specified multiple -p options. This was
fixed in version 1.02.00.
* The man-page shows `:syslogtag, isequal, "NATLOG:" stop' rather than
(the now deprecated) `:syslogtag, isequal, "NATLOG:" ~'.
* The previously discontinued option conntrack-path is no longer recognized.
* The --protocol option can also be specified as -P.
* Added the file 'required' to the source distribution summarizing the
required software for building natlog.
-- Frank B. Brokken Mon, 23 Feb 2015 11:05:53 +0100
natlog (1.01.0)
* Added configuration option `conntrack-command'. With the `conntrack'
command the icmp, udp and tcp layer four protocols are monitored. By
default natlog's `conntrack' command monitors the tcp protocol.
* Added configuration option `conntrack-restart, to specify how often
conntrack may be restarted if its process prematurely ends.
* The configuration option `conntrack-path' is discontinued, and
`conntrack-command' should be used instead. See the man-page for details.
* Added configuration option `protocol', to specify which layer four
protocols to monitor with the `conntrack' command.
* The default pid file path is set to `/run/natlog.pid'.
* Replaced FBB::Errno calls by FBB::Exception
-- Frank B. Brokken Mon, 10 Feb 2014 20:21:27 +0100
natlog (1.00.2)
* Added a missing #include to the showseconds.ih header, required
by g++ 8.4.2.
-- Frank B. Brokken Sun, 01 Dec 2013 18:15:46 +0100
natlog (1.00.1)
* Natlog's version bumped to 1.00.1, after 1 year of active use.
* Removed the class Signal from natlog's classes as it's available in
Bobcat.
* Explicitly including previously implicitly included bobcat/errno
* Cleanup of icmconf file
-- Frank B. Brokken Sat, 08 Jun 2013 10:57:34 +0200
natlog (0.91.3)
* Natlog returns 0 for options --help and --version
* Catching Errno exceptions is replaced by catching std::exception
exceptions
-- Frank B. Brokken Fri, 25 Jan 2013 08:58:07 +0100
natlog (0.91.2)
* Added build-depends file and INSTALL files.
-- Frank B. Brokken Wed, 07 Nov 2012 12:03:53 +0100
natlog (0.91.1)
* build script recognizes CXX, CXXFLAGS, LDFLAGS environment variables
-- Frank B. Brokken Sun, 15 Jul 2012 14:40:11 +0200
natlog (0.91.0)
* Normal end of program (e.g., the starting daemon or ending
natfork/childprocess) now returns 0, otherwise 1
* Checking whether conntrack runs is implemented by inspecting the access
rights for /proc/net/ip_conntrack
* Reorganized message handling: all messages generated by the daemon are
sent to the syslog daemon, unless --no-syslog was specified
* General code cleanup
-- Frank B. Brokken Thu, 21 Jun 2012 13:45:11 +0200
natlog (0.90.0)
* Updated sourceforge's `excluded' file.
* Added the --pid-file option defining the location of a file holding
the daemon's PID. By default the pid-file is /var/run/natlog.pid.
-- Frank B. Brokken Sat, 16 Jun 2012 12:03:01 +0200
natlog (0.80.0)
* Added auto-detection of devices without Ethernet packet headers
* Natlog's pcap mode now writes syslog messages
* Added option --stdout (-s) writing syslog-equivalent messages to the
standard ouput
* General code cleanup and reorganization
-- Frank B. Brokken Fri, 15 Jun 2012 17:01:08 +0200
natlog (0.30.0)
* Initial implementation of 'natlog in out', performing direct packet
capturing on the `in' and `out' devices.
-- Frank B. Brokken Thu, 14 Jun 2012 14:37:42 +0200
natlog (0.20.0)
* NATLOG writes incomplete connections to syslog when terminated by a
SIGTERM signal.
-- Frank B. Brokken Mon, 11 Jun 2012 16:42:40 +0200
natlog (0.10.0)
* NATLOG now hosted at sourceforge (http://natlog.sourceforge.net/).
* Added maintenance files to handle uploads to sourceforge
-- Frank B. Brokken Sat, 09 Jun 2012 16:39:34 +0200
natlog (0.03.0)
* Syslog message and man-page cleanup
-- Frank B. Brokken Thu, 07 Jun 2012 17:20:04 +0200
natlog (0.02.0)
* Processed elements are now removed from `record' in conntrack/run.cc
-- Frank B. Brokken Thu, 07 Jun 2012 14:10:19 +0200
natlog (0.01.0)
* Project Start.
-- Frank B. Brokken Tue, 05 Jun 2012 22:17:08 +0200
natlog-3.01.00/connectionsconsumer/ 0000775 0000000 0000000 00000000000 14743162762 0017251 5 ustar 00root root 0000000 0000000 natlog-3.01.00/connectionsconsumer/cleanupicmpudp.cc 0000664 0000000 0000000 00000000232 14743162762 0022566 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
void ConnectionsConsumer::cleanupICMP_UDP(time_t now_ttl)
{
d_icmp.cleanup(now_ttl);
d_udp.cleanup(now_ttl);
}
natlog-3.01.00/connectionsconsumer/cleanupwrap.cc 0000664 0000000 0000000 00000001207 14743162762 0022101 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
// static
void ConnectionsConsumer::cleanupWrap(ConnectionsConsumer *consumer)
{
// if lastUsed + ttl < now then log and remove the record
// so: if lastUsed < now - ttl log and remove the record
while (not consumer->d_storage.empty())
{
this_thread::sleep_for(chrono::seconds(3));
consumer->cleanupICMP_UDP(time(0) - consumer->d_ttl);
IPbase::setLogType(IPbase::EXPIRED);
consumer->d_tcp.cleanup(time(0) - Options::instance().ttlTCP());
IPbase::setLogType(IPbase::COMPLETE);
}
consumer->d_stdMsg << "cleanupWrap thread ends" << endl;
}
natlog-3.01.00/connectionsconsumer/connectionsconsumer.h 0000664 0000000 0000000 00000002466 14743162762 0023530 0 ustar 00root root 0000000 0000000 #ifndef INCLUDED_CONNECTIONSCONSUMER_
#define INCLUDED_CONNECTIONSCONSUMER_
#include
#include
#include
#include "../rotatingstream/rotatingstream.h"
#include "../icmp/icmp.h"
#include "../udp/udp.h"
#include "../tcp/tcp.h"
#include "../record/record.h"
class Storage;
// ConnectionsConsumer object constructed in natfork/childprocess
class ConnectionsConsumer: public FBB::SignalHandler
{
RotatingStream d_logDataStream;
std::ostream &d_stdMsg;
Storage &d_storage;
ICMP d_icmp;
UDP d_udp;
TCP d_tcp;
std::unordered_map< Record::Protocol, IPbase * > d_handler;
time_t d_ttl;
public:
ConnectionsConsumer(std::ostream &stdMsg, Storage &storage);
~ConnectionsConsumer() override;
void run(); // process all connections:
// start the producer thread
// and consume the produced data
private:
void signalHandler(size_t signum) override;
static void cleanupWrap(ConnectionsConsumer *consumer);
void cleanupICMP_UDP(time_t now_ttl); // clean up completed
// connections.
static void header(std::ostream &log);
};
#endif
natlog-3.01.00/connectionsconsumer/connectionsconsumer.ih 0000664 0000000 0000000 00000000473 14743162762 0023675 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.h"
#include
#include
#include
#include
#include
#include
#include "../showseconds/showseconds.h"
#include "../storage/storage.h"
#include "../options/options.h"
using namespace std;
using namespace FBB;
natlog-3.01.00/connectionsconsumer/connectionsconsumer1.cc 0000664 0000000 0000000 00000001356 14743162762 0023744 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
ConnectionsConsumer::ConnectionsConsumer(ostream &stdMsg, Storage &storage)
:
d_logDataStream(header),
d_stdMsg(stdMsg),
d_storage(storage),
d_icmp(stdMsg, d_logDataStream),
d_udp(stdMsg, d_logDataStream),
d_tcp(stdMsg, d_logDataStream),
d_handler
{
{ Record::ICMP, &d_icmp },
{ Record::TCP, &d_tcp },
{ Record::UDP, &d_udp },
},
d_ttl(Options::instance().ttl())
{
if (
string logData = Options::instance().logData();
not logData.empty()
)
d_logDataStream.open(logData, false); // prepare for data log
Signal::instance().add(SIGINT, *this);
Signal::instance().add(SIGTERM, *this);
}
natlog-3.01.00/connectionsconsumer/destructor.cc 0000664 0000000 0000000 00000000277 14743162762 0021764 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
//f: ConnectionsConsumer::~ConnectionsConsumer()
//c: ConnectionsConsumer::signalHandler(unsigned long)
ConnectionsConsumer::~ConnectionsConsumer()
{}
natlog-3.01.00/connectionsconsumer/frame 0000664 0000000 0000000 00000000075 14743162762 0020270 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
ConnectionsConsumer::
{
}
natlog-3.01.00/connectionsconsumer/header.cc 0000664 0000000 0000000 00000001777 14743162762 0021024 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
void ConnectionsConsumer::header(ostream &log)
{
log << "type," <<
setw(11) << "srcNr" << ',' <<
setw(16) << "srcIP" << ',' <<
setw(8) << "srcPort" << ',';
if (Options::instance().showDst())
log <<
setw(11) << "dstNr" << ',' <<
setw(16) << "dstIP" << ',' <<
setw(8) << "dstPort" << ',';
if (Options::instance().showVia())
log <<
setw(11) << "viaNr" << ',' <<
setw(16) << "viaIP" << ',' <<
setw(8) << "viaPort" << ',';
if (Options::instance().byteCounts())
log <<
setw(11) << "sent" << ',' <<
setw(11) << "recvd" << ',';
log <<
setw(11) << "begin" << ',' <<
setw(11) << "end" << ", " <<
setw(22) << "beginTime" << ", " <<
setw(22) << "endTime" << ", status" << endl;
// 1234567890
}
natlog-3.01.00/connectionsconsumer/icmconf 0000777 0000000 0000000 00000000000 14743162762 0023126 2../icmconf.lib ustar 00root root 0000000 0000000 natlog-3.01.00/connectionsconsumer/run.cc 0000664 0000000 0000000 00000003053 14743162762 0020365 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
void ConnectionsConsumer::run()
{
thread cleanupThread;
// when logging in Conntrack-mode or Device-mode (realTime)
// inspect the TTL of the incoming packages in the background.
bool realTime = Options::instance().realTime();
if (realTime)
cleanupThread = thread{ &ConnectionsConsumer::cleanupWrap, this };
while (true)
{
d_storage.consumeWait();
if (d_storage.empty())
break;
Record *record = d_storage.fetch(); // makes available the next
// record-> Since this is the
// only thread fetching records
// there's no need to copy the
// record at this point
d_storage.produceNotify();
// process incoming protocol data, calls ipbase::process()
// which calls inDev, outDev, insert, or destroy.
// inDev, outDev are overridden by the classes TCP, UDP and ICMP
// (cf, directories tcp/, udp/, icmp/)
// tcp::process(), udp::process() or icmp::process() through
//
d_handler[record->protocol()]->process( RecordPtr{ record } );
}
if (realTime)
cleanupThread.join();
time_t eop = time(0) + 1;
cleanupICMP_UDP(eop); // what's still in the maps is
// there at EOP
d_tcp.cleanup(eop);
}
natlog-3.01.00/connectionsconsumer/signalhandler.cc 0000664 0000000 0000000 00000000225 14743162762 0022372 0 ustar 00root root 0000000 0000000 #include "connectionsconsumer.ih"
void ConnectionsConsumer::signalHandler([[maybe_unused]] size_t signum)
{
IPbase::setLogType(IPbase::EOP);
}
natlog-3.01.00/conntrackproducer/ 0000775 0000000 0000000 00000000000 14743162762 0016701 5 ustar 00root root 0000000 0000000 natlog-3.01.00/conntrackproducer/activatebytecounts.cc 0000664 0000000 0000000 00000000362 14743162762 0023131 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
void ConntrackProducer::activateByteCounts() const
{
ofstream out = Exception::factory(s_nfConntrackAcct,
ios::in | ios::out);
out.put('1');
}
natlog-3.01.00/conntrackproducer/childprocess.cc 0000664 0000000 0000000 00000000612 14743162762 0021671 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
void ConntrackProducer::childProcess()
{
vector cmd(String::split(static_cast(0),
d_options.conntrackCommand()));
char const **args = String::argv(cmd);
execv(args[0], const_cast(args));
throw 0; // this should not be reached, but if so main properly ends.
}
natlog-3.01.00/conntrackproducer/childredirections.cc 0000664 0000000 0000000 00000000236 14743162762 0022707 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
void ConntrackProducer::childRedirections()
{
int fd[] = {STDOUT_FILENO, STDERR_FILENO};
d_pipe.writtenBy(fd, 2);
}
natlog-3.01.00/conntrackproducer/conntrackproducer.h 0000664 0000000 0000000 00000003314 14743162762 0022601 0 ustar 00root root 0000000 0000000 #ifndef INCLUDED_CONNTRACKPRODUCER_
#define INCLUDED_CONNTRACKPRODUCER_
#include
#include
#include
#include
#include "../producersignals/producersignals.h"
class Options;
class Storage;
namespace FBB
{
class Pattern;
}
class ConntrackProducer: public ProducerSignals, public FBB::Fork
{
FBB::Pipe d_pipe;
Options &d_options;
std::ostream &d_stdMsg;
Storage &d_storage;
bool d_signaled = false;
bool (ConntrackProducer::*d_tcpUdp)(std::string const &line);
bool (ConntrackProducer::*d_icmp)(std::string const &line);
static FBB::Pattern s_tcpudp;
static FBB::Pattern s_icmp;
static char const s_nfConntrackAcct[];
public:
ConntrackProducer(std::ostream &stdMsg, Storage &storage);
~ConntrackProducer();
private:
void activateByteCounts() const;
bool icmp(std::string const &line); // process ICMP connections
bool notUsed(std::string const &line); // false: used for unused
// connection types
void process(std::string const &line); // process the conntrack info
void setTcpUdp(size_t protocolType, // set d_tcpUdp for TCP/UDP
char const *label);
bool tcpUdp(std::string const &line); // process TCP/UDP connections
void childProcess() override;
void childRedirections() override;
void parentProcess() override;
void parentRedirections() override;
void run() override;
void signalHandler(size_t signum) override;
};
#endif
natlog-3.01.00/conntrackproducer/conntrackproducer.ih 0000664 0000000 0000000 00000000565 14743162762 0022757 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "../options/options.h"
#include "../storage/storage.h"
#include "../conntrackrecord/conntrackrecord.h"
using namespace std;
using namespace FBB;
natlog-3.01.00/conntrackproducer/conntrackproducer1.cc 0000664 0000000 0000000 00000001340 14743162762 0023015 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
ConntrackProducer::ConntrackProducer(ostream &stdMsg, Storage &storage)
:
d_options(Options::instance()),
d_stdMsg(stdMsg),
d_storage(storage),
d_tcpUdp(&ConntrackProducer::notUsed)
{
if (access(d_options.conntrackDevice(), R_OK) != 0)
throw Exception{} << "Cannot read " << d_options.conntrackDevice();
if (d_options.byteCounts())
activateByteCounts();
setTcpUdp(IP_Types::TCP, "TCP");
setTcpUdp(IP_Types::UDP, "UDP");
if (not d_options.hasProtocol(IP_Types::ICMP))
d_icmp = &ConntrackProducer::notUsed;
else
{
imsg << "conntrack reports ICMP connections" << endl;
d_icmp = &ConntrackProducer::icmp;
}
}
natlog-3.01.00/conntrackproducer/data.cc 0000664 0000000 0000000 00000005756 14743162762 0020136 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
char const ConntrackProducer::s_nfConntrackAcct[] =
"/proc/sys/net/netfilter/nf_conntrack_acct";
// [1338987414.52626 ] [NEW] tcp 6 120 SYN_SENT
// src=192.168.1.4 dst=129.125.14.80 sport=59783 dport=22
// [UNREPLIED]
// packets=7 bytes=450
// src=129.125.14.80 dst=129.125.100.246 sport=22 dport=59783
// packets=7 bytes=450 ....
Pattern ConntrackProducer::s_tcpudp
{
R"(\[(\d+)\.(\d+).*\[(NEW|DESTROY)\]\s+(tcp|udp).*)"
// 1 2 3 4 time: [1338899277.41469 ]
R"(src=(\S+)\s+dst=(\S+)\s+)" // source to nat, dest
// 5 6
R"(sport=(\d+)\s+dport=(\d+))" // source from, dest port
// 7 8
R"((\s+packets=(\d+)\s+bytes=(\d+))?.*)" // maybe sent packets/bytes
//9 10 11
R"(dst=(\S+).*)" // natted source (key)
// 12 (was: 9)
R"(dport=(\d+))" // natted dport (key)
// 13 (was: 10)
R"((\s+packets=(\d+)\s+bytes=(\d+))?)", // maybe recv'd packets/bytes
//14 15 16
true, static_cast(CTtcpudp::nFields)
};
// If packets/bytes are not provided then the final #14 thru #16 are not
// available, and end() returns 14, otherwise 17.
///////////////////////////////////////////////////////////////////////////
// [1387190207.153486] [NEW] icmp 1 30
// src=192.168.17.7 dst=129.125.3.162 type=8 code=0 id=7016
// [UNREPLIED]
// packets=1 bytes=84 <-- maybe
// src=129.125.3.162 dst=129.125.100.246 type=0 code=0 id=7016
// packets=1 bytes=84 <-- maybe
Pattern ConntrackProducer::s_icmp
{
// [1514579857.235298] [DESTROY] icmp 1
R"(\[(\d+)\.(\d+).*\[(NEW|DESTROY)\]\s+icmp.*)"
// 1 2 3
//src=192.168.17.6 dst=129.125.3.162
R"(src=(\S+)\s+dst=(\S+)\s+)" // source to nat, dest
// 4 5
// type=8 code=0 id=3269
R"(\S+\s+\S+\s+id=(\d+)\s+)" // id= (key)
// 6
// packets=4 bytes=336
R"((packets=(\d+)\s+bytes=(\d+)\s+)?)" // maybe sent packets/bytes
// 7 8 9
// src=129.125.3.162 dst=192.168.8.17 type=0 code=0 id=3269
R"(.*dst=(\S+).*id=\d+)" // natted source
// 10 (was: 7)
// packets=4 bytes=336
R"((\s+packets=(\d+)\s+bytes=(\d+))?)", // maybe rev'd packets/bytes
// 11 12 13
true, static_cast(CTicmp::nFields)
};
// If packets/bytes are not provided then the final #11 thru #13 are not
// available, and end() returns 11, otherwise 14.
natlog-3.01.00/conntrackproducer/destructor.cc 0000664 0000000 0000000 00000000351 14743162762 0021405 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
//f: ConntrackProducer::~ConntrackProducer()
//c: ConntrackProducer::signalHandler(unsigned long)
ConntrackProducer::~ConntrackProducer()
{
d_stdMsg << "monitoring conntrack ends" << endl;
}
natlog-3.01.00/conntrackproducer/frame 0000664 0000000 0000000 00000000071 14743162762 0017714 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
ConntrackProducer::
{
}
natlog-3.01.00/conntrackproducer/icmconf 0000777 0000000 0000000 00000000000 14743162762 0022556 2../icmconf.lib ustar 00root root 0000000 0000000 natlog-3.01.00/conntrackproducer/icmp.cc 0000664 0000000 0000000 00000001075 14743162762 0020143 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
bool ConntrackProducer::icmp(string const &line)
{
if (not (s_icmp << line)) // this is not an ICMP connection
return false; // (maybe there are other than icmp,
// tcp and udp connections, hence the
// check)
// if not requested then notUsed() instead of icmp() is called
d_storage.push( new ConntrackRecord{ Record::ICMP, s_icmp } );
return true; // not used (see process())
}
natlog-3.01.00/conntrackproducer/notused.cc 0000664 0000000 0000000 00000000275 14743162762 0020675 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
// see conntrackproducer1.cc
bool ConntrackProducer::notUsed([[maybe_unused]] string const &line)
{
return false;
}
natlog-3.01.00/conntrackproducer/parentprocess.cc 0000664 0000000 0000000 00000000537 14743162762 0022105 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
// See also README.conntrack
void ConntrackProducer::parentProcess()
{
string line; // co-used for retrieving the IP Header size
while (getline(cin, line))
process(line);
waitForChild();
if (not d_signaled)
d_stdMsg << "conntrack terminated" << endl;
}
natlog-3.01.00/conntrackproducer/parentredirections.cc 0000664 0000000 0000000 00000000165 14743162762 0023116 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
void ConntrackProducer::parentRedirections()
{
d_pipe.readFrom(STDIN_FILENO);
}
natlog-3.01.00/conntrackproducer/process.cc 0000664 0000000 0000000 00000002532 14743162762 0020670 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
void ConntrackProducer::process(string const &line)
{
imsg << "LINE: " << line << endl;
if ((this->*d_tcpUdp)(line) or (this->*d_icmp)(line))
return;
imsg << " (not matched)" << endl;
// if (s_tcpudp << line) // if this is a UDP or TCP conn.
// { // process them.
// if (not (this->*d_tcp)()) // At TCP and unhandled tcp:
// (this->*d_udp)(); // true is returned
// return;
// }
//
// if ((this->*d_icmp)(line))
// return;
//
// if (s_icmp << line) // or try an ICMP connection
// {
// (this->*d_icmp)();
// return;
// }
}
// if (s_tcpudp << line) // try to match UDP or TCP
// {
// if ( d_options.hasProtocol(
// s_tcpudp[ static_cast(CTtcpudp::PROTOCOL) ] )
// )
// d_storage.push( new ConntrackRecord{ // (also for UDP)
// Record::TCP, s_tcpudp } );
// return;
// }
//
// // or try to match ICMP
// if (s_icmp << line and d_options.hasProtocol(Record::ICMP))
// {
// d_storage.push( new ConntrackRecord{ Record::ICMP, s_icmp } );
// return;
// }
natlog-3.01.00/conntrackproducer/run.cc 0000664 0000000 0000000 00000001601 14743162762 0020012 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
//f: ConntrackProducer::run()
//c: ConntrackProducer::childProcess()
//c: ConntrackProducer::parentProcess()
//c: ConntrackProducer::childRedirections()
//c: ConntrackProducer::parentRedirections()
void ConntrackProducer::run()
{
size_t max = d_options.conntrackRestart();
d_stdMsg << "Starting `" << d_options.conntrackCommand() <<
"' (max " << max << " restarts)" << endl;
++max; // restarts, so add 1 for initial startup.
for (size_t idx = 0; idx != max; )
{
++idx;
try
{
d_pipe = Pipe();
fork();
return;
}
catch (Options::ExitStatus status)
{
d_stdMsg << "conntrack run " << idx << " ended" << endl;
}
}
d_stdMsg << "conntrack started " << max << " times, giving up" << endl;
}
natlog-3.01.00/conntrackproducer/settcpudp.cc 0000664 0000000 0000000 00000000442 14743162762 0021223 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
void ConntrackProducer::setTcpUdp(size_t protocolType , char const *label)
{
if (not d_options.hasProtocol(protocolType))
return;
imsg << "conntrack reports " << label << " connections" << endl;
d_tcpUdp = &ConntrackProducer::tcpUdp;
}
natlog-3.01.00/conntrackproducer/signalhandler.cc 0000664 0000000 0000000 00000000474 14743162762 0022030 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
void ConntrackProducer::signalHandler(size_t signum)
{
d_stdMsg << "received signal " << signum << " (" <<
(signum == SIGINT ? "SIGINT" : "SIGTERM") << ')' << endl;
d_signaled = true;
kill(pid(), SIGTERM);
kill(pid(), SIGTERM);
kill(pid(), SIGKILL);
}
natlog-3.01.00/conntrackproducer/tcpudp.cc 0000664 0000000 0000000 00000001455 14743162762 0020514 0 ustar 00root root 0000000 0000000 #include "conntrackproducer.ih"
// false is returned when line does not contain TCP or UDP info
// (or, via notUsed, if neither TCP or UDP should be logged)
// true is otherwise returned. If the udp or tcp protocol is handled
// then handled protocol records are pushed into the storage
bool ConntrackProducer::tcpUdp(string const &line)
{
if (not (s_tcpudp << line)) // if this is not an UDP or TCP connection
return false;
if ( // if UDP/TCP is requested: push it
d_options.hasProtocol(
s_tcpudp[ static_cast(CTtcpudp::PROTOCOL) ]
)
)
d_storage.push( new ConntrackRecord{ Record::TCP, s_tcpudp } );
return true; // see process()
}
natlog-3.01.00/conntrackrecord/ 0000775 0000000 0000000 00000000000 14743162762 0016334 5 ustar 00root root 0000000 0000000 natlog-3.01.00/conntrackrecord/conntrackrecord.h 0000664 0000000 0000000 00000002614 14743162762 0021671 0 ustar 00root root 0000000 0000000 #ifndef INCLUDED_CONNTRACKRECORD_
#define INCLUDED_CONNTRACKRECORD_
// CTtcpudp and CTicmp: see below
#include
#include "../record/record.h"
namespace FBB
{
class Pattern;
}
class ConntrackRecord: public Record
{
FBB::Pattern const &d_pattern;
public:
ConntrackRecord(Protocol protocol, FBB::Pattern const &pattern);
// ~ConntrackRecord() override;
private:
void initTCP_UDP(FBB::Pattern const &pattern);
void initICMP(FBB::Pattern const &pattern);
template
std::string pat(Enum value) const;
};
// Indices when matching conntrackproducer entries with Pattern for tcp/udp
enum class CTtcpudp
{
SECONDS = 1, // 1st three entries are common with CTicmp
MU_SECONDS,
TYPE, // NEW, DESTROY
PROTOCOL, // tcp/udp
SRC,
DST,
SPORT,
DPORT,
SENTPACKETTEXT,
SENTPACKETS,
SENTBYTES,
NATSRC,
NATPORT,
RECVDPACKETTEXT,
RECVDPACKETS,
RECVDBYTES,
nFields,
};
// Indices when matching conntrackproducer entries with Pattern for tcp/udp
enum class CTicmp
{
SECONDS = 1,
MU_SECONDS,
TYPE, // NEW, DESTROY
SRC,
DST,
ID,
SENTPACKETTEXT,
SENTPACKETS,
SENTBYTES,
NATSRC,
RECVDPACKETTEXT,
RECVDPACKETS,
RECVDBYTES,
nFields,
};
#endif
natlog-3.01.00/conntrackrecord/conntrackrecord.ih 0000664 0000000 0000000 00000000475 14743162762 0022045 0 ustar 00root root 0000000 0000000 #include "conntrackrecord.h"
#include
#include
#include
#include "../options/options.h"
using namespace std;
using namespace FBB;
template
inline std::string ConntrackRecord::pat(Enum value) const
{
return d_pattern[ static_cast(value) ];
}
natlog-3.01.00/conntrackrecord/conntrackrecord1.cc 0000664 0000000 0000000 00000000630 14743162762 0022104 0 ustar 00root root 0000000 0000000 #include "conntrackrecord.ih"
ConntrackRecord::ConntrackRecord(Protocol type, Pattern const &pattern)
:
d_pattern(pattern)
{
setLastUsed(::time(0));
setType(pat(CTicmp::TYPE) == "NEW" ? NEW : DESTROY);
setAllTimes(stoul(pat(CTicmp::SECONDS)),
stoul(pat(CTicmp::MU_SECONDS)));
if (type == ICMP)
initICMP(pattern);
else
initTCP_UDP(pattern);
}
natlog-3.01.00/conntrackrecord/frame 0000664 0000000 0000000 00000000065 14743162762 0017352 0 ustar 00root root 0000000 0000000 #include "conntrackrecord.ih"
ConntrackRecord::
{
}
natlog-3.01.00/conntrackrecord/icmconf 0000777 0000000 0000000 00000000000 14743162762 0022211 2../icmconf.lib ustar 00root root 0000000 0000000 natlog-3.01.00/conntrackrecord/initicmp.cc 0000664 0000000 0000000 00000001547 14743162762 0020466 0 ustar 00root root 0000000 0000000 #include "conntrackrecord.ih"
void ConntrackRecord::initICMP(Pattern const &pattern)
{
setSourceIP( aton(pat(CTicmp::SRC)) );
setDestIP( aton(pat(CTicmp::DST)) );
setViaIP( aton(pat(CTicmp::NATSRC)) );
setProtocol(ICMP);
setIDKey( stoul(pat(CTicmp::ID)), 0 ); // no sequence nr available
if (type() == DESTROY)
{
if (pattern.end() == static_cast(CTicmp::nFields))
{
size_t ipHeaderSize = Options::instance().IPheaderSize();
if (ipHeaderSize != 0)
ipHeaderSize *= stoul(pat(CTicmp::RECVDPACKETS));
size_t nBytes = stoul(pat(CTicmp::SENTBYTES));
setSentBytes( nBytes ? nBytes - ipHeaderSize : 0 );
nBytes = stoul(pat(CTicmp::RECVDBYTES));
setReceivedBytes( nBytes ? nBytes - ipHeaderSize : 0 );
}
};
}
natlog-3.01.00/conntrackrecord/inittcpudp.cc 0000664 0000000 0000000 00000002132 14743162762 0021024 0 ustar 00root root 0000000 0000000 #include "conntrackrecord.ih"
void ConntrackRecord::initTCP_UDP(Pattern const &pattern)
{
setSourceIP( aton(pat(CTtcpudp::SRC)) );
setDestIP( aton(pat(CTtcpudp::DST)) );
setViaIP( aton(pat(CTtcpudp::NATSRC)) );
setPorts( stoul(pat(CTtcpudp::SPORT)), stoul(pat(CTtcpudp::DPORT)) );
setViaPort( stoul(pat(CTtcpudp::NATPORT)) );
setProtocol( pat(CTtcpudp::PROTOCOL) == "tcp" ? TCP : UDP );
setSrcKey();
if (type() == DESTROY) // DESTROY records may have sent/received
{ // byte counts
if (pattern.end() == static_cast(CTtcpudp::nFields))
{
size_t ipHeaderSize = Options::instance().IPheaderSize();
if (ipHeaderSize != 0)
ipHeaderSize *= stoul(pat(CTtcpudp::RECVDPACKETS));
size_t nBytes = stoul(pat(CTtcpudp::SENTBYTES));
setSentBytes( nBytes ? nBytes - ipHeaderSize : 0 );
nBytes = stoul(pat(CTtcpudp::RECVDBYTES));
setReceivedBytes( nBytes ? nBytes - ipHeaderSize : 0 );
}
};
}
natlog-3.01.00/devicesproducer/ 0000775 0000000 0000000 00000000000 14743162762 0016341 5 ustar 00root root 0000000 0000000 natlog-3.01.00/devicesproducer/destructor.cc 0000664 0000000 0000000 00000000464 14743162762 0021052 0 ustar 00root root 0000000 0000000 #include "devicesproducer.ih"
//f: DevicesProducer::~DevicesProducer()
//c: DevicesProducer::signalHandler(unsigned long)
DevicesProducer::~DevicesProducer()
{
if (not d_endSignal)
d_stdMsg << "monitoring " << d_inName <<
" and " << d_outName << " ends" << endl;
}
natlog-3.01.00/devicesproducer/devicesproducer.h 0000664 0000000 0000000 00000001251 14743162762 0021677 0 ustar 00root root 0000000 0000000 #ifndef INCLUDED_DEVICESPRODUCER_
#define INCLUDED_DEVICESPRODUCER_
#include
#include
#include "../producersignals/producersignals.h"
class Storage;
class DevicesProducer: public ProducerSignals//, public FBB::SignalHandler
{
std::ostream &d_stdMsg;
Storage &d_storage;
FBB::Semaphore d_signaled;
bool d_endSignal = false;
char const *d_inName;
char const *d_outName;
public:
DevicesProducer(std::ostream &stdMsg, Storage &storage);
~DevicesProducer() override;
private:
void run() override;
void signalHandler(size_t signum) override;
};
#endif
natlog-3.01.00/devicesproducer/devicesproducer.ih 0000664 0000000 0000000 00000000357 14743162762 0022056 0 ustar 00root root 0000000 0000000 #include "devicesproducer.h"
#include
#include
#include "../options/options.h"
#include "../storage/storage.h"
#include "../pcapfilter/pcapfilter.h"
#include "../nic/nic.h"
using namespace std;
using namespace FBB;
natlog-3.01.00/devicesproducer/devicesproducer1.cc 0000664 0000000 0000000 00000000540 14743162762 0022116 0 ustar 00root root 0000000 0000000 #include "devicesproducer.ih"
DevicesProducer::DevicesProducer(ostream &stdMsg, Storage &storage)
:
d_stdMsg(stdMsg),
d_storage(storage),
d_signaled(0)
{
Options const &options = Options::instance();
d_inName = options[0];
d_outName = options[1];
g_nic.set(Record::IN, d_inName);
g_nic.set(Record::OUT, d_outName);
}
natlog-3.01.00/devicesproducer/frame 0000664 0000000 0000000 00000000065 14743162762 0017357 0 ustar 00root root 0000000 0000000 #include "devicesproducer.ih"
DevicesProducer::
{
}
natlog-3.01.00/devicesproducer/icmconf 0000777 0000000 0000000 00000000000 14743162762 0022216 2../icmconf.lib ustar 00root root 0000000 0000000 natlog-3.01.00/devicesproducer/run.cc 0000664 0000000 0000000 00000000756 14743162762 0017464 0 ustar 00root root 0000000 0000000 #include "devicesproducer.ih"
void DevicesProducer::run()
{
PcapFilter in{ d_inName, Record::IN, d_stdMsg, d_storage };
PcapFilter out{ d_outName, Record::OUT, d_stdMsg, d_storage };
thread { in }.detach();
thread { out }.detach();
d_stdMsg << "starting capturing " << d_inName << " and " << d_outName <<
endl;
d_signaled.wait();
d_endSignal = true;
in.stop();
out.stop();
}
natlog-3.01.00/devicesproducer/signalhandler.cc 0000664 0000000 0000000 00000000353 14743162762 0021464 0 ustar 00root root 0000000 0000000 #include "devicesproducer.ih"
void DevicesProducer::signalHandler(size_t signum)
{
d_stdMsg << "received signal " << signum << " (" <<
(signum == SIGINT ? "SIGINT" : "SIGTERM") << ')' << endl;
d_signaled.notify();
}
natlog-3.01.00/documentation/ 0000775 0000000 0000000 00000000000 14743162762 0016024 5 ustar 00root root 0000000 0000000 natlog-3.01.00/documentation/README.conntrack 0000664 0000000 0000000 00000006450 14743162762 0020672 0 ustar 00root root 0000000 0000000 On Debian Linux systems conntrack uses the /proc/net/nf_conntrack device. This
device may not be available in other Linux variants (e.g., Ubuntu). Sebastian
Monte provided information about how conntrack can be used in those cases. See
README.no_nf_conntrack for a description of his findings.
Conntrack byte counts add the sizes of the IP headers (usually 20 bytes) to
the byte counts. So, icmp packets are usually reported as having size 84,
even though ping etc reports the payload (64 bytes). Since the actual size of
the IP headers cannot be determined from conntrack's output, the sizes
reported via natlog's conntrack mode are as reported, and are therefore not
corrected for IP header lengths.
Example conntrack lines:
The 'maybe' entries appear if the command
$ echo 1 > /proc/sys/net/netfilter/nf_conntrack_acct
has been issued before starting natlog.
[1338987414.52626 ] [NEW] tcp 6 120 SYN_SENT
src=192.168.1.4 dst=129.125.14.80 sport=59783 dport=22 [UNREPLIED]
src=129.125.14.80 dst=129.125.100.246 sport=22 dport=59783
[1387190223.487711] [DESTROY] tcp 6
src=192.168.17.21 dst=192.87.23.111 sport=50029 dport=443
packets=7 bytes=450 <-- maybe
src=192.87.23.111 dst=129.125.100.246 sport=443 dport=50029
packets=5 bytes=1679 <-- maybe
[ASSURED]
[1515751941.057688] [NEW] tcp 6 120 SYN_SENT
src=192.168.17.6 dst=129.125.3.162 sport=49590 dport=22 [UNREPLIED]
src=129.125.3.162 dst=192.168.8.17 sport=22 dport=49590
[1515752071.886964] [DESTROY] tcp 6
src=192.168.17.6 dst=129.125.3.162 sport=49590 dport=22
packets=29 bytes=4840
src=129.125.3.162 dst=192.168.8.17 sport=22 dport=49590
packets=30 bytes=5132 [ASSURED]
With conntrack records the source port and unique port combinations (1st line)
are unique and are used as the key.
-------------------------------------------------------------------------------
[1387190207.172139] [NEW] udp 17 30
src=10.4.0.6 dst=129.125.4.6 sport=42998 dport=53 [UNREPLIED]
src=129.125.4.6 dst=129.125.100.246 sport=53 dport=42998
[1387190187.423829] [DESTROY] udp 17
src=10.4.0.6 dst=216.239.34.10 sport=60840 dport=53
packets=1 bytes=138 <-- maybe
src=216.239.34.10 dst=129.125.100.246 sport=53 dport=60840
packets=1 bytes=524 <-- maybe
Note that the tcp and udp lines are identically organized
With conntrack records the source port and unique port combinations (1st line)
are unique and are used as the key.
-------------------------------------------------------------------------------
[1387190207.153486] [NEW] icmp 1 30
src=192.168.17.7 dst=129.125.3.162 type=8 code=0 id=7016 [UNREPLIED]
src=129.125.3.162 dst=129.125.100.246 type=0 code=0 id=7016
[1387190237.151720] [DESTROY] icmp 1
src=192.168.17.7 dst=129.125.3.162 type=8 code=0 id=7016
packets=1 bytes=84 <-- maybe
src=129.125.3.162 dst=129.125.100.246 type=0 code=0 id=7016
packets=1 bytes=84 <-- maybe
With conntrack records the IDs are unique and are used as the key.
-------------------------------------------------------------------------------
natlog-3.01.00/documentation/README.key 0000664 0000000 0000000 00000000151 14743162762 0017470 0 ustar 00root root 0000000 0000000 ICMP:
src -> dst id, seq id + seq is used as key
nat -> dst
dst -> nat
dst -> src
natlog-3.01.00/documentation/README.no_nf_conntrack 0000664 0000000 0000000 00000002552 14743162762 0022050 0 ustar 00root root 0000000 0000000 On Debian Linux systems conntrack uses the /proc/net/nf_conntrack device. This
device may not be available in other Linux variants (e.g., Ubuntu). Sebastian
Monte provided information about how conntrack can be used in those cases. His
findings are summarized below:
If you want to use conntrack with Ubuntu issue the following commands:
1: apt install pkg-config libfuse-dev
2: mkdir /opt/scriptfs
3: cd /opt/scriptfs
4: wget https://github.com/frodonh/scriptfs/archive/refs/heads/master.zip
5: unzip master.zip
6: cd scriptfs-master
7: make
8: ln -s /opt/scriptfs/scriptfs-master/scriptfs /usr/bin/scriptfs
9: mkdir executable
10: mkdir conntrack
11: echo 'conntrack -E' > executable/conntrack.sh
12: chmod +x executable/conntrack.sh
Now we have a directory /opt/scriptfs which looks like this:
drwxr-xr-x 2 root root 4096 Apr 16 18:34 conntrack
drwxr-xr-x 2 root root 4096 Apr 16 18:34 executable
-rw-r--r-- 1 root root 57065 Apr 16 17:53 master.zip
drwxr-xr-x 2 root root 4096 Apr 16 18:02 scriptfs-master
Finally do:
13: insert
#!/bin/bash
at the first line of /opt/scriptfs/executable/conntrack.sh
14: scriptfs /opt/scriptfs/executable /opt/scriptfs/conntrack
15: in etc/natlog.conf specify
conntrack-device: /opt/scriptfs/conntrack/conntrack.sh
natlog-3.01.00/documentation/README.packet 0000664 0000000 0000000 00000012602 14743162762 0020153 0 ustar 00root root 0000000 0000000 struct pcap_pkthdr {
struct timeval ts; /* time stamp */
bpf_u_int32 caplen; /* length of portion present */
bpf_u_int32 len; /* length this packet (off wire) */
};
These values should be fairly self explanatory. The last argument is a pointer
to a u_char, and it points to the first byte of a chunk of data containing the
entire packet, as sniffed by pcap_loop().
The following are the structure definitions that I use to describe a TCP/IP
packet over Ethernet.
/* Ethernet addresses are 6 bytes */
/* Ethernet header */
struct sniff_ethernet {
u_char ether_dhost[6]; /* Destination host address */
u_char ether_shost[6]; /* Source host address */
u_short ether_type; /* IP? ARP? RARP? etc */
};
/* IP header */
struct sniff_ip {
u_char ip_vhl; /* version << 4 | header length >> 2 */
u_char ip_tos; /* type of service */
u_short ip_len; /* total length */
u_short ip_id; /* identification */
u_short ip_off; /* fragment offset field */
#define IP_RF 0x8000 /* reserved fragment flag */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
u_char ip_ttl; /* time to live */
u_char ip_p; /* protocol */
u_short ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
};
#define IP_HL(ip) (((ip)->ip_vhl) & 0x0f)
#define IP_V(ip) (((ip)->ip_vhl) >> 4)
/* TCP header */
struct sniff_tcp {
u_short th_sport; /* source port */
u_short th_dport; /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
u_char th_offx2; /* data offset, rsvd */
#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4)
u_char th_flags;
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
#define TH_ECE 0x40
#define TH_CWR 0x80
#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)
u_short th_win; /* window */
u_short th_sum; /* checksum */
u_short th_urp; /* urgent pointer */
};
we're going to assume that we are dealing with a TCP/IP packet over
Ethernet. This same technique applies to any packet; the only difference is
the structure types that you actually use. So let's begin by defining the
variables and compile-time definitions we will need to deconstruct the packet
data.
/* ethernet headers are always exactly 14 bytes */
#define SIZE_ETHERNET 14
const struct sniff_ethernet *ethernet; /* The ethernet header */
const struct sniff_ip *ip; /* The IP header */
const struct sniff_tcp *tcp; /* The TCP header */
const char *payload; /* Packet payload */
u_int size_ip;
u_int size_tcp;
And now we do our magical typecasting:
ethernet = (struct sniff_ethernet*)(packet);
ip = (struct sniff_ip*)(packet + SIZE_ETHERNET);
size_ip = IP_HL(ip)*4;
if (size_ip < 20) {
printf(" * Invalid IP header length: %u bytes\n", size_ip);
return;
}
tcp = (struct sniff_tcp*)(packet + SIZE_ETHERNET + size_ip);
size_tcp = TH_OFF(tcp)*4;
if (size_tcp < 20) {
printf(" * Invalid TCP header length: %u bytes\n", size_tcp);
return;
}
payload = (u_char *)(packet + SIZE_ETHERNET + size_ip + size_tcp);
For the sake of simplicity, we'll say that the address this pointer is set to
is the value X. Well, if our three structures are just sitting in line, the
first of them (sniff_ethernet) being located in memory at the address X, then
we can easily find the address of the structure after it; that address is X
plus the length of the Ethernet header, which is 14, or SIZE_ETHERNET.
Similarly if we have the address of that header, the address of the structure
after it is the address of that header plus the length of that header. The IP
header, unlike the Ethernet header, does not have a fixed length; its length
is given, as a count of 4-byte words, by the header length field of the IP
header. As it's a count of 4-byte words, it must be multiplied by 4 to give
the size in bytes. The minimum length of that header is 20 bytes.
The TCP header also has a variable length; its length is given, as a number of
4-byte words, by the "data offset" field of the TCP header, and its minimum
length is also 20 bytes.
So let's make a chart:
Variable Location (in bytes)
sniff_ethernet X
sniff_ip X + SIZE_ETHERNET
sniff_tcp X + SIZE_ETHERNET + {IP header length}
payload X + SIZE_ETHERNET + {IP header length} + {TCP header length}
The sniff_ethernet structure, being the first in line, is simply at location
X.
sniff_ip, who follows directly after sniff_ethernet, is at the location X,
plus however much space the Ethernet header consumes (14 bytes, or
SIZE_ETHERNET). sniff_tcp is after both sniff_ip and sniff_ethernet, so it is
location at X plus the sizes of the Ethernet and IP headers (14 bytes, and 4
times the IP header length, respectively). Lastly, the payload (which doesn't
have a single structure corresponding to it, as its contents depends on the
protocol being used atop TCP) is located after all of them.
natlog-3.01.00/documentation/README.tcp 0000664 0000000 0000000 00000050747 14743162762 0017506 0 ustar 00root root 0000000 0000000 An example of TCP communication as processed by Pcap (DevicesProducer and
TcpdumpProducer)
Note: usually cport and nport are identical, but that's not necessarily so,
so cport and nport cannot be used to identify the nathost and nat-port (nport)
Here is an example of the TCP communication:
SYN:
====
start connection at the client computer:
09:42:20.615902 br0 (IN) client.cport > remote.22: Flags [S], seq 442193845,
win 29200, options [mss 1460,sackOK,TS
val 918415591 ecr 0,nop,wscale 7], length 0
NAT: nathost is the natting host on the outbound interface
09:42:20.616029 eth1 (OUT) nathost.nport > remote.22: Flags [S], seq 442193845,
win 29200, options [mss 1460,sackOK,TS
val 918415591 ecr 0,nop,wscale 7], length 0
Initially, on the IN and OUT devices the seq. nrs are identical,
and are used to match the two SYN records. This is only required once:
to determine the nathost's address and port.
SYN connections start the connection, so when a SYN is received on the IN
device, then the src and sport values as well as the dst and dport values are
known. The NAT host receives the same sequence number and thus obtains the
nathost and nport values.
Thereafter, the key is computed from the IN packets:
SYN: then a new connections -> key from src and sport
if existing: old connection is ended (logged as expired)
FIN: existing: connections ends and is logged
otherwise: ignore
otherwise:
existing: bytes are sent
key(dst, dport) exists: recvd
otherwise: uknown, ignore
not existing: key must be dst, dport: recvd
-----------------------------------------------------------
SYN ACK:
========
reply from remote -> nathost
09:42:20.665832 eth1 (OUT) remote.22 > nathost.nport: Flags [S.],
seq 3499515712
ack 442193846 win 65535,
options [mss 1409,nop,wscale 7,sackOK,TS
val 1600635341
ecr 918415591 = previous val length 0
remote reply forwarded by nathost to client
09:42:20.665882 br0 (IN) remote.22 > client.cport: Flags [S.],
seq 3499515712,
ack 442193846, win 65535,
options [mss 1409,nop,wscale 7,sackOK,TS
val 1600635341
ecr 918415591 = previous val length 0
These SYN ACK records do not contain useful information (for us). E.g., no length
-----------------------------------------------------------
ACK:
====
client sends ACK to remote
09:42:20.666158 br0 (IN) client.cport > remote.22: Flags [.], ack 1, win 229, options [nop,nop,TS val 918415641 ecr 1600635341], length 0
nathost forwards ACK to remote:
09:42:20.666202 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 1, win 229, options [nop,nop,TS val 918415641 ecr 1600635341], length 0
Same
-----------------------------------------------------------
Data:
=====
client sends data packet:
09:42:20.666543 br0 (IN) client.cport > remote.22: Flags [P.], seq 1:33, ack 1, win 229,
options [nop,nop,TS
val 918415642
ecr 1600635341 = previous val
length 32
Using cport|22 as key, the #sent bytes is updated
if the record's source port is equal to the record[key]'s source port
-----------------------------------------------------------
nathost forwards data to remote:
09:42:20.666583 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 1:33, ack 1, win 229,
options [nop,nop,TS val 918415642 ecr 1600635341],
length 32
Since this is mere forwarding, no administration is required.
-----------------------------------------------------------
remote: data to nathost
09:42:20.695657 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 1:33, ack 33, win 1023,
options [nop,nop,TS val 1600635344 ecr 918415642],
length 32
Incoming data, which can also be ignored, since it'll arrive at the client
-----------------------------------------------------------
nathost forwards to client:
09:42:20.695704 br0 (IN) remote.22 > client.cport: Flags [P.], seq 1:33, ack 33, win 1023,
options [nop,nop,TS
val 1600635344 ecr 918415642],
length 32
Data arriving at the client: using cport|22 as key, the #received bytes is updated
if the record's dest port is equal to the record[key]'s source port
-----------------------------------------------------------
client sends ACK to remote
09:42:20.695976 br0 (IN) client.cport > remote.22: Flags [.], ack 33, win 229, options [nop,nop,TS
val 918415671
ecr 1600635344] , length 0
nathost forwards ACK to remote
09:42:20.696019 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 33, win 229, options [nop,nop,TS
val 918415671
ecr 1600635344 ], length 0
09:42:20.696687 br0 (IN) client.cport > remote.22: Flags [P.], seq 33:1393, ack 33, win 229, options [nop,nop,TS val 918415672 ecr 1600635344], length 1360
09:42:20.696730 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 33:1393, ack 33, win 229, options [nop,nop,TS val 918415672 ecr 1600635344], length 1360
09:42:20.699595 eth1 (OUT) remote.22 > nathost.nport: Flags [.], ack 33, win 1024, options [nop,nop,TS val 1600635344 ecr 918415642], length 0
09:42:20.699634 br0 (IN) remote.22 > client.cport: Flags [.], ack 33, win 1024, options [nop,nop,TS val 1600635344 ecr 918415642], length 0
09:42:20.704898 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 33:929, ack 33, win 1024, options [nop,nop,TS val 1600635345 ecr 918415642], length 896
09:42:20.704939 br0 (IN) remote.22 > client.cport: Flags [P.], seq 33:929, ack 33, win 1024, options [nop,nop,TS val 1600635345 ecr 918415642], length 896
09:42:20.737513 eth1 (OUT) remote.22 > nathost.nport: Flags [.], ack 1393, win 1024, options [nop,nop,TS val 1600635348 ecr 918415672], length 0
09:42:20.737555 br0 (IN) remote.22 > client.cport: Flags [.], ack 1393, win 1024, options [nop,nop,TS val 1600635348 ecr 918415672], length 0
09:42:20.737821 br0 (IN) client.cport > remote.22: Flags [P.], seq 1393:1441, ack 929, win 251, options [nop,nop,TS val 918415713 ecr 1600635345], length 48
09:42:20.737864 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 1393:1441, ack 929, win 251, options [nop,nop,TS val 918415713 ecr 1600635345], length 48
09:42:20.783898 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 929:1469, ack 1441, win 1024, options [nop,nop,TS val 1600635353 ecr 918415713], length 540
09:42:20.783988 br0 (IN) remote.22 > client.cport: Flags [P.], seq 929:1469, ack 1441, win 1024, options [nop,nop,TS val 1600635353 ecr 918415713], length 540
09:42:20.790159 br0 (IN) client.cport > remote.22: Flags [P.], seq 1441:1457, ack 1469, win 265, options [nop,nop,TS val 918415765 ecr 1600635353], length 16
09:42:20.790211 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 1441:1457, ack 1469, win 265, options [nop,nop,TS val 918415765 ecr 1600635353], length 16
09:42:20.928624 eth1 (OUT) remote.22 > nathost.nport: Flags [.], ack 1457, win 1024, options [nop,nop,TS val 1600635367 ecr 918415765], length 0
09:42:20.928715 br0 (IN) remote.22 > client.cport: Flags [.], ack 1457, win 1024, options [nop,nop,TS val 1600635367 ecr 918415765], length 0
etc. etc.
09:42:20.928949 br0 (IN) client.cport > remote.22: Flags [P.], seq 1457:1501, ack 1469, win 265, options [nop,nop,TS val 918415904 ecr 1600635367], length 44
09:42:20.929001 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 1457:1501, ack 1469, win 265, options [nop,nop,TS val 918415904 ecr 1600635367], length 44
09:42:20.965643 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 1469:1513, ack 1501, win 1024, options [nop,nop,TS val 1600635371 ecr 918415904], length 44
09:42:20.965696 br0 (IN) remote.22 > client.cport: Flags [P.], seq 1469:1513, ack 1501, win 1024, options [nop,nop,TS val 1600635371 ecr 918415904], length 44
09:42:20.966059 br0 (IN) client.cport > remote.22: Flags [P.], seq 1501:1561, ack 1513, win 265, options [nop,nop,TS val 918415941 ecr 1600635371], length 60
09:42:20.966083 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 1501:1561, ack 1513, win 265, options [nop,nop,TS val 918415941 ecr 1600635371], length 60
09:42:21.008693 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 1513:1589, ack 1561, win 1024, options [nop,nop,TS val 1600635375 ecr 918415941], length 76
09:42:21.008722 br0 (IN) remote.22 > client.cport: Flags [P.], seq 1513:1589, ack 1561, win 1024, options [nop,nop,TS val 1600635375 ecr 918415941], length 76
09:42:21.009433 br0 (IN) client.cport > remote.22: Flags [P.], seq 1561:1925, ack 1589, win 265, options [nop,nop,TS val 918415984 ecr 1600635375], length 364
09:42:21.009457 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 1561:1925, ack 1589, win 265, options [nop,nop,TS val 918415984 ecr 1600635375], length 364
09:42:21.051808 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 1589:1905, ack 1925, win 1024, options [nop,nop,TS val 1600635379 ecr 918415984], length 316
09:42:21.051839 br0 (IN) remote.22 > client.cport: Flags [P.], seq 1589:1905, ack 1925, win 1024, options [nop,nop,TS val 1600635379 ecr 918415984], length 316
09:42:21.057729 br0 (IN) client.cport > remote.22: Flags [P.], seq 1925:2561, ack 1905, win 279, options [nop,nop,TS val 918416033 ecr 1600635379], length 636
09:42:21.057753 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 1925:2561, ack 1905, win 279, options [nop,nop,TS val 918416033 ecr 1600635379], length 636
09:42:21.102581 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 1905:1933, ack 2561, win 1024, options [nop,nop,TS val 1600635385 ecr 918416033], length 28
09:42:21.102606 br0 (IN) remote.22 > client.cport: Flags [P.], seq 1905:1933, ack 2561, win 1024, options [nop,nop,TS val 1600635385 ecr 918416033], length 28
09:42:21.103151 br0 (IN) client.cport > remote.22: Flags [P.], seq 2561:2665, ack 1933, win 279, options [nop,nop,TS val 918416078 ecr 1600635385], length 104
09:42:21.103173 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 2561:2665, ack 1933, win 279, options [nop,nop,TS val 918416078 ecr 1600635385], length 104
09:42:21.130577 eth1 (OUT) remote.22 > nathost.nport: Flags [.], ack 2665, win 1024, options [nop,nop,TS val 1600635387 ecr 918416078], length 0
09:42:21.130596 br0 (IN) remote.22 > client.cport: Flags [.], ack 2665, win 1024, options [nop,nop,TS val 1600635387 ecr 918416078], length 0
remote sends data to client:
09:42:21.138829 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 1933:2585, ack 2665, win 1024, options [nop,nop,TS val 1600635388 ecr 918416078], length 652
09:42:21.138857 br0 (IN) remote.22 > client.cport: Flags [P.], seq 1933:2585, ack 2665, win 1024, options [nop,nop,TS val 1600635388 ecr 918416078], length 652
remote sends data to nathost:
09:42:21.146627 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 2585:2629, ack 2665, win 1024, options [nop,nop,TS val 1600635389 ecr 918416078], length 44
09:42:21.146647 br0 (IN) remote.22 > client.cport: Flags [P.], seq 2585:2629, ack 2665, win 1024, options [nop,nop,TS val 1600635389 ecr 918416078], length 44
09:42:21.146951 br0 (IN) client.cport > remote.22: Flags [.], ack 2629, win 293, options [nop,nop,TS val 918416122 ecr 1600635388], length 0
09:42:21.146974 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 2629, win 293, options [nop,nop,TS val 918416122 ecr 1600635388], length 0
client sends data to remote (via nathost)
09:42:21.151816 br0 (IN) client.cport > remote.22: Flags [P.], seq 2665:2773, ack 2629, win 293, options [nop,nop,TS val 918416127 ecr 1600635388], length 108
09:42:21.151837 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 2665:2773, ack 2629, win 293, options [nop,nop,TS val 918416127 ecr 1600635388], length 108
09:42:21.151997 br0 (IN) client.cport > remote.22: Flags [P.], seq 2773:3209, ack 2629, win 293, options [nop,nop,TS val 918416127 ecr 1600635388], length 436
09:42:21.152019 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 2773:3209, ack 2629, win 293, options [nop,nop,TS val 918416127 ecr 1600635388], length 436
09:42:21.192828 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 2629:2741, ack 3209, win 1024, options [nop,nop,TS val 1600635394 ecr 918416127], length 112
09:42:21.192886 br0 (IN) remote.22 > client.cport: Flags [P.], seq 2629:2741, ack 3209, win 1024, options [nop,nop,TS val 1600635394 ecr 918416127], length 112
09:42:21.192918 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 2741:2945, ack 3209, win 1024, options [nop,nop,TS val 1600635394 ecr 918416127], length 204
09:42:21.192956 br0 (IN) remote.22 > client.cport: Flags [P.], seq 2741:2945, ack 3209, win 1024, options [nop,nop,TS val 1600635394 ecr 918416127], length 204
09:42:21.193401 br0 (IN) client.cport > remote.22: Flags [.], ack 2945, win 307, options [nop,nop,TS val 918416169 ecr 1600635394], length 0
09:42:21.193446 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 2945, win 307, options [nop,nop,TS val 918416169 ecr 1600635394], length 0
09:42:21.237611 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 2945:3005, ack 3209, win 1024, options [nop,nop,TS val 1600635398 ecr 918416169], length 60
09:42:21.237654 br0 (IN) remote.22 > client.cport: Flags [P.], seq 2945:3005, ack 3209, win 1024, options [nop,nop,TS val 1600635398 ecr 918416169], length 60
09:42:21.238632 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 3005:3065, ack 3209, win 1024, options [nop,nop,TS val 1600635398 ecr 918416169], length 60
09:42:21.238670 br0 (IN) remote.22 > client.cport: Flags [P.], seq 3005:3065, ack 3209, win 1024, options [nop,nop,TS val 1600635398 ecr 918416169], length 60
09:42:21.239154 br0 (IN) client.cport > remote.22: Flags [.], ack 3065, win 307, options [nop,nop,TS val 918416214 ecr 1600635398], length 0
09:42:21.239198 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 3065, win 307, options [nop,nop,TS val 918416214 ecr 1600635398], length 0
09:42:21.247777 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 3065:3109, ack 3209, win 1024, options [nop,nop,TS val 1600635399 ecr 918416169], length 44
09:42:21.247816 br0 (IN) remote.22 > client.cport: Flags [P.], seq 3065:3109, ack 3209, win 1024, options [nop,nop,TS val 1600635399 ecr 918416169], length 44
09:42:21.247848 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 3109:3201, ack 3209, win 1024, options [nop,nop,TS val 1600635399 ecr 918416169], length 92
09:42:21.247885 br0 (IN) remote.22 > client.cport: Flags [P.], seq 3109:3201, ack 3209, win 1024, options [nop,nop,TS val 1600635399 ecr 918416169], length 92
09:42:21.248158 br0 (IN) client.cport > remote.22: Flags [.], ack 3201, win 307, options [nop,nop,TS val 918416223 ecr 1600635399], length 0
09:42:21.248199 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 3201, win 307, options [nop,nop,TS val 918416223 ecr 1600635399], length 0
09:43:22.683338 br0 (IN) client.cport > remote.22: Flags [P.], seq 3209:3237, ack 3201, win 307, options [nop,nop,TS val 918477658 ecr 1600635399], length 28
09:43:22.683443 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 3209:3237, ack 3201, win 307, options [nop,nop,TS val 918477658 ecr 1600635399], length 28
09:43:22.726840 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 3201:3245, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 44
09:43:22.726897 br0 (IN) remote.22 > client.cport: Flags [P.], seq 3201:3245, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 44
09:43:22.728709 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 3245:3353, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 108
09:43:22.728749 br0 (IN) remote.22 > client.cport: Flags [P.], seq 3245:3353, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 108
09:43:22.729249 br0 (IN) client.cport > remote.22: Flags [.], ack 3353, win 307, options [nop,nop,TS val 918477704 ecr 1600641547], length 0
09:43:22.729293 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 3353, win 307, options [nop,nop,TS val 918477704 ecr 1600641547], length 0
09:43:22.729653 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 3353:3397, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 44
09:43:22.729692 br0 (IN) remote.22 > client.cport: Flags [P.], seq 3353:3397, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 44
09:43:22.730874 eth1 (OUT) remote.22 > nathost.nport: Flags [P.], seq 3397:3541, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 144
09:43:22.730912 br0 (IN) remote.22 > client.cport: Flags [P.], seq 3397:3541, ack 3237, win 8184, options [nop,nop,TS val 1600641547 ecr 918477658], length 144
09:43:22.731374 br0 (IN) client.cport > remote.22: Flags [.], ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 0
09:43:22.731417 eth1 (OUT) nathost.nport > remote.22: Flags [.], ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 0
09:43:22.731492 br0 (IN) client.cport > remote.22: Flags [P.], seq 3237:3265, ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 28
09:43:22.731532 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 3237:3265, ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 28
09:43:22.731553 br0 (IN) client.cport > remote.22: Flags [P.], seq 3265:3325, ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 60
09:43:22.731591 eth1 (OUT) nathost.nport > remote.22: Flags [P.], seq 3265:3325, ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 60
-------------------------------------------------------------------------
FIN:
client sends FIN+ACK to remote
09:43:22.731605 br0 (IN) client.cport > remote.22: Flags [F.], seq 3325, ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 0
once FIN is received, no further useful information arrives for this connection
and the tcp-record entry is logged and erased.
Any further info arriving for cport|22 is now ignored since the record matching
the key no longer exists: see below for examples of additionally arriving
packets:
-------------------------------------------------------------------------------
nathost forwards FIN+ACK to remote
09:43:22.731645 eth1 (OUT) nathost.nport > remote.22: Flags [F.], seq 3325, ack 3541, win 321, options [nop,nop,TS val 918477707 ecr 1600641547], length 0
remote replies by sending ACK to nathost
09:43:22.759772 eth1 (OUT) remote.22 > nathost.nport: Flags [.], ack 3265, win 8184, options [nop,nop,TS val 1600641550 ecr 918477707], length 0
nathost forwards remote ACK to cient
09:43:22.759813 br0 (IN) remote.22 > client.cport: Flags [.], ack 3265, win 8184, options [nop,nop,TS val 1600641550 ecr 918477707], length 0
remote sends another ACL to nathost
09:43:22.763745 eth1 (OUT) remote.22 > nathost.nport: Flags [.], ack 3265, win 8184, options [nop,nop,TS val 1600641550 ecr 918477707,sack 1 {3325:3325},eol], length 0
nathorst forwards another ACK to client
09:43:22.763784 br0 (IN) remote.22 > client.cport: Flags [.], ack 3265, win 8184, options [nop,nop,TS val 1600641550 ecr 918477707,sack 1 {3325:3325},eol], length 0
remote sends another ACK to nathost
09:43:22.763809 eth1 (OUT) remote.22 > nathost.nport: Flags [.], ack 3325, win 8183, options [nop,nop,TS val 1600641550 ec
nathost forwards ACK to client
09:43:22.763857 br0 (IN) remote.22 > client.cport: Flags [.], ack 3325, win 8183, options [nop,nop,TS val 1600641550 ec
natlog-3.01.00/documentation/README.tcp.flow 0000664 0000000 0000000 00000016154 14743162762 0020446 0 ustar 00root root 0000000 0000000 192.168.0.106.52136 > 129.125.3.162.22: [S], seq 1963498643, val 1478669495 ecr 0, length 0
129.125.3.162.22 > 192.168.0.106.52136: [S.], seq 3105777655, ack 1963498644, val 2992299246 ecr 1478669495], length 0
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 1, val 1478669714 ecr 2992299246], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 1:33, ack 1, val 1478669715 ecr 2992299246], length 32
129.125.3.162.22 > 192.168.0.106.52136: [.], ack 33, val 2992299465 ecr 1478669715], length 0
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 1:33, ack 33, val 2992299469 ecr 1478669715], length 32
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 33, val 1478670005 ecr 2992299469], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 33:1393, ack 33, val 1478670005 ecr 2992299469], length 1360
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 33:929, ack 33, val 2992299752 ecr 1478670005], length 896
129.125.3.162.22 > 192.168.0.106.52136: [.], ack 1393, val 2992299767 ecr 1478670005], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 1393:1441, ack 929, val 1478670250 ecr 2992299752], length 48
129.125.3.162.22 > 192.168.0.106.52136: [.], ack 1441, val 2992299998 ecr 1478670250], length 0
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 929:1469, ack 1441, val 2992300008 ecr 1478670250], length 540
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 1441:1457, ack 1469, val 1478670547 ecr 2992300008], length 16
129.125.3.162.22 > 192.168.0.106.52136: [.], ack 1457, val 2992300297 ecr 1478670547], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 1457:1501, ack 1469, val 1478670782 ecr 2992300297], length 44
129.125.3.162.22 > 192.168.0.106.52136: [.], ack 1501, val 2992300529 ecr 1478670782], length 0
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 1469:1513, ack 1501, val 2992300529 ecr 1478670782], length 44
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 1501:1561, ack 1513, val 1478671049 ecr 2992300529], length 60
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 1513:1589, ack 1561, val 2992300798 ecr 1478671049], length 76
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 1561:1925, ack 1589, val 1478671353 ecr 2992300798], length 364
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 1589:1905, ack 1925, val 2992301107 ecr 1478671353], length 316
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 1925:2561, ack 1905, val 1478671670 ecr 2992301107], length 636
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 1905:1933, ack 2561, val 2992301417 ecr 1478671670], length 28
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 2561:2665, ack 1933, val 1478671968 ecr 2992301417], length 104
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 1933:2137, ack 2665, val 2992301717 ecr 1478671968], length 204
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 2137, val 1478672212 ecr 2992301717], length 0
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2137:2181, ack 2665, val 2992301967 ecr 1478672212], length 44
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 2181, val 1478672480 ecr 2992301967], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 2665:2773, ack 2181, val 1478672485 ecr 2992301967], length 108
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 2773:3225, ack 2181, val 1478672485 ecr 2992301967], length 452
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2181:2209, ack 2773, val 2992302230 ecr 1478672485], length 28
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2209:2293, ack 3225, val 2992302232 ecr 1478672485], length 84
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2293:2497, ack 3225, val 2992302233 ecr 1478672485], length 204
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2497:2557, ack 3225, val 2992302256 ecr 1478672485], length 60
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2557:2617, ack 3225, val 2992302256 ecr 1478672485], length 60
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2617:2677, ack 3225, val 2992302270 ecr 1478672485], length 60
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2677:2721, ack 3225, val 2992302270 ecr 1478672485], length 44
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2721:2813, ack 3225, val 2992302270 ecr 1478672485], length 92
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 2557, val 1478672790 ecr 2992302230], length 0
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 2813, val 1478672790 ecr 2992302256], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 3225:3253, ack 2813, val 1478674331 ecr 2992302256], length 28
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2813:2857, ack 3253, val 2992304077 ecr 1478674331], length 44
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2857:2901, ack 3253, val 2992304077 ecr 1478674331], length 44
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2901:2993, ack 3253, val 2992304077 ecr 1478674331], length 92
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 2901, val 1478674638 ecr 2992304077], length 0
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 2993, val 1478674681 ecr 2992304077], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 3253:3281, ack 2993, val 1478676074 ecr 2992304077], length 28
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 2993:3037, ack 3281, val 2992305826 ecr 1478676074], length 44
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 3037, val 1478676373 ecr 2992305826], length 0
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 3037:3145, ack 3281, val 2992305828 ecr 1478676074], length 108
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 3145, val 1478676373 ecr 2992305828], length 0
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 3145:3189, ack 3281, val 2992305829 ecr 1478676074], length 44
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 3189, val 1478676373 ecr 2992305829], length 0
129.125.3.162.22 > 192.168.0.106.52136: [P.], seq 3189:3333, ack 3281, val 2992305829 ecr 1478676074], length 144
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 3333, val 1478676373 ecr 2992305829], length 0
192.168.0.106.52136 > 129.125.3.162.22: [P.], seq 3281:3309, ack 3333, val 1478676374 ecr 2992305829], length 28
192.168.0.106.52136 > 129.125.3.162.22: [FP.], seq 3309:3369, ack 3333, val 1478676374 ecr 2992305829], length 60
129.125.3.162.22 > 192.168.0.106.52136: [.], ack 3370, val 2992306127 ecr 1478676374], length 0
129.125.3.162.22 > 192.168.0.106.52136: [F.], seq 3333, ack 3370, val 2992306130 ecr 1478676374], length 0
192.168.0.106.52136 > 129.125.3.162.22: [.], ack 3334, val 1478676677 ecr 2992306130], length 0
natlog-3.01.00/documentation/README.tcpdump 0000664 0000000 0000000 00000020257 14743162762 0020365 0 ustar 00root root 0000000 0000000 http://www.kroosec.com/2012/10/a-look-at-pcap-file-format.html
Hani's blog
Software/Security Engineering, Linux, Open Source and /dev/random
Saturday, October 13, 2012
A look at the pcap file format
A couple of days ago, someone came on #Nmap IRC channel asking about pcap
file format. He was writing a parser in Haskell but had some issues,
especially with extracting the timestamp values of the each packet. As I
walked him through the file format, I decided to write this blog post as a
quick reference, a reminder, or a clearer explanation depending on who is
reading it. While detailing the file format, we will have a closer look at
this capture file.
A pcap file is structured in this way:
Global Header | Header1 | Data1 | Header2 | Data2 | ... | HeaderN | DataN
The parts in blue are added by libpcap/capture software, while the parts in
red are the actual data captured on the wire. The first part of the file is
the global header, which is inserted only once in the file, at the start.
The global header has a fixed size of 24 bytes.
kroosec@dojo:~$ hexdump -n 24 -C connection\ termination.cap | cut -c 11-59
d4 c3 b2 a1 02 00 04 00 00 00 00 00 00 00 00 00
ff ff 00 00 01 00 00 00
The first 4 bytes d4 c3 b2 a1 constitute the magic number which is used to
identify pcap files.
The next 4 bytes 02 00 04 00 are the Major version (2
bytes) and Minor Version (2 bytes), in our case 2.4. Why is 2 written on 2
bytes as 0x0200 and not 0x0002 ? This is called little endianess in which, the
least significant byte is stored in the least significant position: This means
that 2 would be written on 2 bytes as 02 00. How do we know that we are not
using Big Endianness instead ? The magic number is also used to distinguish
between Little and Big Endianness. The "real" value is 0xa1b2c3d4, if we read
it as as a1 b2 c3 d4, it means Big E. Otherwise (0xd4c3b2a1), it means Little
E.
Following are the GMT timezone offset minus the timezone used in the
headers in seconds (4 bytes) and the accuracy of the timestamps in the capture
(4 bytes). These are set to 0 most of the time which gives us the 00 00 00 00
00 00 00 00.
Next is the Snapshot Length field (4 bytes) which indicates the maximum
length of the captured packets (dataX) in bytes. In our file it is set to ff
ff 00 00 which equals to 65535 (0xffff), the default value for tcpdump and
wireshark.
The last 4 bytes in the global header specify the Link-Layer Header
Type. Our file has the value of 0x1 ( 01 00 00 00 ), which indicates that the
link-layer protocol is Ethernet. There are many other types such as PPPoE,
USB, Frame Relay etc,. The complete list is available here.
After the Global header, we have a certain number of packet header / data
pairs.
Taking a closer look at the first packet header:
kroosec@dojo:~$ hexdump -C connection\ termination.cap -s 24 -n 16 | cut -c
11-59
c2 ba cd 4f b6 35 0f 00 36 00 00 00 36 00 00 00
The first 4 bytes are the timestamp in Seconds. This is the number of seconds
since the start of 1970, also known as Unix Epoch. The value of this field in
our pcap file is 0x4fcdbac2. An easy way to convert it to a human readable
format:
kroosec@dojo:~$ calc 0x4fcdbac2
1338882754
kroosec@dojo:~$ date --date='1970-01-01 1338882754 sec GMT'
Tue Jun 5 08:52:34 CET 2012
FBB: Note that the time stamps are already in host by order.
The second field (4 Bytes) is the microseconds part of the time at which the
packet was captured. In our case it equals to b6 35 0f 00 or 996790
microseconds.
FBB:: Note that size(pcap_pkthdr) is/can be 24. struct timeval holds at least
time_t tv_sec seconds
suseconds_t tv_usec microseconds
where time_t is a signed int, 32 or 64 bits long,
and suseconds_t probably of the same type.
Also, the values written to the binary file are in host byte order.
The third field is 4 bytes long and contains the size of the saved packet data
in our file in bytes (the part in red following the header).
The Fourth field is 4 bytes long too and contains the length of the packet as
it was captured on the wire. Both fields' value is 36 00 00 00 (54 Bytes) in
our file but these may have different values in cases where we set the maximum
packet length (whose value is 65535 in the global header of our file) to a
smaller size.
After the packet header comes the data!
Starting from the lower layer we see the Ethernet destination address
00:12:cf:e5:54:a0 followed by the source address 00:1f:3c:23:db:d3.
To sum it up here is our file.
kroosec@dojo:~$ hexdump -C connection\ termination.cap | cut -c 11-59
global header: d4 c3 b2 a1 02 00 04 00 00 00 00 00 00 00 00 00
ff ff 00 00 01 00 00 00
packet hdr: c2 ba cd 4f b6 35 0f 00
36 00 00 00 36 00 00 00
|<--------- 0x36 bytes beyond
the next packet starts
data:
Ethernet_Header:
destmac: 00 12 cf e5 54 a0
srcmac: 00 1f
3c 23 db d3
ethertype: 08 00
IP_Header:
hdrLength,version: 45
tos 00 |<--------- 0x10
length: 00 28
0x28 bytes beyond the IP header's
begin the next packet starts
ident: 4a a6
fragmentOffset: 40 00
TTL: 40
protocol: 06 (TCP)
checksum: 58 eb
sourceaddr: c0 a8 0a e2
|<-- 0x10 (wrt IP_Header)
destaddr: c0 a8 0b 0c
|<--------- 0x20
TCP_Header:
src port: 4c fb
dst port: 00 17
sequence: e7 ca
f8 58
ackNr: 26 13 45 de
|<-- 0x20 (wrt IP_Header)
data offset 50
flags: 11
|<--------- 0x30
window: 40 c7
checksum: 3e a6
urgentPtr: 00 00
packet hdr: c3 ba
cd 4f 60 04 00 00 3c 00 00 00 3c 00 00 00 00
data: 1f
3c 23 db d3 00 12 cf e5 54 a0 08 00 45 00 00 28
8a f7 00 00 40 06 58 9a c0 a8 0b 0c c0 a8 0a e2
00 17 4c fb 26 13 45 de e7 ca f8 59 50 10 01 df
7d 8e 00 00 00 00 00 00 00 00
packet hdr: c3 ba cd 4f 70 2f
00 00 3c 00 00 00 3c 00 00 00
data: 00 1f 3c 23 db d3
00 12 cf e5 54 a0 08 00 45 00 00 28 26 f9 00 00
40 06 bc 98 c0 a8 0b 0c c0 a8 0a e2 00 17 4c fb
26 13 45 de e7 ca f8 59 50 11 01 df 7d 8d 00 00
00 00 00 00 00 00
packet hdr: c3 ba cd 4f db 2f 00 00 36 00
00 00 36 00 00 00
data: 00 12 cf e5 54 a0 00 1f 3c 23
db d3 08 00 45 00 00 28 4a a7 40 00 40 06 58 ea
c0 a8 0a e2 c0 a8 0b 0c 4c fb 00 17 e7 ca f8 59
26 13 45 df 50 10 40 c7 3e a5 00 00
And here is what the file utility thinks of it
kroosec@dojo:~$ type file
file is /usr/bin/file
kroosec@dojo:~$ file connection\ termination.cap
connection termination.cap: tcpdump capture file (little-endian) - version 2.4
(Ethernet, capture length 65535)
A hexdump of a file written by tcpdump is in the file br0.hex in the current
directory.
natlog-3.01.00/documentation/README.udp 0000664 0000000 0000000 00000005151 14743162762 0017475 0 ustar 00root root 0000000 0000000 Setting up a demo udp connection:
On the server run (make sure the firewall accepts incoming connections for
the used port:
iptables -A INPUT -p udp --dport -j ACCEPT
Start nc to listen on the port:
nc -l -u -p
Start nc on the client:
nc -u server
Run tcpdump -ni udp and port to inspect the flow.
Example:
Server (e.g., www.rug.nl):
nc -l -u -p 12345
Client:
nc -u www.rug.nl 12345
Tcpdump (e.g. at the client)
tcpdump -ni eth0 udp and port 12345
When sending UDP packets, the ID's at the client and nat computer are
identical:
Client (1.2) to destination (2.51):
15:43:54.437608 IP (tos 0x0, ttl 64, id 36222, offset 0, flags [DF], proto UDP (17), length 34)
192.168.1.2.51757 > 129.125.2.51.12345: UDP, length 6
src:sport -> dst:dport, id = a
15:44:13.541867 IP (tos 0x0, ttl 52, id 18749, offset 0, flags [DF], proto UDP (17), length 38)
129.125.2.51.12345 > 192.168.1.2.51757: UDP, length 10
dst:dport -> src:sport, id = b
15:45:49.393355 IP (tos 0x0, ttl 64, id 63059, offset 0, flags [DF], proto UDP (17), length 37)
192.168.1.2.51757 > 129.125.2.51.12345: UDP, length 9
src:sport -> dst:dport, id = c
15:46:17.583739 IP (tos 0x0, ttl 52, id 24262, offset 0, flags [DF], proto UDP (17), length 40)
129.125.2.51.12345 > 192.168.1.2.51757: UDP, length 12
dst:dport -> src:sport id = d
Nathost (17.6) to destination (2.51):
15:43:54.437689 IP (tos 0x0, ttl 63, id 36222, offset 0, flags [DF], proto UDP (17), length 34)
192.168.17.6.51757 > 129.125.2.51.12345: UDP, length 6
nat:nport -> dst:dport, id = a
15:44:13.541818 IP (tos 0x0, ttl 53, id 18749, offset 0, flags [DF], proto UDP (17), length 38)
129.125.2.51.12345 > 192.168.17.6.51757: UDP, length 10
dst:dport -> nat:nport, id = b
15:45:49.393444 IP (tos 0x0, ttl 63, id 63059, offset 0, flags [DF], proto UDP (17), length 37)
192.168.17.6.51757 > 129.125.2.51.12345: UDP, length 9
nat:nport -> dst:dport, id = c
15:46:17.583695 IP (tos 0x0, ttl 53, id 24262, offset 0, flags [DF], proto UDP (17), length 40)
129.125.2.51.12345 > 192.168.17.6.51757: UDP, length 12
dst:dport -> nat:nport id = d
Multiple udp packets may be sent by identical processes, in which case the
client and nathost computers may use different ports.
The IN connections store the source, dest, IP-addresses and ports, and uses
d_id (like the tcp's sequence nr) to allow association with the matching OUT
packet. Once the association is made, the via IP-address and port can be set,
and the d_id entry can be removed.
natlog-3.01.00/documentation/README.udp.flow 0000664 0000000 0000000 00000002222 14743162762 0020437 0 ustar 00root root 0000000 0000000 When sending UDP packets, the ID's at the client and nat computer are
identical:
Client (1.2) to destination (2.51):
id 36222, length 34 192.168.1.2. 51757 > 129.125.2.51. 12345, length 6
id 18749, length 38 129.125.2.51. 12345 > 192.168.1.2. 51757, length 10
id 63059, length 37 192.168.1.2. 51757 > 129.125.2.51. 12345, length 9
id 24262, length 40 129.125.2.51. 12345 > 192.168.1.2. 51757, length 12
Nathost (17.6) to destination (2.51):
id 36222, length 34 192.168.17.6. 51757 > 129.125.2.51. 12345, length 6
id 18749, length 38 129.125.2.51. 12345 > 192.168.17.6. 51757, length 10
id 63059, length 37 192.168.17.6. 51757 > 129.125.2.51. 12345, length 9
id 24262, length 40 129.125.2.51. 12345 > 192.168.17.6. 51757, length 12
Multiple udp packets may be sent by identical processes, in which case the
client and nathost computers may use different ports.
The IN connections store the source, dest, IP-addresses and ports, and uses
d_id (like the tcp's sequence nr) to allow association with the matching OUT
packet. Once the association is made, the via IP-address and port can be set,
and the d_id entry can be removed.
natlog-3.01.00/documentation/ip-header-v41.png 0000664 0000000 0000000 00000530055 14743162762 0021010 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR ø–M iCCPICC Profile xœíVYP“W=" ‹HY‚(B¨ŠˆDVEŠ¢ˆÕ*IˆKÂÏOdQP‹
¢ (T\)®B]ª¥HA¢Vm‹
V¬Åô!¶v¦uêsË™¹3çž¹óÍ=÷<Üh>â‘d
€X"¥ü½Ü˜!¡aLµ. ` ˜óñ¤+—ËÁ;ñì: ¸Æâ‘dÌ»Ïý#ÆP!¡a Á /Rr ú|%_ @?QJJb) }A/ H VT ? J h‹”¼€6_Éë h¯ˆ¤ ѨêJ"£%€Z@×ŽÆ Ç ö HJ
hnÀ‹c#Í‹ ,BBØÊkÆz³_ôü·
TÑ€qÑÌ}݉Àâ6È €`4ů°· Z òB¡œ¨ÕÔB1´G¡ÞÐ{€Æ8AµêÍÄUàßöJŸo@' @³¤¿R9¬¤NרвÓ0–£Ó¤;Gï¸#Ýð¡‘ÛøÝžMœg²Ù´ÝÌàÃðIù“[ÌiS-DÓò-ë¦ßeiΰ´ö³Ùn°+±¯v¸2óÖ,ùlš“öG&Îs纸øÌ[í~ÿƒÎ‡²ŽüXðSZÔ£€Ÿ]äÓå¿ô>¹