Skip to content

Commit

Permalink
Add Ubuntu 24.04 support [Fixed network plugin for new Wireshark head…
Browse files Browse the repository at this point in the history
…ers, add building LLVM and libosi]
  • Loading branch information
SneakyFoxy authored and SneakyFoxy committed Jan 21, 2025
1 parent 0ae118a commit 46bc4a9
Show file tree
Hide file tree
Showing 45 changed files with 3,796 additions and 37 deletions.
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5412,9 +5412,9 @@ if test "$llvm" != "no"; then

llvm_components=""
llvm_cxxflags=$($llvm_config $llvm_components --cxxflags 2> /dev/null)
llvm_ldflags=$($llvm_config $llvm_components --ldflags 2> /dev/null)
# Add ltinfo for fixing LLVM linking error [Maybe i just messed up with LLVM compiling]
llvm_ldflags="$($llvm_config $llvm_components --ldflags 2> /dev/null) -ltinfo"
llvm_libs=$($llvm_config $llvm_components --libs 2> /dev/null)

if compile_prog_clangxx "$llvm_cxxflags -Wno-unused-variable" "$llvm_libs $llvm_ldflags" ; then
: LLVM found
elif test "$llvm" = "yes"; then
Expand Down
90 changes: 90 additions & 0 deletions panda/dependencies/ubuntu_24.04_base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Panda dependencies
# Note that libcapstone >= v4.1 is also required, but that's not available in apt
git
libdwarf1
libjsoncpp-dev
# libllvm11
libprotobuf-c-dev
libvte-2.91-0
libwireshark-dev
libwiretap-dev
# Fixes config.h build error
wireshark-dev
libxen-dev
libz3-dev
python3
python3-pip
wget

# pyperipheral (only needed for armel)
libpython3-dev

# pypanda dependencies
genisoimage
libffi-dev
python3-protobuf
python3-colorama

# Not sure what this one is needed for
liblzo2-2

# apt-rdepends qemu-system-common
acl
libc6
libcap-ng0
libcap2
libgbm1
libglib2.0-0
libglib2.0-dev
zlib1g-dev
libgnutls30
libnettle8
libpixman-1-0
libvirglrenderer1

# apt-rdepends qemu-block-extra
libcurl3-gnutls
libglib2.0-0
libiscsi7
librados2
librbd1
libssh-4

# apt-rdepends qemu-system-arm, seems most of the system-[arch]es have same dependencies
libaio1t64
libasound2t64
libbrlapi-dev
libc6
libcacard0
libepoxy0
libfdt1
libgbm1
libgcc-s1
libglib2.0-0
libgnutls30
libibverbs1
libjpeg8
libncursesw6
libnuma1
libpixman-1-0
libpmem1
libpng16-16
librdmacm1
libsasl2-2
libseccomp2
libslirp0
libspice-server1
libstdc++6
libtinfo6
libusb-1.0-0
libusbredirparser1
libvirglrenderer1
zlib1g

# rr2 dependencies
libarchive-dev
libssl-dev

# libosi build dependecies
pkg-config
libglib2.0-dev
90 changes: 90 additions & 0 deletions panda/dependencies/ubuntu_24.04_build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
libc++-dev
libelf-dev
libtool-bin
libwireshark-dev
libwiretap-dev
# lsb-core
zip

# panda build deps
# Note libcapstone-dev is required, but we need v4 + which isn't in apt
build-essential
chrpath
# clang-11
gcc
libdwarf-dev
libprotoc-dev
# llvm-11-dev
protobuf-c-compiler
protobuf-compiler
python3-dev
libpixman-1-dev
zip

# pypanda dependencies
python3-setuptools
python3-wheel

# pypanda test dependencies
gcc-multilib
libc6-dev-i386
nasm

# Qemu build deps
debhelper
device-tree-compiler
libgnutls28-dev
libaio-dev
libasound2-dev
libattr1-dev
libbrlapi-dev
libcacard-dev
libcap-dev
libcap-ng-dev
libcurl4-gnutls-dev
libdrm-dev
libepoxy-dev
libfdt-dev
libgbm-dev
libibumad-dev
libibverbs-dev
libiscsi-dev
libjpeg-dev
libncursesw5-dev
libnuma-dev
libpmem-dev
libpng-dev
libpulse-dev
librbd-dev
librdmacm-dev
libsasl2-dev
libseccomp-dev
libslirp-dev
libspice-protocol-dev
libspice-server-dev
libssh-dev
libudev-dev
libusb-1.0-0-dev
libusbredirparser-dev
libvirglrenderer-dev
nettle-dev
python3
python3-sphinx
texinfo
uuid-dev
xfslibs-dev
zlib1g-dev
libc6.1-dev-alpha-cross

# qemu build deps that conflict with gcc-multilib
#gcc-alpha-linux-gnu
#gcc-powerpc64-linux-gnu
#gcc-s390x-linux-gnu

# rust install deps
curl

# libosi install deps
cmake
ninja-build
rapidjson-dev
48 changes: 24 additions & 24 deletions panda/plugins/network/network.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* PANDABEGINCOMMENT
*
*
* Authors:
* Tim Leek tleek@ll.mit.edu
* Ryan Whelan rwhelan@ll.mit.edu
* Joshua Hodosh josh.hodosh@ll.mit.edu
* Michael Zhivich mzhivich@ll.mit.edu
* Brendan Dolan-Gavitt brendandg@gatech.edu
*
* This work is licensed under the terms of the GNU GPL, version 2.
* See the COPYING file in the top-level directory.
*
*
* This work is licensed under the terms of the GNU GPL, version 2.
* See the COPYING file in the top-level directory.
*
PANDAENDCOMMENT */
// This needs to be defined before anything is included in order to get
// the PRIx64 macro
Expand All @@ -21,6 +21,7 @@

#include <wireshark/config.h>
#include <wiretap/wtap.h>
#include <wiretap/wtap_opttypes.h>

// These need to be extern "C" so that the ABI is compatible with
// QEMU/PANDA, which is written in C
Expand Down Expand Up @@ -56,7 +57,7 @@ bool init_plugin(void *self) {
.snaplen = 65535,
.shb_hdrs = NULL,
.idb_inf = NULL,
.nrb_hdrs = NULL,
.nrbs_growing = NULL,
.dsbs_initial = NULL,
.dsbs_growing = NULL
};
Expand All @@ -76,20 +77,19 @@ bool init_plugin(void *self) {
fprintf(stderr, "Plugin 'network' needs argument: -panda-arg network:file=<file>\n");
return false;
}

int file_type = wtap_pcapng_file_type_subtype();
#if (VERSION_MAJOR == 2 && VERSION_MINOR >= 6 ) || (VERSION_MAJOR>=3)
wtap_init(false);
#elif VERSION_MAJOR == 2 && VERSION_MINOR == 2 && VERSION_MICRO >= 4
wtap_init();
#endif

#if (VERSION_MAJOR>=3)
#if (VERSION_MAJOR>=4 || VERSION_MINOR>=4)
gchar *write_err_info;
#endif
plugin_log = wtap_dump_open(
tblog_filename,
WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
file_type,
WTAP_UNCOMPRESSED, // assuming this...
&wdparams, // the new structure that wraps all the ng params
&err
Expand All @@ -100,15 +100,15 @@ bool init_plugin(void *self) {
#else
plugin_log = wtap_dump_open_ng(
/*filename*/tblog_filename,
/*file_type_subtype*/WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
/*file_type_subtype*/file_type,
/*encap*/WTAP_ENCAP_ETHERNET,
/*snaplen*/65535,
/*compressed*/1,
/*shb_hdrs*/NULL,
/*idb_inf*/NULL,
#if VERSION_MAJOR == 2
#if VERSION_MAJOR == 2
/*nrb_hdrs*/NULL,
#endif
#endif
/*err*/&err);
#endif

Expand All @@ -134,7 +134,8 @@ void uninit_plugin(void *self) {
#endif
#if (VERSION_MAJOR>=4 || (VERSION_MAJOR==3 && VERSION_MINOR>=4))
gchar *write_err_info;
gboolean ret = wtap_dump_close(plugin_log, &err, &write_err_info);
gboolean needs_reload;
gboolean ret = wtap_dump_close(plugin_log, &needs_reload, &err, &write_err_info);
#else
gboolean ret = wtap_dump_close(plugin_log, &err);
#endif
Expand Down Expand Up @@ -163,8 +164,8 @@ void handle_packet(CPUState *env, uint8_t *buf, size_t size, uint8_t direction,
rec.rec_header.packet_header.caplen = size;
rec.rec_header.packet_header.len = size;
rec.rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
rec.opt_comment = comment_buf;
rec.has_comment_changed = true;
wtap_block_t pkt_block = wtap_block_create(WTAP_BLOCK_PACKET);
wtap_block_add_string_option(pkt_block, OPT_COMMENT, comment_buf, strlen(comment_buf) + 1);
ret = wtap_dump(
/*wtap_dumper*/ plugin_log,
/*wtap_rec*/ &rec,
Expand All @@ -173,9 +174,9 @@ void handle_packet(CPUState *env, uint8_t *buf, size_t size, uint8_t direction,
/*err_info*/ &err_info);
#else
struct wtap_pkthdr header;
#if VERSION_MAJOR >= 2
wtap_phdr_init(&header);
#endif
#if VERSION_MAJOR >= 2
wtap_phdr_init(&header);
#endif
header.ts.secs = now_tv.tv_sec;
header.ts.nsecs = now_tv.tv_usec * 1000;
header.caplen = size;
Expand All @@ -187,14 +188,14 @@ void handle_packet(CPUState *env, uint8_t *buf, size_t size, uint8_t direction,
/*wtap_pkthdr*/ &header,
/*buf*/ buf,
/*err*/ &err
#if VERSION_MAJOR >= 2
#if VERSION_MAJOR >= 2
,
/*err_info*/ &err_info
#endif
#endif
);
#if VERSION_MAJOR >= 2
wtap_phdr_cleanup(&header);
#endif
#if VERSION_MAJOR >= 2
wtap_phdr_cleanup(&header);
#endif
#endif
if (!ret) {
fprintf(stderr, "Plugin 'network': failed wtap_dump() with error %d", err);
Expand All @@ -206,4 +207,3 @@ void handle_packet(CPUState *env, uint8_t *buf, size_t size, uint8_t direction,
return;
}
#endif

6 changes: 6 additions & 0 deletions panda/python/core/.eggs/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.

This directory caches those eggs to prevent repeated downloads.

However, it is safe to delete this directory.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit 46bc4a9

Please sign in to comment.