Description: Detect if you receive a Ping and make a list with Date.
Autor: @LordRNA
#! /usr/bin/env python
########################################################################
#Script : WhoPingMe.py #
#Description: Detect if you receive a Ping and make a list with Date. #
#By : LordRNA #
#Comments : Tested on Python 2.6.5 #
########################################################################
import socket, datetime
def whopingme(date):
source = '' #To put the IP Source.
header = ["%i"%ord(x) for x in data]
#I made a list of int values for each byte in data variable.
if int(header[20])==8:#If Type(ICMP) is 8, i received a Echo Request.
for x in range(4):#To make a string with the IP Source.
source += str(header[12+x])
if x<3:source data-blogger-escaped----="---" data-blogger-escaped-date="date" data-blogger-escaped-len="len" data-blogger-escaped-print="print"> "+ str(source)
#I deleted the Miliseconds with [:len(date)-7]
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
#ICMP Protocol on RAW Socket
while 1:
data = sock.recv(21)#I Just want these bytes, IPHeader Lenght + Type(ICMPHeader)
whopingme(data)#Sending data to whopingme() function.
0 comentarios:
Publicar un comentario