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

Allow specifing client MAC which will be attacked #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
166 changes: 166 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
StatementAttributeLikeMacros:
- Q_EMIT
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ build/partition_table/*
!build/partition_table/*.bin
sdkconfig
sdkconfig.old
doc/api
doc/api
Binary file modified build/bootloader/bootloader.bin
Binary file not shown.
Binary file modified build/esp32-wifi-penetration-tool.bin
Binary file not shown.
99 changes: 54 additions & 45 deletions components/frame_analyzer/frame_analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author risinek ([email protected])
* @date 2021-04-05
* @copyright Copyright (c) 2021
*
*
* @brief Implements frame analysis
*/
#include "frame_analyzer.h"
Expand All @@ -12,70 +12,79 @@
#include <string.h>

#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
#include "esp_log.h"
#include "esp_err.h"
#include "esp_event.h"
#include "esp_log.h"

#include "wifi_controller.h"
#include "frame_analyzer_parser.h"
#include "wifi_controller.h"

static const char *TAG = "frame_analyzer";
static uint8_t target_bssid[6];
static search_type_t search_type = -1;


/**
* @brief Analyzes data frames from sniffer.
*
* @param args
* @param event_base
* @param event_id
* @param event_data
*
* @param args
* @param event_base
* @param event_id
* @param event_data
*/
static void data_frame_handler(void *args, esp_event_base_t event_base, int32_t event_id, void *event_data) {
ESP_LOGV(TAG, "Handling DATA frame");
wifi_promiscuous_pkt_t *frame = (wifi_promiscuous_pkt_t *) event_data;
static void data_frame_handler(void *args, esp_event_base_t event_base,
int32_t event_id, void *event_data) {
ESP_LOGV(TAG, "Handling DATA frame");
wifi_promiscuous_pkt_t *frame = (wifi_promiscuous_pkt_t *)event_data;

if(!is_frame_bssid_matching(frame, target_bssid)){
ESP_LOGV(TAG, "Not matching BSSIDs.");
return;
}
if (!is_frame_bssid_matching(frame, target_bssid)) {
ESP_LOGV(TAG, "Not matching BSSIDs.");
return;
}

eapol_packet_t *eapol_packet = parse_eapol_packet((data_frame_t *) frame->payload);
if(eapol_packet == NULL){
ESP_LOGV(TAG, "Not an EAPOL packet.");
return;
}
eapol_packet_t *eapol_packet =
parse_eapol_packet((data_frame_t *)frame->payload);
if (eapol_packet == NULL) {
ESP_LOGV(TAG, "Not an EAPOL packet.");
return;
}

eapol_key_packet_t *eapol_key_packet = parse_eapol_key_packet(eapol_packet);
if(eapol_key_packet == NULL){
ESP_LOGV(TAG, "Not an EAPOL-Key packet");
return;
}
eapol_key_packet_t *eapol_key_packet = parse_eapol_key_packet(eapol_packet);
if (eapol_key_packet == NULL) {
ESP_LOGV(TAG, "Not an EAPOL-Key packet");
return;
}

if(search_type == SEARCH_HANDSHAKE){
// TODO handle timeouts properly by e.g. for cycle
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_post(FRAME_ANALYZER_EVENTS, DATA_FRAME_EVENT_EAPOLKEY_FRAME, frame, sizeof(wifi_promiscuous_pkt_t) + frame->rx_ctrl.sig_len, portMAX_DELAY));
return;
}
if (search_type == SEARCH_HANDSHAKE) {
// TODO handle timeouts properly by e.g. for cycle
ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_post(
FRAME_ANALYZER_EVENTS, DATA_FRAME_EVENT_EAPOLKEY_FRAME, frame,
sizeof(wifi_promiscuous_pkt_t) + frame->rx_ctrl.sig_len,
portMAX_DELAY));
return;
}

if(search_type == SEARCH_PMKID){
pmkid_item_t *pmkid_items;
if((pmkid_items = parse_pmkid(eapol_key_packet)) == NULL){
return;
}
ESP_ERROR_CHECK(esp_event_post(FRAME_ANALYZER_EVENTS, DATA_FRAME_EVENT_PMKID, &pmkid_items, sizeof(pmkid_item_t *), portMAX_DELAY));
return;
if (search_type == SEARCH_PMKID) {
pmkid_item_t *pmkid_items;
if ((pmkid_items = parse_pmkid(eapol_key_packet)) == NULL) {
return;
}
ESP_ERROR_CHECK(esp_event_post(FRAME_ANALYZER_EVENTS,
DATA_FRAME_EVENT_PMKID, &pmkid_items,
sizeof(pmkid_item_t *), portMAX_DELAY));
return;
}
}

void frame_analyzer_capture_start(search_type_t search_type_arg, const uint8_t *bssid){
ESP_LOGI(TAG, "Frame analysis started...");
search_type = search_type_arg;
memcpy(&target_bssid, bssid, 6);
ESP_ERROR_CHECK(esp_event_handler_register(SNIFFER_EVENTS, SNIFFER_EVENT_CAPTURED_DATA, &data_frame_handler, NULL));
void frame_analyzer_capture_start(search_type_t search_type_arg,
const uint8_t *bssid) {
ESP_LOGI(TAG, "Frame analysis started...");
search_type = search_type_arg;
memcpy(&target_bssid, bssid, 6);
ESP_ERROR_CHECK(esp_event_handler_register(
SNIFFER_EVENTS, SNIFFER_EVENT_CAPTURED_DATA, &data_frame_handler, NULL));
}

void frame_analyzer_capture_stop(){
ESP_ERROR_CHECK(esp_event_handler_unregister(ESP_EVENT_ANY_BASE, ESP_EVENT_ANY_ID, &data_frame_handler));
void frame_analyzer_capture_stop() {
ESP_ERROR_CHECK(esp_event_handler_unregister(
ESP_EVENT_ANY_BASE, ESP_EVENT_ANY_ID, &data_frame_handler));
}
Loading