-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the scaffold for the HTTP 1.x reassembler
example application.
- Loading branch information
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { // No options provided | ||
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); | ||
} | ||
} | ||
} |