#!/usr/bin/perl # # Just a simple Bluetooth Vcard Uploader # Scans for Bluetooth devices and uploads a Vcard via OPUSH # See http://www.saunalahti.fi/~laakkon1/linux/3650_blue.php # to set up ussp-push # NOTE: You maybe have to edit the config below! # # Programmed by Bastian Ballmann @ 20C3 # Last update: 28.12.2003 # # This program is free software; you can redistribute # it and/or modify it under the terms of the # GNU General Public License version 2 as published # by the Free Software Foundation. # # This program is distributed in the hope that it will # be useful, but WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. ###[ Config ]### $hcitool="/usr/bin/hcitool"; $sdptool="/usr/bin/sdptool"; $rfcomm="/bin/rfcomm"; $push_file="/usr/bin/ussp-push"; $infile="dein_handy_stinkt.vcf"; $outfile="dein_handy_stinkt.vcf"; ###[ Main part ]### $count = 0; print "Scanning for bluetooth devices...\n"; open(HCI,"$hcitool scan|") or die "$!\n"; while() { @tmp = split(/\s/,$_); for(@tmp) { next if $_ =~ /Scanning/; if($_ =~ /\w\w\:\w\w\:\w\w\:\w\w\:\w\w\:\w\w/) { $addr = $_; } elsif($_ =~ /\w+$/) { $host = $_; } } if( ($host ne "") && ($addr ne "") ) { print "Found host $host addr $addr\n"; print "Scanning available services...\n"; open(OUT,">$host"); open(SDP,"$sdptool browse $addr|"); $flag = 0; while() { print OUT $_ if OUT; if($_ =~ /Service Name\: OBEX Object Push/) { $flag = 1; } if( ($flag == 1) && ($_ =~ /Channel\:\s(\d+)/) ) { $channel = $1; print "OBEX Object Push found on channel $channel\n"; system("$rfcomm bind $count $addr $channel"); system("$push_file /dev/rfcomm$count $infile $outfile"); system("$rfcomm release $count $channel"); $flag = 0; $count++; } } close(SDP); close(OUT) if OUT; } } close(HCI); print "Done\n\n";