0

I am working with an ESP8266 (NodeMCU) with MicroPython and want to be able to do packet injection or send raw packets / freedom packets. I cannot find anyway to open a raw socket (usocket/socket module) or do this via the 'network' module. Is there anyway I can do this?

The normal python equivalent would be:

import socket
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(0x0003))
s.bind(("wlan0", 0x0003)) #wlan0 being in monitor mode

In micropython, you can enter monitor mode (station mode) like this

import network
sta_if = network.WLAN(network.STA_IF)

But from there, you cannot send/receive any packets. Is there any way to be able to do this?

Any help is much appreciated.

Sorry for the lack of detail but I have no idea what to do from here.

larsks
  • 277,717
  • 41
  • 399
  • 399
meep
  • 334
  • 3
  • 10

1 Answers1

1

I don't think you can achieve raw socket by using micropython@esp8266

One reason is the memory are very limited on esp8266. Another reason is their socket doesn't implement raw socket.

You could try to use CC3200 ports and modify it's micropython's firmware.

YuSheng
  • 191
  • 1
  • 4
  • Thanks for the help. I will look into it. I agree swith you on the memory issue but I was thinking as the network module was able to scan for APs, perhaps it did it via raw socket? – meep Mar 19 '19 at 13:33
  • If you have ability modify the micropython firmware, it's doable. You could do the following items to achieve your goals.(scanning APs) 1. modify modlwip.c to enable raw socket. 2. Turn on your WiFi chip's promiscuous mode. – YuSheng Mar 19 '19 at 14:42
  • I've had a look at some of the .c files and am looking at perhaps implementing some of the ESP8266WiFi.h Arduino library functions (e.g wifi_send_pkt_freedom). Perhaps that might help? – meep Mar 19 '19 at 15:13