init config
8
Readme.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Readme
|
||||
|
||||
Ce dépot contient les fichiers de test pour l'implémentation de `scapy`
|
||||
Vous allez procéder de la façon suivante:
|
||||
1. Installation de l'environnement virtuel et de jupyter notebook à partir de la commande `install.sh`
|
||||
1. TD1_Scapy.ipynb
|
||||
1. TD2_Sacpy.ipynb
|
||||
|
377
TD1_Scapy.ipynb
Normal file
@ -0,0 +1,377 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d6d5af9c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Introduction à Scapy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4ec54431-5aff-479e-94ef-cf86e326ad79",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Configuration de base\n",
|
||||
"Dans un premier temps il faut importer le module `scapy` puis définir l'interface de comunication dans la bibliothèque `conf` de `scapy`. Dans cette configuration on choisira un le niveau de verbosité, ainsi qu'un thème."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "366e27c2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from scapy.all import *\n",
|
||||
"import netifaces as ni\n",
|
||||
"conf.verb=0 #0 très bavard, 1: moins bavard\n",
|
||||
"conf.iface=interface='en0'\n",
|
||||
"conf.color_theme = RastaTheme()\n",
|
||||
"#interface='en0'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e644b2aa-e5af-4180-b653-37436add76ff",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Affichage des interfaces présentes sur l'ordinateur"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7ebaf725",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ni.interfaces()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9ae96c9d-55d8-46de-8c9a-f4e5c801b33a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Affichage d'information concernant une interface\n",
|
||||
"Le module `netifaces` nous permettra de récupérer des informations des couches 2 et 3 du modèle OSI.\n",
|
||||
"- **Utiliser** la fonction `ifaddresses` pour afficher ces informations.\n",
|
||||
"- On souhaite récupérer uniquement les informations ipv4, **Extraire** cette information. "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"id": "2fac4a68",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{18: [{'addr': '6c:7e:67:c7:fb:e4'}],\n",
|
||||
" 30: [{'addr': 'fe80::499:abb:4b55:759e%en0',\n",
|
||||
" 'netmask': 'ffff:ffff:ffff:ffff::/64',\n",
|
||||
" 'flags': 1024}],\n",
|
||||
" 2: [{'addr': '10.122.13.217',\n",
|
||||
" 'netmask': '255.255.248.0',\n",
|
||||
" 'broadcast': '10.122.15.255'}]}"
|
||||
]
|
||||
},
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"ni.ifaddresses(interface)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f39eee36",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ni.ifaddresses(interface)[2]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "77c47399",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ni.ifaddresses(interface)[2][0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f96618f3-7b3c-4419-978f-c05dece2273d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"- **Afficher** uniquement l'adresse ipv4 de l'interface\n",
|
||||
"- puis l'adresse mac de celle-ci"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "64cf7e40",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(\"Adresse Ipv4:\\t\", ni.ifaddresses(interface)[2][0]['addr'])\n",
|
||||
"print(\"Adresse Mac:\\t\", ni.ifaddresses(interface)[18][0]['addr'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "aa8d735d-25af-4e36-9f6f-787c697e635f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Affichons les constantes du module `netifaces` en utilisant la fonction `dir`"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "8ba5fa2f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['AF_APPLETALK',\n",
|
||||
" 'AF_CCITT',\n",
|
||||
" 'AF_CHAOS',\n",
|
||||
" 'AF_CNT',\n",
|
||||
" 'AF_COIP',\n",
|
||||
" 'AF_DATAKIT',\n",
|
||||
" 'AF_DECnet',\n",
|
||||
" 'AF_DLI',\n",
|
||||
" 'AF_ECMA',\n",
|
||||
" 'AF_HYLINK',\n",
|
||||
" 'AF_IMPLINK',\n",
|
||||
" 'AF_INET',\n",
|
||||
" 'AF_INET6',\n",
|
||||
" 'AF_IPX',\n",
|
||||
" 'AF_ISDN',\n",
|
||||
" 'AF_ISO',\n",
|
||||
" 'AF_LAT',\n",
|
||||
" 'AF_LINK',\n",
|
||||
" 'AF_NATM',\n",
|
||||
" 'AF_NDRV',\n",
|
||||
" 'AF_NETBIOS',\n",
|
||||
" 'AF_NS',\n",
|
||||
" 'AF_PPP',\n",
|
||||
" 'AF_PUP',\n",
|
||||
" 'AF_ROUTE',\n",
|
||||
" 'AF_SIP',\n",
|
||||
" 'AF_SNA',\n",
|
||||
" 'AF_SYSTEM',\n",
|
||||
" 'AF_UNIX',\n",
|
||||
" 'AF_UNSPEC',\n",
|
||||
" 'IN6_IFF_AUTOCONF',\n",
|
||||
" 'IN6_IFF_DYNAMIC',\n",
|
||||
" 'IN6_IFF_OPTIMISTIC',\n",
|
||||
" 'IN6_IFF_SECURED',\n",
|
||||
" 'IN6_IFF_TEMPORARY',\n",
|
||||
" '__doc__',\n",
|
||||
" '__file__',\n",
|
||||
" '__loader__',\n",
|
||||
" '__name__',\n",
|
||||
" '__package__',\n",
|
||||
" '__spec__',\n",
|
||||
" 'address_families',\n",
|
||||
" 'gateways',\n",
|
||||
" 'ifaddresses',\n",
|
||||
" 'interfaces',\n",
|
||||
" 'version']"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"dir(ni)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f2f11e19-d7e8-4c9c-94bb-9acb81c5c0b2",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Recherche de correspondances\n",
|
||||
"**Afficher** la valeur correspondant aux constantes `AF_INET`, `AF_INET6` et `AF_LINK` et en déduire le type d'information correspondante."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"id": "cb666c80",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Valeur de AF_INET: 2 correspond à l'adresse IPv4\n",
|
||||
"Valeur de AF_INET6: 30 correspond à l'adresse IPv6\n",
|
||||
"Valeur de AF_LINK: 18 correspond à l'adresse Mac\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(f\"Valeur de AF_INET: {ni.AF_INET} correspond à l'adresse IPv4\")\n",
|
||||
"print(f\"Valeur de AF_INET6: {ni.AF_INET6} correspond à l'adresse IPv6\")\n",
|
||||
"print(f\"Valeur de AF_LINK: {ni.AF_LINK} correspond à l'adresse Mac\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d9e820b6-924c-4395-96a0-54a837e22b1b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Réécrire** l'affichage de l'adresse ipv4 et de l'adresse mac en utilisant les constante trouvée précédemment"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"id": "145ed80b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Adresse Ipv4:\t 10.122.13.217\n",
|
||||
"Adresse Mac:\t 6c:7e:67:c7:fb:e4\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(\"Adresse Ipv4:\\t\", ni.ifaddresses(interface)[ni.AF_INET][0]['addr'])\n",
|
||||
"print(\"Adresse Mac:\\t\", ni.ifaddresses(interface)[ni.AF_LINK][0]['addr'])\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"id": "ee6e8aaa",
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'default': {2: ('10.122.8.1', 'en0')}, 2: [('10.122.8.1', 'en0', True)], 30: [('fe80::%utun0', 'utun0', False), ('fe80::%utun1', 'utun1', False), ('fe80::%utun2', 'utun2', False), ('fe80::%utun3', 'utun3', False), ('fe80::%utun4', 'utun4', False), ('fe80::%utun5', 'utun5', False), ('fe80::%utun6', 'utun6', False), ('fe80::%utun7', 'utun7', False)]}\n",
|
||||
"17\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"gw=ni.gateways()\n",
|
||||
"print(gw)\n",
|
||||
"print(ni.AF_ROUTE)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "19549d9f-298b-4283-9147-f7602b88b63e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d68994da-4f06-4ca7-ab53-d26ab747d35d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"id": "2e11d4da-9540-4ccf-bd77-4f391d7e92d9",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"route par défaut: 10.122.8.1\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(\"route par défaut: \",gw['default'][ni.AF_INET][0])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"id": "c45ca8a1",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"hwtype : XShortEnumField = ('1')\n",
|
||||
"ptype : XShortEnumField = ('2048')\n",
|
||||
"hwlen : FieldLenField = ('None')\n",
|
||||
"plen : FieldLenField = ('None')\n",
|
||||
"op : ShortEnumField = ('1')\n",
|
||||
"hwsrc : MultipleTypeField (SourceMACField, StrFixedLenField) = ('None')\n",
|
||||
"psrc : MultipleTypeField (SourceIPField, SourceIP6Field, StrFixedLenField) = ('None')\n",
|
||||
"hwdst : MultipleTypeField (MACField, StrFixedLenField) = ('None')\n",
|
||||
"pdst : MultipleTypeField (IPField, IP6Field, StrFixedLenField) = ('None')\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"ls(ARP)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "caf02c2d-46d6-4d31-8a75-5a3d5ea1c8a6",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "sae24_env",
|
||||
"language": "python",
|
||||
"name": "sae24_env"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
2340
TD2_Scapy.ipynb
Normal file
BIN
Wireshark/McDiarmid.pcap
Normal file
BIN
Wireshark/McDiarmid.pcapng
Normal file
BIN
Wireshark/Ping_Google.pcap
Normal file
BIN
Wireshark/Ping_Google.pcapng
Normal file
BIN
Wireshark/SIP.pcap
Normal file
BIN
Wireshark/SIP.pcapng
Normal file
BIN
Wireshark/ftp.pcap
Executable file
BIN
Wireshark/sip-rtp-g711.pcap
Executable file
BIN
images/Capture d’écran 2021-12-17 à 09.51.35.png
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
images/Capture d’écran 2021-12-17 à 11.31.51.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
images/Capture_Wireshark.png
Normal file
After Width: | Height: | Size: 815 KiB |
BIN
images/fichier_bin.png
Normal file
After Width: | Height: | Size: 271 KiB |
BIN
images/fin_transfert.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
images/ls.png
Normal file
After Width: | Height: | Size: 155 KiB |
BIN
images/mode_actif.png
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
images/page1SW2.png
Normal file
After Width: | Height: | Size: 124 KiB |
BIN
images/page2SW2.png
Normal file
After Width: | Height: | Size: 528 KiB |
BIN
images/ping_google.png
Normal file
After Width: | Height: | Size: 527 KiB |
BIN
images/rand_fonction.png
Normal file
After Width: | Height: | Size: 253 KiB |
BIN
images/sniff_filter.png
Normal file
After Width: | Height: | Size: 358 KiB |
9
install.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
echo -e "********************************************\n** Installation de l'environnement python **\n********************************************"
|
||||
python3.11 -m venv sae24_env
|
||||
source sae24_env/bin/activate
|
||||
pip install -r requirements.txt
|
||||
python -m ipykernel install --user --name=sae24_env
|
||||
echo -e "Attention Ne pas oublier de sélectionner l'environnement virtuel sae24_env au niveau du Kernel !"
|
||||
jupyter notebook --allow-root
|
||||
|
7
requirements.txt
Normal file
@ -0,0 +1,7 @@
|
||||
scapy==2.5.0
|
||||
netifaces
|
||||
ipykernel
|
||||
ipython
|
||||
jupyter_client
|
||||
jupyter_core
|
||||
|