iPhone通过Shortcut(捷径)将验证码短信发送到Windows/macOS电脑 图标

iPhone通过Shortcut(捷径)将验证码短信发送到Windows/macOS电脑

1258 次浏览 分类:安卓软件
网址
分类
收录时间
2026-07-24 08:21

数据统计

1258 浏览量
0 评论数
2026-07-24 收录时间
2026-07-24 更新时间
<
功能说明
通过 IOS Shortcut的Automation功能,在收到验证码短信的时候,解析数字验证码,并将其发送到【同 wifi 网络下】电脑(windows/macos)的监听服务中,程序会自动复制到系统剪切板,我们只需要ctrl + v粘贴就可以了。

如果你使用mac,可以不用看了,你可以通过iphone message 自带的 Text Message Forwarding功能,在mac上直接看到验证码。但是我不喜欢这个功能,因为它会把所有的短信都转发,有泄露隐私的风险。

写在前面(为什么做这个)
最近被气死!
重装了windows系统,在重新登陆很多网站的时候发现即使输入了账户密码,网站还是要求要验证码验证。 要不停在手机和电脑屏幕间切换,一下子就把想专注工作的心思打碎了。
为了避免下次重装再被气死,也方便有同样需求的网友,于是就有了这个帖子,因为最近在学习rust,所以这个算是用rust写的练手项目。

如何使用
1. 安装我的工作流(https://www.icloud.com/shortcuts/750e2f275d464e9da34812eabc289d74)或者看图自己设置:
iPhone通过Shortcut(捷径)将验证码短信发送到Windows/macOS电脑
2.  让iPhone和电脑连接同个网络(wifi);
3. 在电脑运行我的程序 sms_notification,sms_notification 使用 rust 编写:你根据平台可以下载附件中的【macOS版本】或【Windows版本】并运行(默认端口8080,当然你也可以在启动程序时传入不同的端口号):
包含mac和windows链接:
当然,你也可以下载代码自行编译【源码和cargo.toml】然后运行;
4. 在运行 sms_notification 的电脑获取电脑的局域网ip(比如 192.168.3.232):Windows: 使用命令 ipconfig /all 找到本地 ipv4 地址;macOS: 使用命令 ifconfig -a 找到本地 ipv4 地址;修改【工作流】中的 Text 中 网址部分的 ip;
5. 找个发送短信的网页(比如豆包)尝试验证码登陆;
效果展示

源码
如需自行编译,请使用cargo新建一个项目,并使用下方代码替换你的main.rs, cargo.toml。然后使用命令 cargo build --release编译release版本
main.rs
use clap::Parser;use tracing::{info, error};use tokio::sync::mpsc;use std::convert::Infallible;use warp::Filter;#[derive(Parser, Debug)]#[command(name = "sms_notification")]#[command(about = "HTTP server that copies SMS to clipboard and shows notifications")]struct Args {    #[arg(short, long, default_value_t = 8080)]    port: u16,}#[derive(Clone)]struct AppState {    sms_tx: mpsc::Sender<String>,}async fn handle_sms(    query: std::collections::HashMap<String, String>,    state: AppState,) -> Result<impl warp::Reply, Infallible> {    if let Some(sms) = query.get("sms") {        let sms_clone = sms.clone();        if state.sms_tx.send(sms_clone).await.is_err() {            error!("Failed to send SMS to notification handler");        }        info!("Received SMS: {}", sms);        println!("sms: {}", sms);        Ok(warp::reply::html(format!("SMS received: {}", sms)))    } else {        Ok(warp::reply::html("Usage: GET /?sms=<message>".to_string()))    }}async fn start_http_server(port: u16, sms_tx: mpsc::Sender<String>) {    let state = AppState { sms_tx };    let route = warp::path::end()        .and(warp::get())        .and(warp::query::<std::collections::HashMap<String, String>>())        .and(with_state(state))        .and_then(handle_sms);    let (_, server) = warp::serve(route)        .bind_with_graceful_shutdown(([0, 0, 0, 0], port), async {            tokio::time::sleep(tokio::time::Duration::MAX).await        });    info!("HTTP server listening on port {}", port);    server.await;}fn with_state(state: AppState) -> impl Filter<Extract = (AppState,), Error = Infallible> + Clone {    warp::any().map(move || state.clone())}fn copy_to_clipboard(text: &str) -> bool {    match arboard::Clipboard::new() {        Ok(mut clipboard) => {            match clipboard.set_text(text) {                Ok(_) => {                    info!("Copied to clipboard: {}", text);                    true                }                Err(e) => {                    error!("Failed to set clipboard: {:?}", e);                    false                }            }        }        Err(e) => {            error!("Failed to open clipboard: {:?}", e);            false        }    }}fn show_dialog(title: &str, body: &str) {    let result = rfd::MessageDialog::new()        .set_title(title)        .set_description(body)        .show();    if !result {        error!("Failed to show dialog: show() returned false");    } else {        info!("Dialog shown: {} - {}", title, body);    }}fn main() {    // Parse CLI    let args = Args::parse();    // Setup logging to file + stdout    let log_file = std::fs::File::create("sms_notification.log").unwrap();    let (non_blocking, _guard) = tracing_appender::non_blocking(log_file);    tracing_subscriber::fmt()        .with_writer(non_blocking)        .with_ansi(false)        .init();    info!("SMS Notification App starting on port {}", args.port);    // Shared state for last SMS (for tray click -> clipboard)    use std::sync::Arc;    use tokio::sync::Mutex;    let last_sms = Arc::new(Mutex::new(String::new()));    let (sms_tx, mut sms_rx) = mpsc::channel::<String>(100);    // Clipboard channel receiver — runs in background thread    let last_sms_for_receiver = last_sms.clone();    std::thread::spawn(move || {        let rt = tokio::runtime::Runtime::new().unwrap();        rt.block_on(async {            while let Some(sms) = sms_rx.recv().await {                *last_sms_for_receiver.lock().await = sms.clone();                copy_to_clipboard(&sms);                // Show notification in a separate thread to avoid blocking the receiver                let sms_for_notify = sms.clone();                std::thread::spawn(move || {                    show_dialog("SMS Received", &sms_for_notify);                });            }        });    });    // Spawn HTTP server    let http_port = args.port;    let sms_tx_clone = sms_tx.clone();    std::thread::spawn(move || {        let rt = tokio::runtime::Runtime::new().unwrap();        rt.block_on(start_http_server(http_port, sms_tx_clone));    });    // Build SystemTray with menu    use tao::{        menu::{ContextMenu, MenuItemAttributes, MenuId},        system_tray::{SystemTrayBuilder, Icon},        event_loop::{EventLoop, ControlFlow, EventLoopWindowTarget},    };    // Create a simple 1x1 icon (solid color)    let icon_data = vec![0u8; 4]; // RGBA: all zeros = transparent black    let icon = Icon::from_rgba(icon_data, 1, 1).expect("Failed to create icon");    // Build context menu    let mut menu = ContextMenu::new();    let about_item = MenuItemAttributes::new("About")        .with_id(MenuId::new("about"));    let log_item = MenuItemAttributes::new("Log")        .with_id(MenuId::new("log"));    let exit_item = MenuItemAttributes::new("Exit")        .with_id(MenuId::new("exit"));    menu.add_item(about_item);    menu.add_item(log_item);    menu.add_item(exit_item);    // Create EventLoop and build SystemTray    let event_loop: EventLoop<()> = EventLoop::new();    let window_target: &EventLoopWindowTarget<()> = &event_loop;    let _system_tray = SystemTrayBuilder::new(icon, Some(menu))        .with_tooltip("SMS Notification")        .build(window_target)        .expect("Failed to build system tray");    let last_sms_for_tray = last_sms.clone();    event_loop.run(move |event, _, control_flow| {        use tao::event::Event;        use tao::event::TrayEvent as TrayEventType;        match event {            Event::TrayEvent { event: TrayEventType::LeftClick, .. } => {                // Tray icon left click - copy last SMS to clipboard                let last = last_sms_for_tray.clone();                std::thread::spawn(move || {                    let rt = tokio::runtime::Runtime::new().unwrap();                    rt.block_on(async {                        let sms = last.lock().await;                        if !sms.is_empty() {                            copy_to_clipboard(&sms);                            show_dialog("SMS Copied", &sms);                        }                    });                });            }            Event::MenuEvent { menu_id, .. } => {                // Menu item clicked - compare by creating MenuId from same strings                let about_id = MenuId::new("about");                let log_id = MenuId::new("log");                let exit_id = MenuId::new("exit");                if menu_id == about_id {                    let about_text = format!("SMS Notification App\nVersion 0.1.0\nPort: {}", args.port);                    std::thread::spawn(move || {                        show_dialog("About SMS Notification", &about_text);                    });                } else if menu_id == log_id {                    std::thread::spawn(move || {                        if let Ok(log_content) = std::fs::read_to_string("sms_notification.log") {                            let lines: Vec<&str> = log_content.lines().rev().take(20).collect();                            show_dialog("Recent Logs", &lines.join("\n"));                        } else {                            show_dialog("Logs", "No logs found.");                        }                    });                } else if menu_id == exit_id {                    std::process::exit(0);                }            }            _ => {}        }        *control_flow = ControlFlow::Wait;    });}复制代码
cargo.toml
[package]name = "sms_notification"version = "0.1.0"edition = "2021" [dependencies]tokio = { version = "1", features = ["full"] }warp = "0.3"tao = { version = "0.18", features = ["tray"] }arboard = "3"tracing = "0.1"tracing-subscriber = { version = "0.3", features = ["env-filter"] }tracing-appender = "0.2"clap = { version = "4", features = ["derive"] }rfd = "0.11" [profile.release]strip = truelto = true复制代码


原子助手_v2.1.0 VPN破解版 图标

原子助手_v2.1.0 VPN破解版

老牌加速器,已去除所有广告,解锁加速包节点,时长固定为24小时实测稳定性还不错,速度还行。如遇不稳定可考虑本频道机场下载地址
今日水印相机v4.2.7会员版 自定义地址 打卡记录 图标

今日水印相机v4.2.7会员版 自定义地址 打卡记录

软件名称:今日水印相机软件版本:4.2.7软件大小:96.90M测试机型:vivo x23幻彩版软件介绍:一款真实记录“工作”和“生活”的水印拍照,拥有专业的水印模板,适用于:工作拍照留痕、团队考勤打卡、工程施工管理、外勤拍照、综合执法执勤、取证拍照、旅行拍照、宝宝成长记录、记录美好生活等场景!下载地址 :夸克:https://pan.quark.cn/s/6d0a68937385转存后下载&nbsp;&nbsp;防止链接和谐今日水印相机打卡记录本主题由 任务系统 于&nbsp;11&nbsp;
鲍鱼盒子 _5.0.11破解版 图标

鲍鱼盒子 _5.0.11破解版

文章摘要为避免网盘失效,文件已被加密【解密教程点这里】解密密码:58zhainan解密后可正常安装使用,无需多余操作下载地址
3A射击游戏二改开源 图标

3A射击游戏二改开源

3A射击游戏二改开源一款二开国外大佬项目在浏览器里直接运行的 3D 第一人称射击游戏,打开网址就能玩,不用下载。新增内容:1.添加四张地图:盐线码头、盐仓、盐运七号货轮和盐泵站,场景布局和敌人配置各不相同2.支持 4 人开房间联机合作,大厅还有世界频道可以实时聊天。3.添加了后台用户管理天空、海水、集装箱、枪械、音效全部由代码在浏览器里实时生成,不加载任何图片或音频素材。因为不依赖资源服务器,所以复制一个文件就能跑。桌面端用键鼠操作,手机上左半屏拖动移动、右半屏滑动转视角,会自动提示横屏全屏。&
MMSpace1.3(安卓端的鸿蒙虚拟机) 图标

MMSpace1.3(安卓端的鸿蒙虚拟机)

MMSpace内置OpenHarmony系统,安卓手机安装即可体验鸿蒙。可新建、克隆虚拟机,自定义屏幕参数,共享手机传感器,文件双向互传。手机扫码转存下载更快哦!
软件投稿:【步数助手pro】1.0 自定义步数 装X必备 图标

软件投稿:【步数助手pro】1.0 自定义步数 装X必备

【软件名称】:步数助手pro【软件版本】:1.0【软件大小】:15.34M【软件包名】:com.StepAssistantProapps【测试系统】:小米【使用说明】:一款步数小工具App,自定义步数,个性化数据! 提供同步步数功能,让你自定义步数数据,满足个性化需求。 界面简洁,操作便捷,是你的数据小助手。【下载地址】:
评论
还没有评论,来发表第一条吧。
发表评论