polyfile-weave 0.5.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of polyfile-weave might be problematic. Click here for more details.
- polyfile/__init__.py +15 -0
- polyfile/__main__.py +394 -0
- polyfile/arithmetic.py +27 -0
- polyfile/ast.py +114 -0
- polyfile/debugger.py +1039 -0
- polyfile/expressions.py +346 -0
- polyfile/fileutils.py +343 -0
- polyfile/html.py +135 -0
- polyfile/http/__init__.py +1 -0
- polyfile/http/defacto.py +37 -0
- polyfile/http/deprecated.py +51 -0
- polyfile/http/experimental.py +67 -0
- polyfile/http/http_11.py +548 -0
- polyfile/http/matcher.py +37 -0
- polyfile/http/structured_headers.py +48 -0
- polyfile/iterators.py +72 -0
- polyfile/jpeg.py +24 -0
- polyfile/kaitai/__init__.py +0 -0
- polyfile/kaitai/compiler.py +156 -0
- polyfile/kaitai/parser.py +312 -0
- polyfile/kaitai/parsers/__init__.py +0 -0
- polyfile/kaitai/parsers/aix_utmp.py +116 -0
- polyfile/kaitai/parsers/allegro_dat.py +367 -0
- polyfile/kaitai/parsers/andes_firmware.py +64 -0
- polyfile/kaitai/parsers/android_bootldr_asus.py +105 -0
- polyfile/kaitai/parsers/android_bootldr_huawei.py +181 -0
- polyfile/kaitai/parsers/android_bootldr_qcom.py +217 -0
- polyfile/kaitai/parsers/android_dto.py +138 -0
- polyfile/kaitai/parsers/android_img.py +319 -0
- polyfile/kaitai/parsers/android_nanoapp_header.py +83 -0
- polyfile/kaitai/parsers/android_opengl_shaders_cache.py +151 -0
- polyfile/kaitai/parsers/android_sparse.py +237 -0
- polyfile/kaitai/parsers/android_super.py +401 -0
- polyfile/kaitai/parsers/apm_partition_table.py +196 -0
- polyfile/kaitai/parsers/apple_single_double.py +180 -0
- polyfile/kaitai/parsers/asn1_der.py +235 -0
- polyfile/kaitai/parsers/au.py +138 -0
- polyfile/kaitai/parsers/avantes_roh60.py +112 -0
- polyfile/kaitai/parsers/avi.py +296 -0
- polyfile/kaitai/parsers/bcd.py +111 -0
- polyfile/kaitai/parsers/bitcoin_transaction.py +210 -0
- polyfile/kaitai/parsers/blender_blend.py +334 -0
- polyfile/kaitai/parsers/bmp.py +780 -0
- polyfile/kaitai/parsers/bson.py +411 -0
- polyfile/kaitai/parsers/btrfs_stream.py +318 -0
- polyfile/kaitai/parsers/bytes_with_io.py +27 -0
- polyfile/kaitai/parsers/chrome_pak.py +194 -0
- polyfile/kaitai/parsers/code_6502.py +456 -0
- polyfile/kaitai/parsers/compressed_resource.py +217 -0
- polyfile/kaitai/parsers/cpio_old_le.py +154 -0
- polyfile/kaitai/parsers/cramfs.py +344 -0
- polyfile/kaitai/parsers/creative_voice_file.py +342 -0
- polyfile/kaitai/parsers/dbf.py +274 -0
- polyfile/kaitai/parsers/dcmp_0.py +664 -0
- polyfile/kaitai/parsers/dcmp_1.py +422 -0
- polyfile/kaitai/parsers/dcmp_2.py +312 -0
- polyfile/kaitai/parsers/dcmp_variable_length_integer.py +66 -0
- polyfile/kaitai/parsers/dex.py +1086 -0
- polyfile/kaitai/parsers/dicom.py +4370 -0
- polyfile/kaitai/parsers/dime_message.py +201 -0
- polyfile/kaitai/parsers/dns_packet.py +569 -0
- polyfile/kaitai/parsers/doom_wad.py +654 -0
- polyfile/kaitai/parsers/dos_datetime.py +191 -0
- polyfile/kaitai/parsers/dos_mz.py +172 -0
- polyfile/kaitai/parsers/ds_store.py +513 -0
- polyfile/kaitai/parsers/dtb.py +310 -0
- polyfile/kaitai/parsers/dune_2_pak.py +126 -0
- polyfile/kaitai/parsers/edid.py +472 -0
- polyfile/kaitai/parsers/efivar_signature_list.py +331 -0
- polyfile/kaitai/parsers/elf.py +2482 -0
- polyfile/kaitai/parsers/ethernet_frame.py +114 -0
- polyfile/kaitai/parsers/exif.py +723 -0
- polyfile/kaitai/parsers/ext2.py +537 -0
- polyfile/kaitai/parsers/fallout2_dat.py +187 -0
- polyfile/kaitai/parsers/fallout_dat.py +156 -0
- polyfile/kaitai/parsers/fasttracker_xm_module.py +558 -0
- polyfile/kaitai/parsers/ftl_dat.py +90 -0
- polyfile/kaitai/parsers/genmidi_op2.py +161 -0
- polyfile/kaitai/parsers/gettext_mo.py +541 -0
- polyfile/kaitai/parsers/gif.py +492 -0
- polyfile/kaitai/parsers/gimp_brush.py +244 -0
- polyfile/kaitai/parsers/glibc_utmp.py +114 -0
- polyfile/kaitai/parsers/gltf_binary.py +132 -0
- polyfile/kaitai/parsers/google_protobuf.py +151 -0
- polyfile/kaitai/parsers/gpt_partition_table.py +175 -0
- polyfile/kaitai/parsers/gran_turismo_vol.py +140 -0
- polyfile/kaitai/parsers/grub2_font.py +337 -0
- polyfile/kaitai/parsers/gzip.py +232 -0
- polyfile/kaitai/parsers/hashcat_restore.py +60 -0
- polyfile/kaitai/parsers/hccap.py +111 -0
- polyfile/kaitai/parsers/hccapx.py +103 -0
- polyfile/kaitai/parsers/heaps_pak.py +177 -0
- polyfile/kaitai/parsers/heroes_of_might_and_magic_agg.py +116 -0
- polyfile/kaitai/parsers/heroes_of_might_and_magic_bmp.py +34 -0
- polyfile/kaitai/parsers/icmp_packet.py +136 -0
- polyfile/kaitai/parsers/ico.py +129 -0
- polyfile/kaitai/parsers/id3v1_1.py +220 -0
- polyfile/kaitai/parsers/id3v2_3.py +324 -0
- polyfile/kaitai/parsers/id3v2_4.py +423 -0
- polyfile/kaitai/parsers/ines.py +282 -0
- polyfile/kaitai/parsers/ipv4_packet.py +158 -0
- polyfile/kaitai/parsers/ipv6_packet.py +55 -0
- polyfile/kaitai/parsers/iso9660.py +544 -0
- polyfile/kaitai/parsers/java_class.py +1113 -0
- polyfile/kaitai/parsers/jpeg.py +361 -0
- polyfile/kaitai/parsers/luks.py +149 -0
- polyfile/kaitai/parsers/lzh.py +165 -0
- polyfile/kaitai/parsers/mac_os_resource_snd.py +493 -0
- polyfile/kaitai/parsers/mach_o.py +3033 -0
- polyfile/kaitai/parsers/mach_o_fat.py +92 -0
- polyfile/kaitai/parsers/magicavoxel_vox.py +391 -0
- polyfile/kaitai/parsers/manifest.json +1 -0
- polyfile/kaitai/parsers/mbr_partition_table.py +119 -0
- polyfile/kaitai/parsers/mcap.py +1015 -0
- polyfile/kaitai/parsers/microsoft_cfb.py +293 -0
- polyfile/kaitai/parsers/microsoft_network_monitor_v2.py +309 -0
- polyfile/kaitai/parsers/microsoft_pe.py +765 -0
- polyfile/kaitai/parsers/mifare_classic.py +706 -0
- polyfile/kaitai/parsers/minecraft_nbt.py +449 -0
- polyfile/kaitai/parsers/monomakh_sapr_chg.py +69 -0
- polyfile/kaitai/parsers/mozilla_mar.py +239 -0
- polyfile/kaitai/parsers/mp4.py +333 -0
- polyfile/kaitai/parsers/msgpack.py +467 -0
- polyfile/kaitai/parsers/nitf.py +1189 -0
- polyfile/kaitai/parsers/nt_mdt_pal.py +155 -0
- polyfile/kaitai/parsers/ogg.py +118 -0
- polyfile/kaitai/parsers/openpgp_message.py +993 -0
- polyfile/kaitai/parsers/packet_ppi.py +515 -0
- polyfile/kaitai/parsers/pcap.py +344 -0
- polyfile/kaitai/parsers/pcf_font.py +506 -0
- polyfile/kaitai/parsers/pcx.py +195 -0
- polyfile/kaitai/parsers/pcx_dcx.py +79 -0
- polyfile/kaitai/parsers/phar_without_stub.py +399 -0
- polyfile/kaitai/parsers/php_serialized_value.py +505 -0
- polyfile/kaitai/parsers/png.py +721 -0
- polyfile/kaitai/parsers/protocol_body.py +260 -0
- polyfile/kaitai/parsers/psx_tim.py +104 -0
- polyfile/kaitai/parsers/python_pickle.py +718 -0
- polyfile/kaitai/parsers/python_pyc_27.py +510 -0
- polyfile/kaitai/parsers/quake_mdl.py +441 -0
- polyfile/kaitai/parsers/quake_pak.py +112 -0
- polyfile/kaitai/parsers/quicktime_mov.py +634 -0
- polyfile/kaitai/parsers/rar.py +265 -0
- polyfile/kaitai/parsers/regf.py +569 -0
- polyfile/kaitai/parsers/renderware_binary_stream.py +877 -0
- polyfile/kaitai/parsers/resource_fork.py +611 -0
- polyfile/kaitai/parsers/respack.py +57 -0
- polyfile/kaitai/parsers/riff.py +409 -0
- polyfile/kaitai/parsers/rpm.py +964 -0
- polyfile/kaitai/parsers/rtcp_payload.py +579 -0
- polyfile/kaitai/parsers/rtp_packet.py +150 -0
- polyfile/kaitai/parsers/rtpdump.py +115 -0
- polyfile/kaitai/parsers/ruby_marshal.py +423 -0
- polyfile/kaitai/parsers/s3m.py +493 -0
- polyfile/kaitai/parsers/saints_row_2_vpp_pc.py +254 -0
- polyfile/kaitai/parsers/shapefile_index.py +174 -0
- polyfile/kaitai/parsers/shapefile_main.py +893 -0
- polyfile/kaitai/parsers/some_ip.py +209 -0
- polyfile/kaitai/parsers/some_ip_container.py +37 -0
- polyfile/kaitai/parsers/some_ip_sd.py +86 -0
- polyfile/kaitai/parsers/some_ip_sd_entries.py +160 -0
- polyfile/kaitai/parsers/some_ip_sd_options.py +374 -0
- polyfile/kaitai/parsers/specpr.py +404 -0
- polyfile/kaitai/parsers/sqlite3.py +472 -0
- polyfile/kaitai/parsers/ssh_public_key.py +252 -0
- polyfile/kaitai/parsers/standard_midi_file.py +390 -0
- polyfile/kaitai/parsers/stl.py +111 -0
- polyfile/kaitai/parsers/sudoers_ts.py +201 -0
- polyfile/kaitai/parsers/swf.py +406 -0
- polyfile/kaitai/parsers/systemd_journal.py +361 -0
- polyfile/kaitai/parsers/tcp_segment.py +57 -0
- polyfile/kaitai/parsers/tga.py +213 -0
- polyfile/kaitai/parsers/tls_client_hello.py +293 -0
- polyfile/kaitai/parsers/tr_dos_image.py +322 -0
- polyfile/kaitai/parsers/tsm.py +198 -0
- polyfile/kaitai/parsers/ttf.py +1847 -0
- polyfile/kaitai/parsers/udp_datagram.py +42 -0
- polyfile/kaitai/parsers/uefi_te.py +236 -0
- polyfile/kaitai/parsers/uimage.py +198 -0
- polyfile/kaitai/parsers/utf8_string.py +137 -0
- polyfile/kaitai/parsers/vfat.py +410 -0
- polyfile/kaitai/parsers/vlq_base128_be.py +104 -0
- polyfile/kaitai/parsers/vlq_base128_le.py +129 -0
- polyfile/kaitai/parsers/vmware_vmdk.py +167 -0
- polyfile/kaitai/parsers/vp8_ivf.py +112 -0
- polyfile/kaitai/parsers/warcraft_2_pud.py +423 -0
- polyfile/kaitai/parsers/wav.py +1014 -0
- polyfile/kaitai/parsers/websocket.py +167 -0
- polyfile/kaitai/parsers/windows_evt_log.py +304 -0
- polyfile/kaitai/parsers/windows_lnk_file.py +467 -0
- polyfile/kaitai/parsers/windows_minidump.py +575 -0
- polyfile/kaitai/parsers/windows_resource_file.py +243 -0
- polyfile/kaitai/parsers/windows_shell_items.py +190 -0
- polyfile/kaitai/parsers/windows_systemtime.py +52 -0
- polyfile/kaitai/parsers/wmf.py +502 -0
- polyfile/kaitai/parsers/xar.py +181 -0
- polyfile/kaitai/parsers/xwd.py +189 -0
- polyfile/kaitai/parsers/zip.py +685 -0
- polyfile/kaitai/parsers/zisofs.py +158 -0
- polyfile/kaitai/parsers/zx_spectrum_tap.py +184 -0
- polyfile/kaitaimatcher.py +113 -0
- polyfile/languagematcher.py +217 -0
- polyfile/logger.py +135 -0
- polyfile/magic.py +2983 -0
- polyfile/magic_defs/COPYING +29 -0
- polyfile/magic_defs/__init__.py +0 -0
- polyfile/magic_defs/acorn +102 -0
- polyfile/magic_defs/adi +13 -0
- polyfile/magic_defs/adventure +122 -0
- polyfile/magic_defs/aes +29 -0
- polyfile/magic_defs/algol68 +35 -0
- polyfile/magic_defs/allegro +9 -0
- polyfile/magic_defs/alliant +18 -0
- polyfile/magic_defs/alpha +32 -0
- polyfile/magic_defs/amanda +12 -0
- polyfile/magic_defs/amigaos +218 -0
- polyfile/magic_defs/android +259 -0
- polyfile/magic_defs/animation +1197 -0
- polyfile/magic_defs/aout +46 -0
- polyfile/magic_defs/apache +28 -0
- polyfile/magic_defs/apl +7 -0
- polyfile/magic_defs/apple +773 -0
- polyfile/magic_defs/application +7 -0
- polyfile/magic_defs/applix +13 -0
- polyfile/magic_defs/apt +52 -0
- polyfile/magic_defs/archive +2586 -0
- polyfile/magic_defs/aria +38 -0
- polyfile/magic_defs/arm +50 -0
- polyfile/magic_defs/asf +132 -0
- polyfile/magic_defs/assembler +18 -0
- polyfile/magic_defs/asterix +18 -0
- polyfile/magic_defs/att3b +41 -0
- polyfile/magic_defs/audio +1291 -0
- polyfile/magic_defs/avm +33 -0
- polyfile/magic_defs/basis +18 -0
- polyfile/magic_defs/beetle +7 -0
- polyfile/magic_defs/ber +65 -0
- polyfile/magic_defs/bflt +14 -0
- polyfile/magic_defs/bhl +10 -0
- polyfile/magic_defs/bioinformatics +178 -0
- polyfile/magic_defs/biosig +154 -0
- polyfile/magic_defs/blackberry +8 -0
- polyfile/magic_defs/blcr +25 -0
- polyfile/magic_defs/blender +50 -0
- polyfile/magic_defs/blit +24 -0
- polyfile/magic_defs/bm +10 -0
- polyfile/magic_defs/bout +11 -0
- polyfile/magic_defs/bsdi +33 -0
- polyfile/magic_defs/bsi +10 -0
- polyfile/magic_defs/btsnoop +13 -0
- polyfile/magic_defs/burp +7 -0
- polyfile/magic_defs/bytecode +41 -0
- polyfile/magic_defs/c-lang +110 -0
- polyfile/magic_defs/c64 +531 -0
- polyfile/magic_defs/cad +437 -0
- polyfile/magic_defs/cafebabe +107 -0
- polyfile/magic_defs/cbor +21 -0
- polyfile/magic_defs/ccf +14 -0
- polyfile/magic_defs/cddb +12 -0
- polyfile/magic_defs/chord +15 -0
- polyfile/magic_defs/cisco +12 -0
- polyfile/magic_defs/citrus +12 -0
- polyfile/magic_defs/clarion +27 -0
- polyfile/magic_defs/claris +48 -0
- polyfile/magic_defs/clipper +65 -0
- polyfile/magic_defs/clojure +30 -0
- polyfile/magic_defs/coff +98 -0
- polyfile/magic_defs/commands +201 -0
- polyfile/magic_defs/communications +22 -0
- polyfile/magic_defs/compress +461 -0
- polyfile/magic_defs/console +1213 -0
- polyfile/magic_defs/convex +69 -0
- polyfile/magic_defs/coverage +91 -0
- polyfile/magic_defs/cracklib +14 -0
- polyfile/magic_defs/crypto +31 -0
- polyfile/magic_defs/csv +8 -0
- polyfile/magic_defs/ctags +6 -0
- polyfile/magic_defs/ctf +23 -0
- polyfile/magic_defs/cubemap +8 -0
- polyfile/magic_defs/cups +56 -0
- polyfile/magic_defs/dact +11 -0
- polyfile/magic_defs/database +886 -0
- polyfile/magic_defs/dataone +47 -0
- polyfile/magic_defs/dbpf +15 -0
- polyfile/magic_defs/der +146 -0
- polyfile/magic_defs/diamond +12 -0
- polyfile/magic_defs/dif +33 -0
- polyfile/magic_defs/diff +41 -0
- polyfile/magic_defs/digital +59 -0
- polyfile/magic_defs/dolby +69 -0
- polyfile/magic_defs/dsf +25 -0
- polyfile/magic_defs/dump +96 -0
- polyfile/magic_defs/dwarfs +45 -0
- polyfile/magic_defs/dyadic +61 -0
- polyfile/magic_defs/ebml +8 -0
- polyfile/magic_defs/edid +11 -0
- polyfile/magic_defs/editors +43 -0
- polyfile/magic_defs/efi +15 -0
- polyfile/magic_defs/elf +379 -0
- polyfile/magic_defs/encore +22 -0
- polyfile/magic_defs/epoc +62 -0
- polyfile/magic_defs/erlang +21 -0
- polyfile/magic_defs/espressif +57 -0
- polyfile/magic_defs/esri +28 -0
- polyfile/magic_defs/etf +33 -0
- polyfile/magic_defs/fcs +9 -0
- polyfile/magic_defs/filesystems +2694 -0
- polyfile/magic_defs/finger +16 -0
- polyfile/magic_defs/firmware +133 -0
- polyfile/magic_defs/flash +62 -0
- polyfile/magic_defs/flif +36 -0
- polyfile/magic_defs/fonts +449 -0
- polyfile/magic_defs/forth +82 -0
- polyfile/magic_defs/fortran +9 -0
- polyfile/magic_defs/frame +62 -0
- polyfile/magic_defs/freebsd +164 -0
- polyfile/magic_defs/fsav +128 -0
- polyfile/magic_defs/fusecompress +12 -0
- polyfile/magic_defs/games +696 -0
- polyfile/magic_defs/gcc +17 -0
- polyfile/magic_defs/gconv +10 -0
- polyfile/magic_defs/gentoo +85 -0
- polyfile/magic_defs/geo +166 -0
- polyfile/magic_defs/geos +20 -0
- polyfile/magic_defs/gimp +77 -0
- polyfile/magic_defs/git +13 -0
- polyfile/magic_defs/glibc +21 -0
- polyfile/magic_defs/gnome +59 -0
- polyfile/magic_defs/gnu +173 -0
- polyfile/magic_defs/gnumeric +8 -0
- polyfile/magic_defs/gpt +240 -0
- polyfile/magic_defs/gpu +28 -0
- polyfile/magic_defs/grace +21 -0
- polyfile/magic_defs/graphviz +12 -0
- polyfile/magic_defs/gringotts +48 -0
- polyfile/magic_defs/guile +13 -0
- polyfile/magic_defs/hardware +12 -0
- polyfile/magic_defs/hitachi-sh +30 -0
- polyfile/magic_defs/hp +433 -0
- polyfile/magic_defs/human68k +26 -0
- polyfile/magic_defs/ibm370 +52 -0
- polyfile/magic_defs/ibm6000 +35 -0
- polyfile/magic_defs/icc +214 -0
- polyfile/magic_defs/iff +80 -0
- polyfile/magic_defs/images +4210 -0
- polyfile/magic_defs/inform +9 -0
- polyfile/magic_defs/intel +310 -0
- polyfile/magic_defs/interleaf +9 -0
- polyfile/magic_defs/island +10 -0
- polyfile/magic_defs/ispell +63 -0
- polyfile/magic_defs/isz +15 -0
- polyfile/magic_defs/java +52 -0
- polyfile/magic_defs/javascript +171 -0
- polyfile/magic_defs/jpeg +252 -0
- polyfile/magic_defs/json +8 -0
- polyfile/magic_defs/karma +9 -0
- polyfile/magic_defs/kde +11 -0
- polyfile/magic_defs/keepass +20 -0
- polyfile/magic_defs/kerberos +45 -0
- polyfile/magic_defs/kicad +85 -0
- polyfile/magic_defs/kml +34 -0
- polyfile/magic_defs/lammps +64 -0
- polyfile/magic_defs/lecter +6 -0
- polyfile/magic_defs/lex +12 -0
- polyfile/magic_defs/lif +50 -0
- polyfile/magic_defs/linux +557 -0
- polyfile/magic_defs/lisp +78 -0
- polyfile/magic_defs/llvm +22 -0
- polyfile/magic_defs/locoscript +12 -0
- polyfile/magic_defs/lua +31 -0
- polyfile/magic_defs/luks +126 -0
- polyfile/magic_defs/m4 +11 -0
- polyfile/magic_defs/mach +303 -0
- polyfile/magic_defs/macintosh +505 -0
- polyfile/magic_defs/macos +7 -0
- polyfile/magic_defs/magic +10 -0
- polyfile/magic_defs/magic.mgc +0 -0
- polyfile/magic_defs/mail.news +132 -0
- polyfile/magic_defs/make +21 -0
- polyfile/magic_defs/map +413 -0
- polyfile/magic_defs/maple +109 -0
- polyfile/magic_defs/marc21 +30 -0
- polyfile/magic_defs/mathcad +8 -0
- polyfile/magic_defs/mathematica +188 -0
- polyfile/magic_defs/matroska +17 -0
- polyfile/magic_defs/mcrypt +52 -0
- polyfile/magic_defs/measure +44 -0
- polyfile/magic_defs/mercurial +13 -0
- polyfile/magic_defs/metastore +8 -0
- polyfile/magic_defs/meteorological +53 -0
- polyfile/magic_defs/microfocus +21 -0
- polyfile/magic_defs/mime +9 -0
- polyfile/magic_defs/mips +120 -0
- polyfile/magic_defs/mirage +8 -0
- polyfile/magic_defs/misctools +140 -0
- polyfile/magic_defs/mkid +11 -0
- polyfile/magic_defs/mlssa +8 -0
- polyfile/magic_defs/mmdf +6 -0
- polyfile/magic_defs/modem +92 -0
- polyfile/magic_defs/modulefile +9 -0
- polyfile/magic_defs/motorola +71 -0
- polyfile/magic_defs/mozilla +37 -0
- polyfile/magic_defs/msdos +2304 -0
- polyfile/magic_defs/msooxml +68 -0
- polyfile/magic_defs/msvc +222 -0
- polyfile/magic_defs/msx +309 -0
- polyfile/magic_defs/mup +24 -0
- polyfile/magic_defs/music +17 -0
- polyfile/magic_defs/nasa +7 -0
- polyfile/magic_defs/natinst +24 -0
- polyfile/magic_defs/ncr +49 -0
- polyfile/magic_defs/neko +12 -0
- polyfile/magic_defs/netbsd +251 -0
- polyfile/magic_defs/netscape +26 -0
- polyfile/magic_defs/netware +11 -0
- polyfile/magic_defs/news +13 -0
- polyfile/magic_defs/nifty +202 -0
- polyfile/magic_defs/nim-lang +29 -0
- polyfile/magic_defs/nitpicker +14 -0
- polyfile/magic_defs/numpy +9 -0
- polyfile/magic_defs/oasis +12 -0
- polyfile/magic_defs/ocaml +14 -0
- polyfile/magic_defs/octave +6 -0
- polyfile/magic_defs/ole2compounddocs +760 -0
- polyfile/magic_defs/olf +98 -0
- polyfile/magic_defs/openfst +17 -0
- polyfile/magic_defs/opentimestamps +16 -0
- polyfile/magic_defs/oric +16 -0
- polyfile/magic_defs/os2 +186 -0
- polyfile/magic_defs/os400 +39 -0
- polyfile/magic_defs/os9 +80 -0
- polyfile/magic_defs/osf1 +10 -0
- polyfile/magic_defs/palm +156 -0
- polyfile/magic_defs/parix +13 -0
- polyfile/magic_defs/parrot +22 -0
- polyfile/magic_defs/pascal +39 -0
- polyfile/magic_defs/pbf +11 -0
- polyfile/magic_defs/pbm +8 -0
- polyfile/magic_defs/pc88 +24 -0
- polyfile/magic_defs/pc98 +77 -0
- polyfile/magic_defs/pci_ids +116 -0
- polyfile/magic_defs/pcjr +8 -0
- polyfile/magic_defs/pdf +51 -0
- polyfile/magic_defs/pdp +42 -0
- polyfile/magic_defs/perl +100 -0
- polyfile/magic_defs/pgf +52 -0
- polyfile/magic_defs/pgp +581 -0
- polyfile/magic_defs/pgp-binary-keys +388 -0
- polyfile/magic_defs/pkgadd +7 -0
- polyfile/magic_defs/plan9 +25 -0
- polyfile/magic_defs/playdate +57 -0
- polyfile/magic_defs/plus5 +18 -0
- polyfile/magic_defs/pmem +46 -0
- polyfile/magic_defs/polyfile_zip +5 -0
- polyfile/magic_defs/polyml +23 -0
- polyfile/magic_defs/printer +269 -0
- polyfile/magic_defs/project +10 -0
- polyfile/magic_defs/psdbms +14 -0
- polyfile/magic_defs/psl +14 -0
- polyfile/magic_defs/pulsar +13 -0
- polyfile/magic_defs/puzzle +17 -0
- polyfile/magic_defs/pwsafe +14 -0
- polyfile/magic_defs/pyramid +12 -0
- polyfile/magic_defs/python +305 -0
- polyfile/magic_defs/qt +30 -0
- polyfile/magic_defs/revision +66 -0
- polyfile/magic_defs/riff +840 -0
- polyfile/magic_defs/rinex +44 -0
- polyfile/magic_defs/ringdove +45 -0
- polyfile/magic_defs/rpi +52 -0
- polyfile/magic_defs/rpm +45 -0
- polyfile/magic_defs/rpmsg +7 -0
- polyfile/magic_defs/rst +11 -0
- polyfile/magic_defs/rtf +94 -0
- polyfile/magic_defs/ruby +55 -0
- polyfile/magic_defs/rust +21 -0
- polyfile/magic_defs/sc +7 -0
- polyfile/magic_defs/sccs +24 -0
- polyfile/magic_defs/scientific +144 -0
- polyfile/magic_defs/securitycerts +6 -0
- polyfile/magic_defs/selinux +24 -0
- polyfile/magic_defs/sendmail +37 -0
- polyfile/magic_defs/sequent +42 -0
- polyfile/magic_defs/sereal +35 -0
- polyfile/magic_defs/sgi +144 -0
- polyfile/magic_defs/sgml +161 -0
- polyfile/magic_defs/sharc +23 -0
- polyfile/magic_defs/sinclair +40 -0
- polyfile/magic_defs/sisu +18 -0
- polyfile/magic_defs/sketch +6 -0
- polyfile/magic_defs/smalltalk +25 -0
- polyfile/magic_defs/smile +34 -0
- polyfile/magic_defs/sniffer +482 -0
- polyfile/magic_defs/softquad +40 -0
- polyfile/magic_defs/sosi +40 -0
- polyfile/magic_defs/spec +21 -0
- polyfile/magic_defs/spectrum +184 -0
- polyfile/magic_defs/sql +288 -0
- polyfile/magic_defs/ssh +39 -0
- polyfile/magic_defs/ssl +20 -0
- polyfile/magic_defs/statistics +45 -0
- polyfile/magic_defs/subtitle +38 -0
- polyfile/magic_defs/sun +141 -0
- polyfile/magic_defs/svf +5 -0
- polyfile/magic_defs/sylk +36 -0
- polyfile/magic_defs/symbos +42 -0
- polyfile/magic_defs/sysex +429 -0
- polyfile/magic_defs/tcl +29 -0
- polyfile/magic_defs/teapot +6 -0
- polyfile/magic_defs/terminfo +63 -0
- polyfile/magic_defs/tex +141 -0
- polyfile/magic_defs/tgif +7 -0
- polyfile/magic_defs/ti-8x +239 -0
- polyfile/magic_defs/timezone +42 -0
- polyfile/magic_defs/tplink +95 -0
- polyfile/magic_defs/troff +38 -0
- polyfile/magic_defs/tuxedo +8 -0
- polyfile/magic_defs/typeset +8 -0
- polyfile/magic_defs/uf2 +72 -0
- polyfile/magic_defs/unicode +15 -0
- polyfile/magic_defs/unisig +12 -0
- polyfile/magic_defs/unknown +34 -0
- polyfile/magic_defs/usd +21 -0
- polyfile/magic_defs/uterus +16 -0
- polyfile/magic_defs/uuencode +28 -0
- polyfile/magic_defs/vacuum-cleaner +54 -0
- polyfile/magic_defs/varied.out +46 -0
- polyfile/magic_defs/varied.script +21 -0
- polyfile/magic_defs/vax +32 -0
- polyfile/magic_defs/vicar +17 -0
- polyfile/magic_defs/virtual +307 -0
- polyfile/magic_defs/virtutech +12 -0
- polyfile/magic_defs/visx +32 -0
- polyfile/magic_defs/vms +30 -0
- polyfile/magic_defs/vmware +6 -0
- polyfile/magic_defs/vorbis +155 -0
- polyfile/magic_defs/vxl +14 -0
- polyfile/magic_defs/warc +16 -0
- polyfile/magic_defs/weak +16 -0
- polyfile/magic_defs/web +18 -0
- polyfile/magic_defs/webassembly +17 -0
- polyfile/magic_defs/windows +1811 -0
- polyfile/magic_defs/wireless +7 -0
- polyfile/magic_defs/wordprocessors +630 -0
- polyfile/magic_defs/wsdl +23 -0
- polyfile/magic_defs/x68000 +25 -0
- polyfile/magic_defs/xdelta +13 -0
- polyfile/magic_defs/xenix +106 -0
- polyfile/magic_defs/xilinx +58 -0
- polyfile/magic_defs/xo65 +37 -0
- polyfile/magic_defs/xwindows +43 -0
- polyfile/magic_defs/yara +17 -0
- polyfile/magic_defs/zfs +96 -0
- polyfile/magic_defs/zilog +12 -0
- polyfile/magic_defs/zip +126 -0
- polyfile/magic_defs/zyxel +17 -0
- polyfile/nes.py +144 -0
- polyfile/nitf.py +15 -0
- polyfile/pdf.py +1264 -0
- polyfile/pickles.py +45 -0
- polyfile/polyfile.py +409 -0
- polyfile/profiling.py +115 -0
- polyfile/repl.py +624 -0
- polyfile/search.py +310 -0
- polyfile/serialization.py +323 -0
- polyfile/structmatcher.py +46 -0
- polyfile/structs.py +281 -0
- polyfile/templates/download.js +162 -0
- polyfile/templates/hexdump.css +268 -0
- polyfile/templates/hexdump.js +756 -0
- polyfile/templates/jquery-3.4.1.min.js +2 -0
- polyfile/templates/template.html +119 -0
- polyfile/wildcards.py +62 -0
- polyfile/zipmatcher.py +183 -0
- polyfile_weave-0.5.5.dist-info/METADATA +173 -0
- polyfile_weave-0.5.5.dist-info/RECORD +585 -0
- polyfile_weave-0.5.5.dist-info/WHEEL +5 -0
- polyfile_weave-0.5.5.dist-info/entry_points.txt +2 -0
- polyfile_weave-0.5.5.dist-info/licenses/LICENSE +202 -0
- polyfile_weave-0.5.5.dist-info/top_level.txt +2 -0
- polymerge/__init__.py +1 -0
- polymerge/__main__.py +296 -0
- polymerge/cfg.py +127 -0
- polymerge/polymerge.py +227 -0
- polymerge/polytracker.py +190 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
polymerge/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .polymerge import merge
|
polymerge/__main__.py
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
import logging
|
|
4
|
+
import shutil
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from argparse import RawTextHelpFormatter
|
|
8
|
+
from functools import reduce
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
import cxxfilt
|
|
12
|
+
except ModuleNotFoundError:
|
|
13
|
+
cxxfilt = None
|
|
14
|
+
|
|
15
|
+
from intervaltree import IntervalTree
|
|
16
|
+
|
|
17
|
+
from polyfile import logger, __version__
|
|
18
|
+
|
|
19
|
+
from .polymerge import merge, polyfile_type_graph
|
|
20
|
+
from . import polytracker
|
|
21
|
+
|
|
22
|
+
log = logger.getStatusLogger("PolyMerge")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def parse_dataflow_ranges(dataflow):
|
|
26
|
+
dataflow_ranges = None
|
|
27
|
+
|
|
28
|
+
dataflow_from_start = None
|
|
29
|
+
dataflow_to_end = None
|
|
30
|
+
|
|
31
|
+
if dataflow is None:
|
|
32
|
+
return dataflow_from_start, dataflow_to_end, dataflow_ranges
|
|
33
|
+
|
|
34
|
+
for dataflow_range in dataflow:
|
|
35
|
+
parts = dataflow_range.split(':')
|
|
36
|
+
if len(parts) > 2:
|
|
37
|
+
raise ValueError(f"Error: Invalid dataflow range {dataflow_range!r}")
|
|
38
|
+
elif len(parts) == 1:
|
|
39
|
+
start = parts[0]
|
|
40
|
+
end = None
|
|
41
|
+
else:
|
|
42
|
+
start, end = parts
|
|
43
|
+
if start:
|
|
44
|
+
try:
|
|
45
|
+
start = int(start)
|
|
46
|
+
except ValueError:
|
|
47
|
+
raise ValueError(f"Error: Invalid dataflow range start {dataflow_range!r}")
|
|
48
|
+
else:
|
|
49
|
+
start = None
|
|
50
|
+
had_end = False
|
|
51
|
+
if end is not None:
|
|
52
|
+
if end:
|
|
53
|
+
try:
|
|
54
|
+
end = int(end)
|
|
55
|
+
except ValueError:
|
|
56
|
+
raise ValueError(f"Error: Invalid dataflow range end {dataflow_range!r}")
|
|
57
|
+
else:
|
|
58
|
+
had_end = True
|
|
59
|
+
end = None
|
|
60
|
+
if start is not None and end is not None:
|
|
61
|
+
# "start:end"
|
|
62
|
+
if start >= end:
|
|
63
|
+
raise ValueError(f"Error: Dataflow range start must be less than end in {dataflow_range}")
|
|
64
|
+
if dataflow_ranges is None:
|
|
65
|
+
dataflow_ranges = IntervalTree()
|
|
66
|
+
dataflow_ranges[start:end] = True
|
|
67
|
+
elif start is not None:
|
|
68
|
+
if had_end:
|
|
69
|
+
# "start:"
|
|
70
|
+
if dataflow_to_end is None:
|
|
71
|
+
dataflow_to_end = start
|
|
72
|
+
else:
|
|
73
|
+
dataflow_to_end = min(dataflow_to_end, start)
|
|
74
|
+
else:
|
|
75
|
+
# "offset"
|
|
76
|
+
if dataflow_ranges is None:
|
|
77
|
+
dataflow_ranges = IntervalTree()
|
|
78
|
+
dataflow_ranges[start:start+1] = True
|
|
79
|
+
elif end is not None:
|
|
80
|
+
# ":end"
|
|
81
|
+
if dataflow_from_start is None:
|
|
82
|
+
dataflow_from_start = end
|
|
83
|
+
else:
|
|
84
|
+
dataflow_from_start = max(dataflow_from_start, end)
|
|
85
|
+
elif had_end:
|
|
86
|
+
# ":"
|
|
87
|
+
dataflow_to_end = 0
|
|
88
|
+
|
|
89
|
+
return dataflow_from_start, dataflow_to_end, dataflow_ranges
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def main(argv=None):
|
|
93
|
+
parser = argparse.ArgumentParser(description='''A utility to merge the JSON output of `polyfile`
|
|
94
|
+
with a polytracker.json file from PolyTracker.
|
|
95
|
+
|
|
96
|
+
https://github.com/trailofbits/polyfile/
|
|
97
|
+
https://github.com/trailofbits/polytracker/
|
|
98
|
+
''', formatter_class=RawTextHelpFormatter)
|
|
99
|
+
parser.add_argument('FILES', type=argparse.FileType('r'), nargs='+', help='Path to the PolyFile JSON output and/or the PolyTracker JSON output. Merging will only occur if both files are provided. The `--cfg` and `--type-hierarchy` options can be used if only a single file is provided, but no merging will occur.')
|
|
100
|
+
parser.add_argument('--cfg', '-c', type=str, default=None, help='Optional path to output a Graphviz .dot file representing the control flow graph of the program trace')
|
|
101
|
+
parser.add_argument('--cfg-pdf', '-p', type=str, default=None, help='Similar to --cfg, but renders the graph to a PDF instead of outputting the .dot source')
|
|
102
|
+
parser.add_argument('--dataflow', type=str, nargs='*', help='For the CFG generation options, only render functions that participated in dataflow. `--dataflow 10` means that only functions in the dataflow related to byte 10 should be included. `--dataflow 10:30` means that only functions operating on bytes 10 through 29 should be included. The beginning or end of a range can be omitted and will default to the beginning and end of the file, respectively. Multiple `--dataflow` ranges can be specified. `--dataflow :` will render the CFG only with functions that operated on tainted bytes. Omitting `--dataflow` will produce a CFG containing all functions.')
|
|
103
|
+
parser.add_argument('--no-intermediate-functions', action='store_true', help='To be used in conjunction with `--dataflow`. If enabled, only functions in the dataflow graph if they operated on the tainted bytes. This can result in a disjoint dataflow graph.')
|
|
104
|
+
parser.add_argument('--demangle', action='store_true', help='Demangle C++ function names in the CFG (requires that PolyFile was installed with the `demangle` option, or that the `cxxfilt` Python module is installed.)')
|
|
105
|
+
parser.add_argument('--type-hierarchy', '-t', type=str, default=None, help='Optional path to output a Graphviz .dot file representing the type hierarchy extracted from PolyFile')
|
|
106
|
+
parser.add_argument('--type-hierarchy-pdf', '-y', type=str, default=None, help='Similar to --type-hierarchy, but renders the graph to a PDF instead of outputting the .dot source')
|
|
107
|
+
parser.add_argument('--diff', type=argparse.FileType('r'), nargs='*', help='Diff an arbitrary number of input polytracker.json files, all treated as the same class, against one or more polytracker.json provided after `--diff` arguments')
|
|
108
|
+
parser.add_argument('--debug', '-d', action='store_true', help='Print debug information')
|
|
109
|
+
parser.add_argument('--quiet', '-q', action='store_true', help='Suppress all log output (overrides --debug)')
|
|
110
|
+
parser.add_argument('--version', '-v',
|
|
111
|
+
action='version',
|
|
112
|
+
version=f"PolyMerge version {__version__}\n",
|
|
113
|
+
help='Print PolyMerge\'s version information and exit'
|
|
114
|
+
)
|
|
115
|
+
parser.add_argument('-dumpversion',
|
|
116
|
+
action='version',
|
|
117
|
+
version=__version__,
|
|
118
|
+
help='Print PolyMerge\'s raw version information and exit'
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
if argv is None:
|
|
122
|
+
argv = sys.argv
|
|
123
|
+
|
|
124
|
+
args = parser.parse_args(argv[1:])
|
|
125
|
+
|
|
126
|
+
if args.debug:
|
|
127
|
+
logger.setLevel(logging.DEBUG)
|
|
128
|
+
elif args.quiet:
|
|
129
|
+
logger.setLevel(logging.CRITICAL)
|
|
130
|
+
else:
|
|
131
|
+
logger.setLevel(logger.STATUS)
|
|
132
|
+
|
|
133
|
+
build_cfg = args.cfg is not None or args.cfg_pdf is not None
|
|
134
|
+
built_type_hierarchy = args.type_hierarchy is not None or args.type_hierarchy_pdf is not None
|
|
135
|
+
|
|
136
|
+
if len(args.diff) > 0:
|
|
137
|
+
input_program_traces = [polytracker.parse(json.load(diff_file)) for diff_file in args.FILES]
|
|
138
|
+
program_traces_to_diff = [polytracker.parse(json.load(diff_file)) for diff_file in args.diff]
|
|
139
|
+
|
|
140
|
+
def labeler(funcname):
|
|
141
|
+
if args.demangle:
|
|
142
|
+
if funcname.startswith('dfs$'):
|
|
143
|
+
funcname = funcname[4:]
|
|
144
|
+
return cxxfilt.demangle(funcname)
|
|
145
|
+
else:
|
|
146
|
+
return funcname
|
|
147
|
+
|
|
148
|
+
first_funcs = None
|
|
149
|
+
for f in input_program_traces:
|
|
150
|
+
fnames = set(labeler(fname) for fname in f.functions.keys())
|
|
151
|
+
if first_funcs is None:
|
|
152
|
+
first_funcs = fnames
|
|
153
|
+
else:
|
|
154
|
+
first_funcs &= fnames
|
|
155
|
+
|
|
156
|
+
second_funcs = None
|
|
157
|
+
for f in input_program_traces:
|
|
158
|
+
fnames = set(labeler(fname) for fname in f.functions.keys())
|
|
159
|
+
if second_funcs is None:
|
|
160
|
+
second_funcs = fnames
|
|
161
|
+
else:
|
|
162
|
+
second_funcs &= fnames
|
|
163
|
+
|
|
164
|
+
print('\n'.join(second_funcs ^ first_funcs))
|
|
165
|
+
exit(0)
|
|
166
|
+
|
|
167
|
+
if len(args.FILES) == 1:
|
|
168
|
+
if build_cfg and built_type_hierarchy:
|
|
169
|
+
parser.print_help()
|
|
170
|
+
sys.stderr.write('\n')
|
|
171
|
+
log.critical("Error: Two input files (PolyFile, PolyTracker) are required when both `--cfg` and `--type-hierarchy` options are enabled.")
|
|
172
|
+
parser.exit()
|
|
173
|
+
elif build_cfg:
|
|
174
|
+
polyfile_json_file = None
|
|
175
|
+
polytracker_json_file = args.FILES[0]
|
|
176
|
+
elif built_type_hierarchy:
|
|
177
|
+
polyfile_json_file = args.FILES[0]
|
|
178
|
+
polytracker_json_file = None
|
|
179
|
+
else:
|
|
180
|
+
return 0
|
|
181
|
+
elif len(args.FILES) != 2:
|
|
182
|
+
parser.print_help()
|
|
183
|
+
sys.stderr.write('\n')
|
|
184
|
+
log.critical("Error: Expected at most two input files")
|
|
185
|
+
parser.exit()
|
|
186
|
+
else:
|
|
187
|
+
polyfile_json_file = args.FILES[0]
|
|
188
|
+
polytracker_json_file = args.FILES[1]
|
|
189
|
+
|
|
190
|
+
if build_cfg and args.demangle and cxxfilt is None:
|
|
191
|
+
log.critical("Error: The `cxxfilt` package is not installed. Either reinstall PolyFile with the `demangle` option enabled, or run `pip3 install cxxfilt`.")
|
|
192
|
+
parser.exit()
|
|
193
|
+
|
|
194
|
+
try:
|
|
195
|
+
dataflow_from_start, dataflow_to_end, dataflow_ranges = parse_dataflow_ranges(args.dataflow)
|
|
196
|
+
except ValueError as e:
|
|
197
|
+
parser.print_help()
|
|
198
|
+
sys.stderr.write('\n')
|
|
199
|
+
log.critical(f"Error: {e!s}")
|
|
200
|
+
parser.exit()
|
|
201
|
+
|
|
202
|
+
if polyfile_json_file is not None:
|
|
203
|
+
polyfile_json = json.load(polyfile_json_file)
|
|
204
|
+
polyfile_json_file.close()
|
|
205
|
+
else:
|
|
206
|
+
polyfile_json = None
|
|
207
|
+
if polytracker_json_file is not None:
|
|
208
|
+
program_trace = polytracker.parse(json.load(polytracker_json_file))
|
|
209
|
+
polytracker_json_file.close()
|
|
210
|
+
else:
|
|
211
|
+
program_trace = None
|
|
212
|
+
|
|
213
|
+
if polyfile_json is not None and program_trace is not None:
|
|
214
|
+
merged = merge(polyfile_json, program_trace)
|
|
215
|
+
print(json.dumps(merged))
|
|
216
|
+
|
|
217
|
+
if build_cfg:
|
|
218
|
+
log.status("Reconstructing the runtime control flow graph...")
|
|
219
|
+
cfg = program_trace.cfg
|
|
220
|
+
|
|
221
|
+
def labeler(f):
|
|
222
|
+
if args.demangle:
|
|
223
|
+
funcname = f.name
|
|
224
|
+
if funcname.startswith('dfs$'):
|
|
225
|
+
funcname = funcname[4:]
|
|
226
|
+
return cxxfilt.demangle(funcname)
|
|
227
|
+
else:
|
|
228
|
+
return f.name
|
|
229
|
+
|
|
230
|
+
if dataflow_from_start is not None or dataflow_to_end is not None or dataflow_ranges is not None:
|
|
231
|
+
dataflow_functions = set()
|
|
232
|
+
for f in program_trace.functions.values():
|
|
233
|
+
check_more = False
|
|
234
|
+
for offsets in f.input_bytes.values():
|
|
235
|
+
for offset in offsets:
|
|
236
|
+
if (dataflow_to_end is not None and offset >= dataflow_to_end) \
|
|
237
|
+
or (dataflow_from_start is not None and offset < dataflow_from_start) \
|
|
238
|
+
or (dataflow_ranges is not None and dataflow_ranges[offset]):
|
|
239
|
+
dataflow_functions.add(f)
|
|
240
|
+
break
|
|
241
|
+
else:
|
|
242
|
+
check_more = True
|
|
243
|
+
if not check_more:
|
|
244
|
+
break
|
|
245
|
+
else:
|
|
246
|
+
log.debug(f"Function {f!r} did not operate on any tainted bytes")
|
|
247
|
+
if not args.no_intermediate_functions:
|
|
248
|
+
# add all functions that have both an ancestor and descendant
|
|
249
|
+
# in the dominator tree that's also in in dataflow_functions
|
|
250
|
+
doms = program_trace.cfg.dominator_forest
|
|
251
|
+
orig_functions = frozenset(dataflow_functions)
|
|
252
|
+
for f in program_trace.functions.values():
|
|
253
|
+
if f in orig_functions:
|
|
254
|
+
continue
|
|
255
|
+
if doms.ancestors(f).intersection(orig_functions) \
|
|
256
|
+
and doms.descendants(f).intersection(orig_functions):
|
|
257
|
+
log.debug(f"Adding intermediate function {f.name} to the dataflow graph")
|
|
258
|
+
dataflow_functions.add(f)
|
|
259
|
+
|
|
260
|
+
node_filter = lambda func: func in dataflow_functions
|
|
261
|
+
else:
|
|
262
|
+
node_filter = None
|
|
263
|
+
|
|
264
|
+
dot = cfg.to_dot(labeler=labeler, node_filter=node_filter)#(merged_json_obj=merged)
|
|
265
|
+
log.clear_status()
|
|
266
|
+
if args.cfg is not None:
|
|
267
|
+
with open(args.cfg, 'w') as cfg_file:
|
|
268
|
+
cfg_file.write(dot.source)
|
|
269
|
+
log.info(f"Saved CFG .dot graph to {args.cfg}")
|
|
270
|
+
if args.cfg_pdf is not None:
|
|
271
|
+
log.status("Rendering the runtime CFG to a PDF...")
|
|
272
|
+
rendered_path = dot.render(args.cfg_pdf, cleanup=True)
|
|
273
|
+
log.clear_status()
|
|
274
|
+
if rendered_path != args.cfg_pdf:
|
|
275
|
+
shutil.move(rendered_path, args.cfg_pdf)
|
|
276
|
+
log.info(f"Saved CFG graph PDF to {args.cfg_pdf}")
|
|
277
|
+
|
|
278
|
+
if built_type_hierarchy:
|
|
279
|
+
log.status("Building the input file type hierarchy...")
|
|
280
|
+
type_dominators: cfg.DAG = polyfile_type_graph(polyfile_json).dominator_forest
|
|
281
|
+
dot = type_dominators.to_dot()
|
|
282
|
+
if args.type_hierarchy:
|
|
283
|
+
with open(args.type_hierarchy, 'w') as dot_file:
|
|
284
|
+
dot_file.write(dot.source)
|
|
285
|
+
log.info(f"Saved type hierarchy .dot graph to {args.type_hierarchy}")
|
|
286
|
+
if args.type_hierarchy_pdf is not None:
|
|
287
|
+
log.status("Rendering the type hierarchy to a PDF...")
|
|
288
|
+
rendered_path = dot.render(args.type_hierarchy_pdf, cleanup=True)
|
|
289
|
+
log.clear_status()
|
|
290
|
+
if rendered_path != args.type_hierarchy_pdf:
|
|
291
|
+
shutil.move(rendered_path, args.type_hierarchy_pdf)
|
|
292
|
+
log.info(f"Saved type hierarchy PDF to {args.type_hierarchy_pdf}")
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
if __name__ == '__main__':
|
|
296
|
+
main()
|
polymerge/cfg.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
import graphviz
|
|
4
|
+
import networkx as nx
|
|
5
|
+
|
|
6
|
+
from . import polymerge, polytracker
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def roots(graph):
|
|
10
|
+
return (n for n, d in graph.in_degree() if d == 0)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DiGraph(nx.DiGraph):
|
|
14
|
+
def __init__(self, *args, **kwargs):
|
|
15
|
+
super().__init__(*args, **kwargs)
|
|
16
|
+
self._dominator_forest: DiGraph = None
|
|
17
|
+
self._roots = None
|
|
18
|
+
self._path_lengths = None
|
|
19
|
+
|
|
20
|
+
def path_length(self, from_node, to_node):
|
|
21
|
+
if self._path_lengths is None:
|
|
22
|
+
self._path_lengths = dict(nx.all_pairs_shortest_path_length(self, cutoff=None))
|
|
23
|
+
if from_node not in self._path_lengths or to_node not in self._path_lengths[from_node]:
|
|
24
|
+
return math.inf
|
|
25
|
+
else:
|
|
26
|
+
return self._path_lengths[from_node][to_node]
|
|
27
|
+
|
|
28
|
+
def set_roots(self, roots):
|
|
29
|
+
self._roots = roots
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def roots(self):
|
|
33
|
+
if self._roots is None:
|
|
34
|
+
self._roots = tuple(roots(self))
|
|
35
|
+
return self._roots
|
|
36
|
+
|
|
37
|
+
def depth(self, node):
|
|
38
|
+
return min(self.path_length(root, node) for root in self.roots)
|
|
39
|
+
|
|
40
|
+
def ancestors(self, node) -> set:
|
|
41
|
+
return nx.ancestors(self, node)
|
|
42
|
+
|
|
43
|
+
def descendants(self, node) -> frozenset:
|
|
44
|
+
return frozenset(nx.dfs_successors(self, node).keys())
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def dominator_forest(self):
|
|
48
|
+
if self._dominator_forest is not None:
|
|
49
|
+
return self._dominator_forest
|
|
50
|
+
self._dominator_forest = DAG()
|
|
51
|
+
for root in self.roots:
|
|
52
|
+
for node, dominated_by in nx.immediate_dominators(self, root).items():
|
|
53
|
+
if node != dominated_by:
|
|
54
|
+
self._dominator_forest.add_edge(dominated_by, node)
|
|
55
|
+
return self._dominator_forest
|
|
56
|
+
|
|
57
|
+
def to_dot(self, comment: str = None, labeler=str, node_filter=None) -> graphviz.Digraph:
|
|
58
|
+
if comment is not None:
|
|
59
|
+
dot = graphviz.Digraph(comment=comment)
|
|
60
|
+
else:
|
|
61
|
+
dot = graphviz.Digraph()
|
|
62
|
+
node_ids = {node: i for i, node in enumerate(self.nodes)}
|
|
63
|
+
for node in self.nodes:
|
|
64
|
+
if node_filter is None or node_filter(node):
|
|
65
|
+
dot.node(f'func{node_ids[node]}', label=labeler(node))
|
|
66
|
+
for caller, callee in self.edges:
|
|
67
|
+
if node_filter is None or (node_filter(caller) and node_filter(callee)):
|
|
68
|
+
dot.edge(f'func{node_ids[caller]}', f'func{node_ids[callee]}')
|
|
69
|
+
return dot
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class DAG(DiGraph):
|
|
73
|
+
def vertex_induced_subgraph(self, vertices):
|
|
74
|
+
vertices = frozenset(vertices)
|
|
75
|
+
subgraph = self.copy()
|
|
76
|
+
to_remove = set(self.nodes) - vertices
|
|
77
|
+
for v in vertices:
|
|
78
|
+
node = v
|
|
79
|
+
parent = None
|
|
80
|
+
while True:
|
|
81
|
+
parents = tuple(subgraph.predecessors(node))
|
|
82
|
+
if not parents:
|
|
83
|
+
if parent is not None:
|
|
84
|
+
subgraph.remove_edge(parent, v)
|
|
85
|
+
subgraph.add_edge(node, v)
|
|
86
|
+
break
|
|
87
|
+
assert len(parents) == 1
|
|
88
|
+
ancestor = parents[0]
|
|
89
|
+
if parent is None:
|
|
90
|
+
parent = ancestor
|
|
91
|
+
if ancestor in vertices:
|
|
92
|
+
to_remove.add(v)
|
|
93
|
+
break
|
|
94
|
+
node = ancestor
|
|
95
|
+
subgraph.remove_nodes_from(to_remove)
|
|
96
|
+
return subgraph
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class CFG(DiGraph):
|
|
100
|
+
def __init__(self, trace):
|
|
101
|
+
super().__init__()
|
|
102
|
+
self.trace: polytracker.ProgramTrace = trace
|
|
103
|
+
|
|
104
|
+
def to_dot(self,
|
|
105
|
+
comment='PolyTracker Program Trace',
|
|
106
|
+
merged_json_obj=None,
|
|
107
|
+
only_labeled_functions=False,
|
|
108
|
+
labeler=None,
|
|
109
|
+
**kwargs
|
|
110
|
+
) -> graphviz.Digraph:
|
|
111
|
+
if merged_json_obj is not None:
|
|
112
|
+
function_labels = {
|
|
113
|
+
func_name: ', '.join(['::'.join(label) for label in labels])
|
|
114
|
+
for func_name, labels in polymerge.function_labels(merged_json_obj).items()
|
|
115
|
+
}
|
|
116
|
+
else:
|
|
117
|
+
function_labels = {}
|
|
118
|
+
|
|
119
|
+
def func_labeler(f):
|
|
120
|
+
if labeler is not None:
|
|
121
|
+
return labeler(f)
|
|
122
|
+
elif f.name in function_labels:
|
|
123
|
+
return f"{f.name} ({function_labels[f.name]})"
|
|
124
|
+
else:
|
|
125
|
+
return f.name
|
|
126
|
+
|
|
127
|
+
return super().to_dot(comment, labeler=func_labeler, **kwargs)
|