mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
74_Nmap: added commandref example to scan two networks with one device
git-svn-id: https://svn.fhem.de/fhem/trunk@14107 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8f62e3d7ea
commit
223b8ca22c
@ -55,8 +55,8 @@ sub Nmap_Initialize($) {
|
|||||||
$hash->{SetFn} = $TYPE."_Set";
|
$hash->{SetFn} = $TYPE."_Set";
|
||||||
$hash->{AttrFn} = $TYPE."_Attr";
|
$hash->{AttrFn} = $TYPE."_Attr";
|
||||||
|
|
||||||
$hash->{AttrList} =
|
$hash->{AttrList} = ""
|
||||||
"absenceThreshold "
|
. "absenceThreshold "
|
||||||
. "args "
|
. "args "
|
||||||
. "deleteOldReadings "
|
. "deleteOldReadings "
|
||||||
. "devAlias:textField-long "
|
. "devAlias:textField-long "
|
||||||
@ -182,10 +182,7 @@ sub Nmap_Attr(@) {
|
|||||||
if($attribute eq "args"){
|
if($attribute eq "args"){
|
||||||
$hash->{ARGS} = $cmd eq "set" ? $value : "-sn";
|
$hash->{ARGS} = $cmd eq "set" ? $value : "-sn";
|
||||||
}
|
}
|
||||||
elsif(
|
elsif($attribute eq "devAlias" && $cmd eq "set"){
|
||||||
$attribute eq "devAlias"
|
|
||||||
&& $cmd eq "set"
|
|
||||||
){
|
|
||||||
return(
|
return(
|
||||||
"$SELF: Value \"$value\" is not allowed for devAlias!\n"
|
"$SELF: Value \"$value\" is not allowed for devAlias!\n"
|
||||||
. "Must be \"<ID>:<ALIAS> <ID2>:<ALIAS2> ...\", "
|
. "Must be \"<ID>:<ALIAS> <ID2>:<ALIAS2> ...\", "
|
||||||
@ -282,9 +279,8 @@ sub Nmap_statusRequest($) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if( AttrVal($SELF, "sudo", 0) == 1
|
||||||
AttrVal($SELF, "sudo", 0) == 1
|
&& qx(sudo -n $path -V 2>&1 > /dev/null)
|
||||||
&& qx(sudo -n $path -V 2>&1 > /dev/null)
|
|
||||||
){
|
){
|
||||||
readingsSingleUpdate($hash, "state", "aborted", 1);
|
readingsSingleUpdate($hash, "state", "aborted", 1);
|
||||||
Log3($SELF, 1, "$TYPE ($SELF) - sudo password required");
|
Log3($SELF, 1, "$TYPE ($SELF) - sudo password required");
|
||||||
@ -413,9 +409,8 @@ sub Nmap_done($) {
|
|||||||
|
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
if(
|
if( $oldMetaReading
|
||||||
$oldMetaReading
|
&& ReadingsVal($SELF, $oldMetaReading."_ip", "") ne $ip
|
||||||
&& ReadingsVal($SELF, $oldMetaReading."_ip", "") ne $ip
|
|
||||||
){
|
){
|
||||||
Log3($SELF, 4, "$TYPE ($SELF) - new IP: $hostname ($ip)");
|
Log3($SELF, 4, "$TYPE ($SELF) - new IP: $hostname ($ip)");
|
||||||
|
|
||||||
@ -429,9 +424,8 @@ sub Nmap_done($) {
|
|||||||
DoTrigger($SELF, "new host: $hostname ($ip)");
|
DoTrigger($SELF, "new host: $hostname ($ip)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if( $oldMetaReading && $oldMetaReading ne $metaReading
|
||||||
$oldMetaReading && $oldMetaReading ne $metaReading
|
&& AttrVal($SELF, "keepReadings", 0) == 0
|
||||||
&& AttrVal($SELF, "keepReadings", 0) == 0
|
|
||||||
){
|
){
|
||||||
delete $knownHosts{$oldMetaReading};
|
delete $knownHosts{$oldMetaReading};
|
||||||
CommandDeleteReading(undef, "$SELF $oldMetaReading.*");
|
CommandDeleteReading(undef, "$SELF $oldMetaReading.*");
|
||||||
@ -453,9 +447,8 @@ sub Nmap_done($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (keys %knownHosts){
|
foreach (keys %knownHosts){
|
||||||
next if(
|
next if( $knownHosts{$_} == 1
|
||||||
$knownHosts{$_} == 1
|
|| ReadingsVal($SELF, $_."_state", "present") eq "absent"
|
||||||
|| ReadingsVal($SELF, $_."_state", "present") eq "absent"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
my $absenceThreshold = ReadingsVal($SELF, ".".$_."_absenceThreshold", 1);
|
my $absenceThreshold = ReadingsVal($SELF, ".".$_."_absenceThreshold", 1);
|
||||||
@ -616,7 +609,9 @@ sub Nmap_updateUptime($$;$) {
|
|||||||
Nmap will scan all IP addresses where the first numbits match those of
|
Nmap will scan all IP addresses where the first numbits match those of
|
||||||
the given IP or host name. For example, 192.168.10.0/24 would scan the
|
the given IP or host name. For example, 192.168.10.0/24 would scan the
|
||||||
256 hosts between 192.168.10.0 and 192.168.10.255. 192.168.10.40/24 would
|
256 hosts between 192.168.10.0 and 192.168.10.255. 192.168.10.40/24 would
|
||||||
scan exactly the same targets.<br>
|
scan exactly the same targets. It's also possible to scan multiple
|
||||||
|
networks at the same time. For example 192.168.1.0/24 192.168.2.0/24
|
||||||
|
would scan the 512 hosts between 192.168.1.0 and 192.168.2.255.<br>
|
||||||
See
|
See
|
||||||
<a href="https://nmap.org/man/de/man-target-specification.html">
|
<a href="https://nmap.org/man/de/man-target-specification.html">
|
||||||
<u>Nmap Manpage (Specifying Destinations)</u>
|
<u>Nmap Manpage (Specifying Destinations)</u>
|
||||||
@ -879,7 +874,9 @@ sub Nmap_updateUptime($$;$) {
|
|||||||
IP oder des gegebenen Hostnamens übereinstimmen. Zum Beispiel
|
IP oder des gegebenen Hostnamens übereinstimmen. Zum Beispiel
|
||||||
würde 192.168.10.0/24 die 256 Hosts zwischen 192.168.10.0 und
|
würde 192.168.10.0/24 die 256 Hosts zwischen 192.168.10.0 und
|
||||||
192.168.10.255 scannen. 192.168.10.40/24 würde genau dieselben Ziele
|
192.168.10.255 scannen. 192.168.10.40/24 würde genau dieselben Ziele
|
||||||
scannen.<br>
|
scannen. Es ist auch möglich mehrere Netzwerke zur gleichen Zeit zu
|
||||||
|
scannen. Zum Beispiel würde 192.168.1.0/24 192.168.2.0/24 die 512
|
||||||
|
Hosts zwischen 192.168.1.0 und 192.168.2.255 scannen.<br>
|
||||||
Siehe
|
Siehe
|
||||||
<a href="https://nmap.org/man/de/man-target-specification.html">
|
<a href="https://nmap.org/man/de/man-target-specification.html">
|
||||||
<u>Nmap Man Page (Angabe von Zielen)</u>
|
<u>Nmap Man Page (Angabe von Zielen)</u>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user