Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending Packages with Scapy
#1
Hello
I'm learning scapy and I have a problem: the TCP packets I send are leaving, but I don't get a response. I tried to disable the firewall and go through a proxy, but nothing works. Another thing, I have an answer only on port 443 of the devices. I have no problem with other types of packages, such as ICMP. If you don't understand something, say the month, because I'm French and use a translator.
Reply
#2
Your issue may stem from incomplete TCP handshakes or port restrictions. If responses only come on port 443, the target likely limits other ports. TCP requires a proper handshake (SYN, SYN-ACK, ACK). Make sure your Scapy script handles this correctly. For example:
from scapy.all import *
ip = IP(dst="target_ip")
syn = TCP(dport=443, flags="S", seq=100)
syn_ack = sr1(ip/syn)
ack = TCP(dport=443, flags="A", seq=syn_ack.ack, ack=syn_ack.seq + 1)
send(ip/ack)
The firewall on the target side may also block some packets. Test the target's open ports using tools like nmap, and ensure your proxy supports the TCP traffic you're sending. ICMP working suggests it's a protocol-specific issue with TCP.
buran write Dec-25-2024, 05:42 AM:
Spam link removed
Reply
#3
I don't think the problem comes from a firewall of the target, because I have also tested on public servers that are unable to respond to these packets on the targeted port. Here's the code I use:
packet = IP(dst=ip)/TCP(dport=port, flags='S')
    
    response = sr1(packet, timeout=5)
    
    if response:
        if response.haslayer(TCP) and response.getlayer(TCP) == 18:
            print(f"le port {port} est ouvert sur l'ip {ip}")
        else:
            print(f"le port {port} n'est pas ouvert sur l'ip {ip}")
    else:
        print("pas de réponse")
Reply
#4
Another thing: I can't scan the port of an IP with scapy with TCP packets, but there is no problem with socket.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Permission issue when using scapy jao 3 16,295 Feb-05-2022, 06:14 PM
Last Post: snippsat
  run scapy from python script .. evilcode1 13 17,839 Sep-13-2018, 01:45 AM
Last Post: ichabod801
  creating new layer with scapy omerccohen 0 4,830 Sep-20-2017, 02:11 PM
Last Post: omerccohen

Forum Jump:

User Panel Messages

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