-
Notifications
You must be signed in to change notification settings - Fork 1
/
MineScan.sh
executable file
·62 lines (45 loc) · 1.63 KB
/
MineScan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /bin/bash
################################################
## MineFinder.sh ##
## Scans address ranges for Minecraft servers.##
## Concept and code by Logic & PHX2600 crew ##
################################################
#Check for Sanity
if [ ! -e /usr/bin/nmap ]; then
echo "Sorry you dont seem to have Nmap installed."
echo "Please install Nmap and try again, Thanks!"
exit
fi
#Prepare the environment
if [ ! -e current.txt ]; then
touch current.txt
else
echo "" > current.txt
fi
if [ ! -e previous.txt ]; then
touch previous.txt
fi
if [ ! -e results.txt ]; then
touch results.txt
fi
# Run Nmap, look for minecraft servers (-p 25565), exclude previously scanned hosts (--excludefile)
# Assume all hosts are up (-PN), make output grepable (-oG) and output to current.txt,
# Use cmdline input for ip range ($1)
nmap -p 25565 -PN --excludefile previous.txt -oG current.txt $1 > /dev/null 2>&1
#Sanitize our output from Nmap and append new IP's to our running scanned IP List
cat current.txt | grep Up | awk '{print $2}' >> previous.txt
#Look for servers with MC port open Sanitize our output from grep and append to running servers list.
cat current.txt | grep open | awk '{print $2}' >> results.txt
#Clean up and sort our bounty!
cat results.txt | sort | uniq > /tmp/temp.txt
cp /tmp/temp.txt results.txt
cat previous.txt | sort | uniq > /tmp/temp.txt
cp /tmp/temp.txt previous.txt
#Let us know what we have
echo -n "New servers found: "
grep open current.txt | wc -l
echo "###############"
grep open current.txt | awk '{print $2}'
echo "###############"
echo -n "Total Servers: "
cat results.txt | wc -l