Search code examples
pythonpacket

Python script Send Packet to IP like packetsender.com


i have trouble with python script to send packet. I already use socket.send like this :

import socket
try:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(10)
    s.connect(("10.10.0.250", 8010))

    print(s)

    while True:
        try:
            s.send(b'1b02fa031b03c8')
            reply = s.recv(131072)
            if not reply:
                break
            print("recvd: ", reply)
        except KeyboardInterrupt:
            print("bye")
            break
    s.close()
except socket.error as socketerror:
    s.close()
    print("Error: ", socketerror)

but show error : Time out. enter image description here I have make sure that 10.10.0.250 is connected to my laptop.

send string i already try at application call packetsender, use this tools all workwell.

enter image description here

The question is WHAT SCRIPT PYTHON Equivalent with use in packetsender?

Thanks anyway. Regards


Solution

  • I have answer about this :

    • Thanks alot to @jackw1111, your comment as clue : When working with raw sockets in scripts, most operating system require advanced privileges (e.g. root user) to run them.
    • Send packet must in ascii :
    packet = b'\x1b\x02\xfa\x03\x1b\x03\xc8'
    s.send(packet)
    

    Thanks all