pythonnetwork-programmingscapypackets

How do i know which url a packet is going to or coming from in python


Below is an example of the packets I'm getting:-

---------------------------------Packet----------------------------------------
Destination MAC : 88:ae:1d:ab:11:95 Source MAC : d0:d0:fd:f5:74:46 Protocol : 8
Version : 4 IP Header Length : 5 TTL : 53 Protocol : 6 Source Address : 196.45.51.39 Destination Address : 10.0.9.137
Source Port : 3128 Dest Port : 52662 Sequence Number : 623854838 Acknowledgement : 396375922 TCP header length : 5

--------------------------------------------------------------------------------

Solution

  • In theory you can try a reverse DNS lookup:

    import socket
    socket.gethostbyaddr(<IP_ADDRESS>)
    

    You have to replace IP_ADDRESS.

    But I am not sure if it works, if your provider use NATs.