Reputation: 919
I've built a webcrawler that uses the HTMLParser lib in Python. It goes on a page, and continues with the next one, linked on the loaded page, etc. It just collects the links. Now I need to protocoll the TCP/IP traffic between the hosts and my PC (packet sniffing). The result should be stored in a file.pcap. I've found an' example that seems to be useful for my purpose. Am I right?
Here the code of the answer I'm interested in:
from scapy.all import wrpcap, Ether, IP, UDP
packet = Ether() / IP(dst="1.2.3.4") / UDP(dport=123)
wrpcap('foo.pcap', [packet])
Upvotes: 1
Views: 396
Reputation: 5421
It appears you are very unaware of what an IP or a port mean. You should start by reading articles about that.
http://mason.gmu.edu/~afinn/html/tele/components/urls_ip.htm https://searchnetworking.techtarget.com/definition/TCP-IP
Once this is done, have a read at the documentation to start with Scapy: https://scapy.readthedocs.io/en/latest/
Also: what is your question?
Do you want to :
sr1(IP(dst="www.google.com")/ICMP())
Upvotes: 3
Reputation: 73
I am not familiar with Scapy, but I know how to get IP by addresses, you can ping
it:
$ ping stackoverflow.com
PING stackoverflow.com (151.101.193.69): 56 data bytes
64 bytes from 151.101.193.69: icmp_seq=0 ttl=46 time=374.685 ms
64 bytes from 151.101.193.69: icmp_seq=1 ttl=46 time=397.401 ms
64 bytes from 151.101.193.69: icmp_seq=2 ttl=46 time=684.908 ms
64 bytes from 151.101.193.69: icmp_seq=3 ttl=46 time=301.389 ms
then you will know that stackoverflow.com's IP is 151.101.193.69
Upvotes: 1