前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >PyFlipper:一款功能强大的Flipper Zero命令行接口封装器

PyFlipper:一款功能强大的Flipper Zero命令行接口封装器

作者头像
FB客服
发布2022-11-14 15:26:55
2.3K0
发布2022-11-14 15:26:55
举报
文章被收录于专栏:FreeBuf

关于PyFlipper

PyFlipper是一款功能强大的Flipper Zero命令行接口封装器,该工具基于纯Python开发,因此具备良好的跨平台特性。

Flipper Zero介绍

Flipper Zero是一种类似于Tamagotchi的小工具,Flipper Zero是开源的并可自定义的,您可以插入其他硬件以获取更多帮助。您可以通过蓝牙将其连接到手机或其他设备,也可以插入MicroSD卡以扩展存储并添加自己的插件。Flipper Zero还具有GPIO和USB端口,可将其连接到其他硬件。

尽管体积小巧,外观简洁,但Flipper Zero实际上配备了多种用于黑客的工具。您有用于模拟遥控器的无线电,RFID阅读器,红外收发器,甚至是GPIO引脚。所有这些尺寸都适合您的口袋,而且设计不会引起太多关注。

功能介绍

1、提供Flipper串口命令行接口封装器; 2、提供Websocket客户端界面;

工具下载

该工具基于Python 3开发,因此广大研究人员首先需要在本地设备上安装并配置好Python 3环境。接下来,使用下列命令将该项目源码克隆至本地,并完成工具的虚拟环境配置:

代码语言:javascript
复制
代码语言:javascript
复制
$ git clone https://github.com/wh00hw/pyFlipper.git
$ cd pyFlipper
$ python3 -m venv venv
$ source venv/bin/activate
代码语言:javascript
复制

(向右滑动,查看更多)

然后使用项目提供的requirements.txt文件安装该工具所需的依赖组件:

代码语言:javascript
复制
代码语言:javascript
复制
$ pip install -r requirements.txt
代码语言:javascript
复制

测试平台

当前版本的PyFlipper已在下列平台和Python版本环境中进行过测试:

1、Python v3.8.10 + Linux 5.1.0 x86_64 2、Python 3.9.10 + Windows 10 3、Python 3.10.5 + Android 12 (Termux + OTGSerial2WebSocket,无需ROOT)

工具使用

连接

代码语言:javascript
复制
from pyflipper import PyFlipper
#本地串口号
flipper = PyFlipper(com="/dev/ttyACM0")
#或者
#远程serial2websocket服务器
flipper = PyFlipper(ws="ws://192.168.1.5:1337")
(向右滑动,查看更多)

电源

代码语言:javascript
复制
#电源信息
info = flipper.power.info()
#关机
flipper.power.off()
#重启
flipper.power.reboot()
#重启进入DFU模式
flipper.power.reboot2dfu()
代码语言:javascript
复制

更新/备份

代码语言:javascript
复制
#从.fuf文件安装更新
flipper.update.install(fuf_file="/ext/update.fuf")
#将Flipper备份至.tar文件
flipper.update.backup(dest_tar_file="/ext/backup.tar")
#从.tar备份文件恢复Flipper
flipper.update.restore(bak_tar_file="/ext/backup.tar")
(向右滑动,查看更多)

加载器

代码语言:javascript
复制
#查看已安装程序列表
apps = flipper.loader.list()
#打开App
flipper.loader.open(app_name="Clock")

Flipper信息

代码语言:javascript
复制
#获取Flipper日期
date = flipper.date.date()
#获取Flipper时间戳
timestamp = flipper.date.timestamp()
#获取进程列表
ps = flipper.ps.list()
#获取设备信息
device_info = flipper.device_info.info()
#获取堆信息
heap = flipper.free.info()
#获取free_blocks字符串
free_blocks = flipper.free.blocks()
#获取蓝牙信息
bt_info = flipper.bt.info()

存储

文件系统信息

代码语言:javascript
复制
#获取文件系统存储信息
ext_info = flipper.storage.info(fs="/ext")
代码语言:javascript
复制

资源管理器

代码语言:javascript
复制
#获取存储/ext目录
ext_list = flipper.storage.list(path="/ext")
#获取存储/ext树目录
ext_tree = flipper.storage.tree(path="/ext")
#获取文件信息
file_info = flipper.storage.stat(file="/ext/foo/bar.txt")
#创建目录
flipper.storage.mkdir(new_dir="/ext/foo")
(向右滑动,查看更多)

文件

代码语言:javascript
复制
#读取文件
plain_text = flipper.storage.read(file="/ext/foo/bar.txt")
#删除文件 
flipper.storage.remove(file="/ext/foo/bar.txt")
#复制文件
flipper.storage.copy(src="/ext/foo/source.txt", dest="/ext/bar/destination.txt")
#重命名文件 
flipper.storage.rename(file="/ext/foo/bar.txt", new_file="/ext/foo/rab.txt")
#MD5哈希文件 
md5_hash = flipper.storage.md5(file="/ext/foo/bar.txt")
#写入文件
file = "/ext/bar.txt"
text = """There are many variations of passages of Lorem Ipsum available,
but the majority have suffered alteration in some form, by injected humour,
or randomised words which don't look even slightly believable.
If you are going to use a passage of Lorem Ipsum,
you need to be sure there isn't anything embarrassing hidden in the middle of text.
"""
flipper.storage.write.file(file, text)
#使用监听器写入文件
file = "/ext/foo.txt"
text_one = """There are many variations of passages of Lorem Ipsum available,
but the majority have suffered alteration in some form, by injected humour,
or randomised words which don't look even slightly believable.
If you are going to use a passage of Lorem Ipsum,
you need to be sure there isn't anything embarrassing hidden in the middle of text.
"""
flipper.storage.write.start(file)
time.sleep(2)
flipper.storage.write.send(text_one)
text_two = """All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as
necessary, making this the first true generator on the Internet.
 It uses a dictionary of over 200 Latin words, combined with a handful of
 model sentence structures, to generate Lorem Ipsum which looks reasonable.
The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.
"""
flipper.storage.write.send(text_two)
time.sleep(3)
#停止写入
flipper.storage.write.stop()
代码语言:javascript
复制

(向右滑动,查看更多)

LED/背光

代码语言:javascript
复制
#打开通用LED (r,b,g,bl)
flipper.led.set(led='r', value=255)
#关闭LED蓝光
flipper.led.blue(value=0)
#设置LED绿光值
flipper.led.green(value=175)
#打开背光
flipper.led.backlight_on()
#关闭背光
flipper.led.backlight_off()
#关闭LED
flipper.led.off()
代码语言:javascript
复制

震动

代码语言:javascript
复制
#开启或关闭震动功能
flipper.vibro.set(True)
#打开震动
flipper.vibro.on()
#关闭震动
flipper.vibro.off()
代码语言:javascript
复制

音乐播放器

代码语言:javascript
复制
#播放RTTTL格式音乐
rttl_song = "Littleroot Town - Pokemon:d=4,o=5,b=100:8c5,8f5,8g5,4a5,8p,8g5,8a5,8g5,8a5,8a#5,8p,4c6,8d6,8a5,8g5,8a5,8c#6,4d6,4e6,4d6,8a5,8g5,8f5,8e5,8f5,8a5,4d6,8d5,8e5,2f5,8c6,8a#5,8a#5,8a5,2f5,8d6,8a5,8a5,8g5,2f5,8p,8f5,8d5,8f5,8e5,4e5,8f5,8g5"
#循环播放
flipper.music_player.play(rtttl_code=rttl_song)
#停止循环播放
flipper.music_player.stop()
#播放20秒
flipper.music_player.play(rtttl_code=rttl_song, duration=20)
#蜂鸣器
flipper.music_player.beep()
#蜂鸣器开启5秒
flipper.music_player.beep(duration=5)
(向右滑动,查看更多)

NFC

代码语言:javascript
复制
#检测NFC
nfc_detected = flipper.nfc.detect()
#模拟NFC
flipper.nfc.emulate()

RFID

代码语言:javascript
复制
#读取RFID
rfid = flipper.rfid.read()
代码语言:javascript
复制

许可证协议

本项目的开发与发布遵循MIT开源许可证协议。

项目地址

PyFlipper:https://github.com/wh00hw/pyFlipper

参考资料:

https://medium.com/@nic_whr/how-to-hack-a-restaurant-5d394be105a9 https://play.google.com/store/apps/details?id=com.wh00hw.serial2websocket

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-10-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 FreeBuf 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 关于PyFlipper
  • Flipper Zero介绍
  • 功能介绍
  • 工具下载
  • (向右滑动,查看更多)
  • 测试平台
  • 工具使用
    • 连接
      • 电源
        • 更新/备份
          • 加载器
            • Flipper信息
              • 存储
              • (向右滑动,查看更多)
                • LED/背光
                  • 震动
                    • 音乐播放器
                      • NFC
                        • RFID
                        • 许可证协议
                        • 项目地址
                        • 参考资料:
                        领券
                        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档