diff --git a/sensor-node/modules/ROOT/nav.adoc b/sensor-node/modules/ROOT/nav.adoc index 66bd559..567691d 100644 --- a/sensor-node/modules/ROOT/nav.adoc +++ b/sensor-node/modules/ROOT/nav.adoc @@ -1,2 +1,2 @@ -* xref:index.adoc[Network Scanning] +* xref:index.adoc[Sensor node] * xref:exer.adoc[Exercises] diff --git a/sensor-node/modules/ROOT/pages/index.adoc b/sensor-node/modules/ROOT/pages/index.adoc index 421e10d..a7e1369 100644 --- a/sensor-node/modules/ROOT/pages/index.adoc +++ b/sensor-node/modules/ROOT/pages/index.adoc @@ -1,329 +1,383 @@ -= Network Scanning! += Sensor node! image::ROOT:swarmlab.png[swarmlab,150,float=right] -This tutorial demonstrates some common nmap port scanning scenarios and explains the output. +This tutorial demonstrates: *a.* howto create a mote with Raspberry Pi and Arduino *b.* howto use it +==== +A sensor node, also known as a mote, is a node in a sensor network that is capable of performing some processing, gathering sensory information and communicating with other connected nodes +==== -== Find IP -[source,bash] ----- -# ifconfig ή ip a +== Create a mote with Raspberry Pi -eth0: flags=4163 mtu 1500 - inet 172.21.0.2 netmask 255.255.0.0 broadcast 172.21.255.255 - ether 02:42:ac:15:00:02 txqueuelen 0 (Ethernet) - RX packets 61 bytes 9309 (9.3 KB) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 0 bytes 0 (0.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 +The Raspberry Pi is a low-cost credit-card sized single-board computer. The Raspberry Pi was created in the UK by the Raspberry Pi Foundation. The Raspberry Pi Foundation's goal is to "advance the education of adults and children, particularly in the field of computers, computer science and related subjects." -lo: flags=73 mtu 65536 - inet 127.0.0.1 netmask 255.0.0.0 - loop txqueuelen 1000 (Local Loopback) - RX packets 248 bytes 14260 (14.2 KB) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 248 bytes 14260 (14.2 KB) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ----- +https://simple.wikipedia.org/wiki/Raspberry_Pi[Wikipedia] -TIP: inet ***172.21.0.2*** netmask 255.255.0.0 broadcast 172.21.255.255 -== Find live hosts +.Raspberry Pi 2 Model B +image:./Raspberry_Pi_2_Model_B_v1.1_top_new.jpg[alt="Raspberry Pi 2 Model B"] -[source,bash] ----- -nmap -sP 172.21.0.* +[NOTE] +.Remember +==== +A mote is a node but a node is not always a mote! -Nmap scan report for 172.21.0.1 (172.21.0.1) -Host is up (0.00028s latency). -MAC Address: 02:42:56:48:D0:61 (Unknown) -Nmap scan report for testnetwork2_worker_1.testnetwork2_net (172.21.0.3) -Host is up (0.00015s latency). -MAC Address: 02:42:AC:15:00:03 (Unknown) -Nmap scan report for testnetwork2_worker_3.testnetwork2_net (172.21.0.4) -Host is up (0.00018s latency). -MAC Address: 02:42:AC:15:00:04 (Unknown) -Nmap scan report for testnetwork2_worker_4.testnetwork2_net (172.21.0.5) -Host is up (0.00015s latency). -MAC Address: 02:42:AC:15:00:05 (Unknown) -Nmap scan report for testnetwork2_worker_2.testnetwork2_net (172.21.0.6) -Host is up (0.00017s latency). -MAC Address: 02:42:AC:15:00:06 (Unknown) -Nmap scan report for 9110d42e466b (172.21.0.2) +image:./arduino-connect-pi.jpg[alt="Raspberry Pi and Arduino"] +==== -nmap -sP 172.21.0.* | grep Nmap | cut -d' ' -f5-6 -172.21.0.1 (172.21.0.1) -testnetwork2_worker_1.testnetwork2_net (172.21.0.3) -testnetwork2_worker_3.testnetwork2_net (172.21.0.4) -testnetwork2_worker_4.testnetwork2_net (172.21.0.5) -testnetwork2_worker_2.testnetwork2_net (172.21.0.6) -9110d42e466b (172.21.0.2) +=== Install Raspberry Pi ----- +==== Step 1: Download Raspbian + +https://www.raspberrypi.org/downloads/raspbian/[Download] the Raspbian disc image - Choose Raspbian Lite -.What is Nmap? [NOTE] +.Why Raspbian Lite? ==== -Nmap, short for Network Mapper, is a free, open-source tool for vulnerability scanning and network discovery. Network administrators use Nmap to identify what devices are running on their systems, discovering hosts that are available and the services they offer, finding open ports and detecting security risks. +Because it is a lightweight version of the Raspbian and it doesn’t have a graphical user interface installed. -See https://en.wikipedia.org/wiki/Nmap[Nmap-wikipedia^] +This means that it doesn’t have any unnecessary software installed that we don’t need for our projects, so this makes it the perfect solution for future automation projects. ==== +==== Step 2: Unzip the file -== Scan Ports +- Windows users, you’ll want 7-Zip. +- Linux users will use the appropriately named Unzip. -=== Scan a Single Port, All Ports, or Series -[source,bash] ----- -Nmap commands can be used to scan a single port or a series of ports: ----- +==== Step 3: Write the disc image to your microSD card -=== Scan port 80 on the target system: +Next, pop your microSD card into your computer and write the disc image to it. You’ll need a specific program to do this: -[source,bash] ----- -nmap –p 80 172.21.0.3 ----- +- Windows users, your answer is https://sourceforge.net/projects/win32diskimager/[Win32 Disk Imager]. +- Linux people, https://www.balena.io/etcher/[Etcher – which also works on Windows – is what the Raspberry Pi Foundation recommends.] -=== Scan ports 1 through 200 on the target system: +The process of actually writing the image will be slightly different across these programs, but it’s pretty self-explanatory no matter what you’re using. -[source,bash] ----- -nmap –p 1-200 172.21.0.3 ----- +- Each of these programs will have you select the destination (make sure you’ve picked your microSD card!) and the disc image (the unzipped Raspbian file). +- Choose, double-check, and then hit the button to write. -=== Scan (Fast) the most common ports: -[source,bash] ----- -nmap –F 172.21.0.3 ----- - -=== To scan all ports (1 – 65535): - -[source,bash] ----- -nmap –p– 172.21.0.3 ----- +==== Step 4: Enabling SSH +- Windows users +.Create ssh file (no extension) +image:./ssh-file-to-sd-card.jpg[alt="Create ssh file"] -=== Scan All TCP UDP Ports +- Linux Users -Scan all UDP and TCP ports in a single command. We will use -sU for UDP and sT for TCP protocol. +.Create ssh file [source,bash] ---- -nmap -sU -sT -p0-65535 IP +sudo fdisk -l +# find dev and Boot partition +sudo mkdir /mnt/sdcardP1 +sudo mount /dev/device_partion_boot /mnt/sdcardP1 -rw +cd /mnt/sdcardP1 +sudo touch ssh ---- +==== Step 5: Put the microSD card in your Pi and boot up -.What Are Ports? -[NOTE] -==== - -On modern operating systems, ports are numbered addresses for network traffic. Different kinds of services use different ports by default. - -For example, normal web traffic uses Port 80, while POP3 email uses Port 110. One of the ways that a firewall works is by allowing or restricting traffic over a particular port. +Your default credentials are username **pi** and password **raspberry** -Because the ports into your computer can cause a security risk, it’s critical to know which ports are open and which are blocked. -==== +==== Step 6: Access via SSH -== netstat -=== Listing (Almost all) +- The boot protocol for the ethernet interface is set to DHCP by default -[source,bash] ----- -netstat -antlupe ----- +You can find the open SSH ports on your network using the nmap utility: -=== Listing TCP Ports connections +.find ports on Network [source,bash] ---- -netstat -at +nmap -p 22 --open -sV 192.168.1.0/24 ---- -.Netstat -[NOTE] -==== -Netstat command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc., -==== +You should find your pi listed in the output along with the IP assigned to the pi. -=== Listing UDP Ports connections +- You can change the boot protocol to static and define a static IP address for the pi by editing the ifcfg-eth0 file: +.static IP address [source,bash] ---- -netstat -au +sudo fdisk -l +# find dev and Boot partition +sudo mkdir /mnt/sdcardP1 +sudo mount /dev/device_partion_ext /mnt/sdcardP1 -rw +cd /mnt/sdcardP1 +vi /etc/sysconfig/network-scripts/ifcfg-eth0 ---- +Then edit the file to suit your needs -=== Listing all LISTENING Connections - +.static IP address [source,bash] ---- -netstat -l +DEVICE=eth0 +BOOTPROTO=static +ONBOOT=yes +NETWORK=192.168.1.0 +NETMASK=255.255.255.0 +IPADDR=192.168.1.200 +GATEWAY=192.168.1.1 ---- -=== Listing all TCP Listening Ports +==== Step 7: Configure your Raspberry Pi. -[source,bash] ----- -netstat -lt ----- +**raspi-config** is the Raspberry Pi configuration tool -=== Listing all UDP Listening Ports +.config Pi [source,bash] ---- -netstat -lu +sudo raspi-config ---- +It has the following options available: -=== Listing all UNIX Listening Ports - +.config options [source,bash] ---- -netstat -lx + +┌───────────────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├────────────────────┐ +│ │ +│ 1 Change User Password Change password for the current user │ +│ 2 Network Options Configure network settings │ +│ 3 Boot Options Configure options for start-up │ +│ 4 Localisation Options Set up language and regional settings to match your location │ +│ 5 Interfacing Options Configure connections to peripherals │ +│ 6 Overclock Configure overclocking for your Pi │ +│ 7 Advanced Options Configure advanced settings │ +│ 8 Update Update this tool to the latest version │ +│ 9 About raspi-config Information about this configuration tool │ +│ │ +│ │ +│ │ +│