Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP packet fragmentation support #1212

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ add_subdirectory(ArpSpoofing)
add_subdirectory(DNSResolver)
add_subdirectory(DnsSpoofing)
add_subdirectory(HttpAnalyzer)
add_subdirectory(HttpReassembler)
add_subdirectory(IcmpFileTransfer)
add_subdirectory(IPDefragUtil)
add_subdirectory(IPFragUtil)
Expand Down
17 changes: 17 additions & 0 deletions Examples/HttpReassembler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
add_executable(HttpReassembler main.cpp)

target_link_libraries(HttpReassembler PUBLIC PcapPlusPlus::Pcap++)

if(MSVC)
# This executable requires getopt.h not available on VStudio
target_link_libraries(HttpReassembler PRIVATE Getopt-for-Visual-Studio)
endif()

set_target_properties(HttpReassembler PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PCAPPP_BINARY_EXAMPLES_DIR}")

if(PCAPPP_INSTALL)
install(
TARGETS HttpReassembler
EXPORT PcapPlusPlusTargets
RUNTIME DESTINATION ${PCAPPP_INSTALL_BINDIR})
endif()
14 changes: 14 additions & 0 deletions Examples/HttpReassembler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
HTTP Traffic Analyzer
=====================

This application reassembless HTTP 1.x packets and generate a file from the payload. It read packets from a pcap/pcap-ng file.

Using the utility (Work In Progress)
-----------------
When extracting HTTP traffic payload a pcap/pcap-ng file:

Basic usage:
HttpAnalyzer [-h] -f input_file
Options:
-f : The input pcap file to analyze. Required argument for this mode
-h : Displays this help message and exits
86 changes: 86 additions & 0 deletions Examples/HttpReassembler/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* HttpReassembler application
* ========================
* This application reassembles HTTP payloads from captured packets as a text file.
*/

#include <iostream>
#include <getopt.h>
#include "PcapPlusPlusVersion.h"
#include "SystemUtils.h"

#define EXIT_WITH_ERROR(reason) do { \
printUsage(); \
std::cout << std::endl << "ERROR: " << reason << std::endl << std::endl; \
exit(1); \
} while(0)

static struct option HttpReassemblerOptions[] =
{
{"help", no_argument, nullptr, 'h'},
{"version", no_argument, nullptr, 'v'}
};

/**
* Print application usage
*/
void printUsage()
{
std::cout << std::endl
<< "Usage:" << std::endl
<< "----------------------" << std::endl
<< pcpp::AppName::get() << " [-vh]" << std::endl
<< std::endl
<< "Options:" << std::endl
<< std::endl
<< " -v : Displays the current version and exists" << std::endl
<< " -h : Displays this help message and exits" << std::endl
<< std::endl;
}

/**
* Print application version
*/
void printAppVersion()
{
std::cout
<< pcpp::AppName::get() << " " << pcpp::getPcapPlusPlusVersionFull() << std::endl
<< "Built: " << pcpp::getBuildDateTime() << std::endl
<< "Built from: " << pcpp::getGitInfo() << std::endl;
exit(0);
}

/**
* Utility's main method
*/
int main(int argc, char* argv[])
{
pcpp::AppName::init(argc, argv);

int optionIndex = 0;
int opt = 0;

if (argc == 1) {
printUsage();
exit(0);
}

while((opt = getopt_long(argc, argv, "hv", HttpReassemblerOptions, &optionIndex)) != -1)
{
switch (opt)
{
case 0:
break;
case 'h':
printUsage();
exit(0);
break;
case 'v':
printAppVersion();
break;
default:
printUsage();
exit(-1);
}
}
}
2 changes: 2 additions & 0 deletions Packet++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ add_library(
src/GreLayer.cpp
src/GtpLayer.cpp
src/HttpLayer.cpp
src/HttpReassembly.cpp
src/IcmpLayer.cpp
src/IcmpV6Layer.cpp
src/IgmpLayer.cpp
Expand Down Expand Up @@ -81,6 +82,7 @@ set(public_headers
header/GreLayer.h
header/GtpLayer.h
header/HttpLayer.h
header/HttpReassembly.h
header/IcmpLayer.h
header/IcmpV6Layer.h
header/IgmpLayer.h
Expand Down
18 changes: 18 additions & 0 deletions Packet++/header/HttpReassembly.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef PACKETPP_HTTP_REASSEMBLY
#define PACKETPP_HTTP_REASSEMBLY

/**
* @file
* This file includes an implementation of HTTP/1.x reassembly mechanism.
*/

/**
* @namespace pcpp
* @brief The main namespace for the PcapPlusPlus lib
*/
namespace pcpp
{

}

#endif /* PACKETPP_HTTP_REASSEMBLY */
6 changes: 6 additions & 0 deletions Packet++/src/HttpReassembly.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "HttpReassembly.h"

namespace pcpp
{

}
1 change: 1 addition & 0 deletions Tests/Packet++Test/PacketExamples/HTTP1_chunk_1.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
02000000450000bb00004000400600007f0000017f000001d6291f90952ce877082609dd801818ebfeaf00000101080ab3a7bb94ad87e6f5474554202f20485454502f312e310d0a486f73743a206c6f63616c686f73743a383038300d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a4163636570743a202a2f2a0d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a557365722d4167656e743a204854545069652f332e322e320d0a0d0a
1 change: 1 addition & 0 deletions Tests/Packet++Test/PacketExamples/HTTP1_chunk_2.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
020000004500008300004000400600007f0000017f0000011f90d629082609dd952ce8fe801818e9fe7700000101080aad87e6f5b3a7bb94485454502f312e3120323030204f4b0d0a436f6e74656e742d547970653a206170706c69636174696f6e2f6a736f6e0d0a5472616e736665722d456e636f64696e673a206368756e6b65640d0a0d0a
1 change: 1 addition & 0 deletions Tests/Packet++Test/PacketExamples/HTTP1_chunk_3.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
020000004500006a00004000400600007f0000017f0000011f90d62908260a2c952ce8fe801818e9fe5e00000101080aad87e6f5b3a7bb9433300d0a7b226e616d65223a20225261796d6f6e6420537072696e676572222c2022616765223a2033302c20226d6172726965640d0a
1 change: 1 addition & 0 deletions Tests/Packet++Test/PacketExamples/HTTP1_chunk_4.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
02000000450000ac00004000400600007f0000017f0000011f90d62908260a62952ce8fe801918e9fea000000101080aad87e6f5b3a7bb9433300d0a223a20747275652c20226368696c6472656e223a205b7b226e616d65223a20224a616e6520537072696e676572222c200d0a33300d0a22616765223a2031307d2c207b226e616d65223a2022506574657220537072696e676572222c2022616765223a20387d0d0a320d0a5d7d0d0a300d0a0d0a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0000000000000000000000000800450000a8936b40004006a8e27f0000017f0000011f90828444879dbe8b41fcea8018015efe9c00000101080a11cf192d11cf192ddf32ad69a7598da17c5e87909772fb81f819f0b4c890c5984b43d7005650cc6c4a2851683c8c3c167af936a37cf73fffa563b862734ac75710ee532215f1a232a1465e84dbdc4b4bac842b167266dee2780d66c48cbd67e19880b86b5cf501379ff188a386ef145d325a43f93f000000ffff0d0a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
000000000000000000000000080045000e59936c400040069b307f0000017f0000011f90828444879e328b41fcea8018015e0c4e00000101080a11cf192d11cf192d6531650d0a945ccb72db3ad27e15eca78c45ce2c66ebbb63c73e2acb49eafc9b54936c92104140c145b2fc46b39ccdac66775eecaf6e4849081f423a3b57b78c0281be7cfd7593492393261d4f0d01f5fc05dd4773a6ea5e392b54b0ab68c41d74cad8c9b249c35be3bf0a364c409d6a192a01d6d30bf72ca2558c97104bfe746f7b231eeb2b74a30d617ade2b76f6d5a04cd0a525b06dc53df4d96dada0e7cbf23d50c98fa1b48d0b078d78b615eab31beb1c7335bffa9583861763bab58be09ac262e7beb7837802073b30303543201d1f704de546691570d6883ba53576e0a72e01a4e345289d8cf05a3a1ef0ec9aa69b5ef50ad8ab0d0658afcb370446dce00e8896982cc12a7950f1612bca95a593fe5dab0dd9f47905538bb650015bb2b1d6cf9bf14bafd0b99d38370d958dbf2cb0d748d6b04b341bd01bf0b2c292e9dc581f72576f49c6176e6db32d5ff7827a0ce2c5ba0de8e9f9ac491336b4ceabb5e3084a1f4b55c1aea9c076d6d47d9eb2644862be783bae63405770d02720d2493c61a459a7ec098dc1c8f71f4757cac876545ec3467c8979ae091b12f15e80ea2bd9cf5dd9835dc134060e24e144a5baadea0a11f0f316c52d11ff753f59e1f316e55e4eebac7ba5addff9f998fc159c4323feb0d174d3e700d3a109b4ca910bba43350c4a7c81a028c74d1dbb47ef239f86972106d9aab92ce7b013776028476558093b7e98b0b55ddcf9c2d5deb30bbc0025ba2e64996e157ec8f9823d3a2f3dd70cad755d09565cc106c5650f6bf4839a9a5f53b3987368334a5bc8e3f730a2179716b378338e297dd6ca94a00d61c92ba7b08f191068f642be700d3be6e60aa7b40c111c37d78dc669acf0ace295c657bef6f90d718a22688ad3edac6ccf074cd87dac34511405e33940ad4b78038de12fb1569d740753ac75ac0afbdaa3e505b80d6427155845af9191eab458788bcea9206eb1cf4dfb562621af4324f9bc975d3a509d78c22d66d8b626454a593d7e8f28e3770a3b12e622cf75231e114c766f38b2ec94fc79a5308ce0c4028383e9f15c2519ad72fd69793eff3837c48f3ea31ab3e8d96ed9903b90444a055574aa1be260c0884fb6b76d3b5d47335c776dfdaf0f1f4afe6eeb1e8db8710a1b9787c2152bff814447614aeabe7630ce3fd602a2165f51d7bd329e46537fcd5910b5dcfed0713c421d89bda5205f881d3676e209de204b3424e1bcde38e8ac51a62e060fcade085e2cd530e008d318fbdb87dff8bc606c76541fe979003e88c7d86bf401d5d49ac7713c09f7dc3ae86114173a911ed3a2b6875156ace10372aac7c64129793c836ec5b2ee0daa26b32607ba95fea0fa15ccfbb91bfc038cda8807885905b91b20a5f5ee482e6313f8680dfa3abebb7fde426ddd5a3a5b3ae18be8f2e433821b2afa7feecd9bc20e96015b30e219a09a866607509de2e0bc854b0dbb7c0f759225f06f5dc9371fa988412d9eed5b0f1b3fecfeb2200fb6ee0d48a6089435543daa39d3bb8a9d58da0c6334b1f3d6741cd8ad197057e406d2965efefcdf6b168843c4d71486dbfe6c8c6808b8cebbf9858b358a07eba6075c0dd655294ad822eef72816d8382b08b3a37253675cad3976354ac65199deca750155a88658745fdb8c1a686083895b48caa330fb61855aa3a357bea739743dacd86c5f55a9fa58f44af37c0e6456df2bfd2d24d70bb0513e40c16abea227a2a28121f3e47e2ffcbbb88b2a4f17c48b87693076c1833a295aa5c4fb8861cabfd52386372ee769e6aab083053a71a36d3d64058c932d494f38da7b9ac47ec09c695b0db867d988bb7e46a8fb621d4e99f22b6afd17c0b6da2639d75395d2ba84fd80c6969458006cac7e0fd73d981018af7b5fdad067cd2de707856e84ddf4b6633a96b58c866a5a0a0b3077be4fa8b4b88b26af340d2a2d7b96272c89ae53fecc7f8fe0b039964feeac7efb8b64c2852b6a7dd45e9e6de354173360eb585a27b8172a5558e6ba115fc119550f98394257edd3febadf797a29dec5d09147cc179b8969b8275f313ebbaf15530dab83ee047bbc716006b154a6d3985b524b3ae90f3a3e79a76aef6d29633de04619b1eca73e4a5941f99edd74f41f3ec85e95811293bf374ef90cc78d2dcbd85b7d742dba79947411dd80e25316c52a927ed3c0760d9dd25c54941268084a3cc435b8770e32b2520e07256f6b50f3756d8af27730aef3d36efa244c754d5d3c6113c4b5e97c707ffe774aae0ffb1a3d1a15a456711e1b3d5b63148a25f4d497e832d326dd37bfd7315079c303569aaf462eacb31ec4810ec97b132c9415ff88d65c7ebc7ebc7e5acabbe73994abf11508e98a851437e8dcbbf40a875fb03787da2a0effb272f3e4770f0e5660c4d229dfef344c4ff0e70fe48f1f9c8884b1130f4ab776a7f11d65c141d0614373bac5f440a4c0b51437d44ecbe9369625d839ca551f0b5122e1804fa8de536d1ad529c0715f38dfaa719d353df67573c71ac625e81c38358fb1ce53efebb2cfaa0c2a9fd814428f34b112d06c6d9146bcecc15193fe136ed0856c3156ed79bf51aeadde8dc489c32c6dd734620955b6a9906ade2d56d4d92b84a8eb86286e2b167ffedbe19bf8ec304cad13d7e8908145834a2ad3ca58ff364af4e58e483af9777146996ff02d9d3d2db983deda620fce853106f118190be6088c74e9314d63351a946be289e6bb3504b8b578448dce6e553d4550492b7f6a13453d2838de25bc75d8bcdfe0a149b88a46ad8ba0eca3b171ea708a24ec279c64ac93abf511a2fd42d9a935d94ad9207fa50b8e178bc1a97a105fad6ea7fb59afb8abf6666bd056d6a875d4e0248c48535a45a8b737893bd4d33e40924b9273cea98d3c741566aff0590185bd2d648ee33c89f6acac8f5cb9bd41917f67a606ea68dea6165fa34ed27460af856b5bd63604f18ca675d3968b27450a97a42b113e118c78b11a1b9be51a12fdddf2e21ec19cfd7cbc051a8341e54118c1d487dfc8f5e137bcdd461262aa3160a239e79b8cb4fe1f192ae9d6ffa46f019ce2dad70ea86f6a4cc6fa8161f460d741d5a0a1aed197b0dfb96976e2cedaa965c1aab7968daa65be773edd3f032df0585fdb2c82bab146ab12fcec6984be888d3b70e263a7d1ab2ce821a9a4daab4e00b3c92940fc5ed1b7c2f2abdb6be50fedc98e730fa919477d61556708642fe42c169a12652f05637743037a269f4848230d1bfbbd989253576f41113d4bc9a9abb7264d1ad6585373ae44b892adf230e7fef12ea142ada79ed4aeea24a53537698a68367d1dc8fb67a8dc0c77ef58f5f7bcc5c456f8298ee98c5aafd57092b370f7f2d1d2c044d699c0b6956352c8e478c742fc39856c713ef479810ac0b25370d5028701c4920bee0c9c0d43327383a12646ee481571adbcc9f6d120cb4e799665c00d8a2b550fef864048c31120000d4c8339c22f462f9688bd6ddf7bdc10bd3ce8d8c495f3754f916adedd3e218a0b747933966b917da8b5456ed0066bac5354849a2c358c7b5da23d9591cd1c77fb826e85e2c1d9ae813e03c038b8744fafc141d1f6c09cb1a359e5c563ccbc76d58ea9335c69d450f9e368fcab0a619b9dcb1e8e6f932a05354d75503f7b6521f40abc78dab52d1aecf2931ef73f90e6e70f4e5877015aa3f8b4ab07ec00dc34adb09223d30fbd6ce6868b9e14bd7ae4c505e8c166a0ba4ab2e365f28b1dc567b5d24d5e28bcd8511e147cfe6337df24391f9403716d1a3be5210836f77b67253a9f2e6f1e66de3ac011c51d6e7367eb7a96a5290a37f656a31c717eee6a015e896b677326224d1215b9875bb4ae131b6bc4ffe19baffbadca78d06ec3b8fd037fdeb004dd02925d88afa88cc3bcd3c6e12395167b75c957c1d5e251691a819c9eef2fc87b1cd30fe4d3efcbc5f9e3914ef4ad758da571a907a273a7bd8a8e757c6df479a633fae85c09d16f50d38b0336985d66cdf432d55e73328ea078e4e3806219df62d651f491cf7e80b174f2dcf7db8a4ba643320b809a5ff3382527be7030798883f590b334e0e5c08a3d8fd4eeca1032f52183ad87f7900ba4ffa160fcb629f55b39313ea9014cdefbe3d428cd5e956acb111a556ba88a05e6a87c2f1e6ddb423636d7b32a0d87d9d89481ee03bc45df2bb18cdd6e9a4e86334f32a612cdd66b39a2ef2534f391e0458d6261430e20c2da722cf23056509a2784ae8fe2dc74d0644d106059ea620cc4b695ee1f54b243f090db218b782bb6658256b671a5828fc500478f451f31eb333736499620e9a6d42ea270fda47c9521c717c3325a20bd5b7378d5a634d490a6989e703b054706b7e98c8d74eea8df3f5a9751feeb4d1a06eb65fd363f97631a718175def4aa18e157a43eab583def0977a8cc9b583830210778ac9207556af3378a66bae61fe7a3a316f2439f0d59aaa1078e16df236866cc4abce40e1c8ce28b7c9eacb15991e2b4411383be17573173c4a689a9da3fb6c01374e056d180f882c64cc396d9908856b970ea75ff91e0d9e2db5198b19b6cda6e250dc9f629ddef7cc071fe9e9f55cddcdf05386731c006fffccf744faefaa14a5bdb606cad2b6ded5c83d9cf7667280134987eaf3861066fdf3c0113def07d4f87849c9fff599a0b63a655a1b88a59d7aa6e626af8b79bbaf8302dcd059d3b6333ee2a6964d27057497b98f78634f52c68f8381f506b5825aba44adc079a2d6c4a2df2f30646b18c7a547516fba04991aa6ec1c93836057efd019c122f4a3935bc6f9b0e4486879fca53c8d034e24d2f9999b76ca89054f25cfe5072657666f97b7ba5744a1d802fa0eb1e3759184bc2c37955be29d801356168f223e378ce1d89d816dda6f85cd128f108fadd29ad8691a57ce2b5ec4be3a03c88732dc5b51b06f5ae6ec6d49a6455892e84c156345da477ef46994975da79dcab512c159a77d6e3f7c2d49af4608c3a567ed3b01a9a1c3fb72c4bf4a554d5588caa60405c2bfa1678c8990012eef35da34076763397b43428272e2d7d0f709ab4489186db602c777dd510eb5e89f31d8c316fd2251903c0f467e178f72f73fc3f000000ffff0d0a
Loading
Loading