Python Forum
Graphic of total different connection opened by one ip (per seconds) by time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Graphic of total different connection opened by one ip (per seconds) by time
#1
Graphic of total different connection opened by one ip (per seconds) by time (slowloris attack)

I have a network dump (PCAP file) from a "conversation" between a web server apache (192.168.1.2) and some clients:

[Image: W0UKb]




This was a simulation of slowloris attack in Apache web server.

Counting how many different connection are opened by one ip:

   /usr/sbin/tcpdump -anr myfile.pcap |
       sed 's/^.*IP \([^:]*\)192.168.1.2.80:.*/\1/p;d' |
       sort |
       uniq -c

This will show a lot of

   10 192.168.1.8.36684 >
   4 192.168.1.8.39619 >
   9 192.168.1.8.39856 >
   4 192.168.1.8.39896 >
   5 192.168.1.8.40195 >
   12 192.168.1.8.40196 >
   9 192.168.1.8.52288 >
   7 192.168.1.8.58529 >
   9 192.168.1.8.58639 >
   9 192.168.1.8.58730 >
   6 192.168.1.8.58835 >
   13 192.168.1.8.58851 >
   12 192.168.1.8.58852 >
   10 192.168.1.8.58882 >

Number of different connection are opened by one ip per second: (saida.txt)

   tcpdump -anr slowloris.pcap host 192.168.1.2 and port 80 |
       sed -une '
         s/^\(.\{8\}\).* IP \(.*\)\.[0-9]\+ > 192.168.1.2.80: Flags \[S\],.*/\1 \2/p
       ' |
       sort | uniq -c

This Python script compute the total of different connection opened by one ip per second:

   
    with open('saida.txt') as f: 
           linhas = f.readlines()
           soma = 0 
           for linha in linhas:
               soma += int(linha.strip().split(" ")[0])
   
   print(soma)
How could I plot using Python the "total of different connection opened by one ip per second" x time?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  does not save in other path than opened files before icode 3 913 Jun-23-2023, 07:25 PM
Last Post: snippsat
  Problem with module time and leap seconds Pedroski55 3 1,253 Oct-07-2022, 11:27 PM
Last Post: Pedroski55
  Graphic line plot with matplotlib, text file in pytho khadija 2 1,394 Aug-15-2022, 12:00 PM
Last Post: khadija
Question How to get html information from a tab of my default browser opened with webbrowser? noahverner1995 2 4,509 Jan-14-2022, 10:02 AM
Last Post: noahverner1995
  Store variable data and display sum after 60 seconds the_dude 11 3,466 Dec-16-2021, 07:07 PM
Last Post: deanhystad
  Serial connection connection issue Joni_Engr 15 8,099 Aug-30-2021, 04:46 PM
Last Post: deanhystad
  Rmarkdown opened by python code - errors Rav013 0 2,094 Apr-27-2021, 03:13 PM
Last Post: Rav013
  splitting total time between days tester_V 7 3,079 Nov-14-2020, 04:40 AM
Last Post: tester_V
  How to calculate time difference between each row of dataframe in seconds Mekala 1 2,582 Jul-16-2020, 12:57 PM
Last Post: Larz60+
  Need to add hours min and seconds tester_V 5 3,115 Jun-02-2020, 05:29 PM
Last Post: tester_V

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020