Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send SYN packet failed on Windows 10 #519

Open
WorstCodeWay opened this issue Dec 4, 2023 · 8 comments
Open

Send SYN packet failed on Windows 10 #519

WorstCodeWay opened this issue Dec 4, 2023 · 8 comments

Comments

@WorstCodeWay
Copy link

WorstCodeWay commented Dec 4, 2023

Hi, I new to socket, but I want to scan ports which are opened on other host or not. I find libtins can do this. Thanks for your work!

I meet a problem when doing my work, the libtins complains cannot sent ip packet, where an exception that implies socket_write_error (error:10022 within sendto). I have looked into libtins sources, and found that socket is created normally, IP_HDRINCL is ok too. But it just cannot send packet.

And I also have run the example codes Scanner for scanning, same problem.

I need help, guys.

@ahmedtalaat327
Copy link

I have same exception on win11 I think this is a socket limitation Raw sockets not allowed to work on 10 and 11

@WorstCodeWay
Copy link
Author

WorstCodeWay commented Dec 11, 2023

I have same exception on win11 I think this is a socket limitation Raw sockets not allowed to work on 10 and 11

@ahmedtalaat327 You're right. Confirmed by more than one ways. At last, I introduce Npcap into my project and work like a charm.

@ahmedtalaat327
Copy link

I think its possible to send the UPD carrying the TCP sender.

@ahmedtalaat327
Copy link

@WorstCodeWay I think this works
asasas

@WorstCodeWay
Copy link
Author

WorstCodeWay commented Dec 12, 2023

@WorstCodeWay I think this works

@ahmedtalaat327
Sorry, where is Port Scan.exe from? Is it built from Tins example source code?

@ahmedtalaat327
Copy link

@WorstCodeWay I think this works

@ahmedtalaat327 Sorry, where is Port Scan.exe from? Is it built from Tins example source code?

this is the same libtins yeah But using EthernetII instead of sending packet directly
` EthernetII eth = EthernetII("a0:8c:fd:61:5a:1d","94:08:53:64:6c:63") / IP("192.168.100.140", "192.168.100.45") / TCP(100, 1521) / Tins::RawPDU("I'm payload!");;

// Retrieve a pointer to the stored TCP PDU
TCP* tcp = eth.find_pdu<TCP>();
tcp->set_flag(Tins::TCP::SYN, 1);
tcp->seq(1733878791);
tcp->ack_seq(0);



// You can also retrieve a reference. This will throw a
// pdu_not_found exception if there is no such PDU in this packet.
IP& ip = eth.rfind_pdu<IP>();



// The sender
PacketSender sender;
//sender.send(eth, iface);
// Send and receive the response.
(sender.send(eth, iface));`

@WorstCodeWay
Copy link
Author

@WorstCodeWay I think this works

@ahmedtalaat327 Sorry, where is Port Scan.exe from? Is it built from Tins example source code?

this is the same libtins yeah But using EthernetII instead of sending packet directly ` EthernetII eth = EthernetII("a0:8c:fd:61:5a:1d","94:08:53:64:6c:63") / IP("192.168.100.140", "192.168.100.45") / TCP(100, 1521) / Tins::RawPDU("I'm payload!");;

// Retrieve a pointer to the stored TCP PDU
TCP* tcp = eth.find_pdu<TCP>();
tcp->set_flag(Tins::TCP::SYN, 1);
tcp->seq(1733878791);
tcp->ack_seq(0);



// You can also retrieve a reference. This will throw a
// pdu_not_found exception if there is no such PDU in this packet.
IP& ip = eth.rfind_pdu<IP>();



// The sender
PacketSender sender;
//sender.send(eth, iface);
// Send and receive the response.
(sender.send(eth, iface));`

Interesting! I tried very like this, but without raw payload field, and it didn’t work. I will try this later.

Besides, in practice, you need target MAC address to fill the first parameter of EthernetII constructor, how will you get that? In my case, broadcast arp message may help.

@ahmedtalaat327
Copy link

ahmedtalaat327 commented Dec 12, 2023

@WorstCodeWay ARP reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants