fork(1) download
  1. #! /usr/bin/env perl
  2. #16:44:00.094758 1.0 Mb/s 2427 MHz 11b -53dBm signal antenna 1 Probe Request (M-PM-0M-PM-1M-PM-2M-PM-3M-PM-4M-PM-5M-QM-^QM-PM-6M-PM-7M-PM-8M-PM-9M-PM-:) [1.0 2.0 5.5 11.0 Mbit]
  3. # 0x0000: 0018 d0b0 d0b1 d0b2 d0b3 d0b4 d0b5 d191
  4. # 0x0010: d0b6 d0b7 d0b8 d0b9 d0ba 0104 0204 0b16
  5. # 0x0020: 3208 0c12 1824 3048 606c 0301 072d 1a2c
  6. # 0x0030: 0103 ff00 0000 0000 0000 0000 0000 0000
  7. # 0x0040: 0000 0000 0000 0000 00dd 0700 50f2 0800
  8. # 0x0050: 5400
  9.  
  10. #use strict;
  11.  
  12. sub capture {
  13. my $iface = shift;
  14. my %hashes;
  15. open my $fd, "tcpdump -lnxi $iface subtype probe-req |" or die $!;
  16. my @bytes;
  17. while (<$fd>) {
  18. if (/^\s*(0x\w+):\s+(.+)/) {
  19. push @bytes, hex($_) for $2 =~ /\w{2}/g;
  20. }
  21. elsif (@bytes) {
  22. shift @bytes;
  23. my $essid_length = shift @bytes;
  24. next unless $essid_length;
  25. my $essid = join '', map chr, @bytes[0 .. $essid_length - 1];
  26. unless ($hashes{$essid}) {
  27. $hashes{$essid} = 1;
  28. print "$essid\n";
  29. }
  30. @bytes = ();
  31. }
  32. }
  33. close $fd;
  34.  
  35. }
  36.  
  37. $| = 1;
  38. my $iface = @ARGV ? $ARGV[0] : 'wlan0';
  39. capture($iface);
  40.  
  41.  
Runtime error #stdin #stdout #stderr 0.26s 84060KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
===SORRY!=== Error while compiling /home/iHQdBd/prog.pl
Unsupported use of =~ to do pattern matching; in Perl 6 please use ~~
at /home/iHQdBd/prog.pl:19
------>           push @bytes, hex($_) for $2 =~⏏ /\w{2}/g;