Instant Os detection method

pull/384/head
TheDragonkeeper 2019-06-01 12:26:06 +01:00 committed by GitHub
parent 9c9a1a0ef4
commit 8440b7416a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 15 deletions

View File

@ -18,21 +18,23 @@ function GET() {
export SWITCH_POSITION="invalid"
;;
"TARGET_OS")
GET TARGET_IP
ScanForOS=$(nmap -Pn -O $TARGET_IP -p1 -v2)
[[ $ScanForOS == *"Too many fingerprints"* ]] && ScanForOS=$(nmap -Pn -O $TARGET_IP --osscan-guess -v2)
[[ "${ScanForOS,,}" == *"windows"* ]] && export TARGET_OS='WINDOWS' && return
[[ "${ScanForOS,,}" == *"apple"* ]] && export TARGET_OS='MACOS' && return
[[ "${ScanForOS,,}" == *"linux"* ]] && export TARGET_OS='LINUX' && return
export TARGET_OS='UNKNOWN'
;;
"TARGET_OS_QUICK")
GET TARGET_IP
ScanForOS=$(ping -c1 $TARGET_IP)
[[ "${ScanForOS,,}" == *"ttl=128"* ]] && export TARGET_OS='WINDOWS' && return
[[ "${ScanForOS,,}" == *"ttl=64"* ]] && export TARGET_OS='LINUX' && return
[[ "${ScanForOS,,}" == *"ttl=63"* ]] && export TARGET_OS='CHROMEOS' && return
export TARGET_OS='UNKNOWN'
DATABASE=/root/udisk/payloads/extensions/OSdatabase
FINGERPRINT=$(cat /var/log/syslog | grep FINGERPRINT | awk '{ print $9 " " $7 }' | sort -u | awk '{ print $2 }' | awk 'END{print}')
[[ -f $DATABASE ]] || touch $DATABASE
sed -i $FINGERPRINT > /var/log/syslog
if [ -f $DATABASE ] ; then
TARGET_OS=$(cat $DATABASE | grep $FINGERPRINT | awk '{ print $2 }')
GET TARGET_IP
if [ -z $TARGET_OS ]; then
ScanForOS=$(nmap -Pn -O $TARGET_IP -p1 -v2)
[[ $ScanForOS == *"Too many fingerprints"* ]] && ScanForOS=$(nmap -Pn -O $TARGET_IP --osscan-guess -v2)
[[ "${ScanForOS,,}" == *"linux"* ]] && export TARGET_OS='LINUX'
[[ "${ScanForOS,,}" == *"apple"* ]] && export TARGET_OS='MACOS'
[[ "${ScanForOS,,}" == *"windows"* ]] && export TARGET_OS='WINDOWS'
[[ -z $TARGET_OS ]] && export TARGET_OS='UNKNOWN'
echo $FINGERPRINT $TARGET_OS >> $DATABASE
fi
fi
;;
esac
}