root/honeyclient/branches/rel/1.0/Capture2/capture-client-xeno-mod/Monitor.h
| Revision 823, 3.5 kB (checked in by xkovah, 1 year ago) |
|---|
| Line | |
|---|---|
| 1 | /* |
| 2 | * PROJECT: Capture |
| 3 | * FILE: Monitor.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 | #include "CaptureGlobal.h" |
| 26 | #include <list> |
| 27 | #include <string> |
| 28 | #include <iostream> |
| 29 | #include <fstream> |
| 30 | #include <vector> |
| 31 | #include <hash_map> |
| 32 | #include <winioctl.h> |
| 33 | #include <tchar.h> |
| 34 | #include "Permission.h" |
| 35 | |
| 36 | using namespace std; |
| 37 | using namespace boost; |
| 38 | |
| 39 | |
| 40 | |
| 41 | /* |
| 42 | Class: Monitor |
| 43 | |
| 44 | Provides a common interface for the construction of system monitors |
| 45 | */ |
| 46 | |
| 47 | /* |
| 48 | Constants: Kernel Driver IOCTL Codes |
| 49 | |
| 50 | IOCTL_CAPTURE_START - Starts the kernel drivers monitor. |
| 51 | IOCTL_CAPTURE_STOP - Stops the kernel drivers monitor. |
| 52 | */ |
| 53 | #define IOCTL_CAPTURE_START CTL_CODE(0x00000022, 0x0805, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) |
| 54 | #define IOCTL_CAPTURE_STOP CTL_CODE(0x00000022, 0x0806, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) |
| 55 | |
| 56 | typedef pair <wstring, std::list<Permission*>*> Permission_Pair; |
| 57 | |
| 58 | class Monitor |
| 59 | { |
| 60 | public: |
| 61 | Monitor(); |
| 62 | virtual ~Monitor(); |
| 63 | |
| 64 | virtual void start() = 0; |
| 65 | virtual void stop() = 0; |
| 66 | /* |
| 67 | Function: clearExclusionList |
| 68 | |
| 69 | Clears all exclusions added through the exclusion lists. Excluded all the |
| 70 | permaneant exclusions which are created during object creation. |
| 71 | */ |
| 72 | void clearExclusionList(); |
| 73 | |
| 74 | protected: |
| 75 | /* |
| 76 | Function: convertTimeFieldToWString |
| 77 | |
| 78 | Converts a <TIME_FIELDS> structure to a readible wstring |
| 79 | */ |
| 80 | wstring convertTimeFieldToWString(SYSTEMTIME time); |
| 81 | /* |
| 82 | Function: EventIsAllowed |
| 83 | Checks whether an event is allowed |
| 84 | */ |
| 85 | bool isEventAllowed(std::wstring eventType, std::wstring subject, std::wstring object); |
| 86 | /* |
| 87 | Function: InstallKernelDriver |
| 88 | Installs a kernel driver |
| 89 | */ |
| 90 | bool installKernelDriver(wstring driverPath, wstring driverName, wstring driverDescription); |
| 91 | /* |
| 92 | Function: UnInstallKernelDriver |
| 93 | Uninstalls a kernel driver |
| 94 | */ |
| 95 | void unInstallKernelDriver(); |
| 96 | /* |
| 97 | Function: LoadExclusionList |
| 98 | Loads an exclusion list from a a file and creates a permission list |
| 99 | */ |
| 100 | void loadExclusionList(wstring file); |
| 101 | /* |
| 102 | Function: prepareStringForExclusion |
| 103 | |
| 104 | Helper function which parses a string for "." and adds a "\" in front of it |
| 105 | */ |
| 106 | void prepareStringForExclusion(wstring* s); |
| 107 | |
| 108 | /* |
| 109 | Function: addExclusion |
| 110 | |
| 111 | Creates a permission and adds an the exclusion to the internal list |
| 112 | */ |
| 113 | void addExclusion(wstring excluded, wstring action, wstring subject, wstring object, bool permaneant = false); |
| 114 | |
| 115 | |
| 116 | SC_HANDLE hService; |
| 117 | |
| 118 | /* |
| 119 | Variable: permissionMap |
| 120 | A map containing a list of permissions based on a particular event type |
| 121 | */ |
| 122 | stdext::hash_map<wstring, std::list<Permission*>*> permissionMap; |
| 123 | }; |
Note: See TracBrowser for help on using the browser.
