码迷,mamicode.com
首页 > 其他好文 > 详细

永不消逝的电波(二)HackRF入门:家用无线门铃信号重放

时间:2015-11-22 15:56:30      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:

0×00 前言

在第一篇文章:永不消逝的电波(一):无线电入门篇 我们了解了一下无线电的发展史以及无线电的一些物理知识,在第二篇里我们将用HackRF录制家用门铃的无线信号,然后重放门铃信号。

门铃从某宝买的,如图:

技术分享

0×01 环境搭建:

MAC下可以用gqrx和hackrf (需要有Xcode、Mac Port的支持)

sudo port install gnuradio
sudo port install hackrf
sudo port install rtl-sdr
sudo port install gr-osmosdr
sudo port install hackrf

技术分享

sudo port install gqrx

技术分享

也可以参考:在Mac上安装HackRF环境

0×02 步入正题:

安装完成以后,插入HackRF,终端执行 hackrf_info:

hackrf_info 
Found HackRF board.
Board ID Number: 2 (HackRF One)
Firmware Version: git-815d1f6
Part ID Number: 0xa000cb3c 0x00664f49
Serial Number: 0x00000000 0x00000000 0x583064c0 0x2640ad4b
#通过终端启动gqrx
gqrx

技术分享

按下遥控器,我们可以看到信号的频率在314.100000Mhz(读作:314.1兆赫兹)左右

1Mhz=1000000hz;
1Khz=1000hz

314.1Mhz=314100000hz;

关掉gqrx启动hackrf

hackrf_transfer Usage:

Usage:
    -r <filename> # Receive data into file. 把接收到的信号、数据保存到文件中;(信号录制)
    -t <filename> # Transmit data from file. 从文件中提取、发送射频信号;(信号播放)
    -w # Receive data into file with WAV header and automatic name.
       # This is for SDR# compatibility and may not work with other software.
    [-f freq_hz] # Frequency in Hz [0MHz to 7250MHz].
    [-i if_freq_hz] # Intermediate Frequency (IF) in Hz [2150MHz to 2750MHz].
    [-o lo_freq_hz] # Front-end Local Oscillator (LO) frequency in Hz [84MHz to 5400MHz].
    [-m image_reject] # Image rejection filter selection, 0=bypass, 1=low pass, 2=high pass.
    [-a amp_enable] # RX/TX RF amplifier 1=Enable, 0=Disable.
    [-p antenna_enable] # Antenna port power, 1=Enable, 0=Disable.
    [-l gain_db] # RX LNA (IF) gain, 0-40dB, 8dB steps
    [-g gain_db] # RX VGA (baseband) gain, 0-62dB, 2dB steps
    [-x gain_db] # TX VGA (IF) gain, 0-47dB, 1dB steps
    [-s sample_rate_hz] # Sample rate in Hz (8/10/12.5/16/20MHz, default 10MHz).
    [-n num_samples] # Number of samples to transfer (default is unlimited).
    [-c amplitude] # CW signal source mode, amplitude 0-127 (DC value to DAC).
    [-b baseband_filter_bw_hz] # Set baseband filter bandwidth in MHz.
    Possible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz, default < sample_rate_hz.
hackrf_transfer -r /dev/stdout -f 314100000 -a 1 -g 16 -l 32 -s 8000000

没按遥控器

技术分享

按下遥控器:

技术分享

由于hackrf_transfer后面没带解码参数,so我们看到一堆乱码数据;

0×03 录制信号&信号分析

录制遥控的无线信号:

hackrf_transfer -r door.raw -f 314100000 -g 16 -l 32 -a 1 -s 8000000 -b 4000000

终端输出:

hackrf_transfer -r door.raw -f 314100000 -g 16 -l 32 -a 1 -s 8000000 -b 4000000
call hackrf_sample_rate_set(8000000 Hz/8.000 MHz)
call hackrf_baseband_filter_bandwidth_set(3500000 Hz/3.500 MHz)
call hackrf_set_freq(314100000 Hz/314.100 MHz)
call hackrf_set_amp_enable(1)
Stop with Ctrl-C
16.0 MiB / 1.005 sec = 15.9 MiB/second
16.0 MiB / 1.003 sec = 15.9 MiB/second
16.0 MiB / 1.004 sec = 15.9 MiB/second
16.3 MiB / 1.004 sec = 16.2 MiB/second
16.0 MiB / 1.002 sec = 16.0 MiB/second
16.0 MiB / 1.001 sec = 16.0 MiB/second
16.0 MiB / 1.004 sec = 15.9 MiB/second
16.0 MiB / 1.003 sec = 15.9 MiB/second
16.3 MiB / 1.003 sec = 16.2 MiB/second
16.0 MiB / 1.003 sec = 15.9 MiB/second
16.0 MiB / 1.005 sec = 15.9 MiB/second
^CCaught signal 2
 8.1 MiB / 0.510 sec = 15.9 MiB/second

User cancel, exiting...
Total time: 11.54724 s
hackrf_stop_rx() done
hackrf_close() done
hackrf_exit() done
fclose(fd) done
exit

技术分享


信号波形分析:

这里用到的软件是Audacity,导入录制的音频信号(未压缩原始数据)

技术分享

然后出现如下界面:

技术分享

使用默认参数,直接导入:

技术分享

中间的那部分就是按下遥控时录制到的无线信号,我们使用Audacity的放大镜放大来看:

技术分享

继续放大我们可以看到:

技术分享

继续放大:

技术分享

再放大:

技术分享

这时经验比较丰富的童鞋可以通过图形,把无线射频信号转换成二进制数据:01010101**** ,接着可以把二进制写到GRC(Gnu Radio Cpmpainon),制作一个框图,使用GNC项目重放无线信号,大致方法如下:

启动Gnu Radio Cpmpainon  :Kali Linux—->无线攻击—>Software defined Radio—>GnuRadio-Companion

技术分享

源:在右侧Misc一栏找到Vector Source

技术分享

通过搜索添加Repeat(old)、Moving Average、osmocom Sink

技术分享

四个组件:

技术分享

按照流程连线:

技术分享

GNC用得不多,暂时还不上手,这种方法以后再试 :)


0×04 信号重放

使用hackrf_transfer重放信号:

hackrf_transfer -t door.raw -f 314100000 -x 47 -a 1 -s 8000000 -b 4000000

终端输出:

hackrf_transfer -t door.raw -f 314100000 -g 16 -l 32 -a 1 -s 8000000 -b 4000000
call hackrf_sample_rate_set(8000000 Hz/8.000 MHz)
call hackrf_baseband_filter_bandwidth_set(3500000 Hz/3.500 MHz)
call hackrf_set_freq(314100000 Hz/314.100 MHz)
call hackrf_set_amp_enable(1)
Stop with Ctrl-C
16.0 MiB / 1.004 sec = 15.9 MiB/second
16.0 MiB / 1.004 sec = 15.9 MiB/second
16.0 MiB / 1.003 sec = 15.9 MiB/second
16.0 MiB / 1.001 sec = 16.0 MiB/second
16.0 MiB / 1.000 sec = 16.0 MiB/second
16.3 MiB / 1.001 sec = 16.2 MiB/second
16.0 MiB / 1.003 sec = 16.0 MiB/second
16.0 MiB / 1.001 sec = 16.0 MiB/second
16.0 MiB / 1.005 sec = 15.9 MiB/second
16.0 MiB / 1.003 sec = 15.9 MiB/second
16.3 MiB / 1.003 sec = 16.2 MiB/second
 8.4 MiB / 1.004 sec =  8.4 MiB/second
 
 
Exiting... hackrf_is_streaming() result: HACKRF_ERROR_STREAMING_EXIT_CALLED (-1004)
Total time: 12.03184 s
hackrf_stop_tx() done
hackrf_close() done
hackrf_exit() done
fclose(fd) done
exit

技术分享

0×05 演示视频

熊孩子的正确使用姿势是这样的:

for i in {1..999}; do hackrf_transfer -t door.raw -f 314100000 -g 16 -l 32 -a 1 -s 8000000 -b 4000000; done

嗯,你没看错,重复播放九百九十九次 :)

0×06 参考:

Hacking fixed key remotes

Exploring Bluetooth & iBeacons – from software to radio signals and back.

中文版:HackRF嗅探蓝牙重放iBeacons信号

GNU_Radio入门_V0.99

永不消逝的电波(二)HackRF入门:家用无线门铃信号重放

标签:

原文地址:http://www.cnblogs.com/k1two2/p/4985779.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!