so with LanMarshal It's filtering down to Apple devices hence why it didn't work for me. I just need to figure out what to edit here.
#!/bin/sh
#
# This script extracts mobile devices from a Nmap scan. This version recognizes
# Apple devices.
#
# copyright 2013 Artelsys.com
#
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Global constants and variables
dumpfile="/home/app/servers/dump.txt"
tempfile="/home/app/servers/temp.txt"
result="/home/app/servers/result.txt"
# It ...
#
function _extract_device() {
# Extract relevant fields
MAC=$(grep -n -m 1 "MAC Address" $tempfile | awk -F " " '{print $3 }')
IP=$(grep -n -m 1 "Nmap scan report" $tempfile | awk -F " " '{print $5 }')
DEVICE=$(grep -n -m 1 "Device type:" $tempfile | awk -F " " '{print $3 " " $4 }')
OS=$(grep -n -m 1 "Running:" $tempfile | awk -F " " '{$1=""; print }')
OS_CPE=$(grep -n -m 1 "OS CPE:" $tempfile | awk -F " " '{$1=""; $2=""; print }')
OS_DETAILS=$(grep -n -m 1 "OS details:" $tempfile | awk -F " " '{$1=""; $2=""; print }')
# Remove leading white spaces
OS=$(echo $OS | sed 's/^ *//g')
OS_CPE=$(echo $OS_CPE | sed 's/^ *//g')
OS_DETAILS=$(echo $OS_DETAILS | sed 's/^ *//g')
echo "$MAC;$IP;$DEVICE;$OS;$OS_CPE;$OS_DETAILS" >> $result
}
# It ...
#
function _extract_block() {
# Extract the block and copy it to
sed -n '/Nmap scan/,/Network Distance/p;/Network Distance/q' $dumpfile > $tempfile
lines=$(wc -l < $tempfile)
#sed q $tempfile
#echo "$lines lines have been extracted."
# Delete the extracted block from input file
while [ $lines -gt 0 ]; do
sed -i "1d" $dumpfile
let lines=lines-1
done
# Check if extracted device info matches 'iPhone OS'.
if grep -q 'iphone_os' $tempfile; then
#echo 'Bingo!';
_extract_device
fi
}
# -----------------------------------------------------------------------------
# Main program
#
# -----------------------------------------------------------------------------
# Delete file containing list of detected devices
if [ -e "$result" ]; then
rm $result
fi
touch $result
# Clean up the file by removing the two first lines and the empty lines
sed -i '1,2d' $dumpfile
sed -i '/^$/d' $dumpfile
# Extract the 'Nmap' blocks and store detected mobile into database
# echo "extracting Nmap blocks ..."
# Do until all the blocks are extracted
size=$(wc -l < $dumpfile)
while [ $size -gt 3 ]; do
_extract_block
size=$(wc -l < $dumpfile)
done
exit 0