|
|
|
@ -3,21 +3,74 @@
|
|
|
|
|
#include "WiFi.h"
|
|
|
|
|
#include <Adafruit_Neopixel.h>
|
|
|
|
|
|
|
|
|
|
#define NUMPIXELS 1
|
|
|
|
|
#define PIN_NEOPIXEL 39
|
|
|
|
|
#define NUMPIXELS 8
|
|
|
|
|
#define PIN_NEOPIXEL_ONBOARD 39
|
|
|
|
|
#define PIN_NEOPIXEL 9
|
|
|
|
|
#define NEOPIXEL_POWER 38
|
|
|
|
|
|
|
|
|
|
#define PROTO_ICMP 1
|
|
|
|
|
#define PROTO_TCP 6
|
|
|
|
|
#define PROTO_UDP 17
|
|
|
|
|
|
|
|
|
|
char ssid[] = "MyWifi"; // your network SSID (name)
|
|
|
|
|
char pass[] = "MyPassphrase"; // your network password (use for WPA, or use as key for WEP)
|
|
|
|
|
|
|
|
|
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
|
|
|
|
|
Adafruit_NeoPixel onboard_pixel(1, PIN_NEOPIXEL_ONBOARD, NEO_GRB + NEO_KHZ800);
|
|
|
|
|
|
|
|
|
|
void ssh_attempt() {
|
|
|
|
|
printf("Someone connected to SSH!");
|
|
|
|
|
pixels.fill(pixels.Color(255, 0, 0));
|
|
|
|
|
pixels.show();
|
|
|
|
|
delay(200);
|
|
|
|
|
pixels.clear();
|
|
|
|
|
pixels.show();
|
|
|
|
|
delay(100);
|
|
|
|
|
pixels.fill(pixels.Color(255, 0, 0));
|
|
|
|
|
pixels.show();
|
|
|
|
|
delay(200);
|
|
|
|
|
pixels.fill(pixels.Color(0,0,0));
|
|
|
|
|
pixels.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void icmp_ping() {
|
|
|
|
|
pixels.setPixelColor(2, pixels.Color(255, 255, 255));
|
|
|
|
|
pixels.setPixelColor(3, pixels.Color(255, 255, 255));
|
|
|
|
|
pixels.setPixelColor(6, pixels.Color(255, 255, 255));
|
|
|
|
|
pixels.setPixelColor(7, pixels.Color(255, 255, 255));
|
|
|
|
|
pixels.show();
|
|
|
|
|
delay(100);
|
|
|
|
|
pixels.setPixelColor(2, 0);
|
|
|
|
|
pixels.setPixelColor(3, 0);
|
|
|
|
|
pixels.setPixelColor(6, 0);
|
|
|
|
|
pixels.setPixelColor(7, 0);
|
|
|
|
|
pixels.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
void log_packet(uint16_t port) {
|
|
|
|
|
void log_packet(uint16_t port, u16_t proto) {
|
|
|
|
|
if (WiFi.status() == WL_CONNECTED) {
|
|
|
|
|
pixels.rainbow(port);
|
|
|
|
|
uint32_t color = pixels.ColorHSV(port);
|
|
|
|
|
switch (proto) {
|
|
|
|
|
case PROTO_ICMP:
|
|
|
|
|
icmp_ping();
|
|
|
|
|
break;
|
|
|
|
|
case PROTO_TCP:
|
|
|
|
|
if (port == 22) {
|
|
|
|
|
ssh_attempt();
|
|
|
|
|
} else {
|
|
|
|
|
pixels.setPixelColor(0, color);
|
|
|
|
|
pixels.setPixelColor(1, color);
|
|
|
|
|
pixels.show();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case PROTO_UDP:
|
|
|
|
|
pixels.setPixelColor(4, color);
|
|
|
|
|
pixels.setPixelColor(5, color);
|
|
|
|
|
pixels.show();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -33,14 +86,20 @@ extern "C" void app_main()
|
|
|
|
|
digitalWrite(NEOPIXEL_POWER, HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
|
|
|
|
|
onboard_pixel.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
|
|
|
|
|
pixels.setBrightness(20); // not so bright
|
|
|
|
|
onboard_pixel.setBrightness(20);
|
|
|
|
|
|
|
|
|
|
printf("Connecting");
|
|
|
|
|
onboard_pixel.fill(onboard_pixel.Color(255, 255, 0));
|
|
|
|
|
onboard_pixel.show();
|
|
|
|
|
WiFi.begin(ssid, pass);
|
|
|
|
|
while (WiFi.status() != WL_CONNECTED) {
|
|
|
|
|
delay(500);
|
|
|
|
|
printf(".");
|
|
|
|
|
}
|
|
|
|
|
onboard_pixel.fill(onboard_pixel.Color(0, 255, 0));
|
|
|
|
|
onboard_pixel.show();
|
|
|
|
|
printf("\nConnected!\n");
|
|
|
|
|
printf("SSID: %s\n", WiFi.SSID().c_str());
|
|
|
|
|
printf("IP: %s\n", WiFi.localIP().toString().c_str());
|
|
|
|
|