blob: 731fc2d0765134218ded3189c3256c1aa9959a79 (
plain)
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
|
#!/bin/bash
# coding: utf-8
#sudo tcpdump -i wlp2s0 -c1 -v -w temp.pcap
#b=$(sudo tcpdump -r temp.pcap > tempcat)
#cat tempcat
#a=$(cat tempcat | cut -d" " -f13)
#echo "$a"
#if [ "$a" == "TCP" ] ; then
# echo 'Youpi'
#elif [ "$a" == "UDP" ] ; then
# echo 'Ah bah non ça marche pas'
#else
# echo 'KC'
#fi
while :
do
sudo tcpdump -i wlp2s0 -c1 -nn tcp -w capturetcp.pcap
sudo tcpdump -nn -r capturetcp.pcap > grostastcp
echo -e "Voici un paquet TCP\n"
cat grostastcp | cut -d" " -f1 >> /tmp/heuretcp.txt
cat grostastcp | cut -d" " -f2 >> /tmp/protocoletcp.txt
cat grostastcp | cut -d" " -f3 >> /tmp/sourcetcp.txt
cat grostastcp | cut -d" " -f5 >> /tmp/destinationtcp.txt
cat grostastcp | cut -d" " -f15 >> /tmp/tailletcp.txt
tail -n1 /tmp/heuretcp.txt
tail -n1 /tmp/protocoletcp.txt
tcpvar=$(tail -n1 /tmp/sourcetcp.txt)
echo "${tcpvar%.*}" >> /tmp/ipsrctcp.txt
echo "${tcpvar##*.}" >> /tmp/portsrctcp.txt
tail -n1 /tmp/ipsrctcp.txt
tail -n1 /tmp/portsrctcp.txt
tcprav=$(tail -n1 /tmp/destinationtcp.txt)
echo "${tcprav%.*}" >> /tmp/ipdsttcp.txt
echo "${tcprav##*.}" | cut -d":" -f1 >> /tmp/portdsttcp.txt
tail -n1 /tmp/ipdsttcp.txt
tail -n1 /tmp/portdsttcp.txt
tail -n1 /tmp/tailletcp.txt
# Attention ici c'est UDP
sudo tcpdump -i wlp2s0 -c1 -nn udp -w captureudp.pcap
sudo tcpdump -nn -r captureudp.pcap > grostasudp
echo -e "Voici un paquet UDP\n"
cat grostasudp | cut -d" " -f1 >> /tmp/heureudp.txt
cat grostasudp | cut -d" " -f2 >> /tmp/protocoleudp.txt
cat grostasudp | cut -d" " -f3 >> /tmp/sourceudp.txt
cat grostasudp | cut -d" " -f5 >> /tmp/destinationudp.txt
cat grostasudp | cut -d" " -f8 >> /tmp/tailleudp.txt
tail -n1 /tmp/heureudp.txt
tail -n1 /tmp/protocoleudp.txt
udpvar=$(tail -n1 /tmp/sourceudp.txt)
echo "${udpvar%.*}" >> /tmp/ipsrcudp.txt
echo "${udpvar##*.}" >> /tmp/portsrcudp.txt
tail -n1 /tmp/ipsrcudp.txt
tail -n1 /tmp/portsrcudp.txt
udprav=$(tail -n1 /tmp/destinationudp.txt)
echo "${udprav%.*}" >> /tmp/ipdstudp.txt
echo "${udprav##*.}" | cut -d":" -f1 >> /tmp/portdstudp.txt
tail -n1 /tmp/ipdstudp.txt
tail -n1 /tmp/portdstudp.txt
tail -n1 /tmp/tailleudp.txt
done
|