Bonjour,
Je suis nouveau ds la programmation réseau, j'utilise le langage c++
Mon but est de récupérer des packets et les analyser. Pour ceci j'utilise Winpcap sous vs2010 mais j'ai diffuculté à charger les dll wpcap et Packet
dans l'onglet module lors du débogage j'ai comme sortie:
et voici le contenu de l'onglet sortie
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 a.exe C:\Documents and Settings\user\Mes documents\Visual Studio 2010\Projects\a\Debug\a.exe N/A N/A Les symboles ont été chargés. C:\Documents and Settings\user\Mes documents\Visual Studio 2010\Projects\a\Debug\a.pdb 1 12/03/2012 08:37 00400000-0042C000 [2292] a.exe: Natif mscorlib.dll C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll Oui N/A Les symboles ont été chargés. C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\mscorlib.pdb\A21F40D38EAB4B64B449E50DE8F5A3431\mscorlib.pdb 1 4.0.30319.1 (RTMRel.030319-0100) 18/03/2010 08:46 79880000-7A643000 [2292] a.exe: Managé (v4.0.30319) ntdll.dll C:\WINDOWS\system32\ntdll.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\ntdll.pdb\1751003260CA42598C0FB326585000ED2\ntdll.pdb 2 5.1.2600.5512 (xpsp.080413-2111) 14/04/2008 03:33 7C910000-7C9C6000 [2292] a.exe: Natif a.exe C:\Documents and Settings\user\Mes documents\Visual Studio 2010\Projects\a\Debug\a.exe Non N/A Les symboles ont été chargés. C:\Documents and Settings\user\Mes documents\Visual Studio 2010\Projects\a\Debug\a.pdb 2 12/03/2012 08:37 00400000-0042C000 [2292] a.exe: Managé (v4.0.30319) mscoree.dll C:\WINDOWS\system32\mscoree.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\mscoree.pdb\DBEE0410B7644D97A9BFD1DB523618F02\mscoree.pdb 3 4.0.31106.0 (Main.031106-0000) 06/11/2009 06:09 79000000-7904A000 [2292] a.exe: Natif System.dll C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll Oui N/A Les symboles ont été chargés. C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\System.pdb\E4B5ADE9D40A46208A6B50E854B5E7C61\System.pdb 3 4.0.30319.1 built by: RTMRel 18/03/2010 09:10 7A820000-7B0B8000 [2292] a.exe: Managé (v4.0.30319) kernel32.dll C:\WINDOWS\system32\kernel32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\kernel32.pdb\34560E80F5C54175B208848EF863C5BD2\kernel32.pdb 4 5.1.2600.5512 (xpsp.080413-2111) 14/04/2008 03:33 7C800000-7C906000 [2292] a.exe: Natif mscorlib.resources.dll C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_fr_b77a5c561934e089\mscorlib.resources.dll Non N/A Aucun symbole n'a été chargé. 4 4.0.30319.1 (RTMRel.030319-0100) 03/04/2010 04:39 03BC0000-03C14000 [2292] a.exe: Managé (v4.0.30319) advapi32.dll C:\WINDOWS\system32\advapi32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\advapi32.pdb\5EFB9BF42CC64024AB64802E467394642\advapi32.pdb 5 5.1.2600.5512 (xpsp.080413-2113) 14/04/2008 03:31 77DA0000-77E4C000 [2292] a.exe: Natif rpcrt4.dll C:\WINDOWS\system32\rpcrt4.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\rpcrt4.pdb\CCD4FE9B704E48B6B8A12F31E112AA6F2\rpcrt4.pdb 6 5.1.2600.5512 (xpsp.080413-2108) 14/04/2008 03:32 77E50000-77EE2000 [2292] a.exe: Natif secur32.dll C:\WINDOWS\system32\secur32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\secur32.pdb\E8D378740B8E4A46B19CAFCD2D6DDF7D2\secur32.pdb 7 5.1.2600.5512 (xpsp.080413-2113) 14/04/2008 03:32 77FC0000-77FD1000 [2292] a.exe: Natif msvcp100d.dll C:\WINDOWS\system32\msvcp100d.dll N/A N/A Les symboles ont été chargés. C:\WINDOWS\symbols\dll\msvcp100d.i386.pdb 8 10.00.30319.1 18/03/2010 08:53 10480000-10537000 [2292] a.exe: Natif msvcr100d.dll C:\WINDOWS\system32\msvcr100d.dll N/A N/A Les symboles ont été chargés. C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\msvcr100d.i386.pdb\9E26F0DD2C2543B99754DB8B9BA5F8681\msvcr100d.i386.pdb 9 10.00.30319.1 18/03/2010 08:52 10200000-10372000 [2292] a.exe: Natif wpcap.dll C:\WINDOWS\system32\wpcap.dll N/A N/A Chargement désactivé par le paramètre Include/Exclude. 10 4.01.0.2001 25/06/2010 17:47 10000000-1004C000 [2292] a.exe: Natif ws2_32.dll C:\WINDOWS\system32\ws2_32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\ws2_32.pdb\A7605F8695A34329B38DDB8421A004CA2\ws2_32.pdb 11 5.1.2600.5512 (xpsp.080413-0852) 14/04/2008 03:34 719F0000-71A07000 [2292] a.exe: Natif msvcrt.dll C:\WINDOWS\system32\msvcrt.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\msvcrt.pdb\7BCF30D8C91B4F1B85FA4E55896250111\msvcrt.pdb 12 7.0.2600.5512 (xpsp.080413-2111) 14/04/2008 03:34 77BE0000-77C38000 [2292] a.exe: Natif ws2help.dll C:\WINDOWS\system32\ws2help.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\ws2help.pdb\6049CF5877C54E2AB512ABC1B4B2E7992\ws2help.pdb 13 5.1.2600.5512 (xpsp.080413-0852) 14/04/2008 03:34 719E0000-719E8000 [2292] a.exe: Natif Packet.dll C:\WINDOWS\system32\Packet.dll N/A N/A Exportations chargées. 14 4.01.0.2001 25/06/2010 17:47 003C0000-003D9000* [2292] a.exe: Natif version.dll C:\WINDOWS\system32\version.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\version.pdb\EA3D1BD3FE65475C8449C8D8B00722962\version.pdb 15 5.1.2600.5512 (xpsp.080413-2105) 14/04/2008 03:32 77BD0000-77BD8000 [2292] a.exe: Natif npptools.dll C:\WINDOWS\system32\npptools.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\npptools.pdb\89A8F9DE336B4034AADA2F8A2FA2B8151\npptools.pdb 16 5.1.2600.5512 (xpsp.080413-0852) 14/04/2008 03:32 669B0000-669C1000 [2292] a.exe: Natif mfc42u.dll C:\WINDOWS\system32\mfc42u.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MFC42U.pdb\B2242053C169418ABE8C1499D77B0AB1e\MFC42U.pdb 17 6.02.8071.0 31/08/2006 04:06 5F800000-5F8F2000 [2292] a.exe: Natif gdi32.dll C:\WINDOWS\system32\gdi32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\gdi32.pdb\740F60A99F2A417E96C387400994588D2\gdi32.pdb 18 5.1.2600.5512 (xpsp.080413-2105) 14/04/2008 03:31 77EF0000-77F39000 [2292] a.exe: Natif user32.dll C:\WINDOWS\system32\user32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\user32.pdb\D18A41B74E7F458CAAAC1847E2D8BF022\user32.pdb 19 5.1.2600.5512 (xpsp.080413-2105) 14/04/2008 03:32 7E390000-7E421000 [2292] a.exe: Natif ole32.dll C:\WINDOWS\system32\ole32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\ole32.pdb\ED517599D2C14CF19200861833059C142\ole32.pdb 20 5.1.2600.5512 (xpsp.080413-2108) 14/04/2008 03:32 774A0000-775DD000 [2292] a.exe: Natif oleaut32.dll C:\WINDOWS\system32\oleaut32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\oleaut32.pdb\F2A209009B694EFCAD1A6CE9D992EBC12\oleaut32.pdb 21 5.01.2600.5512 14/04/2008 03:32 770E0000-7716B000 [2292] a.exe: Natif iphlpapi.dll C:\WINDOWS\system32\iphlpapi.dll N/A N/A Exportations chargées. 22 5.1.2600.5512 (xpsp.080413-0852) 14/04/2008 03:31 76D10000-76D29000 [2292] a.exe: Natif imm32.dll C:\WINDOWS\system32\imm32.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\imm32.pdb\F7A5B5DB13324153B57AAF340C77EA512\imm32.pdb 23 5.1.2600.5512 (xpsp.080413-2105) 14/04/2008 03:32 76320000-7633D000 [2292] a.exe: Natif mfc42loc.dll C:\WINDOWS\system32\mfc42loc.dll N/A N/A Le fichier binaire n'a pas été généré avec les informations de débogage. 24 6.00.8665.0 23/08/2001 17:46 61D70000-61D7E000 [2292] a.exe: Natif mscoreei.dll C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MicrosoftPublicSymbols\mscoreei.pdb\C37CEAA96283461D863B6336B281284B2\mscoreei.pdb 25 4.0.30319.1 (RTMRel.030319-0100) 18/03/2010 08:39 603B0000-60416000 [2292] a.exe: Natif shlwapi.dll C:\WINDOWS\system32\shlwapi.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\shlwapi.pdb\8519E3403447478884CFFE7F1A91BAE02\shlwapi.pdb 26 6.00.2900.5512 (xpsp.080413-2105) 14/04/2008 03:32 77F40000-77FB6000 [2292] a.exe: Natif clr.dll C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll N/A N/A Exportations chargées. 27 4.0.30319.1 (RTMRel.030319-0100) 18/03/2010 08:44 79140000-797AF000 [2292] a.exe: Natif msvcr100_clr0400.dll C:\WINDOWS\system32\msvcr100_clr0400.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MicrosoftPublicSymbols\msvcr100_clr0400.i386.pdb\C128595F51E243469FDE9FA0CC7EBFDF2\msvcr100_clr0400.i386.pdb 28 10.00.30319.1 18/03/2010 08:53 79060000-7911E000 [2292] a.exe: Natif Culture.dll C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Culture.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MicrosoftPublicSymbols\culture.pdb\4DB23A75CD624A66998A4E80E9EE7F162\culture.pdb 29 4.0.30319.1 (RTMRel.030319-0100) 18/03/2010 08:39 60340000-6034D000 [2292] a.exe: Natif mscorlib.ni.dll C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\246f1a5abb686b9dcdf22d3505b08cea\mscorlib.ni.dll N/A N/A Aucun symbole natif dans le fichier de symboles. 30 4.0.30319.1 (RTMRel.030319-0100) 18/03/2010 08:46 79880000-7A643000 [2292] a.exe: Natif nlssorting.dll C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\nlssorting.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MicrosoftPublicSymbols\nlssorting.pdb\1E72F4D369764E76BC897C7E1D236C042\nlssorting.pdb 31 4.0.30319.1 (RTMRel.030319-0100) 18/03/2010 08:39 60930000-60940000 [2292] a.exe: Natif clrjit.dll C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clrjit.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MicrosoftPublicSymbols\clrjit.pdb\6B6765120AD34E558DA48B0AE0B47F0E2\clrjit.pdb 32 4.0.30319.1 (RTMRel.030319-0100) 18/03/2010 08:45 79810000-79870000 [2292] a.exe: Natif diasymreader.dll C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MicrosoftPublicSymbols\diasymreader.pdb\A8B6A120EC834FA5AD60DC5F2EA944962\diasymreader.pdb 33 10.0.30319.1 built by: RTMRel 18/03/2010 13:10 5E0D0000-5E17A000 [2292] a.exe: Natif System.ni.dll C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System\964da027ebca3b263a05cadb8eaa20a3\System.ni.dll N/A N/A Aucun symbole natif dans le fichier de symboles. 34 4.0.30319.1 built by: RTMRel 18/03/2010 09:10 7A820000-7B0B8000 [2292] a.exe: Natif ndisnpp.dll C:\WINDOWS\system32\npp\ndisnpp.dll N/A N/A Symboles chargés (informations sources supprimées). C:\Documents and Settings\user\Local Settings\Temp\SymbolCache\MicrosoftPublicSymbols\ndisnpp.pdb\0942DCEB0B6740488FBF6FE96C3BD92A1\ndisnpp.pdb 35 5.1.2600.5512 (xpsp.080413-0852) 14/04/2008 03:32 673F0000-67401000 [2292] a.exe: Natif
J'utulise le code suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 'a.exe' : Chargé 'C:\Documents and Settings\user\Mes documents\Visual Studio 2010\Projects\a\Debug\a.exe', Les symboles ont été chargés. 'a.exe' : Chargé 'C:\WINDOWS\system32\ntdll.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\mscoree.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\kernel32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\advapi32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\rpcrt4.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\secur32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\msvcp100d.dll', Les symboles ont été chargés. 'a.exe' : Chargé 'C:\WINDOWS\system32\msvcr100d.dll', Les symboles ont été chargés. 'a.exe' : Chargé 'C:\WINDOWS\system32\wpcap.dll', Chargement désactivé par le paramètre Include/Exclude. 'a.exe' : Chargé 'C:\WINDOWS\system32\ws2_32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\msvcrt.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\ws2help.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\Packet.dll', Exportations chargées. 'a.exe' : Chargé 'C:\WINDOWS\system32\version.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\npptools.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\mfc42u.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\gdi32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\user32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\ole32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\oleaut32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\iphlpapi.dll', Exportations chargées. 'a.exe' : Chargé 'C:\WINDOWS\system32\imm32.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\mfc42loc.dll', Le fichier binaire n'a pas été généré avec les informations de débogage. 'a.exe' : Chargé 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\system32\shlwapi.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll', Exportations chargées. 'a.exe' : Chargé 'C:\WINDOWS\system32\msvcr100_clr0400.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Culture.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\246f1a5abb686b9dcdf22d3505b08cea\mscorlib.ni.dll', Aucun symbole natif dans le fichier de symboles. 'a.exe' (Managé (v4.0.30319)) : 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll' chargé, symboles chargés. 'a.exe' : Chargé 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\nlssorting.dll', Symboles chargés (informations sources supprimées). 'a.exe' (Managé (v4.0.30319)) : 'C:\Documents and Settings\user\Mes documents\Visual Studio 2010\Projects\a\Debug\a.exe' chargé, symboles chargés. 'a.exe' : Chargé 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clrjit.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll', Symboles chargés (informations sources supprimées). 'a.exe' : Chargé 'C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System\964da027ebca3b263a05cadb8eaa20a3\System.ni.dll', Aucun symbole natif dans le fichier de symboles. 'a.exe' (Managé (v4.0.30319)) : 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll' chargé, symboles chargés. 'a.exe' : Chargé 'C:\WINDOWS\system32\npp\ndisnpp.dll', Symboles chargés (informations sources supprimées). 'a.exe' (Managé (v4.0.30319)) : 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_fr_b77a5c561934e089\mscorlib.resources.dll' chargé Une exception de première chance de type 'System.NullReferenceException' s'est produite dans a.exe Une exception non gérée du type 'System.NullReferenceException' s'est produite dans a.exe Informations supplémentaires : La référence d'objet n'est pas définie à une instance d'un objet. C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_fr_b77a5c561934e089\mscorlib.resources.dll: Aucun symbole n'a été chargé.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #include <iostream> #include "Packet.h" using namespace std; #include <conio.h> #pragma comment (lib, "user32.lib") int main(array<System::String ^> ^args) { Console::WriteLine(L"Hello World"); Packet P; pcap_if_t *alldevs; pcap_if_t *d; pcap_t *ad; int numInterface; ad=P.ChooseDev(); Console::WriteLine(L"c'est bon"); //ad=P.OpenDev(alldevs,numInterface); P.ParseDataPacket(ad); // int num=P. system("PAUSE"); getch(); return 0; }La bibliothèque pcap.h a été bien installé
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 #include "Packet.h" #include <iostream> #include <stdio.h> pcap_t* Packet::ChooseDev() { char *dev; char errbuf[PCAP_ERRBUF_SIZE]; pcap_t* descr; bpf_u_int32 maskp; /* subnet mask */ bpf_u_int32 netp; dev = pcap_lookupdev(errbuf); if(dev == NULL) { printf("%s\n",errbuf); exit(1); } /* ask pcap for the network address and mask of the device */ pcap_lookupnet(dev,&netp,&maskp,errbuf); /* open device for reading. NOTE: defaulting to * promiscuous mode*/ descr = pcap_open_live(dev,BUFSIZ,1,-1,errbuf); Console::WriteLine("C'est ouvert"); if(descr == NULL) { Console::WriteLine("pcap_open_live(): "); exit(1); } return descr; } Packet::Packet() { } pcap_t * Packet::OpenDev(pcap_if_t *alldevs, int inum) //return -1 if error and return 0 else { pcap_t *adhandle; pcap_if_t *d; char errbuf[PCAP_ERRBUF_SIZE]; int i; for(d=alldevs, i=0; i< inum-1 ;d=d->next, i++); Console::WriteLine(L"Le bloccage est ici"); if ( (adhandle= pcap_open(d->name, // name of the device 65536, // portion of the packet to capture. // 65536 guarantees that the whole packet will be captured on all the link layers PCAP_OPENFLAG_PROMISCUOUS, // promiscuous mode 1000, // read timeout NULL, // authentication on the remote machine errbuf // error buffer ) ) == NULL) { /* Free the device list */ cout <<"Le bloccage est ici"; pcap_freealldevs(alldevs); } cout <<"\nlistening on %s...\n"<< d->description; /* At this point, we don't need any more the device list. Free it */ pcap_freealldevs(alldevs); return adhandle; } void Packet::ParseDataPacket(pcap_t *adhandle){ const u_char *packet; struct pcap_pkthdr *header; int res; res=3; while(( res = pcap_next_ex( adhandle, &header, &packet)) >= 0){ if(res == 0){ /* Timeout elapsed */ Console::WriteLine("Le packet a été bien récupéré"); const struct sniff_ethernet *ethernet; /* The ethernet header */ const struct sniff_ip *ip; /* The IP header */ const struct sniff_tcp *tcp; /* The TCP header */ char *payload; /* Packet payload */ u_int size_ip; u_int size_tcp; ethernet = (struct sniff_ethernet*)(packet); //Console::WriteLine("Dir Sourc: %d\n", ethernet->ether_type); ip = (struct sniff_ip*)(packet + SIZE_ETHERNET); //size_ip = IP_HL(ip)*4; size_ip= (ip->ip_vhl & 0xf) * 4; if (size_ip < 20) cerr <<" * Invalid IP header length: %u bytes\n" << size_ip; tcp = (struct sniff_tcp*)(packet + SIZE_ETHERNET + size_ip); size_tcp = TH_OFF(tcp)*4; if (size_tcp < 20) cerr <<" * Invalid TCP header length: %u bytes\n"<< size_tcp; payload = (char *)(packet + SIZE_ETHERNET + size_ip + size_tcp); //Traitement des données char OctetParticulier = payload[ 4 ]; cout<< "L'octet 4 affiché est %d"<< OctetParticulier ; } if(res == -1){ cerr <<"Error reading the packets: %s\n" <<pcap_geterr(adhandle); } } }
S'il vous plait qui pourra m'aider à résoudre ceci ça fait plus que 3 jours que j'essaye
Merci
Partager