mdlayher / raw

Package raw enables reading and writing data at the device driver level for a network interface. MIT Licensed.
MIT License
425 stars 71 forks source link

IPv6 packet #61

Closed eloydegen closed 4 years ago

eloydegen commented 4 years ago

Hi, I am trying to build a portscanner with this library.

I am crafting a TCP SYN for IPv6 the following way:

func sendMessages(c net.PacketConn, source net.HardwareAddr) {
    // rewrite function to portscan of single IP
    WholePacket := make([]byte, 80)

    // IP header, consists of IP version, DiffServ, etc.
    src := []byte("600d0fcd00280640")
    var IPheader = WholePacket[0:8]
    hex.Decode(IPheader, src)

    src = []byte("20014c10100900010000000000000008")
    var SourceIP = WholePacket[8:24]
    hex.Decode(SourceIP, src)

    src = []byte("20010bc8472c27090000000000000001")
    var DestIP = WholePacket[24:40]
    hex.Decode(DestIP, src)

    // source port
    src = []byte("b86c")
    var SourcePort = WholePacket[40:42]
    hex.Decode(SourcePort, src)

    // dest port 
    src = []byte("0050")
    var DestPort = WholePacket[42:44]
    hex.Decode(DestPort, src)

    // tcp data 
    src = []byte("8aa5439c00000000a002708040a90000020405a00402080a07c181540000000001030307")
    var TCPData = WholePacket[44:80]
    hex.Decode(TCPData, src)
}

I have omitted the rest of the function which is comparable to the example code.

I can see that the packet is being sent with tcpdump and I can see that is being received on the remote host. But, the remote host does not reply on this packet. I have tried randomizing the source port and sequence number, but this does not help. I can use nmap without issues to scan the remote host.

Thanks in advance for any help!

mdlayher commented 4 years ago

Hey there! Since this library is working as intended and is sending your packet over the network, there's nothing to be done here with regards to the library itself.

I'm going to close this issue, but I recommend reaching out on one of the Go help forums or perhaps #networking on Gophers Slack where folks might be able to provide some more thoughts. I myself am far from an expert in TCP and don't have any immediate thoughts on the matter. Apologies!