root/capture-mod/trunk/CaptureGlobal.h

Revision 823, 5.4 kB (checked in by xkovah, 1 year ago)

adding the files finally

Line 
1 /*
2  *  PROJECT: Capture
3  *  FILE: CaptureGlobal.h
4  *  AUTHORS: Ramon Steenson (rsteenson@gmail.com) & Christian Seifert (christian.seifert@gmail.com)
5  *
6  *  Developed by Victoria University of Wellington and the New Zealand Honeynet Alliance
7  *
8  *  This file is part of Capture.
9  *
10  *  Capture is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  Capture is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with Capture; if not, write to the Free Software
22  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23  */
24 #pragma once
25 #define _WIN32_WINNT 0x0501
26 #define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
27 //#define LOCALTEST         // Output some local statistics for debugging
28
29 /*
30     This header is included by all objects in the client. This allows all object
31     to have access to the various singleton objects in the project
32 */
33 #include "ErrorCodes.h"
34 #include <windows.h>
35 #include "ProcessManager.h"
36 #include "EventController.h"
37 #include "Logger.h"
38 #include "OptionsManager.h"
39
40 static const wchar_t * hexenc[] = {
41     L"%00", L"%01", L"%02", L"%03", L"%04", L"%05", L"%06", L"%07",
42     L"%08", L"%09", L"%0a", L"%0b", L"%0c", L"%0d", L"%0e", L"%0f",
43     L"%10", L"%11", L"%12", L"%13", L"%14", L"%15", L"%16", L"%17",
44     L"%18", L"%19", L"%1a", L"%1b", L"%1c", L"%1d", L"%1e", L"%1f",
45     L"%20", L"%21", L"%22", L"%23", L"%24", L"%25", L"%26", L"%27",
46     L"%28", L"%29", L"%2a", L"%2b", L"%2c", L"%2d", L"%2e", L"%2f",
47     L"%30", L"%31", L"%32", L"%33", L"%34", L"%35", L"%36", L"%37",
48     L"%38", L"%39", L"%3a", L"%3b", L"%3c", L"%3d", L"%3e", L"%3f",
49     L"%40", L"%41", L"%42", L"%43", L"%44", L"%45", L"%46", L"%47",
50     L"%48", L"%49", L"%4a", L"%4b", L"%4c", L"%4d", L"%4e", L"%4f",
51     L"%50", L"%51", L"%52", L"%53", L"%54", L"%55", L"%56", L"%57",
52     L"%58", L"%59", L"%5a", L"%5b", L"%5c", L"%5d", L"%5e", L"%5f",
53     L"%60", L"%61", L"%62", L"%63", L"%64", L"%65", L"%66", L"%67",
54     L"%68", L"%69", L"%6a", L"%6b", L"%6c", L"%6d", L"%6e", L"%6f",
55     L"%70", L"%71", L"%72", L"%73", L"%74", L"%75", L"%76", L"%77",
56     L"%78", L"%79", L"%7a", L"%7b", L"%7c", L"%7d", L"%7e", L"%7f",
57     L"%80", L"%81", L"%82", L"%83", L"%84", L"%85", L"%86", L"%87",
58     L"%88", L"%89", L"%8a", L"%8b", L"%8c", L"%8d", L"%8e", L"%8f",
59     L"%90", L"%91", L"%92", L"%93", L"%94", L"%95", L"%96", L"%97",
60     L"%98", L"%99", L"%9a", L"%9b", L"%9c", L"%9d", L"%9e", L"%9f",
61     L"%a0", L"%a1", L"%a2", L"%a3", L"%a4", L"%a5", L"%a6", L"%a7",
62     L"%a8", L"%a9", L"%aa", L"%ab", L"%ac", L"%ad", L"%ae", L"%af",
63     L"%b0", L"%b1", L"%b2", L"%b3", L"%b4", L"%b5", L"%b6", L"%b7",
64     L"%b8", L"%b9", L"%ba", L"%bb", L"%bc", L"%bd", L"%be", L"%bf",
65     L"%c0", L"%c1", L"%c2", L"%c3", L"%c4", L"%c5", L"%c6", L"%c7",
66     L"%c8", L"%c9", L"%ca", L"%cb", L"%cc", L"%cd", L"%ce", L"%cf",
67     L"%d0", L"%d1", L"%d2", L"%d3", L"%d4", L"%d5", L"%d6", L"%d7",
68     L"%d8", L"%d9", L"%da", L"%db", L"%dc", L"%dd", L"%de", L"%df",
69     L"%e0", L"%e1", L"%e2", L"%e3", L"%e4", L"%e5", L"%e6", L"%e7",
70     L"%e8", L"%e9", L"%ea", L"%eb", L"%ec", L"%ed", L"%ee", L"%ef",
71     L"%f0", L"%f1", L"%f2", L"%f3", L"%f4", L"%f5", L"%f6", L"%f7",
72     L"%f8", L"%f9", L"%fa", L"%fb", L"%fc", L"%fd", L"%fe", L"%ff"
73     };
74
75
76 class CaptureGlobal
77 {
78 public:
79     static wstring urlEncode(wstring text);
80     static wstring urlDecode(wstring text);
81 };
82
83 typedef struct _TIME_FIELDS {
84     WORD wYear;
85     WORD wMonth;
86     WORD wDay;
87     WORD wHour;
88     WORD wMinute;
89     WORD wSecond;
90     WORD wMilliseconds;
91     WORD wWeekday;
92 } TIME_FIELDS;
93
94 /*
95     Various C methods to allow base64 encoding and decoding
96 */
97 extern "C" {
98
99 void DebugPrint(LPCTSTR pszFormat, ... );
100
101 static char b64_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
102
103 #define XX 100
104
105 static int b64_index[256] = {
106     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
107     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
108     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,62, XX,XX,XX,63,
109     52,53,54,55, 56,57,58,59, 60,61,XX,XX, XX,XX,XX,XX,
110     XX, 0, 1, 2,  3, 4, 5, 6,  7, 8, 9,10, 11,12,13,14,
111     15,16,17,18, 19,20,21,22, 23,24,25,XX, XX,XX,XX,XX,
112     XX,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
113     41,42,43,44, 45,46,47,48, 49,50,51,XX, XX,XX,XX,XX,
114     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
115     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
116     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
117     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
118     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
119     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
120     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
121     XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX,
122 };
123
124 void decode_base64(char* encodedBuffer);
125
126 char* encode_base64(char* cleartextBuffer, size_t length, size_t* encodedLength);
127
128 size_t convertTimefieldsToString(TIME_FIELDS time, wchar_t* buffer, size_t bufferLength);
129 };
Note: See TracBrowser for help on using the browser.