├── .clang-format ├── .gitignore ├── .travis.sh ├── .travis.yml ├── CMake ├── GTest.txt.in └── headers.txt ├── CMakeLists.txt ├── Doxyfile.in ├── LICENSE ├── README.md ├── include ├── buffer.h ├── config.in ├── errors.h ├── ndp.h ├── packet.h ├── proto_list.h ├── sender.h └── sender_map.h ├── lib ├── buffer.c ├── errors.c ├── ndp.c ├── packet.c ├── proto_list.c ├── sender.c └── sender_map.c ├── src ├── cfg.c ├── cmds.c ├── include │ ├── cfg.h │ ├── cmds.h │ ├── ipc.h │ └── utils.h ├── ipc.c ├── main.c ├── neighbor-advert.c ├── receiver.c ├── router-advert.c ├── transmitter.c └── utils.c └── tests ├── runner.cpp ├── test_buffer.cpp ├── test_cfg_set.cpp ├── test_errors.cpp ├── test_ipc.cpp ├── test_proto_list.cpp └── test_utils.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: LLVM 4 | AccessModifierOffset: -2 5 | AlignAfterOpenBracket: Align 6 | AlignConsecutiveAssignments: false 7 | AlignConsecutiveDeclarations: false 8 | AlignEscapedNewlines: Right 9 | AlignOperands: true 10 | AlignTrailingComments: true 11 | AllowAllParametersOfDeclarationOnNextLine: true 12 | AllowShortBlocksOnASingleLine: false 13 | AllowShortCaseLabelsOnASingleLine: false 14 | AllowShortFunctionsOnASingleLine: All 15 | AllowShortIfStatementsOnASingleLine: false 16 | AllowShortLoopsOnASingleLine: false 17 | AlwaysBreakAfterDefinitionReturnType: None 18 | AlwaysBreakAfterReturnType: None 19 | AlwaysBreakBeforeMultilineStrings: false 20 | AlwaysBreakTemplateDeclarations: false 21 | BinPackArguments: true 22 | BinPackParameters: true 23 | BraceWrapping: 24 | AfterClass: false 25 | AfterControlStatement: false 26 | AfterEnum: false 27 | AfterFunction: false 28 | AfterNamespace: false 29 | AfterObjCDeclaration: false 30 | AfterStruct: false 31 | AfterUnion: false 32 | BeforeCatch: false 33 | BeforeElse: false 34 | IndentBraces: false 35 | SplitEmptyFunction: true 36 | SplitEmptyRecord: true 37 | SplitEmptyNamespace: true 38 | BreakBeforeBinaryOperators: None 39 | BreakBeforeBraces: Attach 40 | BreakBeforeInheritanceComma: false 41 | BreakBeforeTernaryOperators: true 42 | BreakConstructorInitializersBeforeComma: false 43 | BreakConstructorInitializers: BeforeColon 44 | BreakAfterJavaFieldAnnotations: false 45 | BreakStringLiterals: true 46 | ColumnLimit: 80 47 | CommentPragmas: '^ IWYU pragma:' 48 | CompactNamespaces: false 49 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 50 | ConstructorInitializerIndentWidth: 4 51 | ContinuationIndentWidth: 4 52 | Cpp11BracedListStyle: true 53 | DerivePointerAlignment: false 54 | DisableFormat: false 55 | ExperimentalAutoDetectBinPacking: false 56 | FixNamespaceComments: true 57 | ForEachMacros: 58 | - foreach 59 | - json_object_type_foreach 60 | - SYLKIE_HEADER_LIST_FOREACH 61 | IncludeCategories: 62 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 63 | Priority: 2 64 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 65 | Priority: 3 66 | - Regex: '.*' 67 | Priority: 1 68 | IncludeIsMainRegex: '(Test)?$' 69 | IndentCaseLabels: false 70 | IndentWidth: 2 71 | IndentWrappedFunctionNames: false 72 | JavaScriptQuotes: Leave 73 | JavaScriptWrapImports: true 74 | KeepEmptyLinesAtTheStartOfBlocks: true 75 | MacroBlockBegin: '' 76 | MacroBlockEnd: '' 77 | MaxEmptyLinesToKeep: 1 78 | NamespaceIndentation: None 79 | ObjCBlockIndentWidth: 2 80 | ObjCSpaceAfterProperty: false 81 | ObjCSpaceBeforeProtocolList: true 82 | PenaltyBreakAssignment: 2 83 | PenaltyBreakBeforeFirstCallParameter: 19 84 | PenaltyBreakComment: 300 85 | PenaltyBreakFirstLessLess: 120 86 | PenaltyBreakString: 1000 87 | PenaltyExcessCharacter: 1000000 88 | PenaltyReturnTypeOnItsOwnLine: 60 89 | PointerAlignment: Right 90 | ReflowComments: true 91 | SortIncludes: true 92 | SortUsingDeclarations: true 93 | SpaceAfterCStyleCast: false 94 | SpaceAfterTemplateKeyword: true 95 | SpaceBeforeAssignmentOperators: true 96 | SpaceBeforeParens: ControlStatements 97 | SpaceInEmptyParentheses: false 98 | SpacesBeforeTrailingComments: 1 99 | SpacesInAngles: false 100 | SpacesInContainerLiterals: true 101 | SpacesInCStyleCastParentheses: false 102 | SpacesInParentheses: false 103 | SpacesInSquareBrackets: false 104 | Standard: Cpp11 105 | TabWidth: 8 106 | UseTab: Never 107 | ... 108 | 109 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | build 4 | sylkie_config.h 5 | 6 | # Caryover from gh-pages branch 7 | _site 8 | Gemfile.lock 9 | -------------------------------------------------------------------------------- /.travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "${GEN}" -o -z "${BUILD_TYPE}" ] 4 | then 5 | echo "Must define GEN and BUILD_TYPE" 6 | exit 1 7 | fi 8 | 9 | mkdir ./build 10 | cd build 11 | 12 | cmake -G "${GEN}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTS=ON .. 13 | 14 | if [[ "${GEN}" == "Ninja" ]] 15 | then 16 | ninja -v 17 | else 18 | VERBOSE=1 make 19 | fi 20 | 21 | ./sylkie_test 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | dist: trusty 3 | sudo: require 4 | compiler: 5 | - clang 6 | - gcc 7 | env: 8 | - GEN="Unix Makefiles" BUILD_TYPE=Release 9 | - GEN="Unix Makefiles" BUILD_TYPE=Debug 10 | - GEN="Unix Makefiles" BUILD_TYPE=ASAN 11 | addons: 12 | apt: 13 | packages: 14 | - cmake3 15 | - libseccomp-dev 16 | - libjson-c-dev 17 | - ninja 18 | script: 19 | - ./.travis.sh 20 | -------------------------------------------------------------------------------- /CMake/GTest.txt.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.2) 2 | 3 | project(googletest-download 4 | NONE 5 | ) 6 | 7 | include(ExternalProject) 8 | ExternalProject_Add(googletest 9 | GIT_REPOSITORY https://github.com/google/googletest.git 10 | GIT_TAG "release-@GTEST_VERSION@" 11 | SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" 12 | BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" 13 | CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" 14 | CONFIGURE_COMMAND "" 15 | BUILD_COMMAND "" 16 | INSTALL_COMMAND "" 17 | TEST_COMMAND "" 18 | ) 19 | -------------------------------------------------------------------------------- /CMake/headers.txt: -------------------------------------------------------------------------------- 1 | arpa/inet.h 2 | errno.h 3 | fcntl.h 4 | linux/if_ether.h 5 | linux/if_packet.h 6 | netinet/icmp6.h 7 | netinet/if_ether.h 8 | netinet/ip6.h 9 | stdio.h 10 | stdlib.h 11 | string.h 12 | strings.h 13 | sys/ioctl.h 14 | sys/prctl.h 15 | sys/socket.h 16 | sys/stat.h 17 | sys/types.h 18 | sys/wait.h 19 | unistd.h 20 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 Daniel L. Robertson 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | 21 | cmake_minimum_required(VERSION 3.5) 22 | project( 23 | sylkie 24 | VERSION 0.0.4 25 | LANGUAGES C 26 | ) 27 | 28 | set(LIB_DIR "${PROJECT_SOURCE_DIR}/lib") 29 | set(EXE_DIR "${PROJECT_SOURCE_DIR}/src") 30 | set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include") 31 | set(TEST_DIR "${PROJECT_SOURCE_DIR}/tests") 32 | set(CMAKE_EXTRA "${PROJECT_SOURCE_DIR}/CMake") 33 | 34 | include(CheckIncludeFile) 35 | include(ExternalProject) 36 | 37 | # Additional options 38 | 39 | # Enable features 40 | set(ENABLE_JSON AUTO CACHE STRING "Enable json support") 41 | set_property(CACHE ENABLE_JSON PROPERTY STRINGS AUTO ON OFF) 42 | set(ENABLE_SECCOMP AUTO CACHE STRING "Enable seccomp support") 43 | set_property(CACHE ENABLE_SECCOMP PROPERTY STRINGS AUTO ON OFF) 44 | set(ENABLE_SETUID AUTO CACHE STRING "Set the setuid bit on the executable") 45 | set_property(CACHE ENABLE_SETUID PROPERTY STRINGS AUTO ON OFF) 46 | set(ENABLE_STATIC CACHE STRING "Statically link the executable") 47 | set_property(CACHE ENABLE_STATIC PROPERTY STRINGS ON OFF) 48 | 49 | # Build extras 50 | set(BUILD_TESTS OFF CACHE STRING "Build tests") 51 | set_property(CACHE BUILD_TESTS PROPERTY STRINGS ON OFF) 52 | set(BUILD_DOCS OFF CACHE STRING "Build documentation") 53 | set_property(CACHE BUILD_DOCS PROPERTY STRINGS ON OFF) 54 | 55 | # Deprecated options 56 | option(JSON "JSON" OFF) 57 | option(SECCOMP "SECCOMP" OFF) 58 | option(ENABLE_TESTS "ENABLE_TESTS" OFF) 59 | 60 | if(JSON) 61 | set(ENABLE_JSON "ON") 62 | message(WARNING "JSON option has been deprecated. Use ENABLE_JSON.") 63 | endif(JSON) 64 | if(SECCOMP) 65 | set(ENABLE_SECCOMP "ON") 66 | message(WARNING "SECCOMP option has been deprecated. Use ENABLE_SECCOMP.") 67 | endif(SECCOMP) 68 | if(ENABLE_TESTS) 69 | set(BUILD_TESTS "ON") 70 | message(WARNING "ENABLE_TESTS option has been deprecated. Use BUILD_TESTS.") 71 | endif(ENABLE_TESTS) 72 | 73 | # Check OS 74 | 75 | message("-- Check for OS support") 76 | 77 | if(NOT UNIX) 78 | message(FATAL_ERROR "This project is not yet supported on non-unix systems") 79 | endif() 80 | 81 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 82 | set(BUILD_OS "linux") 83 | set(BUILD_LINUX 1) 84 | else(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux") 85 | message(FATAL_ERROR "This project is not yet supported on ${CMAKE_SYSTEM_NAME}") 86 | endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 87 | 88 | # Check kernel version 89 | 90 | message("-- Check kernel version") 91 | 92 | set(KERNEL_VERSION_STRING ${CMAKE_SYSTEM_VERSION}) 93 | 94 | string(REGEX MATCH "([0-9]+)\\.([0-9]+)[.-]([0-9]+)" 95 | KERNEL_MATCHED "${KERNEL_VERSION_STRING}") 96 | 97 | if(NOT KERNEL_MATCHED) 98 | message(FATAL_ERROR "${CMAKE_SYSTEM_VERSION} did not match kernel regex") 99 | endif(NOT KERNEL_MATCHED) 100 | 101 | set(KERNEL_MAJOR_VERSION ${CMAKE_MATCH_1}) 102 | set(KERNEL_MINOR_VERSION ${CMAKE_MATCH_2}) 103 | set(KERNEL_PATCH_VERSION ${CMAKE_MATCH_3}) 104 | 105 | set(KERNEL_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_4}") 106 | 107 | if(KERNEL_VERSION VERSION_LESS 3.0) 108 | message(FATAL_ERROR "Bad kernel version") 109 | else(KERNEL_VERSION VERSION_LESS 3.0) 110 | message("-- Check kernel version -- works") 111 | endif(KERNEL_VERSION VERSION_LESS 3.0) 112 | 113 | # Check for headers in CMake/headers.txt 114 | 115 | function(header_check filename) 116 | if(EXISTS ${filename}) 117 | file(STRINGS ${filename} HEADERS REGEX "[A-z\/]+\\.h") 118 | foreach(f ${HEADERS}) 119 | check_include_file(${f} HAVE_HEADER_${f}) 120 | if(NOT HAVE_HEADER_${f}) 121 | message(FATAL_ERROR "Could not find ${f}") 122 | endif(NOT HAVE_HEADER_${f}) 123 | endforeach(f) 124 | endif(EXISTS ${filename}) 125 | endfunction(header_check) 126 | 127 | # Check for default headers 128 | header_check(${CMAKE_EXTRA}/headers.txt) 129 | 130 | # Check for OS specific headers 131 | header_check(${CMAKE_EXTRA}/${BUILD_OS}/headers.txt) 132 | 133 | # Basic build 134 | 135 | include_directories(${INCLUDE_DIR}) 136 | 137 | file(GLOB INCLUDE_FILES ${INCLUDE_DIR}/*.h) 138 | 139 | file(GLOB LIB_SRCS ${LIB_DIR}/*.c) 140 | 141 | file(GLOB EXE_SRCS ${EXE_DIR}/*.c) 142 | list(REMOVE_ITEM EXE_SRCS "${EXE_DIR}/main.c") 143 | 144 | # CFLAGS 145 | 146 | set(DEFAULT_DEBUG "-g -O0") 147 | set(DEV_WARNINGS "-Wall -Wshadow -Wstrict-overflow -fno-strict-aliasing") 148 | set(CMAKE_C_FLAGS_DEBUG 149 | "${CMAKE_C_FLAGS_DEBUG} ${DEFAULT_DEBUG} ${DEV_WARNINGS}") 150 | set(CMAKE_CXX_FLAGS_DEBUG 151 | "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 ${DEFAULT_DEBUG} ${DEV_WARNINGS}") 152 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -Wall") 153 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -O2 -Wall") 154 | 155 | # Add custom build type 156 | 157 | # Add new build types 158 | set(CMAKE_C_FLAGS_ASAN 159 | "${DEFAULT_DEBUG} ${DEV_WARNINGS} -fsanitize=address -fno-omit-frame-pointer" 160 | CACHE STRING "Flags used by the C compiler during address sanitizer builds." 161 | FORCE ) 162 | set(CMAKE_CXX_FLAGS_ASAN 163 | "${DEFAULT_DEBUG} ${DEV_WARNINGS} -std=c++11 -fsanitize=address -fno-omit-frame-pointer" 164 | CACHE STRING "Flags used by the C++ compiler during address sanitizer builds." 165 | FORCE ) 166 | set(CMAKE_EXE_LINKER_FLAGS_ASAN 167 | "" 168 | CACHE STRING "Flags used for linking binaries during address sanitizer builds." 169 | FORCE ) 170 | set(CMAKE_SHARED_LINKER_FLAGS_ASAN 171 | "" 172 | CACHE STRING "Flags used by the shared libraries linker during address 173 | sanitizer builds." 174 | FORCE ) 175 | mark_as_advanced( 176 | CMAKE_CXX_FLAGS_ASAN 177 | CMAKE_C_FLAGS_ASAN 178 | CMAKE_EXE_LINKER_FLAGS_ASAN 179 | CMAKE_SHARED_LINKER_FLAGS_ASAN 180 | ) 181 | 182 | # Outputs 183 | 184 | add_library(${PROJECT_NAME}-shared SHARED ${LIB_SRCS}) 185 | set_target_properties(${PROJECT_NAME}-shared PROPERTIES 186 | OUTPUT_NAME ${PROJECT_NAME}) 187 | set_target_properties(${PROJECT_NAME}-shared PROPERTIES 188 | SOVERSION ${PROJECT_VERSION_MAJOR}) 189 | set_property(TARGET ${PROJECT_NAME}-shared PROPERTY C_STANDARD 11) 190 | 191 | add_library(${PROJECT_NAME}-static STATIC ${LIB_SRCS}) 192 | set_target_properties(${PROJECT_NAME}-static PROPERTIES 193 | OUTPUT_NAME ${PROJECT_NAME}) 194 | set_property(TARGET ${PROJECT_NAME}-static PROPERTY C_STANDARD 11) 195 | 196 | add_executable(${PROJECT_NAME}-bin ${EXE_SRCS} ${EXE_DIR}/main.c) 197 | target_include_directories(${PROJECT_NAME}-bin PRIVATE ${EXE_DIR}/include) 198 | set_target_properties(${PROJECT_NAME}-bin PROPERTIES 199 | OUTPUT_NAME ${PROJECT_NAME}) 200 | set_property(TARGET ${PROJECT_NAME}-bin PROPERTY C_STANDARD 11) 201 | if(ENABLE_STATIC) 202 | target_link_libraries(${PROJECT_NAME}-bin PRIVATE 203 | ${PROJECT_NAME}-static) 204 | else(ENABLE_STATIC) 205 | target_link_libraries(${PROJECT_NAME}-bin PRIVATE 206 | ${PROJECT_NAME}-shared) 207 | endif(ENABLE_STATIC) 208 | 209 | # Dependencies 210 | 211 | if(ENABLE_JSON OR ENABLE_JSON STREQUAL "AUTO") 212 | check_include_file(json-c/json.h JSON_HEADER_FOUND) 213 | find_library(JSON_LIB json-c) 214 | if(JSON_LIB AND JSON_HEADER_FOUND) 215 | target_link_libraries(${PROJECT_NAME}-bin PRIVATE json-c) 216 | else(JSON_LIB AND JSON_HEADER_FOUND) 217 | message(FATAL_ERROR "Could not find json-c library. Either install " 218 | "json-c or run with -DENABLE_JSON=OFF to build without json support") 219 | endif(JSON_LIB AND JSON_HEADER_FOUND) 220 | set(BUILD_JSON 1) 221 | endif(ENABLE_JSON OR ENABLE_JSON STREQUAL "AUTO") 222 | 223 | if(ENABLE_SECCOMP OR ENABLE_SECCOMP STREQUAL "AUTO") 224 | check_include_file(seccomp.h SECCOMP_HEADER_FOUND) 225 | check_include_file(sys/prctl.h PRCTL_HEADER_FOUND) 226 | find_library(SECCOMP_LIB seccomp) 227 | if(SECCOMP_LIB AND SECCOMP_HEADER_FOUND AND PRCTL_HEADER_FOUND) 228 | target_link_libraries(${PROJECT_NAME}-bin PRIVATE seccomp) 229 | else(SECCOMP_LIB AND SECCOMP_HEADER_FOUND AND PRCTL_HEADER_FOUND) 230 | message(FATAL_ERROR "Could not find seccomp library. Either install " 231 | "libseccomp or run with -DENABLE_SECCOMP=OFF to build without seccomp support") 232 | endif(SECCOMP_LIB AND SECCOMP_HEADER_FOUND AND PRCTL_HEADER_FOUND) 233 | set(BUILD_SECCOMP 1) 234 | endif(ENABLE_SECCOMP OR ENABLE_SECCOMP STREQUAL "AUTO") 235 | 236 | # Configure sylkie_config.h 237 | 238 | configure_file(${INCLUDE_DIR}/config.in ${INCLUDE_DIR}/${PROJECT_NAME}_config.h) 239 | 240 | # Lints 241 | 242 | add_custom_target(clang-tidy COMMAND clang-tidy ${EXE_DIR}/*.c ${LIB_DIR}/*.c 243 | -- -std=c11 -I${INCLUDE_DIR} -I${EXE_DIR}/include) 244 | 245 | add_custom_target(clang-format COMMAND clang-format -i -style=file 246 | ${EXE_DIR}/*.c ${EXE_DIR}/include/*.h ${LIB_DIR}/*.c 247 | ${TEST_DIR}/*.cpp ${INCLUDE_DIR}/*.h) 248 | 249 | # Docs 250 | 251 | if(BUILD_DOCS) 252 | find_package(Doxygen) 253 | if(DOXYGEN_FOUND) 254 | set(DOC_FILES "") 255 | foreach(str ${LIB_SRCS}) 256 | set(DOC_FILES "${DOC_FILES} ${str}") 257 | endforeach(str) 258 | foreach(str ${INCLUDE_FILES}) 259 | set(DOC_FILES "${DOC_FILES} ${str}") 260 | endforeach(str) 261 | configure_file(${PROJECT_SOURCE_DIR}/Doxyfile.in 262 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) 263 | add_custom_target(doc 264 | ${DOXYGEN_EXECUTABLE} 265 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 266 | WORKING DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 267 | ) 268 | else(DOXYGEN_FOUND) 269 | message(FATAL_ERROR "Must have doxygen install to generate docs") 270 | endif(DOXYGEN_FOUND) 271 | endif(BUILD_DOCS) 272 | 273 | # Tests 274 | 275 | if(BUILD_TESTS) 276 | enable_language(CXX) 277 | enable_testing() 278 | 279 | include(CTest) 280 | 281 | find_package(GTest) 282 | 283 | file(GLOB TEST_SRCS ${TEST_DIR}/test_*.cpp) 284 | 285 | add_executable(${PROJECT_NAME}_test ${TEST_DIR}/runner.cpp ${TEST_SRCS} ${EXE_SRCS} 286 | ${LIB_SRCS}) 287 | set_target_properties(${PROJECT_NAME}_test PROPERTIES LINKER_LANGUAGE CXX) 288 | target_include_directories(${PROJECT_NAME}_test PRIVATE ${EXE_DIR}/include) 289 | if (ENABLE_JSON) 290 | target_link_libraries(${PROJECT_NAME}_test json-c) 291 | endif(ENABLE_JSON) 292 | if(ENABLE_SECCOMP) 293 | target_link_libraries(${PROJECT_NAME}_test seccomp) 294 | endif(ENABLE_SECCOMP) 295 | 296 | if(GTEST_FOUND) 297 | include_directories(${GTEST_INCLUDE_DIRS}) 298 | target_link_libraries(${PROJECT_NAME}_test gtest) 299 | else(GTEST_FOUND) 300 | # From the gtest README.md 301 | 302 | # Download and unpack googletest at configure time 303 | set(GTEST_VERSION "1.8.0") 304 | configure_file(CMake/GTest.txt.in googletest-download/CMakeLists.txt) 305 | execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . 306 | RESULT_VARIABLE result 307 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) 308 | if(result) 309 | message(FATAL_ERROR "CMake step for googletest failed: ${result}") 310 | endif() 311 | execute_process(COMMAND ${CMAKE_COMMAND} --build . 312 | RESULT_VARIABLE result 313 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) 314 | if(result) 315 | message(FATAL_ERROR "Build step for googletest failed: ${result}") 316 | endif() 317 | 318 | # Prevent overriding the parent project's compiler/linker 319 | # settings on Windows 320 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 321 | 322 | # Add googletest directly to our build. This defines 323 | # the gtest and gtest_main targets. 324 | add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src 325 | ${CMAKE_BINARY_DIR}/googletest-build) 326 | 327 | # Link against gtest 328 | target_link_libraries(${PROJECT_NAME}_test gtest_main) 329 | endif(GTEST_FOUND) 330 | 331 | 332 | foreach(test ${TEST_SRCS}) 333 | get_filename_component(TEST_NAME ${test} NAME_WE) 334 | add_test(${PROJECT_NAME}_test ${PROJECT_NAME}_test ${TEST_NAME}) 335 | endforeach(test) 336 | 337 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) 338 | set_property(TARGET ${PROJECT_NAME}_test PROPERTY C_STANDARD 11) 339 | set_property(TARGET ${PROJECT_NAME}_test PROPERTY CXX_STANDARD 11) 340 | endif(BUILD_TESTS) 341 | 342 | # Install 343 | set(DEFAULT_EXEC_PERMISSIONS 344 | OWNER_WRITE OWNER_READ OWNER_EXECUTE 345 | GROUP_READ GROUP_EXECUTE 346 | WORLD_READ WORLD_EXECUTE) 347 | 348 | set(DEFAULT_READ_PERMISSIONS 349 | OWNER_WRITE OWNER_READ 350 | GROUP_READ 351 | WORLD_READ) 352 | 353 | install( 354 | TARGETS ${PROJECT_NAME}-shared ${PROJECT_NAME}-static 355 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 356 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 357 | ) 358 | 359 | if(ENABLE_SETUID OR ENABLE_SETUID STREQUAL "AUTO") 360 | install( 361 | TARGETS ${PROJECT_NAME}-bin 362 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin 363 | PERMISSIONS ${DEFAULT_EXEC_PERMISSIONS} SETUID 364 | ) 365 | else(ENABLE_SETUID OR ENABLE_SETUID STREQUAL "AUTO") 366 | install( 367 | TARGETS ${PROJECT_NAME}-bin 368 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin 369 | PERMISSIONS ${DEFAULT_EXEC_PERMISSIONS} 370 | ) 371 | endif(ENABLE_SETUID OR ENABLE_SETUID STREQUAL "AUTO") 372 | 373 | install( 374 | FILES ${INCLUDE_FILES} 375 | DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME} 376 | PERMISSIONS ${DEFAULT_READ_PERMISSIONS} 377 | ) 378 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Daniel L. Robertson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `sylkie` 2 | 3 | [![Travis Build Status](https://img.shields.io/travis/dlrobertson/sylkie/master.svg?label=master%20build)](https://travis-ci.org/dlrobertson/sylkie) 4 | 5 | A command line tool and library for testing networks for common address 6 | spoofing security vulnerabilities in IPv6 networks using the Neighbor 7 | Discovery Protocol. 8 | 9 | ## Getting Started 10 | 11 | **Note:** This project is still in the early phases of development. If you run into any problems, 12 | please consider submitting an [issue](https://github.com/dlrobertson/sylkie/issues). It currently 13 | only runs on Linux. 14 | 15 | ### Dependencies 16 | 17 | - [libseccomp](https://github.com/seccomp/libseccomp) (Optional, but highly recommended) 18 | - [json-c](https://github.com/json-c/json-c) (Optional, but recommended) 19 | 20 | See [The Wiki](https://github.com/dlrobertson/sylkie/wiki#building) for more details. 21 | 22 | ### Build 23 | 24 | Get the code and compile it! 25 | 26 | ``` 27 | # Get the code 28 | git clone https://github.com/dlrobertson/sylkie 29 | cd ./sylkie 30 | 31 | # Compile the code 32 | mkdir -p ./build 33 | cd ./build 34 | cmake -DCMAKE_BUILD_TYPE=Release .. 35 | make 36 | make install 37 | ``` 38 | 39 | ## Basic usage 40 | 41 | The following describes the basic usage of `sylkie`. Run `sylkie -h` or 42 | `sylkie -h` for more details or check out 43 | [Advanced Usage](https://github.com/dlrobertson/sylkie/wiki#advanced-usage) 44 | for more examples. 45 | 46 | **Note:** `sylkie` uses [raw sockets](http://man7.org/linux/man-pages/man7/packet.7.html) 47 | to send the forged advertisements. As a result, the executable must 48 | either have the setuid bit set, or it must be run as root. 49 | 50 | ### DoS (Router Advert) 51 | 52 | The basic usage of the `router-advert` command is listed below. This 53 | command will send a Router Advertisement message to the given ip or the 54 | all nodes multicast addres causing the targeted nodes to remove 55 | `/` from their list of default routes. 56 | 57 | ``` 58 | sylkie ra -i \ 59 | --target-mac \ 60 | --router-ip \ 61 | --prefix \ 62 | --timeout