-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPKDataLight6.h
More file actions
114 lines (95 loc) · 5.52 KB
/
PKDataLight6.h
File metadata and controls
114 lines (95 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/***************************************************************************
* *
* _ _____ ____ *
* /\ | | | __ \ /\ | _ \ /\ *
* / \ | | | | | | / \ | |_) | / \ *
* / /\ \ | | | | | | / /\ \ | _ < / /\ \ *
* / ____ \ | |___ | |__| / / ____ \ | |_) / / ____ \ *
* /_/ \_\ | ____| |_____/ /_/ \_\ |____/ /_/ \_\ *
* *
* == {Port Knocking/Single Packet Authorization} Security Suite == *
* *
***************************************************************************
* *
* This file is part of Aldaba Knocking Suite. *
* *
* Copyright (c) 2010, Luis MartinGarcia. (aldabaknocking@gmail.com) *
* *
* Aldaba is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free *
* Software Foundation; Version 2 of the License, with the exceptions, *
* conditions and clarifications described in the file named LICENSE.txt, *
* distributed with Aldaba or available from: *
* <http://www.aldabaknocking.com/LICENSE.txt> *
* *
* Aldaba is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
* v2.0 for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with Aldaba; if not, write to the Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
* *
* Please check file LICENSE.txt for the complete version of the license, *
* as this disclaimer does not contain the complete information. Also, note*
* that although Aldaba is licensed under the GNU GPL v2.0 license, it may *
* be possible to obtain copies of it under different, less restrictive, *
* alternative licenses. Requests will be studied on a case by case basis. *
* If you wish to obtain Aldaba under a different license, please use the *
* email address shown above. *
* *
***************************************************************************/
#ifndef __PKDATALIGHT6_H__
#define __PKDATALIGHT6_H__ 1
#include "ApplicationLayerElement.h"
#include "IPAddress.h"
#define PK_LIGHT_IPv6_DATA_LEN 24
#define PK_LIGHT_IPv6_MAC_LEN 6
/**
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 | |
+ +
1 | |
+ Authorized IPv6 Address +
2 | |
+ +
3 | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4 | Knock Port | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+
5 | Message Authentication Code |A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
class PKDataLight6 : public ApplicationLayerElement {
private:
struct pk_light_header_ipv6{
struct in6_addr knock_ip;
u16 knock_port;
u8 mac[PK_LIGHT_IPv6_MAC_LEN];
}__attribute__((__packed__));
typedef struct pk_light_header_ipv6 pk_light_header_ipv6_t;
pk_light_header_ipv6_t h;
protected:
u8 *getBufferPointer();
u8 *getBufferPointer(u32 *len);
int setKnockData(u8 *buffer, u32 *final_len, IPAddress ip, tcp_port_t port, int action, u8 *key, size_t keylen);
public:
PKDataLight6();
~PKDataLight6();
void reset();
int storeRecvData(const u8 *buf, size_t len);
void getKnockData(u8 *buff, u32 *final_len);
u8 *getKnockData(u32 *len);
u8 *getKnockData();
int setKnockData(u8 *buff);
int setKnockData(IPAddress ip, tcp_port_t port, int action, u8 *key, size_t keylen);
IPAddress getAddress();
tcp_port_t getPort();
int getAction();
bool validateKnockData(u8 *key, size_t keylen);
const char *toString();
};
#endif /* __PKDATALIGHT6_H__ */