-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c4f231
commit 57ccb54
Showing
6 changed files
with
680 additions
and
55 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 |
---|---|---|
@@ -1,3 +1,22 @@ | ||
add_executable(FuzzTarget FuzzTarget.cpp) | ||
|
||
target_link_libraries(FuzzTarget PRIVATE Pcap++ -fsanitize=fuzzer) | ||
target_compile_definitions(FuzzTarget PUBLIC FILE_EXT=".pcap") | ||
target_include_directories(FuzzTarget PRIVATE $<TARGET_PROPERTY:EndianPortable,INTERFACE_INCLUDE_DIRECTORIES>) | ||
|
||
add_executable(FuzzTargetNg FuzzTarget.cpp) | ||
target_link_libraries(FuzzTargetNg PRIVATE Pcap++ -fsanitize=fuzzer) | ||
target_compile_definitions(FuzzTargetNg PUBLIC FILE_EXT=".pcapng") | ||
target_include_directories(FuzzTargetNg PRIVATE $<TARGET_PROPERTY:EndianPortable,INTERFACE_INCLUDE_DIRECTORIES>) | ||
|
||
add_executable(FuzzTargetSnoop FuzzTarget.cpp) | ||
target_link_libraries(FuzzTargetSnoop PRIVATE Pcap++ -fsanitize=fuzzer) | ||
target_compile_definitions(FuzzTargetSnoop PUBLIC FILE_EXT=".snoop") | ||
target_include_directories(FuzzTargetSnoop PRIVATE $<TARGET_PROPERTY:EndianPortable,INTERFACE_INCLUDE_DIRECTORIES>) | ||
|
||
add_executable(FuzzWriter FuzzWriter.cpp) | ||
target_link_libraries(FuzzWriter PRIVATE Pcap++ -fsanitize=fuzzer) | ||
target_compile_definitions(FuzzWriter PUBLIC FILE_EXT=".pcap" NG_WRITER) | ||
|
||
add_executable(FuzzWriterNg FuzzWriter.cpp) | ||
target_link_libraries(FuzzWriterNg PRIVATE Pcap++ -fsanitize=fuzzer) | ||
target_compile_definitions(FuzzWriterNg PUBLIC FILE_EXT=".pcapng") |
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,32 @@ | ||
#ifndef DUMP_TO_FILE_H | ||
#define DUMP_TO_FILE_H | ||
|
||
#include <iostream> | ||
|
||
// This function is created as PcapPlusPlus doesn't seem to offer a way of | ||
// parsing Pcap files directly from memory | ||
int dumpDataToPcapFile(const uint8_t *data, size_t size, const char* path) | ||
{ | ||
FILE *fd; | ||
int written = 0; | ||
|
||
fd = fopen(path, "wb"); | ||
if (fd == NULL) | ||
{ | ||
std::cerr << "Error opening pcap file for writing\n"; | ||
return -1; | ||
} | ||
|
||
written = fwrite(data, 1, size, fd); | ||
if (static_cast<size_t>(written) != size) | ||
{ | ||
std::cerr << "Error writing pcap file\n"; | ||
fclose(fd); | ||
return -1; | ||
} | ||
|
||
fclose(fd); | ||
return 0; | ||
} | ||
|
||
#endif // DUMP_TO_FILE_H |
Oops, something went wrong.