From ae14e66616f0e4232ca0123ceec3680885179dd6 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Wed, 10 Jan 2018 22:08:54 +0100 Subject: [PATCH] add check ammad_id for security reasion --- 73_AMADCommBridge.pm | 23 +- 74_AMADDevice.pm | 4 +- ...ml => 74_AMADautomagicFlowset_4.1.99.5.xml | 1856 +++++++++-------- 3 files changed, 1025 insertions(+), 858 deletions(-) rename 74_AMADautomagicFlowset_4.1.99.3.xml => 74_AMADautomagicFlowset_4.1.99.5.xml (78%) diff --git a/73_AMADCommBridge.pm b/73_AMADCommBridge.pm index 156706a..48a84e6 100644 --- a/73_AMADCommBridge.pm +++ b/73_AMADCommBridge.pm @@ -74,8 +74,8 @@ eval "use Encode qw(encode encode_utf8);1" or $missingModul .= "Encode "; eval "use JSON;1" or $missingModul .= "JSON "; -my $modulversion = "4.1.99.26"; -my $flowsetversion = "4.1.99.3"; +my $modulversion = "4.1.99.30"; +my $flowsetversion = "4.1.99.5"; @@ -254,13 +254,20 @@ sub AMADCommBridge_Write($@) { Log3 $name, 4, "AMADCommBridge ($name) - AMADCommBridge_Write Path: $path"; + + + if($remoteServer ne 'Automagic' and $path =~ /\?/) { + $path .= "&amad_id=$amad_id"; + } elsif($remoteServer ne 'Automagic') { + $path .= "?amad_id=$amad_id"; + } return readingsSingleUpdate($dhash,'lastSetCommand',$path,1) if( $remoteServer eq 'other' ); - - - $param = { url => "http://" . $uri . $path, timeout => 15, hash => $hash, amad_id => $amad_id, method => $method, header => $header, doTrigger => 1, callback => \&AMADCommBridge_ErrorHandling } if($remoteServer eq 'Automagic'); - + + $param = { url => "http://" . $uri . $path, timeout => 15, hash => $hash, amad_id => $amad_id, method => $method, header => $header . "\r\namadid: $amad_id", doTrigger => 1, callback => \&AMADCommBridge_ErrorHandling } if($remoteServer eq 'Automagic'); + + $param = { url => "http://" . $uri . "/", data => "{\"message\":\"AMAD=:=$path\", \"sender\":\"AMAD\", \"ttl\":60, \"communication_base_params\":{\"type\":\"Message\", \"fallback\":false, \"via\":\"Wifi\"},\"version\":\"1.62\"}", timeout => 15, hash => $hash, amad_id => $amad_id, method => $method, @@ -268,6 +275,7 @@ sub AMADCommBridge_Write($@) { doTrigger => 1, callback => \&AMADCommBridge_ErrorHandling } if($remoteServer eq 'Autoremote'); + $param = { url => "http://" . $uri . "/", data => "device=AMAD&cmd=".urlEncode($path), timeout => 15, hash => $hash, amad_id => $amad_id, method => $method, @@ -275,7 +283,8 @@ sub AMADCommBridge_Write($@) { doTrigger => 1, callback => \&AMADCommBridge_ErrorHandling } if($remoteServer eq 'TNES'); - + + my $logtext = "AMADCommBridge ($name) - Send with remoteServer: $remoteServer URL: $param->{url}, HEADER: $param->{header}, METHOD: $method"; $logtext .= ", DATA: $param->{data}" if( $remoteServer ne 'Automagic' ); Log3 $name, 5, "$logtext"; diff --git a/74_AMADDevice.pm b/74_AMADDevice.pm index 05ced50..4ccac3b 100644 --- a/74_AMADDevice.pm +++ b/74_AMADDevice.pm @@ -59,7 +59,7 @@ eval "use JSON;1" or $missingModul .= "JSON "; my $modulversion = "4.1.99.30"; -my $flowsetversion = "4.1.99.3"; +my $flowsetversion = "4.1.99.5"; @@ -378,7 +378,7 @@ sub AMADDevice_statusRequest($) { my $fhemCtlMode = AttrVal($hash->{IODev}->{NAME},'fhemControlMode','none' ); my $bport = $hash->{IODev}->{PORT}; - $header .= "\r\nfhemip: $fhemip\r\nfhemdevice: $name\r\nactivetask: $activetask\r\napssid: $apssid\r\nbport: $bport\r\nuserflowstate: $userFlowState\r\namadid: $amad_id\r\nfhemctlmode: $fhemCtlMode"; + $header .= "\r\nfhemip: $fhemip\r\nfhemdevice: $name\r\nactivetask: $activetask\r\napssid: $apssid\r\nbport: $bport\r\nuserflowstate: $userFlowState\r\nfhemctlmode: $fhemCtlMode"; $method = "GET" if( AttrVal($name,'remoteServer','Automagic') eq 'Automagic' ); $method = "POST" if (AttrVal($name,'remoteServer','Automagic') ne 'Automagic' ); diff --git a/74_AMADautomagicFlowset_4.1.99.3.xml b/74_AMADautomagicFlowset_4.1.99.5.xml similarity index 78% rename from 74_AMADautomagicFlowset_4.1.99.3.xml rename to 74_AMADautomagicFlowset_4.1.99.5.xml index 4e170e8..ef21324 100644 --- a/74_AMADautomagicFlowset_4.1.99.3.xml +++ b/74_AMADautomagicFlowset_4.1.99.5.xml @@ -673,6 +673,11 @@ irname=getString("name") Expression: global_userflowstate != "none" global_userflowstate != "none" + + true + Expression: header_amadid == {global_amadid} + header_amadid == {global_amadid} + false Expression: installFlow" @@ -838,6 +843,31 @@ irname=getString("name") Expression: param_orientation == "portrait" param_orientation == "portrait" + + true + Expression: param_pictureresolution == "1024x768" + param_pictureresolution == "1024x768" + + + true + Expression: param_pictureresolution == "1280x720" + param_pictureresolution == "1280x720" + + + true + Expression: param_pictureresolution == "1600x1200" + param_pictureresolution == "1600x1200" + + + true + Expression: param_pictureresolution == "1920x1080" + param_pictureresolution == "1920x1080" + + + true + Expression: param_pictureresolution == "800x600" + param_pictureresolution == "800x600" + true Expression: param_screen=="off" @@ -983,6 +1013,11 @@ irname=getString("name") Expression: System Command" request_path == "/fhem-amad/setCommands/systemcommand" + + false + Expression: takepicture + request_path == "/fhem-amad/setCommands/takepicture" + true Expression: togocount < 6 @@ -1091,8 +1126,8 @@ or trigger == "HTTP Request: /fhem-amad/deviceInfo/" true - Expression: trigger == "HTTP Request: /fhem-amad/deviceInfo/" - trigger == "HTTP Request: /fhem-amad/deviceInfo/" + Expression: trigger == "HTTP Request: /fhem-amad/deviceInfo/" and header_amadid == {global_amadid} + trigger == "HTTP Request: /fhem-amad/deviceInfo/" and header_amadid == {global_amadid} true @@ -1842,6 +1877,96 @@ putString("{param_exkey2}", "{param_exval2}"); SYSTEM_SETTING true + + false + Foto aufnehmen: /storage/emulated/0/AMADpicture.jpg (ohne Benutzeroberfläche) 1024x768 + false + /storage/emulated/0/AMADpicture.jpg + 0 + 1024*768 + 100 + auto + none + + auto + auto + false + true + 2000 + true + + + false + Foto aufnehmen: /storage/emulated/0/AMADpicture.jpg (ohne Benutzeroberfläche) 1280x720 + false + /storage/emulated/0/AMADpicture.jpg + 0 + 1280*720 + 100 + auto + none + + auto + auto + false + true + 2000 + true + + + false + Foto aufnehmen: /storage/emulated/0/AMADpicture.jpg (ohne Benutzeroberfläche) 1600x1200 + false + /storage/emulated/0/AMADpicture.jpg + 0 + 1600*1200 + 100 + auto + none + + auto + auto + false + true + 2000 + true + + + false + Foto aufnehmen: /storage/emulated/0/AMADpicture.jpg (ohne Benutzeroberfläche) 1920x1080 + false + /storage/emulated/0/AMADpicture.jpg + 0 + 1920*1080 + 100 + auto + none + + auto + auto + false + true + 2000 + true + + + false + Foto aufnehmen: /storage/emulated/0/AMADpicture.jpg (ohne Benutzeroberfläche) 800x600 + false + /storage/emulated/0/AMADpicture.jpg + 0 + 800*600 + 100 + auto + none + + auto + auto + false + true + 2000 + true + true Gerät sperren @@ -1849,7 +1974,17 @@ putString("{param_exkey2}", "{param_exval2}"); false Get Android Version - false Script: Set FHEMDATA JSON -