From 5dac16e0e15220cedbb13d8956499de3a457b7c1 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Tue, 18 Jun 2013 20:57:15 +0200 Subject: [PATCH] add support for communicating with the wired gateway --- HMLAN/hmlan-crypt-test.pl | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/HMLAN/hmlan-crypt-test.pl b/HMLAN/hmlan-crypt-test.pl index cab3ad8..37c3523 100755 --- a/HMLAN/hmlan-crypt-test.pl +++ b/HMLAN/hmlan-crypt-test.pl @@ -1,6 +1,12 @@ #!/usr/bin/perl -w -my $key="PUTYOURSECRETHMLANSTICKERKEYHERE"; +# key can either be 32 HEX chars (HMLAN) or a password (wired gateway) +#my $key="00112233445566778899AABBCCDDEEFF"; +#my $key="pA$$w0rd1!"; + +my $key="00112233445566778899AABBCCDDEEFF"; + +# ip address my $hmlan="192.168.1.2"; BEGIN { @@ -11,6 +17,7 @@ BEGIN { use HMLAN_CRYPT; use IO::Socket::INET; use IO::Select; +use Digest::MD5; #This should be random... my $my_iv = '00112233445566778899AABBCCDDEEFF'; @@ -28,17 +35,30 @@ $read_set->add($sock); $read_set->can_read(); chomp(my $iv = <$sock>); +if ($iv =~ /^H/) { + print "${iv}\n"; + chomp($iv = <$sock>); +} + if ($iv =~ /^V(................................)\r$/) { $hmlan_iv = $1; + print $sock "V${my_iv}\r\n"; +} elsif ($iv =~ /^V(..),(................................)\r$/) { + $hmlan_iv = $2; + print $sock "V01,${my_iv}\r\n"; } else { print STDERR "Unknown IV received: ${iv}\n"; exit(1); } -print $sock "V${my_iv}\r\n"; +if (length($key) < 32) { + $key = Digest::MD5::md5($key); +} else { + $key = pack("H*", $key); +} -my $cipher_hmlan=HMLAN_CRYPT->new(pack("H*", $key), pack("H*", $my_iv)); -my $cipher_pc=HMLAN_CRYPT->new(pack("H*", $key), pack("H*", $hmlan_iv)); +my $cipher_hmlan=HMLAN_CRYPT->new($key, pack("H*", $my_iv)); +my $cipher_pc=HMLAN_CRYPT->new($key, pack("H*", $hmlan_iv)); $read_set->add(\*STDIN); -- 2.39.5