aboutsummaryrefslogtreecommitdiffstats
path: root/autoscan/tests
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2013-07-22 03:23:01 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2013-07-22 03:23:01 +0200
commitc16a1c3b6f1fdacf2ad365ff2a35252d7eb73c4e (patch)
tree557b3b788a8597859dee143e2fcae94a967463d2 /autoscan/tests
parentautoscan - automatic fingerprint of visited networks (diff)
downloadlaurent-tools-c16a1c3b6f1fdacf2ad365ff2a35252d7eb73c4e.tar.xz
laurent-tools-c16a1c3b6f1fdacf2ad365ff2a35252d7eb73c4e.zip
autoscan: some code and add tests
Diffstat (limited to 'autoscan/tests')
-rw-r--r--autoscan/tests/Makefile5
-rwxr-xr-xautoscan/tests/spoofbin/ifconfig12
-rwxr-xr-xautoscan/tests/spoofbin/iwconfig4
-rwxr-xr-xautoscan/tests/spoofbin/route7
-rwxr-xr-xautoscan/tests/test_autoscan.sh19
5 files changed, 47 insertions, 0 deletions
diff --git a/autoscan/tests/Makefile b/autoscan/tests/Makefile
new file mode 100644
index 0000000..77bebab
--- /dev/null
+++ b/autoscan/tests/Makefile
@@ -0,0 +1,5 @@
+all: clean
+ ./test_autoscan.sh
+
+clean:
+ rm -rf test_output/
diff --git a/autoscan/tests/spoofbin/ifconfig b/autoscan/tests/spoofbin/ifconfig
new file mode 100755
index 0000000..0df746d
--- /dev/null
+++ b/autoscan/tests/spoofbin/ifconfig
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+echo "eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
+ inet 10.137.2.9 netmask 255.255.255.255 broadcast 10.255.255.255
+ inet6 fe80::216:3eff:fe5e:6c07 prefixlen 64 scopeid 0x20<link>
+ ether 00:16:3e:5e:6c:07 txqueuelen 1000 (Ethernet)
+ RX packets 74405 bytes 93418449 (89.0 MiB)
+ RX errors 0 dropped 0 overruns 0 frame 0
+ TX packets 54640 bytes 5365525 (5.1 MiB)
+ TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
+ device interrupt 47
+"
diff --git a/autoscan/tests/spoofbin/iwconfig b/autoscan/tests/spoofbin/iwconfig
new file mode 100755
index 0000000..2302264
--- /dev/null
+++ b/autoscan/tests/spoofbin/iwconfig
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "eth0 no wireless extensions.
+"
diff --git a/autoscan/tests/spoofbin/route b/autoscan/tests/spoofbin/route
new file mode 100755
index 0000000..20abcc3
--- /dev/null
+++ b/autoscan/tests/spoofbin/route
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+echo "Kernel IP routing table
+Destination Gateway Genmask Flags Metric Ref Use Iface
+0.0.0.0 10.137.2.1 0.0.0.0 UG 0 0 0 eth0
+10.137.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
+"
diff --git a/autoscan/tests/test_autoscan.sh b/autoscan/tests/test_autoscan.sh
new file mode 100755
index 0000000..bea2c34
--- /dev/null
+++ b/autoscan/tests/test_autoscan.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+err() {
+ echo "ERROR: $1"
+ exit 1
+}
+
+export PATH="./spoofbin/:$PATH"
+
+../autoscan.py -f -o test_output/ -r eth0 ||err "autoscan execution failed"
+
+# XXX test output dirs
+dir="test_output/$(ls -1 test_output |tail -n1)"
+[[ $(cat $dir/route/gw) = "10.137.2.1" ]] ||err "route/gw"
+[[ $(cat $dir/ifconfig/ip4) = "10.137.2.9" ]] ||err "ifconfig/ip4"
+[[ $(cat $dir/ifconfig/ip6) = "fe80::216:3eff:fe5e:6c07" ]] ||err "ifconfig/ip6"
+[[ $(cat $dir/pubip_ping/code) = "0" ]] ||err "pubip_ping/code"
+
+echo "TEST OK"