├── Filter ├── dirs ├── process.bat ├── user │ ├── monitorexe.c │ ├── sources │ └── makefile ├── filterdriver │ ├── monitor.c │ ├── piga.rc │ ├── sources │ ├── makefile │ ├── file.c │ ├── sockets.c │ └── process.c ├── include │ ├── fltdrvCommon.h │ ├── fltdrvKernel.h │ ├── sockets.h │ ├── process.h │ └── fltInc.h └── pigamonitor.inf ├── Registry ├── src │ ├── makefile │ ├── sources │ ├── sockets.h │ ├── pigaregmonitor.h │ ├── process.h │ ├── process.c │ ├── sockets.c │ ├── registry.c │ └── pigaregmonitor.c ├── process.bat └── pigaregmonitor.inf ├── Server ├── visu │ ├── mysql.pyc │ ├── file.py │ └── mysql.py ├── python │ ├── mysql.pyc │ ├── registry.py │ ├── file.py │ └── mysql.py ├── server │ ├── line.pyc │ ├── lineThread.pyc │ ├── lineThread.py │ ├── server.py │ ├── server_file.py │ ├── server_reg.py │ └── line.py └── graph │ ├── expension.txt │ ├── Ressources.pyc │ ├── Ressources.py │ └── Test.py ├── visu ├── texture-noise.png ├── style.css ├── tree.html └── save.json ├── README.md └── LICENSE /Filter/dirs: -------------------------------------------------------------------------------- 1 | DIRS= \ 2 | filterdriver \ 3 | user 4 | -------------------------------------------------------------------------------- /Registry/src/makefile: -------------------------------------------------------------------------------- 1 | !INCLUDE $(NTMAKEENV)\makefile.def 2 | 3 | -------------------------------------------------------------------------------- /Filter/process.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Filter/process.bat -------------------------------------------------------------------------------- /Registry/process.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Registry/process.bat -------------------------------------------------------------------------------- /Server/visu/mysql.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Server/visu/mysql.pyc -------------------------------------------------------------------------------- /Filter/user/monitorexe.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Filter/user/monitorexe.c -------------------------------------------------------------------------------- /Server/python/mysql.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Server/python/mysql.pyc -------------------------------------------------------------------------------- /Server/server/line.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Server/server/line.pyc -------------------------------------------------------------------------------- /visu/texture-noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/visu/texture-noise.png -------------------------------------------------------------------------------- /Server/graph/expension.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Server/graph/expension.txt -------------------------------------------------------------------------------- /Filter/filterdriver/monitor.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Filter/filterdriver/monitor.c -------------------------------------------------------------------------------- /Filter/include/fltdrvCommon.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Filter/include/fltdrvCommon.h -------------------------------------------------------------------------------- /Filter/include/fltdrvKernel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Filter/include/fltdrvKernel.h -------------------------------------------------------------------------------- /Server/graph/Ressources.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Server/graph/Ressources.pyc -------------------------------------------------------------------------------- /Server/server/lineThread.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgros/Remote_Malware_Analyzer/HEAD/Server/server/lineThread.pyc -------------------------------------------------------------------------------- /Registry/src/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=pigaregmonitor 2 | TARGETTYPE=DRIVER 3 | DRIVERTYPE=FS 4 | 5 | 6 | TARGETLIBS= $(TARGETLIBS) \ 7 | $(DDK_LIB_PATH)\netio.lib 8 | 9 | SOURCES = pigaregmonitor.c \ 10 | registry.c \ 11 | process.c \ 12 | sockets.c 13 | 14 | -------------------------------------------------------------------------------- /Server/visu/file.py: -------------------------------------------------------------------------------- 1 | from mysql import * 2 | import sys 3 | 4 | if __name__ == "__main__": 5 | if len(sys.argv) < 2: 6 | print("donnez une session") 7 | sys.exit(1) 8 | 9 | dbconfig = dbconfig() 10 | db2 = dbinterface(dbconfig) 11 | run = sys.argv[1] 12 | 13 | db2.PrintProcess(run) 14 | print "toto" 15 | -------------------------------------------------------------------------------- /Filter/filterdriver/piga.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #define VER_FILETYPE 0.2.0.1 6 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 7 | #define VER_FILEDESCRIPTION_STR "Monitor Filter Driver" 8 | #define VER_INTERNALNAME_STR "monitor.sys" 9 | #define VER_ORIGINALFILENAME_STR "monitor.sys" 10 | 11 | #include "common.ver" 12 | 13 | -------------------------------------------------------------------------------- /Filter/filterdriver/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=monitor_piga 2 | TARGETTYPE=DRIVER 3 | DRIVERTYPE=FS 4 | LINKER_FLAGS=/map 5 | 6 | 7 | INCLUDES=$(INCLUDES);..\include 8 | 9 | TARGETLIBS=$(TARGETLIBS) \ 10 | $(DDK_LIB_PATH)\netio.lib \ 11 | $(IFSKIT_LIB_PATH)\fltMgr.lib 12 | 13 | C_DEFINES=$(C_DEFINES) -D_WIN2K_COMPAT_SLIST_USAGE 14 | 15 | SOURCES=file.c process.c monitor.c sockets.c \ 16 | piga.rc \ 17 | 18 | 19 | -------------------------------------------------------------------------------- /Filter/user/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=monitor 2 | TARGETTYPE=PROGRAM 3 | UMTYPE=console 4 | USE_MSVCRT=1 5 | 6 | C_DEFINES=$(C_DEFINES) -DUNICODE -D_UNICODE 7 | 8 | LINKLIBS=$(SDK_LIB_PATH)\shell32.lib 9 | 10 | INCLUDES=$(INCLUDES); \ 11 | $(IFSKIT_INC_PATH); \ 12 | $(DDK_INC_PATH); \ 13 | ..\include 14 | 15 | TARGETLIBS=$(TARGETLIBS) \ 16 | $(IFSKIT_LIB_PATH)\fltLib.lib 17 | 18 | SOURCES=monitorexe.c 19 | -------------------------------------------------------------------------------- /Filter/user/makefile: -------------------------------------------------------------------------------- 1 | !IF 0 2 | 3 | Copyright (C) Microsoft Corporation, 1999 - 2002 4 | 5 | Module Name: 6 | 7 | makefile. 8 | 9 | Notes: 10 | 11 | DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 12 | file to this component. This file merely indirects to the real make file 13 | that is shared by all the components of Windows NT (DDK) 14 | 15 | !ENDIF 16 | 17 | !INCLUDE $(NTMAKEENV)\makefile.def 18 | 19 | -------------------------------------------------------------------------------- /Filter/filterdriver/makefile: -------------------------------------------------------------------------------- 1 | !IF 0 2 | 3 | Copyright (C) Microsoft Corporation, 1999 - 2002 4 | 5 | Module Name: 6 | 7 | makefile. 8 | 9 | Notes: 10 | 11 | DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 12 | file to this component. This file merely indirects to the real make file 13 | that is shared by all the components of Windows NT (DDK) 14 | 15 | !ENDIF 16 | 17 | !INCLUDE $(NTMAKEENV)\makefile.def 18 | 19 | -------------------------------------------------------------------------------- /Server/server/lineThread.py: -------------------------------------------------------------------------------- 1 | ''' 2 | 3 | ''' 4 | import threading 5 | import time 6 | 7 | class lineThread(threading.Thread): 8 | def __init__(self, qu,fil): 9 | threading.Thread.__init__(self) 10 | self.Terminated = False 11 | self.__toRead = qu 12 | self.__file = fil 13 | 14 | 15 | def run(self): 16 | fichier = open(self.__file, "w") 17 | while not self.Terminated: 18 | rest = "" 19 | while self.__toRead.qsize() > 0: 20 | fichier.write(self.__toRead.get()) 21 | fichier.flush() 22 | fichier.close() 23 | def stop(self): 24 | self.Terminated = True 25 | -------------------------------------------------------------------------------- /Filter/include/sockets.h: -------------------------------------------------------------------------------- 1 | #ifndef __SOCKETS__ 2 | #define __SOCKETS__ 3 | 4 | PWSK_SOCKET sock; 5 | WSK_REGISTRATION clireg; 6 | 7 | NTSTATUS 8 | initwsk(PWSK_REGISTRATION clireg, PWSK_PROVIDER_NPI pronpi); 9 | 10 | VOID 11 | cleanupwsk(PWSK_REGISTRATION clireg); 12 | 13 | NTSTATUS 14 | connecttoserver(PWSK_PROVIDER_NPI pronpi, PSOCKADDR remaddr, 15 | PWSK_SOCKET *sock); 16 | 17 | IO_COMPLETION_ROUTINE 18 | createcomplete; 19 | 20 | NTSTATUS 21 | senddata(PWSK_SOCKET sock, PVOID data, ULONG datal); 22 | 23 | IO_COMPLETION_ROUTINE 24 | senddatacomplete; 25 | 26 | NTSTATUS 27 | recvdata(PWSK_SOCKET sock, PVOID data, ULONG datal, ULONG flags, 28 | PULONG_PTR recvd); 29 | 30 | IO_COMPLETION_ROUTINE 31 | recvdatacomplete; 32 | 33 | NTSTATUS 34 | disconnectfromserver(PWSK_SOCKET sock); 35 | 36 | IO_COMPLETION_ROUTINE 37 | disconnectcomplete; 38 | 39 | #endif -------------------------------------------------------------------------------- /Registry/src/sockets.h: -------------------------------------------------------------------------------- 1 | #ifndef __SOCKETS__ 2 | #define __SOCKETS__ 3 | int trace; 4 | PWSK_SOCKET sock; 5 | WSK_REGISTRATION clireg; 6 | 7 | NTSTATUS 8 | initwsk(PWSK_REGISTRATION clireg, PWSK_PROVIDER_NPI pronpi); 9 | 10 | VOID 11 | cleanupwsk(PWSK_REGISTRATION clireg); 12 | 13 | NTSTATUS 14 | connecttoserver(PWSK_PROVIDER_NPI pronpi, PSOCKADDR remaddr, 15 | PWSK_SOCKET *sock); 16 | 17 | IO_COMPLETION_ROUTINE 18 | createcomplete; 19 | 20 | NTSTATUS 21 | senddata(PWSK_SOCKET sock, PVOID data, ULONG datal); 22 | 23 | IO_COMPLETION_ROUTINE 24 | senddatacomplete; 25 | 26 | NTSTATUS 27 | recvdata(PWSK_SOCKET sock, PVOID data, ULONG datal, ULONG flags, 28 | PULONG_PTR recvd); 29 | 30 | IO_COMPLETION_ROUTINE 31 | recvdatacomplete; 32 | 33 | NTSTATUS 34 | disconnectfromserver(PWSK_SOCKET sock); 35 | 36 | IO_COMPLETION_ROUTINE 37 | disconnectcomplete; 38 | 39 | #endif -------------------------------------------------------------------------------- /Server/python/registry.py: -------------------------------------------------------------------------------- 1 | from mysql import * 2 | import sys 3 | 4 | if __name__ == "__main__": 5 | if len(sys.argv) < 2: 6 | print("donnez un fichier en entree") 7 | sys.exit(1) 8 | 9 | fichier = sys.argv[1] 10 | try: 11 | op = open(fichier, "r") 12 | except: 13 | print "ta mere" 14 | sys.exit(1) 15 | 16 | dbconfig = dbconfig() 17 | db2 = dbinterface(dbconfig) 18 | run = db2.IdSession("AZERT1222") 19 | print run 20 | corps = op.readlines() 21 | process = 0 22 | action = 0 23 | creation = 0 24 | buf="" 25 | for f in corps: 26 | traitement = f.replace('\n', '') 27 | if traitement == "-- BEGIN": 28 | action=1 29 | buf="" 30 | continue 31 | if traitement == "-- END": 32 | action=0 33 | db2.addRegistry(buf, run) 34 | buf="" 35 | continue 36 | if action == 1: 37 | buf = buf + traitement + "\n" 38 | op.close() 39 | print "toto" 40 | -------------------------------------------------------------------------------- /Registry/src/pigaregmonitor.h: -------------------------------------------------------------------------------- 1 | #ifndef _PIGAREG_ 2 | #define _PIGAREG_ 3 | 4 | #pragma warning(push, 0) 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #pragma warning(pop) 11 | 12 | #include "process.h" 13 | #include "sockets.h" 14 | 15 | typedef struct _DEVICE_CONTEXT 16 | { 17 | PDRIVER_OBJECT pDriverObject; 18 | PDEVICE_OBJECT pDeviceObject; 19 | LARGE_INTEGER RegCookie; 20 | }DEVICE_CONTEXT, *PDEVICE_CONTEXT; 21 | 22 | NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ); 23 | NTSTATUS RegistryCallback(IN PVOID CallbackContext, IN PVOID Argument1, IN PVOID Argument2); 24 | VOID DriverUnload(IN PDRIVER_OBJECT DriverObject); 25 | NTSTATUS DriverDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); 26 | NTSTATUS DrvWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); 27 | NTSTATUS DrvCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); 28 | 29 | NTSTATUS sendthenrecv(void); 30 | NTSTATUS AddInQueue(__in char * buf); 31 | NTSTATUS RemoveQueue(); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Registry/src/process.h: -------------------------------------------------------------------------------- 1 | #ifndef __PROCESS__ 2 | #define __PROCESS__ 3 | 4 | // #include 5 | #include 6 | 7 | #include 8 | 9 | 10 | int GetParentId(int pid); 11 | int GetSessionId(int pid); 12 | VOID GetUnicodeName(int pid); 13 | INT GetUnicodeName_only(int pid); 14 | 15 | char * ComputeSSID(PUNICODE_STRING fullname); 16 | 17 | HANDLE handle; 18 | 19 | VOID WriteInLog(char * buffer); 20 | 21 | PFAST_MUTEX FastMutex; 22 | 23 | NTSYSAPI 24 | NTSTATUS 25 | NTAPI ZwQueryInformationProcess( 26 | __in HANDLE ProcessHandle, 27 | __in PROCESSINFOCLASS ProcessInformationClass, 28 | __out PVOID ProcessInformation, 29 | __in ULONG ProcessInformationLength, 30 | __out_opt PULONG ReturnLength 31 | ); 32 | 33 | //PPEB NTAPI PsGetProcessPeb ( PEPROCESS Process ) ; 34 | 35 | /** 36 | * Stucture contenant les informations pour les processus 37 | * processname : le path complet (moins le point de montage) 38 | * hash_process : le hash du ssid. 39 | **/ 40 | typedef struct _process_struct { 41 | 42 | struct _process_struct *Next; 43 | UNICODE_STRING processname; 44 | int pid; 45 | int ppid; 46 | char ssid[2048]; 47 | unsigned long hash_process; 48 | } Process_Struct; 49 | 50 | #endif -------------------------------------------------------------------------------- /visu/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: url(texture-noise.png); 3 | overflow: hidden; 4 | margin: 0; 5 | font-size: 14px; 6 | font-family: "Helvetica Neue", Helvetica; 7 | } 8 | 9 | #chart, #header, #footer { 10 | position: absolute; 11 | top: 0; 12 | } 13 | 14 | #header, #footer { 15 | z-index: 1; 16 | display: block; 17 | font-size: 36px; 18 | font-weight: 300; 19 | text-shadow: 0 1px 0 #fff; 20 | } 21 | 22 | #header.inverted, #footer.inverted { 23 | color: #fff; 24 | text-shadow: 0 1px 4px #000; 25 | } 26 | 27 | #header { 28 | top: 80px; 29 | left: 140px; 30 | width: 1000px; 31 | } 32 | 33 | #footer { 34 | top: 680px; 35 | right: 140px; 36 | text-align: right; 37 | } 38 | 39 | rect { 40 | fill: none; 41 | pointer-events: all; 42 | } 43 | 44 | pre { 45 | font-size: 18px; 46 | } 47 | 48 | line { 49 | stroke: #000; 50 | stroke-width: 1.5px; 51 | } 52 | 53 | .string, .regexp { 54 | color: #f39; 55 | } 56 | 57 | .keyword { 58 | color: #00c; 59 | } 60 | 61 | .comment { 62 | color: #777; 63 | font-style: oblique; 64 | } 65 | 66 | .number { 67 | color: #369; 68 | } 69 | 70 | .class, .special { 71 | color: #1181B8; 72 | } 73 | 74 | a:link, a:visited { 75 | color: #000; 76 | text-decoration: none; 77 | } 78 | 79 | a:hover { 80 | color: #666; 81 | } 82 | 83 | .hint { 84 | position: absolute; 85 | right: 0; 86 | width: 1280px; 87 | font-size: 12px; 88 | color: #999; 89 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Remote_Malware_Analyzer 2 | Sandbox d'analyse de malware pour Windows 7 avec un client TCP en mode noyau 3 | 4 | Sandbox d'analyse de malware pour Windows 7 basé sur des filter drivers et des registry callbacks. Aucune modification de table système. Il est ainsi possible de le faire pour Windows 7 64 bits (mais non testé). 5 | 6 | Pour assurer l'intégrité des informations récoltées, un client TCP est implémenté en mode noyau et qui envoie directement les logs sur un serveur. Nous avons deux parties : la première concerne le système de fichiers et la seconde concerne le registre. 7 | 8 | Le serveur est fait en python. Il écoute sur deux sockets (file system et registry) puis stocke dans une base de données MySql les informations récoltées sans aucun traitement. 9 | 10 | Dans le dossier Server, plusieurs scripts permettent de traiter les résultats depuis les informations de la base de données. Ils permettent de décrire, dans le temps, l'évolution du binaire étudié. Ils offrent aussi la possibilité de transformer les résultats en JSON pour être ensuite intégré à d3.js. La partie visualisation est disponible dans le dossier visu. 11 | 12 | Des exemples d'analyses sont disponibles dans le dossier Server. Par exemple, nous avons des rogues mais aussi un ZeroAccess. On peut ainsi voir que l'installeur du ZeroAccess va utiliser un installeur légitime pour infecter le système. 13 | 14 | Ces travaux ont été faits et développés dans le chapitre 5 de la thèse http://www.theses.fr/2014ORLE2017 15 | -------------------------------------------------------------------------------- /Server/server/server.py: -------------------------------------------------------------------------------- 1 | import SocketServer 2 | #from line import readTrace 3 | from lineThread import lineThread 4 | from Queue import * 5 | import threading 6 | import logging 7 | 8 | class traceServer(SocketServer.BaseRequestHandler): 9 | 10 | def settoRead(qu): 11 | self.__toRead = qu 12 | 13 | def handle(self): 14 | rest = "" 15 | while 1: 16 | self.data = self.request.recv(3100) 17 | if not self.data: 18 | print("Connexion Error !!!!!!!!!!!!!!") 19 | self.data = self.request.recv(3100) 20 | if not self.data: 21 | print("Connexion CLOSED !!!!!!!!!!!!") 22 | break 23 | self.server.getQueue().put(self.data) 24 | 25 | class traceServerTCP(SocketServer.TCPServer): 26 | 27 | def setQueue(self,qu): 28 | self.toRead = qu 29 | 30 | def getQueue(self): 31 | return self.toRead 32 | 33 | class traceServerThread(threading.Thread): 34 | def __init__(self, toRead): 35 | threading.Thread.__init__(self) 36 | self.Terminated = False 37 | self.server = traceServerTCP((HOST, PORT), traceServer) 38 | self.server.setQueue(toRead) 39 | 40 | def run(self): 41 | while not self.Terminated: 42 | self.server.serve_forever() 43 | 44 | def stop(self): 45 | self.Terminated = True 46 | 47 | if __name__ == "__main__": 48 | HOST, PORT = "192.168.99.103", 1338 49 | 50 | toRead = Queue() 51 | 52 | 53 | trThread = traceServerThread(toRead) 54 | trThread.daemon = True 55 | trThread.start() 56 | 57 | lineT = lineThread(toRead) 58 | lineT.daemon = True 59 | lineT.start() 60 | lineT.join() 61 | 62 | -------------------------------------------------------------------------------- /Server/server/server_file.py: -------------------------------------------------------------------------------- 1 | import SocketServer 2 | #from line import readTrace 3 | from lineThread import lineThread 4 | from Queue import * 5 | import threading 6 | import logging 7 | import sys 8 | 9 | class traceServer(SocketServer.BaseRequestHandler): 10 | 11 | def settoRead(qu): 12 | self.__toRead = qu 13 | 14 | def handle(self): 15 | rest = "" 16 | while 1: 17 | self.data = self.request.recv(3100) 18 | if not self.data: 19 | print("Connexion Error !!!!!!!!!!!!!!") 20 | self.data = self.request.recv(3100) 21 | if not self.data: 22 | print("Connexion CLOSED !!!!!!!!!!!!") 23 | break 24 | self.server.getQueue().put(self.data) 25 | 26 | class traceServerTCP(SocketServer.TCPServer): 27 | 28 | def setQueue(self,qu): 29 | self.toRead = qu 30 | 31 | def getQueue(self): 32 | return self.toRead 33 | 34 | class traceServerThread(threading.Thread): 35 | def __init__(self, toRead): 36 | threading.Thread.__init__(self) 37 | self.Terminated = False 38 | self.server = traceServerTCP((HOST, PORT), traceServer) 39 | self.server.setQueue(toRead) 40 | 41 | def run(self): 42 | while not self.Terminated: 43 | self.server.serve_forever() 44 | 45 | def stop(self): 46 | self.Terminated = True 47 | 48 | if __name__ == "__main__": 49 | HOST, PORT = "192.168.99.103", 1338 50 | # HOST, PORT = "192.168.1.12", 1338 51 | 52 | toRead = Queue() 53 | 54 | 55 | trThread = traceServerThread(toRead) 56 | trThread.daemon = True 57 | trThread.start() 58 | 59 | lineT = lineThread(toRead, sys.argv[1]) 60 | lineT.daemon = True 61 | lineT.start() 62 | lineT.join() 63 | 64 | -------------------------------------------------------------------------------- /Server/server/server_reg.py: -------------------------------------------------------------------------------- 1 | import SocketServer 2 | #from line import readTrace 3 | from lineThread import lineThread 4 | from Queue import * 5 | import threading 6 | import logging 7 | import sys 8 | import os 9 | 10 | class traceServer(SocketServer.BaseRequestHandler): 11 | 12 | def settoRead(qu): 13 | self.__toRead = qu 14 | 15 | def handle(self): 16 | rest = "" 17 | while 1: 18 | self.data = self.request.recv(3100) 19 | if not self.data: 20 | print("Connexion Error !!!!!!!!!!!!!!") 21 | self.data = self.request.recv(3100) 22 | if not self.data: 23 | print("Connexion CLOSED !!!!!!!!!!!!") 24 | break 25 | self.server.getQueue().put(self.data) 26 | 27 | class traceServerTCP(SocketServer.TCPServer): 28 | 29 | def setQueue(self,qu): 30 | self.toRead = qu 31 | 32 | def getQueue(self): 33 | return self.toRead 34 | 35 | class traceServerThread(threading.Thread): 36 | def __init__(self, toRead): 37 | threading.Thread.__init__(self) 38 | self.Terminated = False 39 | self.server = traceServerTCP((HOST, PORT), traceServer) 40 | self.server.setQueue(toRead) 41 | 42 | def run(self): 43 | while not self.Terminated: 44 | self.server.serve_forever() 45 | 46 | def stop(self): 47 | self.Terminated = True 48 | 49 | if __name__ == "__main__": 50 | #HOST, PORT = "192.168.99.103", 1337 51 | HOST, PORT = "192.168.1.12", 1337 52 | 53 | toRead = Queue() 54 | 55 | 56 | trThread = traceServerThread(toRead) 57 | trThread.daemon = True 58 | trThread.start() 59 | 60 | lineT = lineThread(toRead,sys.argv[1]) 61 | lineT.daemon = True 62 | lineT.start() 63 | lineT.join() 64 | 65 | -------------------------------------------------------------------------------- /Filter/include/process.h: -------------------------------------------------------------------------------- 1 | #ifndef __PROCESS__ 2 | #define __PROCESS__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "fltdrvKernel.h" 11 | int trace; 12 | int GetParentId(int pid); 13 | int GetSessionId(int pid); 14 | VOID GetUnicodeName(int pid); 15 | INT GetUnicodeName_only(int pid); 16 | 17 | char * ComputeSSID(PUNICODE_STRING fullname); 18 | 19 | HANDLE handle; 20 | 21 | VOID WriteInLog(char * buffer); 22 | 23 | PFAST_MUTEX FastMutex; 24 | 25 | 26 | UCHAR *PsGetProcessImageFileName(IN PEPROCESS pep); 27 | 28 | NTSYSAPI 29 | NTSTATUS 30 | NTAPI ZwQueryInformationProcess( 31 | __in HANDLE ProcessHandle, 32 | __in PROCESSINFOCLASS ProcessInformationClass, 33 | __out PVOID ProcessInformation, 34 | __in ULONG ProcessInformationLength, 35 | __out_opt PULONG ReturnLength 36 | ); 37 | 38 | //PPEB NTAPI PsGetProcessPeb ( PEPROCESS Process ) ; 39 | 40 | /** 41 | * Stucture contenant les informations pour les processus 42 | * processname : le path complet (moins le point de montage) 43 | * hash_process : le hash du ssid. 44 | **/ 45 | typedef struct _process_struct { 46 | 47 | struct _process_struct *Next; 48 | UNICODE_STRING processname; 49 | int pid; 50 | int ppid; 51 | char ssid[2048]; 52 | unsigned long hash_process; 53 | } Process_Struct; 54 | 55 | 56 | int DetectPid(); 57 | 58 | typedef struct _callgraph_struct { 59 | struct _callgraph_struct *Suivant; 60 | // struct _callgraph_struct *Precedent; 61 | int pid; 62 | int ppid; 63 | UNICODE_STRING full; 64 | } Callgraph; 65 | 66 | Callgraph * call;// =NULL; 67 | Callgraph * list_head;// = NULL; 68 | 69 | Callgraph * AddProcGraph(int pid, int ppid, Callgraph *list); 70 | VOID InitGraphCall(); 71 | VOID DestroyGraph(); 72 | VOID RemProcGraph(int pid, int ppid, Callgraph *list); 73 | VOID PrintList(Callgraph *list); 74 | VOID PrintFather(int pid, Callgraph *list); 75 | int CallGraph(int pid, int ppid, int create); 76 | 77 | #endif -------------------------------------------------------------------------------- /Server/python/file.py: -------------------------------------------------------------------------------- 1 | from mysql import * 2 | import sys 3 | 4 | if __name__ == "__main__": 5 | if len(sys.argv) < 2: 6 | print("donnez un fichier en entree") 7 | sys.exit(1) 8 | 9 | fichier = sys.argv[1] 10 | try: 11 | op = open(fichier, "r") 12 | except: 13 | print "ta mere" 14 | sys.exit(1) 15 | 16 | dbconfig = dbconfig() 17 | db2 = dbinterface(dbconfig) 18 | run = db2.newIdSession("AZERT1222") 19 | corps = op.readlines() 20 | process = 0 21 | action = 0 22 | creation = 0 23 | buf="" 24 | for f in corps: 25 | traitement = f.replace('\n', '') 26 | if traitement == "------- End loading" and action==1: 27 | db2.addAction(buf, run) 28 | action=0 29 | buf="" 30 | continue 31 | if traitement == "------- Loading": 32 | action =1 33 | continue 34 | if traitement == "------ Create process": 35 | creation =1 36 | continue 37 | if traitement == "------- Enter in IRP": 38 | action=1 39 | buf="" 40 | continue 41 | if traitement == "-------- Exit IRP" and action==1: 42 | db2.addAction(buf, run) 43 | action=0 44 | buf="" 45 | continue 46 | if traitement == "---- Begin": 47 | continue 48 | if traitement == "---- END" and creation==1: 49 | db2.addCreateProcess(buf,run) 50 | buf="" 51 | creation=0 52 | continue 53 | if traitement == "---- END": 54 | continue 55 | if traitement == "------- Fin du detect PID": 56 | process=0 57 | continue 58 | if traitement == "First one": 59 | process=1 60 | continue 61 | if process == 1: 62 | if "Parent" in traitement: 63 | continue 64 | db2.addProcess(traitement, run) 65 | if action == 1: 66 | buf = buf + traitement + "\n" 67 | continue 68 | if creation == 1: 69 | buf = buf + traitement + "\n" 70 | continue 71 | op.close() 72 | print "toto" 73 | -------------------------------------------------------------------------------- /Server/server/line.py: -------------------------------------------------------------------------------- 1 | import re 2 | from xmlParser import parseTrace 3 | class readTrace: 4 | 5 | __file = "" 6 | __pattern_start="" 7 | __pattern_end="" 8 | __pattern_complete = ".*.*" 9 | 10 | def __init__(self, data, logging, dbinterface, rest): 11 | self.__log = logging 12 | if rest[-1:] == "\"": 13 | self.__log.debug("Found a missing space") 14 | rest = rest + " " 15 | if rest[-8:] == "Name, TRUE); 19 | 20 | RtlZeroMemory(&buffer, sizeof(buffer)); 21 | RtlZeroMemory(&buffer_write, sizeof(buffer_write)); 22 | 23 | sprintf_s(buffer, sizeof(buffer), "%s", temp_ansi.Buffer); 24 | RtlFreeAnsiString(&temp_ansi); 25 | if(&name->FinalComponent != NULL) 26 | { 27 | if(strlen(buffer) > 3000) 28 | { 29 | DbgPrint("Buffer Overflow %i %wZ \n", name->Name); 30 | return ; 31 | } 32 | PsLookupProcessByProcessId(PsGetCurrentProcessId(),&pep); 33 | sprintf_s(buffer_write,sizeof(buffer_write), "pid : %s %i \n",PsGetProcessImageFileName(pep), (int)PsGetCurrentProcessId()); 34 | AddInQueue(buffer_write); 35 | RtlZeroMemory(&buffer_write, sizeof(buffer_write)); 36 | sprintf_s(buffer_write,sizeof(buffer_write), "Object Name : %s \n", buffer); 37 | AddInQueue(buffer_write); 38 | } 39 | else 40 | DbgPrint("BUFFFER %s \n", buffer); 41 | 42 | } 43 | 44 | VOID ComputeOSID(char * object) 45 | { 46 | int i=0, j=0; 47 | char * ssid_return = NULL; 48 | char buffer_ansi[1024]; 49 | int taille =strlen("\\Device\\HarddiskVolume2"); 50 | 51 | // if(strlen(object) == taille+1) 52 | // { 53 | // DbgPrint("Object Name : \\ \n"); 54 | // DbgPrint("Object security context : system_t \n"); 55 | // return; 56 | // } 57 | 58 | RtlZeroMemory(&buffer_ansi,sizeof(buffer_ansi)); 59 | 60 | ssid_return = ExAllocatePool(PagedPool, sizeof(char)*2048); 61 | if(ssid_return == NULL) 62 | { 63 | DbgPrint("Echec ExallocatePool for sid compute \n"); 64 | return; 65 | } 66 | 67 | sprintf_s(buffer_ansi,sizeof(buffer_ansi),"%s\0", &object[taille]); 68 | 69 | while(buffer_ansi[i] != '\0' || (i == sizeof(ssid_return))) 70 | { 71 | if( (i==0) && (buffer_ansi[i]!='\\')) 72 | return; 73 | if( (i==0) && (buffer_ansi[i] =='\\')) 74 | { 75 | i++; 76 | continue; 77 | } 78 | if(buffer_ansi[i] == '\\') 79 | { 80 | ssid_return[j] = '_'; 81 | } 82 | else 83 | { 84 | if(buffer_ansi[i] == ' ') 85 | { 86 | i++; 87 | continue; 88 | } 89 | else 90 | { 91 | if(buffer_ansi[i] <= 'Z' && buffer_ansi[i] >= 'A') 92 | ssid_return[j]= (buffer_ansi[i] -'A') + 'a'; 93 | else 94 | ssid_return[j] = buffer_ansi[i]; 95 | } 96 | } 97 | i++; 98 | j++; 99 | } 100 | ssid_return[j]='\0'; 101 | 102 | DbgPrint("Object Name : %s \n", object); 103 | DbgPrint("Object security context : %s \n", ssid_return); 104 | } -------------------------------------------------------------------------------- /Filter/include/fltInc.h: -------------------------------------------------------------------------------- 1 | //Enregistrement des callbacks suivant les IRPs. 2 | CONST FLT_OPERATION_REGISTRATION FSCallbacks[] = 3 | { 4 | {IRP_MJ_CREATE, 0, FSPreCallback, FSPostCallback}, 5 | {IRP_MJ_CREATE_NAMED_PIPE, 0, FSPreCallback, FSPostCallback}, 6 | {IRP_MJ_CLOSE, 0, FSPreCallback, FSPostCallback}, 7 | {IRP_MJ_READ, 0, FSPreCallback, FSPostCallback}, 8 | {IRP_MJ_WRITE, 0, FSPreCallback, FSPostCallback}, 9 | {IRP_MJ_QUERY_INFORMATION, 0, FSPreCallback, FSPostCallback}, 10 | {IRP_MJ_SET_INFORMATION, 0, FSPreCallback, FSPostCallback}, 11 | {IRP_MJ_QUERY_EA, 0, FSPreCallback, FSPostCallback}, 12 | {IRP_MJ_SET_EA, 0, FSPreCallback, FSPostCallback}, 13 | {IRP_MJ_FLUSH_BUFFERS, 0, FSPreCallback, FSPostCallback}, 14 | {IRP_MJ_QUERY_VOLUME_INFORMATION, 0, FSPreCallback, FSPostCallback}, 15 | {IRP_MJ_SET_VOLUME_INFORMATION, 0, FSPreCallback, FSPostCallback}, 16 | {IRP_MJ_DIRECTORY_CONTROL, 0, FSPreCallback, FSPostCallback}, 17 | {IRP_MJ_FILE_SYSTEM_CONTROL, 0, FSPreCallback, FSPostCallback}, 18 | {IRP_MJ_DEVICE_CONTROL, 0, FSPreCallback, FSPostCallback}, 19 | {IRP_MJ_INTERNAL_DEVICE_CONTROL, 0, FSPreCallback, FSPostCallback}, 20 | {IRP_MJ_SHUTDOWN, 0, FSPreCallback, NULL}, 21 | {IRP_MJ_LOCK_CONTROL, 0, FSPreCallback, FSPostCallback}, 22 | {IRP_MJ_CLEANUP, 0, FSPreCallback, FSPostCallback}, 23 | {IRP_MJ_CREATE_MAILSLOT, 0, FSPreCallback, FSPostCallback}, 24 | {IRP_MJ_QUERY_SECURITY, 0, FSPreCallback, FSPostCallback}, 25 | {IRP_MJ_SET_SECURITY, 0, FSPreCallback, FSPostCallback}, 26 | {IRP_MJ_QUERY_QUOTA, 0, FSPreCallback, FSPostCallback}, 27 | {IRP_MJ_SET_QUOTA, 0, FSPreCallback, FSPostCallback}, 28 | {IRP_MJ_PNP, 0, FSPreCallback, FSPostCallback}, 29 | {IRP_MJ_ACQUIRE_FOR_SECTION_SYNCHRONIZATION, 0, FSPreCallback, FSPostCallback}, 30 | {IRP_MJ_RELEASE_FOR_SECTION_SYNCHRONIZATION, 0, FSPreCallback, FSPostCallback}, 31 | {IRP_MJ_ACQUIRE_FOR_MOD_WRITE, 0, FSPreCallback, FSPostCallback}, 32 | {IRP_MJ_RELEASE_FOR_MOD_WRITE, 0, FSPreCallback, FSPostCallback}, 33 | {IRP_MJ_ACQUIRE_FOR_CC_FLUSH, 0, FSPreCallback, FSPostCallback}, 34 | {IRP_MJ_RELEASE_FOR_CC_FLUSH, 0, FSPreCallback, FSPostCallback}, 35 | {IRP_MJ_FAST_IO_CHECK_IF_POSSIBLE, 0, FSPreCallback, FSPostCallback}, 36 | {IRP_MJ_NETWORK_QUERY_OPEN, 0, FSPreCallback, FSPostCallback}, 37 | {IRP_MJ_MDL_READ, 0, FSPreCallback, FSPostCallback}, 38 | {IRP_MJ_MDL_READ_COMPLETE, 0, FSPreCallback, FSPostCallback}, 39 | {IRP_MJ_PREPARE_MDL_WRITE, 0, FSPreCallback, FSPostCallback}, 40 | {IRP_MJ_MDL_WRITE_COMPLETE, 0, FSPreCallback, FSPostCallback}, 41 | {IRP_MJ_VOLUME_MOUNT, 0, FSPreCallback, FSPostCallback}, 42 | {IRP_MJ_VOLUME_DISMOUNT, 0, FSPreCallback, FSPostCallback}, 43 | {IRP_MJ_OPERATION_END} 44 | }; 45 | 46 | const FLT_CONTEXT_REGISTRATION FSContexts[] = { 47 | {FLT_CONTEXT_END} 48 | }; 49 | 50 | CONST FLT_REGISTRATION FilterRegistration = { 51 | 52 | sizeof( FLT_REGISTRATION ), // Size 53 | FLT_REGISTRATION_VERSION, // Version 54 | 0, // Flags 55 | 56 | NULL, // Context 57 | FSCallbacks, // Operation callbacks 58 | 59 | FilterUnload, // MiniFilterUnload 60 | 61 | NULL, // InstanceSetup 62 | NULL, // InstanceQueryTeardown 63 | NULL, // InstanceTeardownStart 64 | NULL, // InstanceTeardownComplete 65 | 66 | NULL, // GenerateFileName 67 | NULL, // GenerateDestinationFileName 68 | NULL // NormalizeNameComponent 69 | 70 | }; 71 | -------------------------------------------------------------------------------- /Filter/pigamonitor.inf: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Minispy 3 | ;;; 4 | ;;; 5 | ;;; Copyright (c) 2001, Microsoft Corporation 6 | ;;; 7 | 8 | [Version] 9 | Signature = "$Windows NT$" 10 | Class = "ActivityMonitor" ;This is determined by the work this filter driver does 11 | ClassGuid = {b86dff51-a31e-4bac-b3cf-e8cfe75c9fc2} ;This value is determined by the Class 12 | Provider = %Msft% 13 | DriverVer = 06/16/2007,1.0.0.0 14 | CatalogFile = pigamonitor.cat 15 | 16 | 17 | [DestinationDirs] 18 | DefaultDestDir = 12 19 | PigaMonitor.DriverFiles = 12 ;%windir%\system32\drivers 20 | PigaMonitor.UserFiles = 10,FltMgr ;%windir%\FltMgr 21 | 22 | ;; 23 | ;; Default install sections 24 | ;; 25 | 26 | [DefaultInstall] 27 | OptionDesc = %ServiceDescription% 28 | CopyFiles = PigaMonitor.DriverFiles, PigaMonitor.UserFiles 29 | 30 | [DefaultInstall.Services] 31 | AddService = %ServiceName%,,PigaMonitor.Service 32 | 33 | ;; 34 | ;; Default uninstall sections 35 | ;; 36 | 37 | [DefaultUninstall] 38 | DelFiles = PigaMonitor.DriverFiles, PigaMonitor.UserFiles 39 | 40 | [DefaultUninstall.Services] 41 | DelService = %ServiceName%,0x200 ;Ensure service is stopped before deleting 42 | 43 | ; 44 | ; Services Section 45 | ; 46 | 47 | [PigaMonitor.Service] 48 | DisplayName = %ServiceName% 49 | Description = %ServiceDescription% 50 | ServiceBinary = %12%\%DriverName%.sys ;%windir%\system32\drivers\ 51 | Dependencies = FltMgr 52 | ServiceType = 2 ;SERVICE_FILE_SYSTEM_DRIVER 53 | StartType = 3 ;SERVICE_DEMAND_START 54 | ErrorControl = 1 ;SERVICE_ERROR_NORMAL 55 | LoadOrderGroup = "FSFilter Activity Monitor" 56 | AddReg = PigaMonitor.AddRegistry 57 | 58 | ; 59 | ; Registry Modifications 60 | ; 61 | 62 | [PigaMonitor.AddRegistry] 63 | HKR,"Instances","DefaultInstance",0x00000000,%DefaultInstance% 64 | HKR,"Instances\"%Instance1.Name%,"Altitude",0x00000000,%Instance1.Altitude% 65 | HKR,"Instances\"%Instance1.Name%,"Flags",0x00010001,%Instance1.Flags% 66 | HKR,"Instances\"%Instance2.Name%,"Altitude",0x00000000,%Instance2.Altitude% 67 | HKR,"Instances\"%Instance2.Name%,"Flags",0x00010001,%Instance2.Flags% 68 | HKR,"Instances\"%Instance3.Name%,"Altitude",0x00000000,%Instance3.Altitude% 69 | HKR,"Instances\"%Instance3.Name%,"Flags",0x00010001,%Instance3.Flags% 70 | 71 | ; 72 | ; Copy Files 73 | ; 74 | 75 | [PigaMonitor.DriverFiles] 76 | %DriverName%.sys 77 | 78 | [PigaMonitor.UserFiles] 79 | %UserAppName%.exe 80 | 81 | [SourceDisksFiles] 82 | pigamonitor.sys = 1,, 83 | pigamonitor.exe = 1,, 84 | 85 | [SourceDisksNames] 86 | 1 = %DiskId1%,,, 87 | 88 | ;; 89 | ;; String Section 90 | ;; 91 | 92 | [Strings] 93 | Msft = "Microsoft Corporation" 94 | ServiceDescription = "Piga Monitor driver" 95 | ServiceName = "PigaMonitor" 96 | DriverName = "pigamonitor" 97 | UserAppName = "pigamonitor" 98 | DiskId1 = "Piga Monitor Device Installation Disk" 99 | 100 | ;Instances specific information. 101 | DefaultInstance = "Piga Monitor - Top Instance" 102 | Instance1.Name = "Piga Monitor - Middle Instance" 103 | Instance1.Altitude = "370000" 104 | Instance1.Flags = 0x0 ; Suppress automatic attachments 105 | Instance2.Name = "Piga Monitor - Bottom Instance" 106 | Instance2.Altitude = "361000" 107 | Instance2.Flags = 0x0 ; Suppress automatic attachments 108 | Instance3.Name = "Piga Monitor - Top Instance" 109 | Instance3.Altitude = "385100" 110 | Instance3.Flags = 0x0 ; Suppress automatic attachments 111 | 112 | -------------------------------------------------------------------------------- /Registry/pigaregmonitor.inf: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;; Minispy 3 | ;;; 4 | ;;; 5 | ;;; Copyright (c) 2001, Microsoft Corporation 6 | ;;; 7 | 8 | [Version] 9 | Signature = "$Windows NT$" 10 | Class = "ActivityMonitor" ;This is determined by the work this filter driver does 11 | ClassGuid = {b86dff51-a31e-4bac-b3cf-e8cfe75c9fc2} ;This value is determined by the Class 12 | Provider = %Msft% 13 | DriverVer = 06/16/2007,1.0.0.0 14 | CatalogFile = pigaregmonitor.cat 15 | 16 | 17 | [DestinationDirs] 18 | DefaultDestDir = 12 19 | pigaregmonitor.DriverFiles = 12 ;%windir%\system32\drivers 20 | pigaregmonitor.UserFiles = 10,FltMgr ;%windir%\FltMgr 21 | 22 | ;; 23 | ;; Default install sections 24 | ;; 25 | 26 | [DefaultInstall] 27 | OptionDesc = %ServiceDescription% 28 | CopyFiles = pigaregmonitor.DriverFiles, pigaregmonitor.UserFiles 29 | 30 | [DefaultInstall.Services] 31 | AddService = %ServiceName%,,pigaregmonitor.Service 32 | 33 | ;; 34 | ;; Default uninstall sections 35 | ;; 36 | 37 | [DefaultUninstall] 38 | DelFiles = pigaregmonitor.DriverFiles, pigaregmonitor.UserFiles 39 | 40 | [DefaultUninstall.Services] 41 | DelService = %ServiceName%,0x200 ;Ensure service is stopped before deleting 42 | 43 | ; 44 | ; Services Section 45 | ; 46 | 47 | [pigaregmonitor.Service] 48 | DisplayName = %ServiceName% 49 | Description = %ServiceDescription% 50 | ServiceBinary = %12%\%DriverName%.sys ;%windir%\system32\drivers\ 51 | Dependencies = FltMgr 52 | ServiceType = 2 ;SERVICE_FILE_SYSTEM_DRIVER 53 | StartType = 3 ;SERVICE_DEMAND_START 54 | ErrorControl = 1 ;SERVICE_ERROR_NORMAL 55 | LoadOrderGroup = "FSFilter Activity Monitor" 56 | AddReg = pigaregmonitor.AddRegistry 57 | 58 | ; 59 | ; Registry Modifications 60 | ; 61 | 62 | [pigaregmonitor.AddRegistry] 63 | HKR,"Instances","DefaultInstance",0x00000000,%DefaultInstance% 64 | HKR,"Instances\"%Instance1.Name%,"Altitude",0x00000000,%Instance1.Altitude% 65 | HKR,"Instances\"%Instance1.Name%,"Flags",0x00010001,%Instance1.Flags% 66 | HKR,"Instances\"%Instance2.Name%,"Altitude",0x00000000,%Instance2.Altitude% 67 | HKR,"Instances\"%Instance2.Name%,"Flags",0x00010001,%Instance2.Flags% 68 | HKR,"Instances\"%Instance3.Name%,"Altitude",0x00000000,%Instance3.Altitude% 69 | HKR,"Instances\"%Instance3.Name%,"Flags",0x00010001,%Instance3.Flags% 70 | 71 | ; 72 | ; Copy Files 73 | ; 74 | 75 | [pigaregmonitor.DriverFiles] 76 | %DriverName%.sys 77 | 78 | [pigaregmonitor.UserFiles] 79 | %UserAppName%.exe 80 | 81 | [SourceDisksFiles] 82 | pigaregmonitor.sys = 1,, 83 | pigaregmonitor.exe = 1,, 84 | 85 | [SourceDisksNames] 86 | 1 = %DiskId1%,,, 87 | 88 | ;; 89 | ;; String Section 90 | ;; 91 | 92 | [Strings] 93 | Msft = "Microsoft Corporation" 94 | ServiceDescription = "Piga Monitor driver" 95 | ServiceName = "pigaregmonitor" 96 | DriverName = "pigaregmonitor" 97 | UserAppName = "pigaregmonitor" 98 | DiskId1 = "Piga Monitor Device Installation Disk" 99 | 100 | ;Instances specific information. 101 | DefaultInstance = "Piga Monitor - Top Instance" 102 | Instance1.Name = "Piga Monitor - Middle Instance" 103 | Instance1.Altitude = "370000" 104 | Instance1.Flags = 0x0 ; Suppress automatic attachments 105 | Instance2.Name = "Piga Monitor - Bottom Instance" 106 | Instance2.Altitude = "361000" 107 | Instance2.Flags = 0x0 ; Suppress automatic attachments 108 | Instance3.Name = "Piga Monitor - Top Instance" 109 | Instance3.Altitude = "385100" 110 | Instance3.Flags = 0x0 ; Suppress automatic attachments 111 | 112 | -------------------------------------------------------------------------------- /Server/visu/mysql.py: -------------------------------------------------------------------------------- 1 | import MySQLdb as mysql 2 | import json 3 | import collections 4 | 5 | class dbconfig: 6 | database = 'sandbox' # Database to connect to. Please use an empty database for best results. 7 | user = 'sandbox' # User ID to connect with 8 | password = 'azerty' # Password for given User ID 9 | hostname = 'localhost' # Hostname 10 | port = 3306 # Port Number 11 | 12 | 13 | class dbinterface: 14 | 15 | def __init__(self, dbconfig): 16 | self.dbconfig = dbconfig 17 | try: 18 | self.conn = mysql.connect (host = self.dbconfig.hostname,db=self.dbconfig.database, user = self.dbconfig.user, passwd = self.dbconfig.password ) 19 | except: 20 | print("Connexion failed: toto") 21 | 22 | 23 | def PrintProcess(self, run): 24 | fichier = open("flare.json", "w") 25 | cursor = self.conn.cursor() 26 | insertLine = "SELECT pid,name,ppid FROM process WHERE run=%i "%(int(run)) 27 | cursor.execute(insertLine) 28 | rows = cursor.fetchall() 29 | liste_json= [] 30 | liste = [] 31 | p = collections.OrderedDict() 32 | for row in rows: 33 | boolean=0 34 | for l in liste: 35 | if l == row[0]: 36 | boolean=1 37 | continue 38 | if boolean ==1: 39 | break 40 | d = collections.OrderedDict() 41 | liste_temp = [] 42 | liste.append(row[0]) 43 | self.FindFils(liste,rows, row, liste_temp,run) 44 | s= row[1].split('\\') 45 | test = s[len(s)-1] 46 | d["name"]=test 47 | d["children"] = liste_temp 48 | liste_json.append(d) 49 | # print json.dumps(liste_json) 50 | 51 | liste_faked = [] 52 | p["name"]="Faked" 53 | p["children"] = liste_json 54 | liste_faked.append(p) 55 | s=json.dumps(liste_faked, indent=4) 56 | fichier.write(s) 57 | # print len(liste) 58 | # print liste 59 | # print s 60 | fichier.close() 61 | cursor.close() 62 | 63 | def FindFils(self, liste, rows, row, liste_tmp, run): 64 | for raw in rows: 65 | boolean =0 66 | if row[0] == raw[2]: 67 | for l in liste: 68 | if l == raw[0]: 69 | boolean=1 70 | break 71 | if boolean ==1: 72 | break 73 | liste.append(raw[0]) 74 | liste_tempo=[] 75 | self.FindFils(liste,rows, raw, liste_tempo, run) 76 | self.AddAction(raw[0], liste_tempo, run) 77 | d = collections.OrderedDict() 78 | s= raw[1].split('\\') 79 | test = s[len(s)-1] 80 | d["name"]=test 81 | d["children"] = liste_tempo 82 | liste_tmp.append(d) 83 | 84 | def AddAction(self, pid, liste,run): 85 | cursor = self.conn.cursor() 86 | #insertLine = "SELECT pid,action,objet FROM action WHERE run=%i and pid=%i and (action='write' or action='load' or action='unlink') "%(int(run), int(pid)) 87 | insertLine = "SELECT DISTINCT objet FROM action WHERE run=%i and pid=%i and (action='write') "%(int(run), int(pid)) 88 | cursor.execute(insertLine) 89 | rows = cursor.fetchall() 90 | print rows 91 | liste_temporaire = [] 92 | p = collections.OrderedDict() 93 | if len(rows) != 0: 94 | for r in rows: 95 | d = collections.OrderedDict() 96 | d["name"]=r 97 | liste_temporaire.append(d) 98 | 99 | p["name"]="write" 100 | p["children"] = liste_temporaire 101 | liste.append(p) 102 | 103 | insertLine = "SELECT DISTINCT objet FROM action WHERE run=%i and pid=%i and (action='load') "%(int(run), int(pid)) 104 | cursor.execute(insertLine) 105 | rows = cursor.fetchall() 106 | print rows 107 | liste_temporaire = [] 108 | p = collections.OrderedDict() 109 | if len(rows) != 0: 110 | for r in rows: 111 | d = collections.OrderedDict() 112 | d["name"]=r 113 | liste_temporaire.append(d) 114 | 115 | p["name"]="load" 116 | p["children"] = liste_temporaire 117 | liste.append(p) 118 | 119 | insertLine = "SELECT DISTINCT objet FROM action WHERE run=%i and pid=%i and (action='unlink') "%(int(run), int(pid)) 120 | cursor.execute(insertLine) 121 | rows = cursor.fetchall() 122 | print rows 123 | liste_temporaire = [] 124 | p = collections.OrderedDict() 125 | if len(rows) != 0: 126 | for r in rows: 127 | d = collections.OrderedDict() 128 | d["name"]=r 129 | liste_temporaire.append(d) 130 | 131 | p["name"]="unlink" 132 | p["children"] = liste_temporaire 133 | liste.append(p) 134 | 135 | cursor.close() 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /Registry/src/process.c: -------------------------------------------------------------------------------- 1 | #include "process.h" 2 | // #include "sockets.h" 3 | #include "pigaregmonitor.h" 4 | VOID GetUnicodeName(int pid) 5 | { 6 | PEPROCESS pep; 7 | ULONG ret,retlen; 8 | NTSTATUS rc,status,ntStatus; 9 | CLIENT_ID ClientId; 10 | int i=0,ppid=0, sid=0; 11 | char temp_buffer[1000]; 12 | HANDLE openproc; 13 | OBJECT_ATTRIBUTES ObjectAttributes; 14 | PVOID unicode; 15 | ANSI_STRING str_ansi; 16 | WCHAR System[] = L"System"; 17 | 18 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 19 | ObjectAttributes.RootDirectory = NULL; 20 | ObjectAttributes.ObjectName = NULL; 21 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 22 | ObjectAttributes.SecurityDescriptor = NULL; 23 | ObjectAttributes.SecurityQualityOfService = NULL; 24 | 25 | pep=NULL; 26 | PsLookupProcessByProcessId((HANDLE)pid,&pep); 27 | if(pep == NULL) 28 | { 29 | return; 30 | } 31 | ClientId.UniqueProcess = (HANDLE) pid; 32 | ClientId.UniqueThread = 0; 33 | 34 | rc = ZwOpenProcess(&openproc, PROCESS_ALL_ACCESS, &ObjectAttributes , &ClientId); 35 | if(rc == STATUS_SUCCESS) 36 | { 37 | rc = ZwQueryInformationProcess(openproc, ProcessImageFileName, NULL, 0, &ret); 38 | if(rc == STATUS_INFO_LENGTH_MISMATCH) 39 | { 40 | unicode = ExAllocatePool(PagedPool, ret); 41 | if(unicode != NULL) 42 | { 43 | rc = ZwQueryInformationProcess(openproc, ProcessImageFileName, unicode, ret, &ret); 44 | if( rc == STATUS_SUCCESS) 45 | { 46 | if(pid == 4) 47 | { 48 | RtlInitUnicodeString(unicode , System); 49 | } 50 | else 51 | { 52 | RtlUnicodeStringToAnsiString(&str_ansi, unicode, TRUE); 53 | RtlZeroMemory(&temp_buffer, sizeof(temp_buffer)); 54 | ppid = GetParentId(pid); 55 | sid = GetSessionId(pid); 56 | sprintf_s(temp_buffer, sizeof(temp_buffer), "Process name : %s pid=%i ppid=%i sid=%i\n",str_ansi.Buffer , pid, ppid, sid); 57 | // ntStatus = senddata(sock, temp_buffer, sizeof(temp_buffer)); 58 | ntStatus = AddInQueue(temp_buffer); 59 | RtlFreeAnsiString(&str_ansi); 60 | } 61 | } 62 | else 63 | RtlInitUnicodeString(unicode, L"Echec" ); 64 | if(unicode != NULL) ExFreePool(unicode); 65 | } 66 | ZwClose(openproc); 67 | } 68 | } 69 | else 70 | { 71 | DbgPrint("Unable to open process %i\n", i); 72 | } 73 | 74 | return; 75 | } 76 | 77 | 78 | int GetSessionId(int pid) 79 | { 80 | PEPROCESS pep; 81 | ULONG ret,retlen; 82 | NTSTATUS rc,status; 83 | CLIENT_ID ClientId; 84 | int i=0; 85 | HANDLE openproc; 86 | OBJECT_ATTRIBUTES ObjectAttributes; 87 | PROCESS_SESSION_INFORMATION unicode; 88 | WCHAR System[] = L"System"; 89 | int retour = 0; 90 | 91 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 92 | ObjectAttributes.RootDirectory = NULL; 93 | ObjectAttributes.ObjectName = NULL; 94 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 95 | ObjectAttributes.SecurityDescriptor = NULL; 96 | ObjectAttributes.SecurityQualityOfService = NULL; 97 | 98 | pep=NULL; 99 | PsLookupProcessByProcessId((HANDLE)pid,&pep); 100 | if(pep == NULL) 101 | return 0; 102 | 103 | ClientId.UniqueProcess = (HANDLE) pid; 104 | ClientId.UniqueThread = 0; 105 | 106 | rc = ZwOpenProcess(&openproc, PROCESS_ALL_ACCESS, &ObjectAttributes , &ClientId); 107 | if(rc == STATUS_SUCCESS) 108 | { 109 | rc = ZwQueryInformationProcess(openproc, ProcessSessionInformation, &unicode, sizeof(unicode), &ret); 110 | if( rc == STATUS_SUCCESS) 111 | { 112 | retour = unicode.SessionId; 113 | // DbgPrint("Session %i\n", retour); 114 | } 115 | ZwClose(openproc); 116 | } 117 | else 118 | { 119 | DbgPrint("Unable to open process %i\n", i); 120 | } 121 | 122 | return retour; 123 | } 124 | 125 | int GetParentId(int pid) 126 | { 127 | PEPROCESS pep; 128 | ULONG ret,retlen; 129 | NTSTATUS rc,status; 130 | CLIENT_ID ClientId; 131 | int i=0; 132 | HANDLE openproc; 133 | OBJECT_ATTRIBUTES ObjectAttributes; 134 | PROCESS_BASIC_INFORMATION unicode; 135 | WCHAR System[] = L"System"; 136 | int retour = 0; 137 | 138 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 139 | ObjectAttributes.RootDirectory = NULL; 140 | ObjectAttributes.ObjectName = NULL; 141 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 142 | ObjectAttributes.SecurityDescriptor = NULL; 143 | ObjectAttributes.SecurityQualityOfService = NULL; 144 | 145 | pep=NULL; 146 | PsLookupProcessByProcessId((HANDLE)pid,&pep); 147 | if(pep == NULL) 148 | return 0; 149 | 150 | ClientId.UniqueProcess = (HANDLE) pid; 151 | ClientId.UniqueThread = 0; 152 | 153 | rc = ZwOpenProcess(&openproc, PROCESS_ALL_ACCESS, &ObjectAttributes , &ClientId); 154 | if(rc == STATUS_SUCCESS) 155 | { 156 | rc = ZwQueryInformationProcess(openproc, ProcessBasicInformation, &unicode, sizeof(unicode), &ret); 157 | if( rc == STATUS_SUCCESS) 158 | { 159 | retour = unicode.InheritedFromUniqueProcessId; 160 | } 161 | ZwClose(openproc); 162 | } 163 | else 164 | { 165 | DbgPrint("Unable to open process %i\n", i); 166 | } 167 | 168 | 169 | return retour; 170 | } 171 | -------------------------------------------------------------------------------- /visu/tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 29 | 30 | 31 |
32 | 34 |
35 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /Registry/src/sockets.c: -------------------------------------------------------------------------------- 1 | #include "pigaregmonitor.h" 2 | 3 | NTSTATUS 4 | initwsk(PWSK_REGISTRATION clireg, PWSK_PROVIDER_NPI pronpi) 5 | { 6 | NTSTATUS status; 7 | WSK_CLIENT_NPI clinpi; 8 | WSK_CLIENT_DISPATCH dispatch = { MAKE_WSK_VERSION(1, 0), 0, NULL }; 9 | 10 | clinpi.ClientContext = NULL; 11 | clinpi.Dispatch = &dispatch; 12 | 13 | status = WskRegister(&clinpi, clireg); 14 | if(!NT_SUCCESS(status)){ 15 | DbgPrint("WskRegister() error : 0x%X\n", status); 16 | return status; 17 | } 18 | 19 | status = WskCaptureProviderNPI(clireg, WSK_INFINITE_WAIT, pronpi); 20 | if(!NT_SUCCESS(status)){ 21 | DbgPrint("WskCaptureProviderNPI() error : 0x%X\n", status); 22 | WskDeregister(clireg); 23 | return status; 24 | } 25 | 26 | return STATUS_SUCCESS; 27 | } 28 | 29 | VOID 30 | cleanupwsk(PWSK_REGISTRATION clireg) 31 | { 32 | WskReleaseProviderNPI(clireg); 33 | WskDeregister(clireg); 34 | 35 | return; 36 | } 37 | 38 | NTSTATUS 39 | connecttoserver(PWSK_PROVIDER_NPI pronpi, PSOCKADDR remaddr, PWSK_SOCKET *sock) 40 | { 41 | NTSTATUS status; 42 | PIRP irp; 43 | KEVENT event; 44 | ULONG SocketOptionState; 45 | SOCKADDR locaddr = {0} ; 46 | 47 | irp = IoAllocateIrp(1, FALSE); 48 | if(!irp){ 49 | return STATUS_INSUFFICIENT_RESOURCES; 50 | } 51 | 52 | KeInitializeEvent(&event, NotificationEvent, FALSE); 53 | 54 | IoSetCompletionRoutine(irp, createcomplete, &event, TRUE, TRUE, TRUE); 55 | 56 | locaddr.sa_family = remaddr->sa_family; 57 | 58 | status = pronpi->Dispatch->WskSocketConnect( 59 | pronpi->Client, /* Client */ 60 | SOCK_STREAM, /* SocketType */ 61 | IPPROTO_TCP, /* Protocol */ 62 | &locaddr, /* LocalAddress */ 63 | remaddr, /* RemoteAddress */ 64 | 0, /* Flags */ 65 | NULL, /* SocketContext */ 66 | NULL, /* Dispatch */ 67 | NULL, /* OwningProcess */ 68 | NULL, /* OwningThread */ 69 | NULL, /* SecurityDescriptor */ 70 | irp); /* Irp */ 71 | if(!NT_SUCCESS(status)){ 72 | IoFreeIrp(irp); 73 | return status; 74 | } 75 | 76 | if(status == STATUS_PENDING){ 77 | KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); 78 | 79 | status = irp->IoStatus.Status; 80 | if(!NT_SUCCESS(status)){ 81 | IoFreeIrp(irp); 82 | return status; 83 | } 84 | } 85 | 86 | *sock = (PWSK_SOCKET)irp->IoStatus.Information; 87 | // SocketOptionState =1; 88 | // status = WskControlSocket( 89 | // sock, 90 | // WskSetOption, 91 | // TCP_NODELAY, 92 | // SOL_SOCKET, 93 | // sizeof(ULONG), 94 | // &SocketOptionState, 95 | // NULL, 96 | // NULL, 97 | // irp); 98 | 99 | 100 | IoFreeIrp(irp); 101 | 102 | return STATUS_SUCCESS; 103 | } 104 | 105 | NTSTATUS 106 | createcomplete(PDEVICE_OBJECT devobj, PIRP irp, PVOID context) 107 | { 108 | UNREFERENCED_PARAMETER(devobj); 109 | UNREFERENCED_PARAMETER(irp); 110 | 111 | KeSetEvent((PKEVENT)context, IO_NO_INCREMENT, FALSE); 112 | 113 | return STATUS_MORE_PROCESSING_REQUIRED; 114 | } 115 | 116 | 117 | NTSTATUS 118 | senddata(PWSK_SOCKET sock, PVOID data, ULONG datal) 119 | { 120 | WSK_BUF wskbuf; 121 | NTSTATUS status; 122 | KEVENT event; 123 | PIRP irp; 124 | 125 | irp = IoAllocateIrp(1, FALSE); 126 | if(!irp){ 127 | return STATUS_INSUFFICIENT_RESOURCES; 128 | } 129 | 130 | KeInitializeEvent(&event, NotificationEvent, FALSE); 131 | 132 | IoSetCompletionRoutine(irp, senddatacomplete, &event, TRUE, TRUE, TRUE); 133 | 134 | wskbuf.Mdl = IoAllocateMdl(data, datal, FALSE, FALSE, NULL); 135 | if(!wskbuf.Mdl){ 136 | DbgPrint("Failed to allocate MDL!\n"); 137 | return STATUS_MORE_PROCESSING_REQUIRED; 138 | } 139 | MmBuildMdlForNonPagedPool(wskbuf.Mdl); 140 | wskbuf.Offset = 0; 141 | wskbuf.Length = datal; 142 | 143 | status = ((PWSK_PROVIDER_CONNECTION_DISPATCH)(sock->Dispatch))->WskSend(sock, &wskbuf, 0, irp); 144 | if(status == STATUS_PENDING){ 145 | KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); 146 | 147 | status = irp->IoStatus.Status; 148 | } 149 | 150 | IoFreeIrp(irp); 151 | 152 | return status; 153 | } 154 | 155 | NTSTATUS 156 | senddatacomplete(PDEVICE_OBJECT devobj, PIRP irp, PVOID context) 157 | { 158 | UNREFERENCED_PARAMETER(devobj); 159 | UNREFERENCED_PARAMETER(irp); 160 | 161 | KeSetEvent((PKEVENT)context, IO_NO_INCREMENT, FALSE); 162 | 163 | return STATUS_MORE_PROCESSING_REQUIRED; 164 | } 165 | 166 | NTSTATUS 167 | disconnectfromserver(PWSK_SOCKET sock) 168 | { 169 | NTSTATUS status; 170 | KEVENT event; 171 | PIRP irp; 172 | 173 | irp = IoAllocateIrp(1, FALSE); 174 | if(!irp){ 175 | return STATUS_INSUFFICIENT_RESOURCES; 176 | } 177 | 178 | KeInitializeEvent(&event, NotificationEvent, FALSE); 179 | 180 | IoSetCompletionRoutine(irp, disconnectcomplete, &event, TRUE, TRUE, 181 | TRUE); 182 | 183 | status = ((PWSK_PROVIDER_CONNECTION_DISPATCH)(sock->Dispatch))-> 184 | WskCloseSocket(sock, irp); 185 | if(status == STATUS_PENDING){ 186 | KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); 187 | 188 | status = irp->IoStatus.Status; 189 | } 190 | 191 | IoFreeIrp(irp); 192 | 193 | return status; 194 | } 195 | 196 | NTSTATUS 197 | disconnectcomplete(PDEVICE_OBJECT devobj, PIRP irp, PVOID context) 198 | { 199 | UNREFERENCED_PARAMETER(devobj); 200 | UNREFERENCED_PARAMETER(irp); 201 | 202 | KeSetEvent((PKEVENT)context, IO_NO_INCREMENT, FALSE); 203 | 204 | return STATUS_MORE_PROCESSING_REQUIRED; 205 | } 206 | 207 | -------------------------------------------------------------------------------- /Filter/filterdriver/sockets.c: -------------------------------------------------------------------------------- 1 | #include "fltdrvKernel.h" 2 | #include "sockets.h" 3 | 4 | NTSTATUS 5 | initwsk(PWSK_REGISTRATION clireg, PWSK_PROVIDER_NPI pronpi) 6 | { 7 | NTSTATUS status; 8 | WSK_CLIENT_NPI clinpi; 9 | WSK_CLIENT_DISPATCH dispatch = { MAKE_WSK_VERSION(1, 0), 0, NULL }; 10 | 11 | clinpi.ClientContext = NULL; 12 | clinpi.Dispatch = &dispatch; 13 | 14 | status = WskRegister(&clinpi, clireg); 15 | if(!NT_SUCCESS(status)){ 16 | DbgPrint("WskRegister() error : 0x%X\n", status); 17 | return status; 18 | } 19 | 20 | status = WskCaptureProviderNPI(clireg, WSK_INFINITE_WAIT, pronpi); 21 | if(!NT_SUCCESS(status)){ 22 | DbgPrint("WskCaptureProviderNPI() error : 0x%X\n", status); 23 | WskDeregister(clireg); 24 | return status; 25 | } 26 | 27 | return STATUS_SUCCESS; 28 | } 29 | 30 | VOID 31 | cleanupwsk(PWSK_REGISTRATION clireg) 32 | { 33 | WskReleaseProviderNPI(clireg); 34 | WskDeregister(clireg); 35 | 36 | return; 37 | } 38 | 39 | NTSTATUS 40 | connecttoserver(PWSK_PROVIDER_NPI pronpi, PSOCKADDR remaddr, PWSK_SOCKET *sock) 41 | { 42 | NTSTATUS status; 43 | PIRP irp; 44 | KEVENT event; 45 | ULONG SocketOptionState; 46 | SOCKADDR locaddr = {0} ; 47 | 48 | irp = IoAllocateIrp(1, FALSE); 49 | if(!irp){ 50 | return STATUS_INSUFFICIENT_RESOURCES; 51 | } 52 | 53 | KeInitializeEvent(&event, NotificationEvent, FALSE); 54 | 55 | IoSetCompletionRoutine(irp, createcomplete, &event, TRUE, TRUE, TRUE); 56 | 57 | locaddr.sa_family = remaddr->sa_family; 58 | 59 | status = pronpi->Dispatch->WskSocketConnect( 60 | pronpi->Client, /* Client */ 61 | SOCK_STREAM, /* SocketType */ 62 | IPPROTO_TCP, /* Protocol */ 63 | &locaddr, /* LocalAddress */ 64 | remaddr, /* RemoteAddress */ 65 | 0, /* Flags */ 66 | NULL, /* SocketContext */ 67 | NULL, /* Dispatch */ 68 | NULL, /* OwningProcess */ 69 | NULL, /* OwningThread */ 70 | NULL, /* SecurityDescriptor */ 71 | irp); /* Irp */ 72 | if(!NT_SUCCESS(status)){ 73 | IoFreeIrp(irp); 74 | return status; 75 | } 76 | 77 | if(status == STATUS_PENDING){ 78 | KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); 79 | 80 | status = irp->IoStatus.Status; 81 | if(!NT_SUCCESS(status)){ 82 | IoFreeIrp(irp); 83 | return status; 84 | } 85 | } 86 | 87 | *sock = (PWSK_SOCKET)irp->IoStatus.Information; 88 | // SocketOptionState =1; 89 | // status = WskControlSocket( 90 | // sock, 91 | // WskSetOption, 92 | // TCP_NODELAY, 93 | // SOL_SOCKET, 94 | // sizeof(ULONG), 95 | // &SocketOptionState, 96 | // NULL, 97 | // NULL, 98 | // irp); 99 | 100 | 101 | IoFreeIrp(irp); 102 | 103 | return STATUS_SUCCESS; 104 | } 105 | 106 | NTSTATUS 107 | createcomplete(PDEVICE_OBJECT devobj, PIRP irp, PVOID context) 108 | { 109 | UNREFERENCED_PARAMETER(devobj); 110 | UNREFERENCED_PARAMETER(irp); 111 | 112 | KeSetEvent((PKEVENT)context, IO_NO_INCREMENT, FALSE); 113 | 114 | return STATUS_MORE_PROCESSING_REQUIRED; 115 | } 116 | 117 | 118 | NTSTATUS 119 | senddata(PWSK_SOCKET sock, PVOID data, ULONG datal) 120 | { 121 | WSK_BUF wskbuf; 122 | NTSTATUS status; 123 | KEVENT event; 124 | PIRP irp; 125 | 126 | irp = IoAllocateIrp(1, FALSE); 127 | if(!irp){ 128 | return STATUS_INSUFFICIENT_RESOURCES; 129 | } 130 | 131 | KeInitializeEvent(&event, NotificationEvent, FALSE); 132 | 133 | IoSetCompletionRoutine(irp, senddatacomplete, &event, TRUE, TRUE, TRUE); 134 | 135 | wskbuf.Mdl = IoAllocateMdl(data, datal, FALSE, FALSE, NULL); 136 | if(!wskbuf.Mdl){ 137 | DbgPrint("Failed to allocate MDL!\n"); 138 | return STATUS_MORE_PROCESSING_REQUIRED; 139 | } 140 | MmBuildMdlForNonPagedPool(wskbuf.Mdl); 141 | wskbuf.Offset = 0; 142 | wskbuf.Length = datal; 143 | 144 | status = ((PWSK_PROVIDER_CONNECTION_DISPATCH)(sock->Dispatch))->WskSend(sock, &wskbuf, 0, irp); 145 | if(status == STATUS_PENDING){ 146 | KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); 147 | 148 | status = irp->IoStatus.Status; 149 | } 150 | 151 | IoFreeIrp(irp); 152 | 153 | return status; 154 | } 155 | 156 | NTSTATUS 157 | senddatacomplete(PDEVICE_OBJECT devobj, PIRP irp, PVOID context) 158 | { 159 | UNREFERENCED_PARAMETER(devobj); 160 | UNREFERENCED_PARAMETER(irp); 161 | 162 | KeSetEvent((PKEVENT)context, IO_NO_INCREMENT, FALSE); 163 | 164 | return STATUS_MORE_PROCESSING_REQUIRED; 165 | } 166 | 167 | NTSTATUS 168 | disconnectfromserver(PWSK_SOCKET sock) 169 | { 170 | NTSTATUS status; 171 | KEVENT event; 172 | PIRP irp; 173 | 174 | irp = IoAllocateIrp(1, FALSE); 175 | if(!irp){ 176 | return STATUS_INSUFFICIENT_RESOURCES; 177 | } 178 | 179 | KeInitializeEvent(&event, NotificationEvent, FALSE); 180 | 181 | IoSetCompletionRoutine(irp, disconnectcomplete, &event, TRUE, TRUE, 182 | TRUE); 183 | 184 | status = ((PWSK_PROVIDER_CONNECTION_DISPATCH)(sock->Dispatch))-> 185 | WskCloseSocket(sock, irp); 186 | if(status == STATUS_PENDING){ 187 | KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); 188 | 189 | status = irp->IoStatus.Status; 190 | } 191 | 192 | IoFreeIrp(irp); 193 | 194 | return status; 195 | } 196 | 197 | NTSTATUS 198 | disconnectcomplete(PDEVICE_OBJECT devobj, PIRP irp, PVOID context) 199 | { 200 | UNREFERENCED_PARAMETER(devobj); 201 | UNREFERENCED_PARAMETER(irp); 202 | 203 | KeSetEvent((PKEVENT)context, IO_NO_INCREMENT, FALSE); 204 | 205 | return STATUS_MORE_PROCESSING_REQUIRED; 206 | } 207 | 208 | -------------------------------------------------------------------------------- /Server/python/mysql.py: -------------------------------------------------------------------------------- 1 | import MySQLdb as mysql 2 | 3 | class dbconfig: 4 | database = 'sandbox' # Database to connect to. Please use an empty database for best results. 5 | user = 'sandbox' # User ID to connect with 6 | password = 'azerty' # Password for given User ID 7 | hostname = 'localhost' # Hostname 8 | port = 3306 # Port Number 9 | 10 | 11 | class dbinterface: 12 | 13 | def __init__(self, dbconfig): 14 | self.dbconfig = dbconfig 15 | try: 16 | self.conn = mysql.connect (host = self.dbconfig.hostname,db=self.dbconfig.database, user = self.dbconfig.user, passwd = self.dbconfig.password ) 17 | except: 18 | print("Connexion failed: toto") 19 | 20 | def IdSession(self, md5): 21 | request = "SELECT MAX(run) FROM session" 22 | 23 | cursor = self.conn.cursor() 24 | cursor.execute(request.encode("utf-8","replace")) 25 | row = cursor.fetchone() 26 | sessionMax = row[0] 27 | cursor.close() 28 | return sessionMax 29 | 30 | 31 | def newIdSession(self, md5): 32 | request = "SELECT MAX(run) FROM session" 33 | 34 | cursor = self.conn.cursor() 35 | cursor.execute(request.encode("utf-8","replace")) 36 | 37 | row = cursor.fetchone() 38 | sessionMax = row[0] 39 | sessionMax = sessionMax + 1 40 | insertLine = "INSERT INTO session(run,md5) VALUES('%i', '%s')"%(sessionMax,str(md5)) 41 | cursor.execute(insertLine) 42 | self.conn.commit() 43 | cursor.close() 44 | return sessionMax 45 | 46 | def addCreateProcess(self, buf, run): 47 | ligne = buf.split("\n") 48 | taille=len(ligne)-2 49 | pid=ligne[taille-1].split("=")[1] 50 | name = "" 51 | finligne = ligne[taille-1].split(":")[1] 52 | religne = finligne.split() 53 | i=0 54 | while not "pid=" in religne[i]: 55 | if name == "": 56 | name = religne[i] 57 | else: 58 | name = name + " " + religne[i] 59 | i=i+1 60 | name = name.replace("\\","\\\\") 61 | name_obj = "" 62 | finligne = ligne[taille].split(":")[1] 63 | religne = finligne.split() 64 | i=0 65 | while not "pid=" in religne[i]: 66 | if name_obj == "": 67 | name_obj = religne[i] 68 | else: 69 | name_obj = name_obj + " " + religne[i] 70 | i=i+1 71 | name_obj = name_obj.replace("\\","\\\\") 72 | cursor = self.conn.cursor() 73 | insertLine = "INSERT INTO action(trace, cpu, timestamp, pid, name, action, objet, run) VALUES('%i','%i','%i','%i', '%s', '%s','%s','%i')"%(int(0), int(0), int(0),int(pid), name, "load", name_obj, int(run)) 74 | cursor.execute(insertLine) 75 | self.conn.commit() 76 | cursor.close() 77 | ligne=buf.split("\n") 78 | taille = len(ligne)-2 79 | self.addProcess(ligne[taille],run) 80 | 81 | def addAction(self, buf, run): 82 | ligne = buf.split("\n") 83 | if len(ligne) != 6: 84 | print ligne 85 | print len(ligne) 86 | return 87 | try: 88 | trace = ligne[0].split("=")[1].split()[0] 89 | cpu = ligne[0].split("=")[2] 90 | timestamp = ligne[1].split("=")[1].split()[0] 91 | access = ligne[2].split(":")[1].split()[0] 92 | name = ligne[3].split(":")[1].split()[0] 93 | pid = ligne[3].split(":")[1].split()[1] 94 | objet = ligne[4].split(":")[1].replace("\\","\\\\") 95 | cursor = self.conn.cursor() 96 | insertLine = "INSERT INTO action(trace, cpu, timestamp, pid, name, action, objet, run) VALUES('%i','%i','%i','%i', '%s', '%s','%s','%i')"%(int(trace), int(cpu), int(timestamp),int(pid), name, access, objet, int(run)) 97 | cursor.execute(insertLine) 98 | self.conn.commit() 99 | cursor.close() 100 | except: 101 | return 102 | 103 | def addProcess(self, ligne, run): 104 | liste = ligne.split(":") 105 | name = "" 106 | reliste = liste[1].split() 107 | i=0 108 | while not "pid=" in reliste[i]: 109 | if name == "": 110 | name = reliste[i] 111 | else: 112 | name = name + " " + reliste[i] 113 | i=i+1 114 | name = name.replace("\\","\\\\") 115 | if name != "System": 116 | finliste = liste[1].split("=") 117 | pidi = finliste[1].split() 118 | ppidi = finliste[2].split() 119 | sidi = finliste[3].split() 120 | pid= pidi[0] 121 | ppid= ppidi[0] 122 | sid= sidi[0] 123 | else: 124 | pid=4 125 | ppid=0 126 | sid=0 127 | 128 | cursor = self.conn.cursor() 129 | insertLine = "INSERT INTO process(pid, name, ppid, sid, run) VALUES('%i', '%s', '%i','%i','%i')"%(int(pid), name, int(ppid), int(sid), int(run)) 130 | cursor.execute(insertLine) 131 | self.conn.commit() 132 | cursor.close() 133 | 134 | def addRegistry(self, buf, run): 135 | ligne = buf.split("\n") 136 | if len(ligne) != 6 and len(ligne) != 7 and len(ligne) != 8: 137 | print ligne 138 | print len(ligne) 139 | return 140 | if len(ligne) == 8: 141 | try: 142 | trace = ligne[0].split("=")[1].split()[0] 143 | cpu = ligne[0].split("=")[2] 144 | timestamp = ligne[1].split("=")[1].split()[0] 145 | access = ligne[2].split(":")[1].split()[0] 146 | name = ligne[3].split(":")[1].split()[0].replace("\\","\\\\") 147 | pid = ligne[3].split(":")[1].split("=")[1].split()[0] 148 | objet = ligne[4].replace("\\","\\\\") 149 | data = ligne[5] 150 | data_set = ligne[6] 151 | data = data + data_set 152 | cursor = self.conn.cursor() 153 | insertLine = "INSERT INTO registre(trace, cpu, timestamp, pid, name, action, objet, data,run) VALUES('%i','%i','%i','%i', '%s', '%s','%s','%s','%i')"%(int(trace), int(cpu), int(timestamp),int(pid), name, access, objet, data,int(run)) 154 | cursor.execute(insertLine) 155 | self.conn.commit() 156 | cursor.close() 157 | return 158 | except: 159 | print "loupe" 160 | print ligne 161 | return 162 | 163 | 164 | try: 165 | trace = ligne[0].split("=")[1].split()[0] 166 | cpu = ligne[0].split("=")[2] 167 | timestamp = ligne[1].split("=")[1].split()[0] 168 | access = ligne[2].split(":")[1].split()[0] 169 | name = ligne[3].split(":")[1].split()[0].replace("\\","\\\\") 170 | pid = ligne[3].split(":")[1].split()[1].split()[0] 171 | objet = ligne[4].replace("\\","\\\\") 172 | data = ligne[5].replace("\\","\\\\") 173 | cursor = self.conn.cursor() 174 | insertLine = "INSERT INTO registre(trace, cpu, timestamp, pid, name, action, objet, data,run) VALUES('%i','%i','%i','%i', '%s', '%s','%s','%s','%i')"%(int(trace), int(cpu), int(timestamp),int(pid), name, access, objet, data,int(run)) 175 | cursor.execute(insertLine) 176 | self.conn.commit() 177 | cursor.close() 178 | except: 179 | print "loupe" 180 | print ligne 181 | return 182 | 183 | 184 | -------------------------------------------------------------------------------- /Registry/src/registry.c: -------------------------------------------------------------------------------- 1 | #include "pigaregmonitor.h" 2 | 3 | NTSTATUS RegistryCallback(IN PVOID CallbackContext, 4 | IN PVOID Argument1, 5 | IN PVOID Argument2) 6 | { 7 | NTSTATUS ntStatus; 8 | PDEVICE_CONTEXT pContext = (PDEVICE_CONTEXT) CallbackContext; 9 | REG_NOTIFY_CLASS Action = (REG_NOTIFY_CLASS) Argument1; 10 | UNICODE_STRING *key = NULL; 11 | ULONG ReturnLength; 12 | ANSI_STRING key_ansi; 13 | ANSI_STRING value_ansi; 14 | char buffer[1000]; 15 | LARGE_INTEGER time; 16 | 17 | RtlZeroMemory(&buffer, sizeof(buffer)); 18 | 19 | UNREFERENCED_PARAMETER(pContext); 20 | 21 | if( ExGetPreviousMode() == KernelMode) return STATUS_SUCCESS; 22 | 23 | switch (Action) 24 | { 25 | case RegNtDeleteKey: 26 | { 27 | PREG_DELETE_KEY_INFORMATION pInfo = (PREG_DELETE_KEY_INFORMATION) Argument2; 28 | __try{ 29 | ntStatus = ObQueryNameString(pInfo->Object, (POBJECT_NAME_INFORMATION)key, 0, &ReturnLength); 30 | key = (PUNICODE_STRING)ExAllocatePoolWithTag(NonPagedPool, ReturnLength, 0); 31 | if (ntStatus == STATUS_INFO_LENGTH_MISMATCH) 32 | { 33 | if (key) 34 | { 35 | ntStatus = ObQueryNameString(pInfo->Object, (POBJECT_NAME_INFORMATION)key, ReturnLength, &ReturnLength); 36 | if(NT_SUCCESS(ntStatus)) 37 | { 38 | ntStatus = AddInQueue("-- BEGIN\n"); 39 | 40 | sprintf_s(buffer,sizeof(buffer),"trace=%i , cpu=%i\n",trace++, KeGetCurrentProcessorNumber()); 41 | AddInQueue(buffer); 42 | 43 | KeQuerySystemTime(&time); 44 | RtlZeroMemory(&buffer, sizeof(buffer)); 45 | sprintf_s(buffer,sizeof(buffer),"timestamp=%I64d\n",time.QuadPart); 46 | AddInQueue(buffer); 47 | AddInQueue("Access : delete\n"); 48 | 49 | RtlZeroMemory(&buffer, sizeof(buffer)); 50 | GetUnicodeName((int)PsGetCurrentProcessId()); 51 | RtlUnicodeStringToAnsiString(&key_ansi, key, TRUE); 52 | sprintf_s(buffer, sizeof(buffer),"%s\n", key_ansi.Buffer); 53 | ntStatus = AddInQueue(buffer); 54 | ntStatus = AddInQueue("-- END\n"); 55 | } 56 | } 57 | else 58 | return STATUS_SUCCESS; 59 | } 60 | } 61 | __except(EXCEPTION_EXECUTE_HANDLER) 62 | { 63 | ntStatus=GetExceptionCode(); 64 | DbgPrint("Exception RegNtPreDeleteKey : %x\n", ntStatus); 65 | } 66 | 67 | ExFreePoolWithTag(key,0); 68 | break; 69 | } 70 | case RegNtPreCreateKeyEx: 71 | { 72 | PREG_CREATE_KEY_INFORMATION pInfo = (PREG_CREATE_KEY_INFORMATION) Argument2; 73 | __try{ 74 | ntStatus = AddInQueue("-- BEGIN\n"); 75 | 76 | sprintf_s(buffer,sizeof(buffer),"trace=%i , cpu=%i\n",trace++, KeGetCurrentProcessorNumber()); 77 | AddInQueue(buffer); 78 | 79 | KeQuerySystemTime(&time); 80 | RtlZeroMemory(&buffer, sizeof(buffer)); 81 | sprintf_s(buffer,sizeof(buffer),"timestamp=%I64d\n",time.QuadPart); 82 | AddInQueue(buffer); 83 | AddInQueue("Access : create\n"); 84 | 85 | RtlZeroMemory(&buffer, sizeof(buffer)); 86 | RtlUnicodeStringToAnsiString(&key_ansi, pInfo->CompleteName, TRUE); 87 | sprintf_s(buffer, sizeof(buffer),"%s\n", key_ansi.Buffer); 88 | GetUnicodeName((int)PsGetCurrentProcessId()); 89 | ntStatus = AddInQueue(buffer); 90 | ntStatus = AddInQueue("-- END\n"); 91 | } 92 | __except(EXCEPTION_EXECUTE_HANDLER) 93 | { 94 | ntStatus=GetExceptionCode(); 95 | DbgPrint("Exception RegNtPreCreateKeyEx : %x\n", ntStatus); 96 | } 97 | break; 98 | } 99 | case RegNtSetValueKey: 100 | { 101 | PREG_SET_VALUE_KEY_INFORMATION pInfo = (PREG_SET_VALUE_KEY_INFORMATION) Argument2; 102 | 103 | __try{ 104 | ntStatus = ObQueryNameString(pInfo->Object, (POBJECT_NAME_INFORMATION)key, 0, &ReturnLength); 105 | key = (PUNICODE_STRING)ExAllocatePoolWithTag(NonPagedPool, ReturnLength, 1); 106 | if (ntStatus == STATUS_INFO_LENGTH_MISMATCH) 107 | { 108 | if (key) 109 | { 110 | ntStatus = ObQueryNameString(pInfo->Object, (POBJECT_NAME_INFORMATION)key, ReturnLength, &ReturnLength); 111 | if(NT_SUCCESS(ntStatus)) 112 | { 113 | ntStatus = AddInQueue("-- BEGIN\n"); 114 | RtlUnicodeStringToAnsiString(&key_ansi, key, TRUE); 115 | 116 | sprintf_s(buffer,sizeof(buffer),"trace=%i , cpu=%i\n",trace++, KeGetCurrentProcessorNumber()); 117 | AddInQueue(buffer); 118 | 119 | KeQuerySystemTime(&time); 120 | RtlZeroMemory(&buffer, sizeof(buffer)); 121 | sprintf_s(buffer,sizeof(buffer),"timestamp=%I64d\n",time.QuadPart); 122 | AddInQueue(buffer); 123 | AddInQueue("Access : set_value_key\n"); 124 | 125 | RtlZeroMemory(&buffer, sizeof(buffer)); 126 | sprintf_s(buffer, sizeof(buffer),"%s\n", key_ansi.Buffer); 127 | GetUnicodeName((int)PsGetCurrentProcessId()); 128 | ntStatus = AddInQueue(buffer); 129 | RtlZeroMemory(&buffer, sizeof(buffer)); 130 | RtlUnicodeStringToAnsiString(&value_ansi, pInfo->ValueName, TRUE); 131 | sprintf_s(buffer, sizeof(buffer),"%s\n", value_ansi.Buffer); 132 | ntStatus = AddInQueue(buffer); 133 | ntStatus = AddInQueue("-- END\n"); 134 | } 135 | 136 | } 137 | } 138 | if(key) 139 | ExFreePoolWithTag(key,1); 140 | 141 | } 142 | __except(EXCEPTION_EXECUTE_HANDLER) 143 | { 144 | ntStatus=GetExceptionCode(); 145 | DbgPrint("Exception RegNtSetValueKey : %x\n", ntStatus); 146 | } 147 | break; 148 | } 149 | 150 | case RegNtQueryValueKey: 151 | { 152 | PREG_QUERY_VALUE_KEY_INFORMATION pInfo = (PREG_QUERY_VALUE_KEY_INFORMATION) Argument2; 153 | __try 154 | { 155 | ntStatus = ObQueryNameString(pInfo->Object, (POBJECT_NAME_INFORMATION)key, 0, &ReturnLength); 156 | key = (PUNICODE_STRING)ExAllocatePoolWithTag(NonPagedPool, ReturnLength, 1); 157 | if (ntStatus == STATUS_INFO_LENGTH_MISMATCH) 158 | { 159 | if (key) 160 | { 161 | ntStatus = ObQueryNameString(pInfo->Object, (POBJECT_NAME_INFORMATION)key, ReturnLength, &ReturnLength); 162 | if(NT_SUCCESS(ntStatus)) 163 | { 164 | ntStatus = AddInQueue("-- BEGIN\n"); 165 | RtlUnicodeStringToAnsiString(&key_ansi, key, TRUE); 166 | 167 | sprintf_s(buffer,sizeof(buffer),"trace=%i , cpu=%i\n",trace++, KeGetCurrentProcessorNumber()); 168 | AddInQueue(buffer); 169 | 170 | KeQuerySystemTime(&time); 171 | RtlZeroMemory(&buffer, sizeof(buffer)); 172 | sprintf_s(buffer,sizeof(buffer),"timestamp=%I64d\n",time.QuadPart); 173 | AddInQueue(buffer); 174 | AddInQueue("Access : query_value_key\n"); 175 | 176 | RtlZeroMemory(&buffer, sizeof(buffer)); 177 | GetUnicodeName((int)PsGetCurrentProcessId()); 178 | sprintf_s(buffer, sizeof(buffer),"%s\n", key_ansi.Buffer); 179 | ntStatus = AddInQueue(buffer); 180 | switch(pInfo->KeyValueInformationClass) 181 | { 182 | case 0: {AddInQueue( "KeyValueBasicInformation\n"); break;} 183 | case 1: {AddInQueue("KeyValueFullInformation\n"); break;} 184 | case 2: {AddInQueue("KeyValuePartialInformation\n"); break;} 185 | case 3: {AddInQueue("KeyValueFullInformationAlign64\n"); break;} 186 | case 4: {AddInQueue("KeyValuePartialInformationAlign64\n"); break;} 187 | case 5: {AddInQueue("MaxKeyValueInfoClass\n"); break;} 188 | default: break; 189 | } 190 | ntStatus = AddInQueue("-- END\n"); 191 | } 192 | if(key) 193 | ExFreePoolWithTag(key,1); 194 | } 195 | } 196 | } 197 | __except(EXCEPTION_EXECUTE_HANDLER) 198 | { 199 | ntStatus=GetExceptionCode(); 200 | DbgPrint("Exception : %x\n", ntStatus); 201 | } 202 | break; 203 | } 204 | 205 | case RegNtPreOpenKeyEx: 206 | { 207 | PREG_CREATE_KEY_INFORMATION pInfo = (PREG_CREATE_KEY_INFORMATION) Argument2; 208 | __try{ 209 | ntStatus = AddInQueue("-- BEGIN\n"); 210 | 211 | sprintf_s(buffer,sizeof(buffer),"trace=%i , cpu=%i\n",trace++, KeGetCurrentProcessorNumber()); 212 | AddInQueue(buffer); 213 | 214 | KeQuerySystemTime(&time); 215 | RtlZeroMemory(&buffer, sizeof(buffer)); 216 | sprintf_s(buffer,sizeof(buffer),"timestamp=%I64d\n",time.QuadPart); 217 | AddInQueue(buffer); 218 | AddInQueue("Access : open\n"); 219 | 220 | RtlZeroMemory(&buffer, sizeof(buffer)); 221 | GetUnicodeName((int)PsGetCurrentProcessId()); 222 | RtlUnicodeStringToAnsiString(&key_ansi, pInfo->CompleteName, TRUE); 223 | sprintf_s(buffer, sizeof(buffer),"%s\n", key_ansi.Buffer); 224 | ntStatus = AddInQueue(buffer); 225 | ntStatus = AddInQueue("-- END\n"); 226 | } 227 | __except(EXCEPTION_EXECUTE_HANDLER) 228 | { 229 | ntStatus=GetExceptionCode(); 230 | DbgPrint("Exception RegNtPreCreateKeyEx : %x\n", ntStatus); 231 | } 232 | break; 233 | } 234 | default: 235 | break; 236 | } 237 | 238 | return STATUS_SUCCESS; 239 | } 240 | 241 | 242 | -------------------------------------------------------------------------------- /Registry/src/pigaregmonitor.c: -------------------------------------------------------------------------------- 1 | #include "pigaregmonitor.h" 2 | 3 | #define DRIVER_NAME L"pigaregmonitor" 4 | 5 | PDEVICE_OBJECT g_pDeviceObject = NULL; 6 | PDEVICE_CONTEXT g_pDeviceContext = NULL; 7 | PDEVICE_OBJECT devobj; 8 | 9 | typedef struct _WORK_QUEUE { 10 | struct _WORK_QUEUE * Next; 11 | struct _WORK_QUEUE * Prev; 12 | char buffer[1000]; 13 | } WORK_QUEUE, *PWORK_QUEUE; 14 | 15 | WORK_QUEUE * Head; 16 | WORK_QUEUE * End; 17 | BOOLEAN Stop; 18 | 19 | PETHREAD Thread; 20 | 21 | HANDLE threadHandle; 22 | 23 | NTSTATUS StartWorkQueue(); 24 | VOID WorkerThread ( __in PVOID Context); 25 | 26 | NTSTATUS DriverEntry( 27 | IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath 28 | ) 29 | { 30 | NTSTATUS status; 31 | PDEVICE_OBJECT deviceObject = NULL; 32 | NTSTATUS ntStatus; 33 | // UNICODE_STRING devname = RTL_CONSTANT_STRING(L"\\Device\\pigaregfilter"); 34 | WCHAR deviceNameBuffer[] = L"\\Device\\"DRIVER_NAME; 35 | UNICODE_STRING deviceNameUnicodeString; 36 | WCHAR deviceLinkBuffer[] = L"\\DosDevices\\"DRIVER_NAME; 37 | UNICODE_STRING deviceLinkUnicodeString; 38 | 39 | UNREFERENCED_PARAMETER(RegistryPath); 40 | 41 | RtlInitUnicodeString (&deviceNameUnicodeString, deviceNameBuffer); 42 | 43 | //Create and Initialize device object 44 | ntStatus = IoCreateDevice (DriverObject, 45 | sizeof (DEVICE_CONTEXT), 46 | &deviceNameUnicodeString, 47 | 0x6666, 48 | 0, 49 | FALSE, 50 | &deviceObject 51 | ); 52 | 53 | 54 | if (NT_SUCCESS(ntStatus)) 55 | { 56 | RtlInitUnicodeString (&deviceLinkUnicodeString, deviceLinkBuffer); 57 | ntStatus = IoCreateSymbolicLink (&deviceLinkUnicodeString, &deviceNameUnicodeString); 58 | 59 | // Simplification de la communication entre user-mode et kernel-mode 60 | if (!NT_SUCCESS(ntStatus)) 61 | { 62 | IoDeleteDevice (deviceObject); 63 | DbgPrint("DriverEntry: IoCreationSymbolicLink failed"); 64 | return ntStatus; 65 | } 66 | 67 | g_pDeviceObject = deviceObject; 68 | g_pDeviceContext = deviceObject->DeviceExtension; 69 | 70 | g_pDeviceContext->pDriverObject = DriverObject; 71 | g_pDeviceContext->pDeviceObject = deviceObject; 72 | 73 | DriverObject->DriverUnload = DriverUnload; 74 | DriverObject->MajorFunction[IRP_MJ_CREATE] = DrvCreateClose; 75 | DriverObject->MajorFunction[IRP_MJ_CLOSE] = DrvCreateClose; 76 | DriverObject->MajorFunction[IRP_MJ_WRITE] = DrvWrite; 77 | DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DriverDispatch; 78 | trace=0; 79 | ntStatus = sendthenrecv(); 80 | StartWorkQueue(); 81 | 82 | 83 | if(!NT_SUCCESS(ntStatus)) 84 | { 85 | IoDeleteSymbolicLink (&deviceLinkUnicodeString); 86 | IoDeleteDevice (deviceObject); 87 | DbgPrint("DriverEntry: Connection failed \n"); 88 | return ntStatus; 89 | } 90 | 91 | 92 | ntStatus= CmRegisterCallback(RegistryCallback, g_pDeviceContext, &g_pDeviceContext->RegCookie); 93 | if(!NT_SUCCESS(ntStatus)) return ntStatus; 94 | 95 | 96 | return STATUS_SUCCESS; 97 | } 98 | else 99 | { 100 | DbgPrint("DriverEntry: IOCreateDevice failed"); 101 | return ntStatus; 102 | } 103 | 104 | } 105 | 106 | 107 | VOID WorkerThread ( 108 | __in PVOID Context 109 | ) 110 | { 111 | NTSTATUS status; 112 | UNREFERENCED_PARAMETER(Context); 113 | KeSetPriorityThread(KeGetCurrentThread(), 1); 114 | 115 | 116 | for(;;) 117 | { 118 | status = RemoveQueue(); 119 | if(status == STATUS_UNSUCCESSFUL && Stop == TRUE) 120 | break; 121 | } 122 | PsTerminateSystemThread(STATUS_SUCCESS); 123 | } 124 | 125 | VOID DriverUnload( 126 | IN PDRIVER_OBJECT DriverObject 127 | ) 128 | { 129 | WCHAR deviceLinkBuffer[] = L"\\DosDevices\\"DRIVER_NAME; 130 | UNICODE_STRING deviceLinkUnicodeString; 131 | DbgPrint("Unload driver...\n"); 132 | 133 | CmUnRegisterCallback(g_pDeviceContext->RegCookie); 134 | 135 | Stop = TRUE; 136 | 137 | KeWaitForSingleObject(Thread, Executive, KernelMode, FALSE, 0); 138 | 139 | ObDereferenceObject(Thread); 140 | // if(threadHandle) 141 | // ZwClose(threadHandle); 142 | 143 | if(sock) disconnectfromserver(sock); 144 | cleanupwsk(&clireg); 145 | 146 | RtlInitUnicodeString (&deviceLinkUnicodeString,deviceLinkBuffer); 147 | IoDeleteSymbolicLink (&deviceLinkUnicodeString); 148 | IoDeleteDevice (DriverObject->DeviceObject); 149 | } 150 | 151 | NTSTATUS AddInQueue(__in char * buf) 152 | { 153 | NTSTATUS status = STATUS_SUCCESS; 154 | WORK_QUEUE * liste_temp = NULL; 155 | 156 | if(buf == NULL) return STATUS_UNSUCCESSFUL; 157 | 158 | if(Head == NULL) // premier element a etre insere 159 | { 160 | __try{ 161 | 162 | Head = (WORK_QUEUE *) ExAllocatePoolWithTag(PagedPool, sizeof(WORK_QUEUE), 0); 163 | if(Head == NULL) return STATUS_UNSUCCESSFUL; 164 | End = (WORK_QUEUE *) ExAllocatePoolWithTag(PagedPool, sizeof(WORK_QUEUE), 0); 165 | if(End == NULL) return STATUS_UNSUCCESSFUL; 166 | 167 | Head->Next = End; 168 | Head->Prev = NULL; 169 | if(strlen(buf) > sizeof(Head->buffer)) return STATUS_UNSUCCESSFUL; 170 | RtlZeroMemory(&Head->buffer, sizeof(Head->buffer)); 171 | strcpy(Head->buffer, buf); 172 | End->Next = NULL; 173 | End->Prev = Head; 174 | strcpy(End->buffer, "First one\n"); 175 | return status; 176 | } 177 | __except(EXCEPTION_EXECUTE_HANDLER) 178 | { 179 | status=GetExceptionCode(); 180 | DbgPrint("Exception RegNtPreDeleteKey : %x\n", status); 181 | return status; 182 | } 183 | } 184 | 185 | if(Head != NULL) // il y a au moins un element dans la liste 186 | { 187 | liste_temp = (WORK_QUEUE *) ExAllocatePoolWithTag(PagedPool, sizeof(WORK_QUEUE), 0); 188 | if(liste_temp == NULL) return STATUS_UNSUCCESSFUL; 189 | 190 | if(strlen(buf) > sizeof(liste_temp->buffer)) return STATUS_UNSUCCESSFUL; 191 | RtlZeroMemory(&liste_temp->buffer, sizeof(liste_temp->buffer)); 192 | strcpy(liste_temp->buffer, buf); 193 | liste_temp->Next = Head->Next; 194 | Head->Prev =liste_temp; 195 | liste_temp->Prev = NULL; 196 | 197 | Head = liste_temp; 198 | 199 | if(End == NULL) End = liste_temp; 200 | return status; 201 | } 202 | return status; 203 | } 204 | 205 | NTSTATUS RemoveQueue() 206 | { 207 | NTSTATUS status = STATUS_SUCCESS; 208 | // WORK_QUEUE * liste_temp = NULL; 209 | 210 | if(End == NULL) return STATUS_UNSUCCESSFUL; 211 | if(End != NULL) // il y a au moins un eleement 212 | { 213 | __try{ 214 | if(End->buffer == NULL) return STATUS_UNSUCCESSFUL; 215 | status = senddata(sock, End->buffer, strlen(End->buffer)); 216 | 217 | if(End->Prev != NULL) 218 | { 219 | End = End->Prev ; 220 | //ExFreePool(End->Next); 221 | End->Next = NULL; 222 | } 223 | else 224 | End = NULL; 225 | 226 | 227 | return status; 228 | } 229 | __except(EXCEPTION_EXECUTE_HANDLER) 230 | { 231 | status=GetExceptionCode(); 232 | DbgPrint("Exception removequereue : %x\n", status); 233 | return status; 234 | } 235 | } 236 | return status; 237 | } 238 | 239 | 240 | 241 | NTSTATUS StartWorkQueue() 242 | { 243 | NTSTATUS status; 244 | PAGED_CODE(); 245 | 246 | Head = NULL; 247 | End = NULL, 248 | Stop = FALSE; 249 | 250 | status = PsCreateSystemThread( 251 | &threadHandle, THREAD_ALL_ACCESS, NULL, NULL, NULL, 252 | WorkerThread, NULL); 253 | DbgPrint("Status thread : %x \n", status); 254 | 255 | 256 | status = ObReferenceObjectByHandle( 257 | threadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, 258 | &Thread, NULL); 259 | 260 | ZwClose(threadHandle); 261 | if(!NT_SUCCESS(status)) { 262 | return status; 263 | } 264 | 265 | return status; 266 | } 267 | 268 | 269 | NTSTATUS 270 | sendthenrecv(void) 271 | { 272 | NTSTATUS status; 273 | 274 | WSK_PROVIDER_NPI pronpi; 275 | SOCKADDR_IN srvaddr; 276 | 277 | srvaddr.sin_family = AF_INET; 278 | srvaddr.sin_port = RtlUshortByteSwap(1337); 279 | srvaddr.sin_addr.S_un.S_un_b.s_b1 = 192; 280 | srvaddr.sin_addr.S_un.S_un_b.s_b2 = 168; 281 | srvaddr.sin_addr.S_un.S_un_b.s_b3 = 99; 282 | srvaddr.sin_addr.S_un.S_un_b.s_b4 = 70; 283 | 284 | status = initwsk(&clireg, &pronpi); 285 | if(!NT_SUCCESS(status)){ 286 | DbgPrint("initwsk() failed: 0x%x\n", status); 287 | return status; 288 | } 289 | 290 | DbgPrint("Initialized!\n"); 291 | 292 | status = connecttoserver(&pronpi, (PSOCKADDR)&srvaddr, &sock); 293 | if(!NT_SUCCESS(status)){ 294 | cleanupwsk(&clireg); 295 | DbgPrint("connecttoserver() failed: 0x%x\n", status); 296 | return status; 297 | } 298 | 299 | DbgPrint("Connected!\n"); 300 | return STATUS_SUCCESS; 301 | } 302 | 303 | 304 | /** 305 | * @description : Fonction qui va recuperer les IRP : DeviceIO 306 | * @param : DeviceObject 307 | * @param : IRP 308 | * @return : NTSTATUS 309 | **/ 310 | NTSTATUS DriverDispatch( 311 | IN PDEVICE_OBJECT DeviceObject, 312 | IN PIRP Irp 313 | ) 314 | { 315 | UNREFERENCED_PARAMETER(DeviceObject); 316 | IoCompleteRequest (Irp, IO_NO_INCREMENT); 317 | return Irp->IoStatus.Status; 318 | } 319 | 320 | /** 321 | * @description : Fonction qui va recuperer les IRP CREATE ET CLOSE 322 | * @param : DeviceObject 323 | * @param : IRP 324 | * @return : NTSTATUS 325 | **/ 326 | 327 | NTSTATUS DrvCreateClose( 328 | IN PDEVICE_OBJECT DeviceObject, 329 | IN PIRP Irp 330 | ) 331 | { 332 | UNREFERENCED_PARAMETER(DeviceObject); 333 | Irp->IoStatus.Status = STATUS_SUCCESS; 334 | IoCompleteRequest (Irp, IO_NO_INCREMENT); 335 | return Irp->IoStatus.Status; 336 | } 337 | 338 | 339 | NTSTATUS DrvWrite( 340 | IN PDEVICE_OBJECT DeviceObject, 341 | IN PIRP Irp 342 | ) 343 | { 344 | UNREFERENCED_PARAMETER(DeviceObject); 345 | Irp->IoStatus.Status = STATUS_SUCCESS; 346 | IoCompleteRequest (Irp, IO_NO_INCREMENT); 347 | return Irp->IoStatus.Status; 348 | } 349 | 350 | 351 | -------------------------------------------------------------------------------- /Server/graph/Ressources.py: -------------------------------------------------------------------------------- 1 | 2 | class res_process : 3 | 4 | nb_creer = 0 # pour compter le nombre de processus creer depuis le debut 5 | nb_exist = 0 # pour compter le nombre de processus encore actifs 6 | def __init__(self): # constructeur par default de la calsse processus, normalement inutile. 7 | self.PID = 0 # on enregistre le PID 8 | self.PPID = 0 # le PID parent 9 | self.nom = "" # on ne nconnait pas le nom 10 | self.papa = "" # ni celui du pere 11 | res_process.nb_creer = res_process.nb_creer + 1 12 | res_process.nb_exist = res_process.nb_exist +1 # on incremente le compteur de processus 13 | 14 | self.corrompu = False # le fichier n'est pas corrompu a la creation 15 | 16 | def __init__(self, chif1, mot1, chif2, mot2): # constructeur de rocessus 17 | self.PID = chif1 18 | self.nom = mot1 19 | 20 | self.PPID = chif2 # on enregistre les pid 21 | self.papa = mot2 # on enregistre les noms 22 | res_process.nb_creer = res_process.nb_creer + 1 23 | res_process.nb_exist = res_process.nb_exist +1 # on incremente les compteur 24 | 25 | self.corrompu = False # le fichier n'est pas corrompu a la creation 26 | 27 | 28 | def __del__(self): # destructeur de processus 29 | res_process.nb_exist = res_process.nb_exist - 1 # on decremente le compteur 30 | 31 | 32 | class res_fichier : 33 | 34 | nb_creer = 0 # poour compter le nombre de fichier creer depuis le debut 35 | nb_exist = 0 # pour compter le nombre de fichier encore existant 36 | def __init__(self): # constructeur par default, normalement inutile 37 | self.name = "" # on ne connait pas le nom 38 | 39 | self.corrompu = False # le fichier n'est pas corrompu a la creation 40 | 41 | res_fichier.nb_exist = res_fichier.nb_exist + 1 # on incremente les compteurs 42 | res_fichier.nb_creer = res_fichier.nb_creer + 1 # on incremente les compteurs 43 | 44 | def __init__(self, mot1): # constructeur de fichier 45 | self.name = mot1 # on enregistre le nom du fichier 46 | 47 | self.corrompu = False # le fchier n'est pas corrompu a la creation 48 | 49 | res_fichier.nb_exist = res_fichier.nb_exist + 1 # on incremente les compteurs 50 | res_fichier.nb_creer = res_fichier.nb_creer + 1 # on incremente les compteurs 51 | 52 | def __del__(self) : 53 | res_fichier.nb_exist = res_fichier.nb_exist - 1 # on decremente le compteur 54 | 55 | 56 | class res_registre : 57 | 58 | nb_creer = 0 # poour compter le nombre de fichier creer depuis le debut 59 | nb_exist = 0 # pour compter le nombre de fichier encore existant 60 | def __init__(self): # constructeur par default, normalement inutile 61 | self.name = "" # on ne connait pas le nom 62 | 63 | self.corrompu = False # le fichier n'est pas corrompu a la creation 64 | 65 | res_fichier.nb_exist = res_fichier.nb_exist + 1 # on incremente les compteurs 66 | res_fichier.nb_creer = res_fichier.nb_creer + 1 # on incremente les compteurs 67 | 68 | def __init__(self, mot1): # constructeur de fichier 69 | self.name = mot1 # on enregistre le nom du fichier 70 | 71 | self.corrompu = False # le fchier n'est pas corrompu a la creation 72 | 73 | res_fichier.nb_exist = res_fichier.nb_exist + 1 # on incremente les compteurs 74 | res_fichier.nb_creer = res_fichier.nb_creer + 1 # on incremente les compteurs 75 | 76 | def __del__(self) : 77 | res_fichier.nb_exist = res_fichier.nb_exist - 1 # on decremente le compteur 78 | 79 | 80 | class systemTrace : 81 | 82 | nb_proces_corrompu = 0 #on compte les object corrompu 83 | nb_fichier_corrompu = 0 84 | nb_registre_corrompu = 0 85 | 86 | def __init__(self): # constructeur, avec initialisation des dict 87 | self.source_corrup = "" # le fichier corrompu de depart doit etre defini 88 | 89 | self.tab_proc = {} # le dict des processus (vide) 90 | self.tab_proc[0] = res_process(0, "system", 0, "system") 91 | 92 | self.tab_fich = {} # le dict des fichiers (vide) 93 | self.tab_reg = {} # le dict des registre (vide) 94 | fichier = open("expension.txt", "w") 95 | fichier.write("Trackeur de trace :\n") 96 | fichier.close() 97 | 98 | def __init__(self, mot): # constructeur, avec initialisation des dict 99 | self.source_corrup = mot # le fichier corrompu de depart a ete donne en parametre 100 | print "La sourc de corruption est : ", mot 101 | 102 | self.tab_proc = {} # le dict des processus (vide) 103 | self.tab_proc[0] = res_process(0, "system", 0, "system") 104 | 105 | self.tab_fich = {} # le dict des fichiers (vide) 106 | self.tab_reg = {} # le dict des registre (vide) 107 | fichier = open("expension.txt", "w") 108 | fichier.write("Trackeur de trace :\n") 109 | fichier.close() 110 | 111 | def def_corrup(self, corrupteur): 112 | self.source_corrup = corrupteur # on defini le fichier corrompu de depart 113 | 114 | 115 | def new_proc(self, bebepid, bebename, papapid, papaname): # on a une creation de processus 116 | if bebepid not in self.tab_proc : # on ajoute une entre pid dans le dico et on creer le processus a metre dedans 117 | self.tab_proc[bebepid] = res_process(bebepid, bebename, papapid, papaname) 118 | else: 119 | print "creation d'un processus deja existant !", bebepid # la, y'a un probleme... 120 | print "\t",self.tab_proc[bebepid].nom 121 | 122 | if papapid in self.tab_proc and self.tab_proc[papapid].corrompu and not self.tab_proc[bebepid].corrompu : 123 | self.tab_proc[bebepid].corrompu = True # on verifie si le fichier pere est corrompu 124 | systemTrace.nb_proces_corrompu = systemTrace.nb_proces_corrompu + 1 125 | self.sauvetrace("-- begin processus corrompu\nsource : processus parent\npid="+str(bebepid)+" ppid="+str(papapid)+"\n-- end process\n") 126 | if self.source_corrup in bebename.split("\\") and not self.tab_proc[bebepid].corrompu : 127 | self.tab_proc[bebepid].corrompu = True # on verifie si le fichier est la source de corrompu 128 | systemTrace.nb_proces_corrompu = systemTrace.nb_proces_corrompu + 1 129 | self.sauvetrace("-- begin processus corrompu\nsource : point depart\npid="+str(bebepid)+" ppid="+str(papapid)+"\n-- end process\n") 130 | 131 | def del_proc(self, bebepid, bebename, papapid, papaname): # un processus est detruit 132 | if bebepid not in self.tab_proc : 133 | print "destruction d'un processus inexistant !" # pas genant, mais bizare ... 134 | else: 135 | del self.tab_proc[bebepid] # on le supprime 136 | 137 | def create_fichier(self, fichier, pidpapa): 138 | if pidpapa not in self.tab_proc : #on verifie que le process pere existe 139 | print "process pere inconnu !", pidpapa 140 | elif fichier not in self.tab_fich : # on verifie que lefichier n'existe pas deja 141 | self.tab_fich[fichier] = res_fichier(fichier) # on le creer 142 | 143 | if pidpapa in self.tab_proc and self.tab_proc[pidpapa].corrompu and not self.tab_fich[fichier].corrompu : # on verifie s'il est corrompu 144 | self.tab_fich[fichier].corrompu = True 145 | systemTrace.nb_fichier_corrompu = systemTrace.nb_fichier_corrompu + 1 146 | self.sauvetrace("-- begin fichier corrompu\nsource : processus create\npid="+str(pidpapa)+" fichier="+str(fichier)+"\n-- end fichier\n") 147 | if self.source_corrup in fichier.split("\\") and not self.tab_fich[fichier].corrompu: 148 | self.tab_fich[fichier].corrompu = True 149 | systemTrace.nb_fichier_corrompu = systemTrace.nb_fichier_corrompu + 1 150 | self.sauvetrace("-- begin fichier corrompu\nsource : point depart\npid="+str(pidpapa)+" fichier="+str(fichier)+"\n-- end fichier\n") 151 | #else : #le fichier existe deja ! 152 | # print "creation d'un fichier deja existant !" 153 | 154 | def acces_fichier(self, fichier, pidpapa) : 155 | if fichier not in self.tab_fich : 156 | #print "acces a un fichier inexistant !" 157 | self.create_fichier(fichier,0) 158 | 159 | if pidpapa not in self.tab_proc : 160 | print "access fichier par un process inexistant !" 161 | else : 162 | if self.tab_fich[fichier].corrompu and not self.tab_proc[pidpapa].corrompu : 163 | self.tab_proc[pidpapa].corrompu = True 164 | systemTrace.nb_fichier_corrompu = systemTrace.nb_fichier_corrompu + 1 165 | self.sauvetrace("-- begin processus corrompu\nsource : lecture fichier\npid="+str(pidpapa)+" fichier="+str(fichier)+"\n-- end process\n") 166 | 167 | def modif_fichier(self, fichier, pidpapa) : 168 | if fichier not in self.tab_fich : 169 | #print "modification d'un fichier inexistant !" 170 | self.create_fichier(fichier,0) 171 | 172 | if pidpapa not in self.tab_proc : 173 | print "modification fichier par un process inexistant !" 174 | else : 175 | if self.tab_proc[pidpapa].corrompu and not self.tab_fich[fichier].corrompu : 176 | self.tab_fich[fichier].corrompu = True 177 | systemTrace.nb_fichier_corrompu = systemTrace.nb_fichier_corrompu + 1 178 | self.sauvetrace("-- begin fichier corrompu\nsource : processus acces\npid="+str(pidpapa)+" fichier="+str(fichier)+"\n-- end fichier\n") 179 | 180 | 181 | 182 | def create_registre(self, registre, pidpapa): 183 | if pidpapa not in self.tab_proc : #on verifie que le process pere existe 184 | print "process pere inconnu !", pidpapa 185 | elif registre not in self.tab_reg : # on verifie que lefichier n'existe pas deja 186 | self.tab_reg[registre] = res_registre(registre) # on le creer 187 | 188 | if pidpapa in self.tab_proc and self.tab_proc[pidpapa].corrompu and not self.tab_reg[registre].corrompu : # on verifie s'il est corrompu 189 | self.tab_reg[registre].corrompu = True 190 | systemTrace.nb_registre_corrompu = systemTrace.nb_registre_corrompu + 1 191 | self.sauvetrace("-- begin registre corrompu\nsource : processus create\npid="+str(pidpapa)+" registre="+str(registre)+"\n-- end fichier\n") 192 | if self.source_corrup in registre.split("\\") and not self.tab_reg[registre].corrompu : 193 | self.tab_reg[registre].corrompu = True 194 | systemTrace.nb_registre_corrompu = systemTrace.nb_registre_corrompu + 1 195 | self.sauvetrace("-- begin registre corrompu\nsource : point depart\npid="+str(pidpapa)+" fichier="+str(registre)+"\n-- end fichier\n") 196 | #else : #le fichier existe deja ! 197 | # print "creation d'un fichier deja existant !" 198 | 199 | def acces_registre(self, registre, pidpapa) : 200 | if registre not in self.tab_reg : 201 | #print "acces a un fichier inexistant !" 202 | self.create_registre(registre,0) 203 | 204 | if pidpapa not in self.tab_proc : 205 | print "access fichier par un process inexistant !" 206 | else : 207 | if self.tab_reg[registre].corrompu and not self.tab_proc[pidpapa].corrompu: 208 | self.tab_proc[pidpapa].corrompu = True 209 | systemTrace.nb_registre_corrompu = systemTrace.nb_registre_corrompu + 1 210 | self.sauvetrace("-- begin processus corrompu\nsource : lecture registre\npid="+str(pidpapa)+" fichier="+str(registre)+"\n-- end process\n") 211 | 212 | def modif_registre(self, registre, pidpapa) : 213 | if registre not in self.tab_reg : 214 | #print "modification d'un fichier inexistant !" 215 | self.create_registre(registre,0) 216 | 217 | if pidpapa not in self.tab_proc : 218 | print "modification fichier par un process inexistant !" 219 | else : 220 | if self.tab_proc[pidpapa].corrompu and not self.tab_reg[registre].corrompu : 221 | self.tab_reg[registre].corrompu = True 222 | systemTrace.nb_registre_corrompu = systemTrace.nb_registre_corrompu + 1 223 | self.sauvetrace("-- begin registre corrompu\nsource : processus acces\npid="+str(pidpapa)+" fichier="+str(registre)+"\n-- end fichier\n") 224 | 225 | 226 | 227 | 228 | def sauvetrace(self, text): 229 | fichier = open("expension.txt", "a") 230 | fichier.write(text) 231 | fichier.close() 232 | -------------------------------------------------------------------------------- /Server/graph/Test.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from Ressources import * 3 | 4 | if __name__ == "__main__": 5 | if len(sys.argv) < 2: 6 | print("donnez un fichier en entree") # pour prendre en argument le fichier a lire. 7 | sys.exit(1) # on avait pas de fichier a lire, alors on s'en va. 8 | 9 | argument = sys.argv[1] # on recupere le nom du fichier a lire. 10 | try: 11 | trace = open(argument, "r") # on ouvre le fichier en lecture 12 | except: 13 | print "Le fichier ne s'ouvre pas !" 14 | sys.exit(1) # si on est ici, il y a eu un probleme d'ouverture du fichier. 15 | 16 | 17 | poursuite = systemTrace("xxx-porn-movie.avi.exe") 18 | 19 | ligne = "go !" #on initialise la ligne 20 | 21 | # je creer des variable pour compter le nombre d'acces au different types de ressources utilise 22 | nb_proc = 0 # les processus 23 | nb_proc_good = 0 24 | nb_proc_bad = 0 25 | 26 | nb_registre = 0 # les acces au registre 27 | 28 | #les types d'acces registre 29 | nb_reg_open = 0 30 | nb_query_value_key = 0 31 | nb_reg_create = 0 32 | nb_reg_set_value_key = 0 33 | nb_reg_delete = 0 34 | 35 | nb_acces = 0 # les acces fichier 36 | 37 | # les types d'acces fichier 38 | nb_create = 0 39 | nb_read = 0 40 | nb_write = 0 41 | nb_Todok = 0 42 | nb_unlink = 0 43 | nb_query = 0 44 | nb_load = 0 45 | nb_device_io_control = 0 46 | nb_query_EA = 0 47 | nb_set_EA = 0 48 | nb_non_renseigne = 0 49 | nb_create_overwrite_if = 0 50 | nb_create_open = 0 51 | 52 | nb_inconnu = 0 # les lignes non traite 53 | 54 | position = 0 # numero de ligne courrante 55 | 56 | # je veut savoir si on me signale que le prochain access processus sera une destruction 57 | destruction = False 58 | 59 | while ligne != '' : # il faut faire une boucle sur tout le fichier 60 | ligne = trace.readline().rstrip('\n\r') # on lit la ligne courante 61 | position = position + 1 62 | phrase = ligne.split() 63 | 64 | if ligne == "------ Create process" : # cette ligne ne sert a rien, vu que par default je considere les processus comme en mode creation 65 | destruction = False 66 | elif ligne == "------ Descruction process" : # l'information que le procesqsus est en mode destruction se trouve en dehors des entre process 67 | destruction = True 68 | elif ligne == "---- Begin" : 69 | nb_proc = nb_proc + 1 # nous entrons dans un nouvel acces processus 70 | papa = ["inconnu","0"] # on initialise le processus parent a 0 71 | bebe = ["inconnu","0"] # on initialise le processus fils a 0, normalement, cela ne sert a rien. 72 | 73 | while ligne != "---- END" : #tant que l'on ne sort pas de l'entree process 74 | ligne = trace.readline().rstrip('\n\r') # on lit la ligne courante 75 | position = position + 1 76 | phrase = ligne.split() 77 | 78 | if phrase[0] == "Parent" : #on cherche le pid du processus parent 79 | papa[0] = phrase[4] 80 | papa[1] = phrase[5].split('=')[1] #on enregistre qui est le processus parent 81 | 82 | elif phrase[0] == "Process" : 83 | bebe[0] = phrase[3] 84 | try: 85 | bebe[1] = phrase[4].split('=')[1] 86 | except: 87 | crade = True 88 | variable = 5 89 | while crade : # il y a un espace dans le nom de fichier, alors j'avance jusqu'a retrouver le PID 90 | try: 91 | bebe[1] = phrase[variable].split('=')[1] 92 | crade = False 93 | except: 94 | variable = variable + 1 95 | 96 | if bebe[0] == "inconnu" : 97 | nb_proc_bad = nb_proc_bad + 1 98 | else : 99 | nb_proc_good = nb_proc_good +1 100 | if destruction : 101 | poursuite.del_proc(bebe[1],bebe[0],papa[1],papa[0]) 102 | else : 103 | poursuite.new_proc(bebe[1],bebe[0],papa[1],papa[0]) 104 | 105 | destruction = False 106 | 107 | 108 | elif phrase.__len__() > 2 and phrase[0] == "Parent" : 109 | # ce cas est pour ratrapper les process sans begin !! 110 | 111 | nb_proc = nb_proc + 1 # nous entrons dans un nouvel acces processus 112 | papa = ["inconnu","0"] # on initialise le processus parent a 0 113 | bebe = ["inconnu","0"] # on initialise le processus fils a 0, normalement, cela ne sert a rien. 114 | 115 | papa[0] = phrase[4] 116 | papa[1] = phrase[5].split("=")[1] #on enregistre qui est le processus parent 117 | 118 | while ligne != "---- END" : #tant que l'on ne sort pas de l'entree process 119 | ligne = trace.readline().rstrip('\n\r') # on lit la ligne courante 120 | position = position + 1 121 | phrase = ligne.split() 122 | 123 | if phrase[0] == "Parent" : #on cherche le pid du processus parent 124 | papa[0] = phrase[4] 125 | papa[1] = phrase[5].split('=')[1] #on enregistre qui est le processus parent 126 | 127 | elif phrase[0] == "Process" and phrase[1] == "name" and phrase[2] == ":": 128 | bebe[0] = phrase[3] 129 | try: 130 | bebe[1] = phrase[4].split('=')[1] 131 | except: 132 | crade = True 133 | variable = 5 134 | while crade : # il y a un espace dans le nom de fichier, alors j'avance jusqu'a retrouver le PID 135 | try: 136 | bebe[1] = phrase[variable].split('=')[1] 137 | crade = False 138 | except: 139 | variable = variable + 1 140 | 141 | if bebe[0] == "inconnu" : 142 | nb_proc_bad = nb_proc_bad + 1 143 | else : 144 | nb_proc_good = nb_proc_good +1 145 | if destruction : 146 | poursuite.del_proc(bebe[1],bebe[0],papa[1],papa[0]) 147 | else : 148 | poursuite.new_proc(bebe[1],bebe[0],papa[1],papa[0]) 149 | 150 | destruction = False 151 | 152 | 153 | 154 | elif ligne == "------- Enter in IRP" or ligne == "------- Loading": 155 | nb_acces = nb_acces + 1 # nous entrons dans un nouvel acces fichier 156 | # un acces fichier est enregistrer sous forme de liste : 157 | # Access = [0: num_trace, 1: num_cpu, 2: timestamp, 3: access_type, 4: pid name, 5: pid number, 6: object name] 158 | Access = ['','','','','','','',''] 159 | 160 | while ligne != "-------- Exit IRP" and ligne != "------- End loading" : 161 | ligne = trace.readline().rstrip('\n\r') # on lit la ligne courante tant qu'on ne sort pas de l'access fichier 162 | position = position + 1 163 | phrase = ligne.split() 164 | 165 | if phrase[0][:5] == "trace" : # si la ligne donne la trace, on la recupere ainssi que le numero cpu 166 | Access[0] = phrase[0] 167 | Access[1] = phrase[2] 168 | 169 | elif phrase[0][:9] == "timestamp" : # si la ligne donne le timestamp, on le recupere (meme si il sert a rien) 170 | Access[2] = phrase[0] 171 | 172 | elif phrase[0] == "Access" : #si la ligne donne le type d'access, on le recopie. 173 | Access[3] = phrase[2] 174 | 175 | elif phrase[0] == "pid" : # si la ligne donne le pid, on le recupere avec le nom du programme 176 | Access[4] = phrase[2] 177 | Access[5] = phrase[3] 178 | 179 | elif phrase[0] == "Object" and phrase[1] == "Name" : # on recupere le nom du fichier accede 180 | Access[6] = phrase[3] 181 | 182 | if Access[3] == "create_create" : 183 | nb_create = nb_create + 1 184 | poursuite.create_fichier(Access[6],Access[5]) # creation d'un fichier avec son nom et le PID parent 185 | elif Access[3] == "read" : 186 | nb_read = nb_read + 1 187 | poursuite.acces_fichier(Access[6],Access[5]) # acces d'un fichier en lecture 188 | elif Access[3] == "write" : 189 | nb_write = nb_write + 1 190 | poursuite.modif_fichier(Access[6],Access[5]) # acces d'un fichier en ecriture 191 | elif Access[3] == "Todok" : 192 | nb_Todok = nb_Todok + 1 193 | # ? 194 | elif Access[3] == "unlink" : 195 | nb_unlink = nb_unlink + 1 196 | poursuite.acces_fichier(Access[6],Access[5]) # acces d'un fichier en lecture 197 | # ? 198 | elif Access[3] == "query" : 199 | nb_query = nb_query +1 200 | poursuite.acces_fichier(Access[6],Access[5]) # acces d'un fichier en lecture 201 | elif Access[3] == "load" : 202 | nb_load = nb_load +1 203 | poursuite.modif_fichier(Access[6],Access[5]) # acces d'un fichier en ecriture 204 | # ? 205 | elif Access[3] == "device_io_control" : 206 | nb_device_io_control = nb_device_io_control + 1 207 | # ? 208 | elif Access[3] == "query_EA" : 209 | nb_query_EA = nb_query_EA +1 210 | # poursuite.acces_fichier(Access[6],Access[5]) # acces d'un fichier en lecture 211 | elif Access[3] == "set_EA" : 212 | nb_set_EA = nb_set_EA +1 213 | poursuite.modif_fichier(Access[6],Access[5]) # acces d'un fichier en ecriture 214 | # elif Access[3] == "create_overwrite_if" : 215 | # nb_create_overwrite_if = nb_create_overwrite_if + 1 216 | # poursuite.create_fichier(Access[6],Access[5]) # creation d'un fichier avec son nom et le PID parent 217 | elif Access[3] == "create_open" : 218 | nb_create_open = nb_create_open + 1 219 | poursuite.create_fichier(Access[6],Access[5]) # creation d'un fichier avec son nom et le PID parent 220 | elif Access[3] == "" : 221 | nb_non_renseigne = nb_non_renseigne + 1 222 | else : 223 | print "type acces fichier inconnu:",Access[3] 224 | 225 | 226 | elif ligne == "-- BEGIN" : 227 | nb_registre = nb_registre + 1 228 | # un acces registre est enregistrer sous forme de liste : 229 | # Access = [0: num_trace, 1: num_cpu, 2: timestamp, 3: access_type, 4: pid name, 5: pid number, 6: object name] 230 | Access = ['','','','','','','',''] 231 | while ligne != "-- END" : 232 | ligne = trace.readline().rstrip('\n\r') # on lit la ligne courante tant qu'on ne sort pas de l'access fichier 233 | position = position + 1 234 | phrase = ligne.split() 235 | 236 | if(len(phrase)>0): 237 | if phrase[0][:5] == "trace" : # si la ligne donne la trace, on la recupere ainssi que le numero cpu 238 | Access[0] = phrase[0] 239 | Access[1] = phrase[2] 240 | 241 | elif phrase[0][:9] == "timestamp" : # si la ligne donne le timestamp, on le recupere (meme si il sert a rien) 242 | Access[2] = phrase[0] 243 | 244 | elif phrase[0] == "Access" : #si la ligne donne le type d'access, on le recopie. 245 | Access[3] = phrase[2] 246 | 247 | elif phrase[0] == "pid" : # si la ligne donne le pid, on le recupere avec le nom du programme 248 | Access[4] = phrase[2] 249 | Access[5] = phrase[3] 250 | 251 | elif len(ligne.split("\\")) > 1 : 252 | Access[6] = ligne 253 | 254 | 255 | if Access[3] == "open" : 256 | nb_reg_open = nb_reg_open + 1 257 | poursuite.acces_registre(Access[6],Access[5]) 258 | elif Access[3] == "query_value_key" : 259 | nb_query_value_key = nb_query_value_key + 1 260 | poursuite.acces_registre(Access[6],Access[5]) 261 | elif Access[3] == "create" : 262 | nb_reg_create = nb_reg_create + 1 263 | poursuite.create_registre(Access[6],Access[5]) 264 | elif Access[3] == "set_value_key" : 265 | nb_reg_set_value_key = nb_reg_set_value_key + 1 266 | poursuite.modif_registre(Access[6],Access[5]) 267 | elif Access[3] == "delete" : 268 | nb_reg_delete = nb_reg_delete + 1 269 | poursuite.modif_registre(Access[6],Access[5]) 270 | #? 271 | else : 272 | print "type acces registre inconnu:", Access[3] 273 | 274 | else : 275 | nb_inconnu = nb_inconnu +1 276 | print "lhs :", position, ":", ligne 277 | 278 | trace.close() 279 | #print "fermeture du fichier." 280 | 281 | print "\non a traite",nb_proc,"processus." 282 | #print "\t",nb_proc_good,"se sont bien passe" 283 | #print "\t",nb_proc_bad,"n'ont pas ete creer" 284 | 285 | print nb_acces,"access fichier on ete effectue:" 286 | print "\t",nb_create,"en creation" 287 | print "\t",nb_create_overwrite_if, "en mode create_overwrite_if" 288 | print "\t", nb_create_open, "en mode create_open" 289 | print "\t",nb_read,"en lecture" 290 | print "\t",nb_write,"en ecriture" 291 | print "\t",nb_Todok,"en todok" 292 | print "\t",nb_unlink,"en unlink" 293 | print "\t",nb_query,"en query" 294 | print "\t",nb_load,"en load" 295 | print "\t",nb_device_io_control,"en device_io_control" 296 | print "\t",nb_query_EA,"en query_EA" 297 | print "\t",nb_set_EA,"en set_EA" 298 | print "\t",nb_non_renseigne, "n'ont pas precise le type d'acces" 299 | 300 | print nb_registre, "access registre on ete effectue:" 301 | print "\t", nb_reg_open, "en mode open" 302 | print "\t",nb_query_value_key, "en mode query_value_key" 303 | print "\t",nb_reg_create,"en mode create" 304 | print "\t",nb_reg_set_value_key, "en mode set_value_key" 305 | print "\t",nb_reg_delete,"en mode delete" 306 | 307 | print nb_inconnu,"lignes etait hors syntaxe." 308 | 309 | print "\nLe nombre de processus corrompu est :", poursuite.nb_proces_corrompu 310 | print "Le nombre de fichiers corrompu est :", poursuite.nb_fichier_corrompu 311 | print "le nombre de registre corrompu est :", poursuite.nb_registre_corrompu 312 | #print poursuite.tab_proc 313 | -------------------------------------------------------------------------------- /visu/save.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flare", 3 | "children": [ 4 | { 5 | "name": "analytics", 6 | "children": [ 7 | { 8 | "name": "cluster", 9 | "children": [ 10 | {"name": "AgglomerativeCluster", "size": 0}, 11 | {"name": "CommunityStructure", "size": 0}, 12 | {"name": "HierarchicalCluster", "size": 0}, 13 | {"name": "MergeEdge", "size": 0 } 14 | ] 15 | }, 16 | { 17 | "name": "graph", 18 | "children": [ 19 | {"name": "BetweennessCentrality", "size": 3534}, 20 | {"name": "LinkDistance", "size": 5731}, 21 | {"name": "MaxFlowMinCut", "size": 7840}, 22 | {"name": "ShortestPaths", "size": 5914}, 23 | {"name": "SpanningTree", "size": 3416} 24 | ] 25 | }, 26 | { 27 | "name": "optimization", 28 | "children": [ 29 | {"name": "AspectRatioBanker", "size": 7074} 30 | ] 31 | } 32 | ] 33 | }, 34 | { 35 | "name": "animate", 36 | "children": [ 37 | {"name": "Easing", "size": 17010}, 38 | {"name": "FunctionSequence", "size": 5842}, 39 | { 40 | "name": "interpolate", 41 | "children": [ 42 | {"name": "ArrayInterpolator", "size": 1983}, 43 | {"name": "ColorInterpolator", "size": 2047}, 44 | {"name": "DateInterpolator", "size": 1375}, 45 | {"name": "Interpolator", "size": 8746}, 46 | {"name": "MatrixInterpolator", "size": 2202}, 47 | {"name": "NumberInterpolator", "size": 1382}, 48 | {"name": "ObjectInterpolator", "size": 1629}, 49 | {"name": "PointInterpolator", "size": 1675}, 50 | {"name": "RectangleInterpolator", "size": 2042} 51 | ] 52 | }, 53 | {"name": "ISchedulable", "size": 1041}, 54 | {"name": "Parallel", "size": 5176}, 55 | {"name": "Pause", "size": 449}, 56 | {"name": "Scheduler", "size": 5593}, 57 | {"name": "Sequence", "size": 5534}, 58 | {"name": "Transition", "size": 9201}, 59 | {"name": "Transitioner", "size": 19975}, 60 | {"name": "TransitionEvent", "size": 1116}, 61 | {"name": "Tween", "size": 6006} 62 | ] 63 | }, 64 | { 65 | "name": "data", 66 | "children": [ 67 | { 68 | "name": "converters", 69 | "children": [ 70 | {"name": "Converters", "size": 721}, 71 | {"name": "DelimitedTextConverter", "size": 4294}, 72 | {"name": "GraphMLConverter", "size": 9800}, 73 | {"name": "IDataConverter", "size": 1314}, 74 | {"name": "JSONConverter", "size": 2220} 75 | ] 76 | }, 77 | {"name": "DataField", "size": 1759}, 78 | {"name": "DataSchema", "size": 2165}, 79 | {"name": "DataSet", "size": 586}, 80 | {"name": "DataSource", "size": 3331}, 81 | {"name": "DataTable", "size": 772}, 82 | {"name": "DataUtil", "size": 3322} 83 | ] 84 | }, 85 | { 86 | "name": "display", 87 | "children": [ 88 | {"name": "DirtySprite", "size": 8833}, 89 | {"name": "LineSprite", "size": 1732}, 90 | {"name": "RectSprite", "size": 3623}, 91 | {"name": "TextSprite", "size": 10066} 92 | ] 93 | }, 94 | { 95 | "name": "flex", 96 | "children": [ 97 | {"name": "FlareVis", "size": 4116} 98 | ] 99 | }, 100 | { 101 | "name": "physics", 102 | "children": [ 103 | {"name": "DragForce", "size": 1082}, 104 | {"name": "GravityForce", "size": 1336}, 105 | {"name": "IForce", "size": 319}, 106 | {"name": "NBodyForce", "size": 10498}, 107 | {"name": "Particle", "size": 2822}, 108 | {"name": "Simulation", "size": 9983}, 109 | {"name": "Spring", "size": 2213}, 110 | {"name": "SpringForce", "size": 1681} 111 | ] 112 | }, 113 | { 114 | "name": "query", 115 | "children": [ 116 | {"name": "AggregateExpression", "size": 1616}, 117 | {"name": "And", "size": 1027}, 118 | {"name": "Arithmetic", "size": 3891}, 119 | {"name": "Average", "size": 891}, 120 | {"name": "BinaryExpression", "size": 2893}, 121 | {"name": "Comparison", "size": 5103}, 122 | {"name": "CompositeExpression", "size": 3677}, 123 | {"name": "Count", "size": 781}, 124 | {"name": "DateUtil", "size": 4141}, 125 | {"name": "Distinct", "size": 933}, 126 | {"name": "Expression", "size": 5130}, 127 | {"name": "ExpressionIterator", "size": 3617}, 128 | {"name": "Fn", "size": 3240}, 129 | {"name": "If", "size": 2732}, 130 | {"name": "IsA", "size": 2039}, 131 | {"name": "Literal", "size": 1214}, 132 | {"name": "Match", "size": 3748}, 133 | {"name": "Maximum", "size": 843}, 134 | { 135 | "name": "methods", 136 | "children": [ 137 | {"name": "add", "size": 593}, 138 | {"name": "and", "size": 330}, 139 | {"name": "average", "size": 287}, 140 | {"name": "count", "size": 277}, 141 | {"name": "distinct", "size": 292}, 142 | {"name": "div", "size": 595}, 143 | {"name": "eq", "size": 594}, 144 | {"name": "fn", "size": 460}, 145 | {"name": "gt", "size": 603}, 146 | {"name": "gte", "size": 625}, 147 | {"name": "iff", "size": 748}, 148 | {"name": "isa", "size": 461}, 149 | {"name": "lt", "size": 597}, 150 | {"name": "lte", "size": 619}, 151 | {"name": "max", "size": 283}, 152 | {"name": "min", "size": 283}, 153 | {"name": "mod", "size": 591}, 154 | {"name": "mul", "size": 603}, 155 | {"name": "neq", "size": 599}, 156 | {"name": "not", "size": 386}, 157 | {"name": "or", "size": 323}, 158 | {"name": "orderby", "size": 307}, 159 | {"name": "range", "size": 772}, 160 | {"name": "select", "size": 296}, 161 | {"name": "stddev", "size": 363}, 162 | {"name": "sub", "size": 600}, 163 | {"name": "sum", "size": 280}, 164 | {"name": "update", "size": 307}, 165 | {"name": "variance", "size": 335}, 166 | {"name": "where", "size": 299}, 167 | {"name": "xor", "size": 354}, 168 | {"name": "_", "size": 264} 169 | ] 170 | }, 171 | {"name": "Minimum", "size": 843}, 172 | {"name": "Not", "size": 1554}, 173 | {"name": "Or", "size": 970}, 174 | {"name": "Query", "size": 13896}, 175 | {"name": "Range", "size": 1594}, 176 | {"name": "StringUtil", "size": 4130}, 177 | {"name": "Sum", "size": 791}, 178 | {"name": "Variable", "size": 1124}, 179 | {"name": "Variance", "size": 1876}, 180 | {"name": "Xor", "size": 1101} 181 | ] 182 | }, 183 | { 184 | "name": "scale", 185 | "children": [ 186 | {"name": "IScaleMap", "size": 2105}, 187 | {"name": "LinearScale", "size": 1316}, 188 | {"name": "LogScale", "size": 3151}, 189 | {"name": "OrdinalScale", "size": 3770}, 190 | {"name": "QuantileScale", "size": 2435}, 191 | {"name": "QuantitativeScale", "size": 4839}, 192 | {"name": "RootScale", "size": 1756}, 193 | {"name": "Scale", "size": 4268}, 194 | {"name": "ScaleType", "size": 1821}, 195 | {"name": "TimeScale", "size": 5833} 196 | ] 197 | }, 198 | { 199 | "name": "util", 200 | "children": [ 201 | {"name": "Arrays", "size": 8258}, 202 | {"name": "Colors", "size": 10001}, 203 | {"name": "Dates", "size": 8217}, 204 | {"name": "Displays", "size": 12555}, 205 | {"name": "Filter", "size": 2324}, 206 | {"name": "Geometry", "size": 10993}, 207 | { 208 | "name": "heap", 209 | "children": [ 210 | {"name": "FibonacciHeap", "size": 9354}, 211 | {"name": "HeapNode", "size": 1233} 212 | ] 213 | }, 214 | {"name": "IEvaluable", "size": 335}, 215 | {"name": "IPredicate", "size": 383}, 216 | {"name": "IValueProxy", "size": 874}, 217 | { 218 | "name": "math", 219 | "children": [ 220 | {"name": "DenseMatrix", "size": 3165}, 221 | {"name": "IMatrix", "size": 2815}, 222 | {"name": "SparseMatrix", "size": 3366} 223 | ] 224 | }, 225 | {"name": "Maths", "size": 17705}, 226 | {"name": "Orientation", "size": 1486}, 227 | { 228 | "name": "palette", 229 | "children": [ 230 | {"name": "ColorPalette", "size": 6367}, 231 | {"name": "Palette", "size": 1229}, 232 | {"name": "ShapePalette", "size": 2059}, 233 | {"name": "SizePalette", "size": 2291} 234 | ] 235 | }, 236 | {"name": "Property", "size": 5559}, 237 | {"name": "Shapes", "size": 19118}, 238 | {"name": "Sort", "size": 6887}, 239 | {"name": "Stats", "size": 6557}, 240 | {"name": "Strings", "size": 22026} 241 | ] 242 | }, 243 | { 244 | "name": "vis", 245 | "children": [ 246 | { 247 | "name": "axis", 248 | "children": [ 249 | {"name": "Axes", "size": 1302}, 250 | {"name": "Axis", "size": 24593}, 251 | {"name": "AxisGridLine", "size": 652}, 252 | {"name": "AxisLabel", "size": 636}, 253 | {"name": "CartesianAxes", "size": 6703} 254 | ] 255 | }, 256 | { 257 | "name": "controls", 258 | "children": [ 259 | {"name": "AnchorControl", "size": 2138}, 260 | {"name": "ClickControl", "size": 3824}, 261 | {"name": "Control", "size": 1353}, 262 | {"name": "ControlList", "size": 4665}, 263 | {"name": "DragControl", "size": 2649}, 264 | {"name": "ExpandControl", "size": 2832}, 265 | {"name": "HoverControl", "size": 4896}, 266 | {"name": "IControl", "size": 763}, 267 | {"name": "PanZoomControl", "size": 5222}, 268 | {"name": "SelectionControl", "size": 7862}, 269 | {"name": "TooltipControl", "size": 8435} 270 | ] 271 | }, 272 | { 273 | "name": "data", 274 | "children": [ 275 | {"name": "Data", "size": 20544}, 276 | {"name": "DataList", "size": 19788}, 277 | {"name": "DataSprite", "size": 10349}, 278 | {"name": "EdgeSprite", "size": 3301}, 279 | {"name": "NodeSprite", "size": 19382}, 280 | { 281 | "name": "render", 282 | "children": [ 283 | {"name": "ArrowType", "size": 698}, 284 | {"name": "EdgeRenderer", "size": 5569}, 285 | {"name": "IRenderer", "size": 353}, 286 | {"name": "ShapeRenderer", "size": 2247} 287 | ] 288 | }, 289 | {"name": "ScaleBinding", "size": 11275}, 290 | {"name": "Tree", "size": 7147}, 291 | {"name": "TreeBuilder", "size": 9930} 292 | ] 293 | }, 294 | { 295 | "name": "events", 296 | "children": [ 297 | {"name": "DataEvent", "size": 2313}, 298 | {"name": "SelectionEvent", "size": 1880}, 299 | {"name": "TooltipEvent", "size": 1701}, 300 | {"name": "VisualizationEvent", "size": 1117} 301 | ] 302 | }, 303 | { 304 | "name": "legend", 305 | "children": [ 306 | {"name": "Legend", "size": 20859}, 307 | {"name": "LegendItem", "size": 4614}, 308 | {"name": "LegendRange", "size": 10530} 309 | ] 310 | }, 311 | { 312 | "name": "operator", 313 | "children": [ 314 | { 315 | "name": "distortion", 316 | "children": [ 317 | {"name": "BifocalDistortion", "size": 4461}, 318 | {"name": "Distortion", "size": 6314}, 319 | {"name": "FisheyeDistortion", "size": 3444} 320 | ] 321 | }, 322 | { 323 | "name": "encoder", 324 | "children": [ 325 | {"name": "ColorEncoder", "size": 3179}, 326 | {"name": "Encoder", "size": 4060}, 327 | {"name": "PropertyEncoder", "size": 4138}, 328 | {"name": "ShapeEncoder", "size": 1690}, 329 | {"name": "SizeEncoder", "size": 1830} 330 | ] 331 | }, 332 | { 333 | "name": "filter", 334 | "children": [ 335 | {"name": "FisheyeTreeFilter", "size": 5219}, 336 | {"name": "GraphDistanceFilter", "size": 3165}, 337 | {"name": "VisibilityFilter", "size": 3509} 338 | ] 339 | }, 340 | {"name": "IOperator", "size": 1286}, 341 | { 342 | "name": "label", 343 | "children": [ 344 | {"name": "Labeler", "size": 9956}, 345 | {"name": "RadialLabeler", "size": 3899}, 346 | {"name": "StackedAreaLabeler", "size": 3202} 347 | ] 348 | }, 349 | { 350 | "name": "layout", 351 | "children": [ 352 | {"name": "AxisLayout", "size": 6725}, 353 | {"name": "BundledEdgeRouter", "size": 3727}, 354 | {"name": "CircleLayout", "size": 9317}, 355 | {"name": "CirclePackingLayout", "size": 12003}, 356 | {"name": "DendrogramLayout", "size": 4853}, 357 | {"name": "ForceDirectedLayout", "size": 8411}, 358 | {"name": "IcicleTreeLayout", "size": 4864}, 359 | {"name": "IndentedTreeLayout", "size": 3174}, 360 | {"name": "Layout", "size": 7881}, 361 | {"name": "NodeLinkTreeLayout", "size": 12870}, 362 | {"name": "PieLayout", "size": 2728}, 363 | {"name": "RadialTreeLayout", "size": 12348}, 364 | {"name": "RandomLayout", "size": 870}, 365 | {"name": "StackedAreaLayout", "size": 9121}, 366 | {"name": "TreeMapLayout", "size": 9191} 367 | ] 368 | }, 369 | {"name": "Operator", "size": 2490}, 370 | {"name": "OperatorList", "size": 5248}, 371 | {"name": "OperatorSequence", "size": 4190}, 372 | {"name": "OperatorSwitch", "size": 2581}, 373 | {"name": "SortOperator", "size": 2023} 374 | ] 375 | }, 376 | {"name": "Visualization", "size": 16540} 377 | ] 378 | } 379 | ] 380 | } 381 | -------------------------------------------------------------------------------- /Filter/filterdriver/process.c: -------------------------------------------------------------------------------- 1 | #include "process.h" 2 | 3 | 4 | unsigned long hash_process(char * str) 5 | { 6 | unsigned long hash = 5321; 7 | int c; 8 | if(str == NULL) 9 | return 0; 10 | while(c = *str++) 11 | hash = ((hash <<5) + hash) + c; 12 | return hash; 13 | } 14 | 15 | char * ComputeSSID(PUNICODE_STRING fullname) 16 | { 17 | ANSI_STRING str_ansi; 18 | int i=0, j=0; 19 | char buffer_ansi[1024]; 20 | char * ssid_return = NULL; 21 | int taille = strlen("\\Device\\HarddiskVolume2"); 22 | int IsExe=0; 23 | 24 | RtlZeroMemory(&buffer_ansi, sizeof(buffer_ansi)); 25 | if(fullname == NULL) 26 | return NULL; 27 | 28 | RtlUnicodeStringToAnsiString(&str_ansi, fullname, TRUE); 29 | 30 | if(strcmp(str_ansi.Buffer,"System") ==0) 31 | { 32 | DbgPrint("system_t\n"); 33 | RtlFreeAnsiString(&str_ansi); 34 | return NULL; 35 | } 36 | 37 | if(str_ansi.Buffer != NULL) 38 | { 39 | if(str_ansi.Length > sizeof(buffer_ansi) ) return NULL; 40 | 41 | sprintf_s(buffer_ansi,sizeof(buffer_ansi),"%s\0", &str_ansi.Buffer[taille]); 42 | 43 | RtlFreeAnsiString(&str_ansi); 44 | 45 | ssid_return = ExAllocatePool(PagedPool, sizeof(char)*2048); 46 | 47 | if(ssid_return == NULL) 48 | { 49 | DbgPrint("Echec ExallocatePool for sid compute \n"); 50 | return NULL; 51 | } 52 | 53 | while(buffer_ansi[i] != '\0' || (i == sizeof(ssid_return))) 54 | { 55 | if( (i==0) && (buffer_ansi[i]!='\\')) 56 | return NULL; 57 | if( (i==0) && (buffer_ansi[i] =='\\')) 58 | { 59 | i++; 60 | continue; 61 | } 62 | if(buffer_ansi[i] == '\\') 63 | { 64 | ssid_return[j] = '_'; 65 | } 66 | else 67 | { 68 | if(buffer_ansi[i] == ' ') 69 | { 70 | i++; 71 | continue; 72 | } 73 | else 74 | { 75 | if(buffer_ansi[i] <= 'Z' && buffer_ansi[i] >= 'A') 76 | ssid_return[j]= (buffer_ansi[i] -'A') + 'a'; 77 | else 78 | ssid_return[j] = buffer_ansi[i]; 79 | } 80 | } 81 | i++; 82 | j++; 83 | } 84 | ssid_return[j]='\0'; 85 | DbgPrint("Process security context : %s \n", ssid_return); 86 | } 87 | return NULL; 88 | } 89 | 90 | INT GetUnicodeName_only(int pid) 91 | { 92 | PEPROCESS pep; 93 | ULONG ret,retlen; 94 | NTSTATUS rc,status; 95 | CLIENT_ID ClientId; 96 | int i=0; 97 | char temp_buffer[1000]; 98 | HANDLE openproc; 99 | OBJECT_ATTRIBUTES ObjectAttributes; 100 | PVOID unicode; 101 | ANSI_STRING str_ansi; 102 | WCHAR System[] = L"System"; 103 | 104 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 105 | ObjectAttributes.RootDirectory = NULL; 106 | ObjectAttributes.ObjectName = NULL; 107 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 108 | ObjectAttributes.SecurityDescriptor = NULL; 109 | ObjectAttributes.SecurityQualityOfService = NULL; 110 | 111 | if(pid%4 !=0) 112 | { 113 | DbgPrint("pid = %i Proces %4 != 0\n", pid); 114 | return -1; 115 | } 116 | 117 | pep=NULL; 118 | PsLookupProcessByProcessId((HANDLE)pid,&pep); 119 | if(pep == NULL) 120 | { 121 | return -1; 122 | } 123 | ClientId.UniqueProcess = (HANDLE) pid; 124 | ClientId.UniqueThread = 0; 125 | __try{ 126 | rc = ZwOpenProcess(&openproc, PROCESS_ALL_ACCESS, &ObjectAttributes , &ClientId); 127 | if(NT_SUCCESS(rc)) 128 | { 129 | rc = ZwQueryInformationProcess(openproc, ProcessImageFileName, NULL, 0, &ret); 130 | if(rc == STATUS_INFO_LENGTH_MISMATCH) 131 | { 132 | unicode = ExAllocatePool(PagedPool, ret); 133 | if(unicode != NULL) 134 | { 135 | rc = ZwQueryInformationProcess(openproc, ProcessImageFileName, unicode, ret, &ret); 136 | if( rc == STATUS_SUCCESS) 137 | { 138 | if(pid == 4) 139 | { 140 | // RtlInitUnicodeString(unicode , System); 141 | AddInQueue("Parent Process name : System pid=4 \n"); 142 | } 143 | else 144 | { 145 | RtlUnicodeStringToAnsiString(&str_ansi, unicode, TRUE); 146 | RtlZeroMemory(&temp_buffer, sizeof(temp_buffer)); 147 | sprintf_s(temp_buffer, sizeof(temp_buffer), "Parent Process name : %s pid=%i \n",str_ansi.Buffer , pid); 148 | // GetSessionId(pid); 149 | // DbgPrint("%s", temp_buffer); 150 | AddInQueue(temp_buffer); 151 | RtlFreeAnsiString(&str_ansi); 152 | } 153 | // ComputeSSID(unicode); 154 | } 155 | else 156 | RtlInitUnicodeString(unicode, L"Echec" ); 157 | if(unicode != NULL) ExFreePool(unicode); 158 | } 159 | ZwClose(openproc); 160 | } 161 | } 162 | else 163 | { 164 | DbgPrint("Unable to open process %i\n", i); 165 | } 166 | } 167 | __except(EXCEPTION_EXECUTE_HANDLER) 168 | { 169 | rc=GetExceptionCode(); 170 | DbgPrint("Exception GetOnly Nuame : %x\n", rc); 171 | return -1; 172 | } 173 | return 0; 174 | } 175 | 176 | VOID GetUnicodeName(int pid) 177 | { 178 | PEPROCESS pep; 179 | ULONG ret,retlen; 180 | NTSTATUS rc,status; 181 | CLIENT_ID ClientId; 182 | int i=0,ppid=0, sid; 183 | char temp_buffer[1000]; 184 | HANDLE openproc; 185 | OBJECT_ATTRIBUTES ObjectAttributes; 186 | PVOID unicode; 187 | ANSI_STRING str_ansi; 188 | WCHAR System[] = L"System"; 189 | 190 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 191 | ObjectAttributes.RootDirectory = NULL; 192 | ObjectAttributes.ObjectName = NULL; 193 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 194 | ObjectAttributes.SecurityDescriptor = NULL; 195 | ObjectAttributes.SecurityQualityOfService = NULL; 196 | 197 | pep=NULL; 198 | PsLookupProcessByProcessId((HANDLE)pid,&pep); 199 | if(pep == NULL) 200 | { 201 | return; 202 | } 203 | ClientId.UniqueProcess = (HANDLE) pid; 204 | ClientId.UniqueThread = 0; 205 | 206 | rc = ZwOpenProcess(&openproc, PROCESS_ALL_ACCESS, &ObjectAttributes , &ClientId); 207 | if(rc == STATUS_SUCCESS) 208 | { 209 | rc = ZwQueryInformationProcess(openproc, ProcessImageFileName, NULL, 0, &ret); 210 | if(rc == STATUS_INFO_LENGTH_MISMATCH) 211 | { 212 | unicode = ExAllocatePool(PagedPool, ret); 213 | if(unicode != NULL) 214 | { 215 | rc = ZwQueryInformationProcess(openproc, ProcessImageFileName, unicode, ret, &ret); 216 | if( rc == STATUS_SUCCESS) 217 | { 218 | if(pid == 4) 219 | { 220 | // RtlInitUnicodeString(unicode , System); 221 | AddInQueue("Process name : System pid=4\n" ); 222 | } 223 | else 224 | { 225 | RtlUnicodeStringToAnsiString(&str_ansi, unicode, TRUE); 226 | RtlZeroMemory(&temp_buffer, sizeof(temp_buffer)); 227 | AddInQueue("---- Begin\n"); 228 | ppid = GetParentId(pid); 229 | sid = GetSessionId(pid); 230 | sprintf_s(temp_buffer, sizeof(temp_buffer), "Process name : %s pid=%i ppid=%i sid=%i\n",str_ansi.Buffer , pid, ppid,sid); 231 | // DbgPrint("%s", temp_buffer); 232 | AddInQueue(temp_buffer); 233 | 234 | AddInQueue("---- END\n"); 235 | 236 | RtlFreeAnsiString(&str_ansi); 237 | } 238 | // ComputeSSID(unicode); 239 | } 240 | else 241 | RtlInitUnicodeString(unicode, L"Echec" ); 242 | if(unicode != NULL) ExFreePool(unicode); 243 | } 244 | ZwClose(openproc); 245 | } 246 | } 247 | else 248 | { 249 | DbgPrint("Unable to open process %i\n", i); 250 | } 251 | 252 | return; 253 | } 254 | 255 | 256 | int GetSessionId(int pid) 257 | { 258 | PEPROCESS pep; 259 | ULONG ret,retlen; 260 | NTSTATUS rc,status; 261 | CLIENT_ID ClientId; 262 | int i=0; 263 | HANDLE openproc; 264 | OBJECT_ATTRIBUTES ObjectAttributes; 265 | PROCESS_SESSION_INFORMATION unicode; 266 | WCHAR System[] = L"System"; 267 | int retour = 0; 268 | 269 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 270 | ObjectAttributes.RootDirectory = NULL; 271 | ObjectAttributes.ObjectName = NULL; 272 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 273 | ObjectAttributes.SecurityDescriptor = NULL; 274 | ObjectAttributes.SecurityQualityOfService = NULL; 275 | 276 | pep=NULL; 277 | PsLookupProcessByProcessId((HANDLE)pid,&pep); 278 | if(pep == NULL) 279 | return 0; 280 | 281 | ClientId.UniqueProcess = (HANDLE) pid; 282 | ClientId.UniqueThread = 0; 283 | 284 | rc = ZwOpenProcess(&openproc, PROCESS_ALL_ACCESS, &ObjectAttributes , &ClientId); 285 | if(rc == STATUS_SUCCESS) 286 | { 287 | rc = ZwQueryInformationProcess(openproc, ProcessSessionInformation, &unicode, sizeof(unicode), &ret); 288 | if( rc == STATUS_SUCCESS) 289 | { 290 | retour = unicode.SessionId; 291 | // AddInQueue("Session %i\n", retour); 292 | } 293 | ZwClose(openproc); 294 | } 295 | else 296 | { 297 | DbgPrint("Unable to open process %i\n", i); 298 | } 299 | 300 | return retour; 301 | } 302 | 303 | int GetParentId(int pid) 304 | { 305 | PEPROCESS pep; 306 | ULONG ret,retlen; 307 | NTSTATUS rc,status; 308 | CLIENT_ID ClientId; 309 | int i=0; 310 | HANDLE openproc; 311 | OBJECT_ATTRIBUTES ObjectAttributes; 312 | PROCESS_BASIC_INFORMATION unicode; 313 | WCHAR System[] = L"System"; 314 | int retour = 0; 315 | 316 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 317 | ObjectAttributes.RootDirectory = NULL; 318 | ObjectAttributes.ObjectName = NULL; 319 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 320 | ObjectAttributes.SecurityDescriptor = NULL; 321 | ObjectAttributes.SecurityQualityOfService = NULL; 322 | 323 | pep=NULL; 324 | PsLookupProcessByProcessId((HANDLE)pid,&pep); 325 | if(pep == NULL) 326 | return 0; 327 | 328 | ClientId.UniqueProcess = (HANDLE) pid; 329 | ClientId.UniqueThread = 0; 330 | 331 | rc = ZwOpenProcess(&openproc, PROCESS_ALL_ACCESS, &ObjectAttributes , &ClientId); 332 | if(rc == STATUS_SUCCESS) 333 | { 334 | rc = ZwQueryInformationProcess(openproc, ProcessBasicInformation, &unicode, sizeof(unicode), &ret); 335 | if( rc == STATUS_SUCCESS) 336 | { 337 | retour = unicode.InheritedFromUniqueProcessId; 338 | } 339 | ZwClose(openproc); 340 | } 341 | else 342 | { 343 | DbgPrint("Unable to open process %i\n", i); 344 | } 345 | if(retour != 0) 346 | { 347 | pep=NULL; 348 | PsLookupProcessByProcessId((HANDLE)retour,&pep); 349 | if(pep != NULL) 350 | GetParentId(retour); 351 | //else 352 | 353 | } 354 | GetUnicodeName_only(retour); 355 | 356 | return retour; 357 | } 358 | 359 | 360 | 361 | int DetectPid() 362 | { 363 | PEPROCESS pep; 364 | ULONG ret,retlen; 365 | NTSTATUS rc,status; 366 | CLIENT_ID ClientId; 367 | int i=0; 368 | HANDLE openproc; 369 | OBJECT_ATTRIBUTES ObjectAttributes; 370 | PVOID unicode; 371 | WCHAR System[] = L"System"; 372 | 373 | ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); 374 | ObjectAttributes.RootDirectory = NULL; 375 | ObjectAttributes.ObjectName = NULL; 376 | ObjectAttributes.Attributes = OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE; 377 | ObjectAttributes.SecurityDescriptor = NULL; 378 | ObjectAttributes.SecurityQualityOfService = NULL; 379 | 380 | for( i = 0 ; i < 65535; i++ ) 381 | { 382 | if(i%4 != 0) continue; 383 | 384 | pep=NULL; 385 | PsLookupProcessByProcessId((HANDLE)i,&pep); 386 | if(pep == NULL) 387 | continue; 388 | GetUnicodeName(i); 389 | 390 | } 391 | AddInQueue("------- Fin du detect PID\n"); 392 | return 1; 393 | } 394 | 395 | VOID CreateRoutine( __in_opt PUNICODE_STRING FullImageName, __in HANDLE ProcessId, __in PIMAGE_INFO ImageInfo ) 396 | { 397 | ANSI_STRING str_ansi; 398 | LARGE_INTEGER time; 399 | PEPROCESS pep; 400 | char buffer[1000]; 401 | char buffer_write[1000]; 402 | RtlUnicodeStringToAnsiString(&str_ansi, FullImageName, TRUE); 403 | 404 | if(_stricmp(&str_ansi.Buffer[strlen(str_ansi.Buffer)-strlen(".exe")],".exe") != 0) 405 | { 406 | AddInQueue("------- Loading\n"); 407 | sprintf_s(buffer,sizeof(buffer),"trace=%i , cpu=%i\n",trace++, KeGetCurrentProcessorNumber()); 408 | AddInQueue(buffer); 409 | KeQuerySystemTime(&time); 410 | RtlZeroMemory(&buffer, sizeof(buffer)); 411 | sprintf_s(buffer,sizeof(buffer),"timestamp=%I64d\n",time.QuadPart); 412 | AddInQueue(buffer); 413 | 414 | AddInQueue("Access : load\n"); 415 | if((int)ProcessId != 0 && (int)ProcessId != 4) 416 | { 417 | PsLookupProcessByProcessId(ProcessId,&pep); 418 | sprintf_s(buffer_write,sizeof(buffer_write), "pid : %s %i \n",PsGetProcessImageFileName(pep), (int)ProcessId); 419 | AddInQueue(buffer_write); 420 | } 421 | else 422 | { 423 | sprintf_s(buffer_write,sizeof(buffer_write), "pid : System %i \n",(int)ProcessId); 424 | AddInQueue(buffer_write); 425 | } 426 | RtlZeroMemory(&buffer_write, sizeof(buffer_write)); 427 | sprintf_s(buffer_write,sizeof(buffer_write), "Object Name : %s \n", str_ansi.Buffer); 428 | AddInQueue(buffer_write); 429 | AddInQueue("------- End loading\n"); 430 | } 431 | if(str_ansi.Length != 0) RtlFreeAnsiString(&str_ansi); 432 | } 433 | 434 | VOID CreateProcessNotify( 435 | HANDLE Process, 436 | HANDLE ProcessId, 437 | BOOLEAN Create 438 | ) 439 | { 440 | if(Create == TRUE) 441 | { 442 | AddInQueue("------ Create process\n"); 443 | GetUnicodeName((int) ProcessId); 444 | 445 | } 446 | else 447 | { 448 | AddInQueue("------ Descruction process\n"); 449 | GetUnicodeName((int)ProcessId); 450 | } 451 | } 452 | 453 | 454 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------