0

A simple client-server raw socket where the client send a custom packet and it will be received from the server.

Here's my code.

Client.py

#!/usr/bin/env python
import socket
import sys
from scapy.all import *
sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
try: 
 a=Ether(dst="90:**:**:**:**:75", src="90:**:**:**:**:96")/IP(src="192.168.240.5", dst="192.168.240.1")/TCP(sport=10000,dport=10000)/"HELLO"
a.show()
sendp(a)
finally:
 print >>sys.stderr, 'closing socket'
 sock.close()

Output:

###[ Ethernet ]###
dst = 90:**:**:**:**:75
src = 90:**:**:**:**:96
type = 0x800
###[ IP ]###
 version = 4
 ihl = None
 tos = 0x0
 len = None
 id = 1
 flags = 
 frag = 0
 ttl = 64
 proto = tcp
 chksum = None
 src = 192.168.240.5
 dst = 192.168.240.1
 \options \
###[ TCP ]###
 sport = 10000
 dport = 10000
 seq = 0
 ack = 0
 dataofs = None
 reserved = 0
 flags = S
 window = 8192
 chksum = None
 urgptr = 0
 options = {}
###[ Raw ]###
 load = 'HELLO'
.
Sent 1 packets.
closing socket

Server.py

#!/usr/bin/env python
import socket
import sys
from scapy.all import *
sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
sock.bind(("wlan0",10000))
def pkt_callback(pkt):
 pkt.show() # debug statement
while True:
 print >>sys.stderr, 'waiting for a connection'
 sniff(iface="wlan0", prn=pkt_callback, store=0)

The server shows me every packets it intercepts but there's no sign of the one sent by the client.py script. I guess it is not sent at all.

What is the problem?

asked Nov 12, 2015 at 13:30
4
  • Do you have a firewall running on your computer , they can intercept sockets sometimes ? Commented Nov 12, 2015 at 14:00
  • No firewall running. Commented Nov 12, 2015 at 14:10
  • Are client and server both the same machine on the network, or two separate machines? Commented Nov 12, 2015 at 20:40
  • Two separate machines on the same netwrok Commented Nov 12, 2015 at 22:17

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.