「Switch 无线传输工具 - ftpsrv」介绍及使用

介绍

ftpsrv是ITotalJustice开发的ftp单线程无线传输工具,
支持的命令控制, 由c语言编写, 具有速度快, 内存占用小等特点.
已支持switch, wii, 3ds, ds等平台.

有系统后台和相册工具两种形式, 可以独立运行,

使用须知

配置

安装模块

  • 打开 Updater > Misc > SysModules > sys-ftp > ftpsrv - Install

  • 安装完成之后重启NS生效

  • 打开 Updater > Misc > NROs > ftpsrv > Install

连接ftp服务器

  • 连接wifi
  • 打开设置 > 互联网 > IP地址: 记录地址信息
  • 电脑操作
    • 在搜索栏上输入ftp://刚才的IP地址:端口, 例如: 192.168.x.x:21
    • 弹窗之后, 选择匿名登陆进入SD卡根目录
    • 可以收藏这个路径, 后续只要NS联网了就可以直接访问
  • 手机操作
    • 安装FTP管理app, 输入ftp://刚才的IP地址:端口, 就可以从手机上访问了
    • iOS: FTPManager
    • 安卓: 我没安卓手机, 谁送我华为奏折机, 我研究一下😊

配置ftpsrv

  • 打开sd卡根目录下的/config/ftpsrv/config.ini.template, 复制并改名为config.ini

##########
# ftpsrv #
##########

#######################################################################
# Rename config.ini.template to config.ini for changes to take effect.#
#######################################################################

[Login]
# disabled by default, do not enable if using ldn_mitm as
# it's a security risk - you have been warned!
# 1: 开启
# 0: 关闭
# 匿名登陆
anon = 0

# if anon is disabled, then user and pass must be set.
# 不使用匿名登陆的时候, 需要把前面的分号删掉, 并填写好
# user = 用户名
# pass = 登陆密码
; user =
; pass =

[Network]
# ports to be opened (< 1024), however, port 21 works fine for me...
# 传输端口, 可以使用5000, 和其他sftp工具统一.
port = 21

# timeout in seconds until a session is closed.
# if 0, then no timeout is set.
# it is recommended to set this to an actual value, eg 20.
# 0: 关闭
# 其他数值是设置自动超时关闭的时间, 单位是秒
timeout = 0

[Misc]
# use local time zone over gm (UTC) time zone.
# 使用本地时间
use_localtime = 0

[Log]
# enables log output to /config/ftpsrv/log.txt
# 1: 开启
# 0: 关闭
# 调试日志, 会在本地生成日志文件, 默认关闭
log = 0

# options specific to Nintendo Switch
[Nx]
# enables showing all available mount points at root "/"
# for example, SdCard is as at "/sdmc:"
# 1: 开启
# 0: 关闭
# 根目录挂载所有可挂载的路径
mount_devices = 0

# allows save data to be writable, needs mount_devices = 1
# 1: 开启
# 0: 关闭
# 存档写入权限, 默认关闭, 避免误操作
save_writable = 0

# allows for bis partitions to be mounted, needs mount_devices = 1
# WARNING: modifying bis files can soft brick your switch!
# 1: 开启
# 0: 关闭
# 开启bis文件挂载
mount_bis = 0

# uncomment to override the port for application
# 应用程序端口, 覆盖默认端口设置
# app_port = 21

# uncomment to override the port for sysmode
# 系统后台模块端口, 覆盖默认端口设置
# sys_port = 21

# enables led on the controller to light flash
# 1: 开启
# 0: 关闭
# 传输时候手柄上的HOME键闪烁
led = 0

# options specific to Nintendo Switch App
# 指定自制应用的设置
[Nx-App]
; anon = 0
; user = ""
; pass = ""
; port = 21
; timeout = 0
; use_localtime = 0
; log = 0
; mount_devices = 0
; save_writable = 0
; mount_bis = 0
; led = 0

# options specific to Nintendo Switch Sysmodule
# 指定系统模块的设置
[Nx-Sys]
; anon = 0
; user = ""
; pass = ""
; port = 21
; timeout = 0
; use_localtime = 0
; log = 0
; mount_devices = 0
; save_writable = 0
; mount_bis = 0
; led = 0


关闭模块

  • 打开相册工具 > Hekate Toolbox
  • 打开Background services > sys-ftp: On 设置成 Off
远程命令

远程命令

Nx Custom Commands
  Custom commands were added to extend the features beyond just transferring files.

  Examples below use ltfp as i found that more suitable for a single one shot command with output.
  You can however use any cli / gui client as all have support for custom commands, usually named as "quote" or "custom commands".

格式: lftp -e "quote 命令`;quit" IP地址


REBT (Reboot console)
  重启switch
  parameters: none.
  example: lftp -e "quote REBT;quit" 192.168.1.71


RTOP (Reboot to payload)
  仅限初代, 重启到Payloads
  parameters: /bootloader/update.bin路径.
  example: lftp -e "quote RTOP /bootloader/update.bin;quit" 192.168.1.71


RTOH (Reboot to hekate)
  重启到Hekate菜单选项:
  0. 重启到payloads, 同RTOP
  1. 重启到引导引导名称(自行替换My Config Name) .
  2. 重启到菜单
  3. 重启到UMS挂载.

  example 0: lftp -e "quote RTOH 0;quit" 192.168.1.71
  example 1: lftp -e "quote RTOH 1 My Config Name;quit" 192.168.1.71
  example 2: lftp -e "quote RTOH 2;quit" 192.168.1.71
  example 3: lftp -e "quote RTOH 3;quit" 192.168.1.71


SHUT (Shutdown console)
  关机
  parameters: none.
  example: lftp -e "quote SHUT;quit" 192.168.1.71


TID (List application title id)
  输出当前应用程序TID.
  parameters: none.
  example: lftp -e "quote TID;quit" 192.168.1.71

  python script自动脚本, 当游戏关闭之后, 可以用来下载或者保存存档.

#!/usr/bin/python

from ftplib import FTP
from io import BytesIO
# pip install python-slugify
from slugify import slugify
import argparse
import time

parser = argparse.ArgumentParser()
parser.add_argument("--ip", required=True, type=str)
parser.add_argument("--username", required=False, default="", type=str)
parser.add_argument("--password", required=False, default="", type=str)
parser.add_argument("--poll", required=False, default=1, type=int)
args = parser.parse_args()

# replace this with your account id that you want to sync with, do LIST /save:/ to see all IDS
ACC_ID = "1000000057CF2FD9BDF4A201A84F639A"
IP = args.ip
USERNAME = args.username
PASSWORD = args.password
POLLRATE = args.poll

cur_tid = ""
cur_name = ""

def poll_ftp(ftp: FTP):
    global cur_tid, cur_name
    res = ftp.sendcmd("tid")
    sp = res.split(' ', 2)

    new_tid = cur_tid
    new_name = ""

    # code = sp[0], tid = sp[1], name = [2]
    new_tid = sp[1]
    if len(sp) > 2:
        new_name = sp[2]
    else:
        new_name = ""

    if cur_tid != new_tid:
        # keep copy of old id / save
        prev_tid = cur_tid
        prev_name = cur_name

        # set new id / name
        cur_tid = new_tid
        cur_name = new_name

        #
        if prev_tid != "" and prev_tid != "0100000000001000":
            buffer = BytesIO()
            cmd = "RETR /save:/" + "[" + ACC_ID + "]/zips/" + "[" + prev_tid + "].zip"
            ftp.retrbinary(cmd, buffer.write)

            filename = prev_tid
            if new_name != "":
                filename = prev_name + " " + filename
            filename = slugify(filename, allow_unicode=True, separator='_', lowercase=False)

            with open(filename + ".zip", 'wb') as f:
                f.write(buffer.getbuffer())
                print("save written to " + filename)

while True:
    try:
        with FTP(IP, USERNAME, PASSWORD) as ftp:
            while True:
                poll_ftp(ftp)
                time.sleep(POLLRATE)
    except Exception as inst:
        print("An exception occurred " + str(inst))

    time.sleep(POLLRATE)

TIDS (List all title ids)
  输出所有应用程序TID.
  parameters: none.
  example: lftp -e "quote TIDS;quit" 192.168.1.71


TRMT (Terminate title id)
  终止指定的TID程序.
  parameters: tid.
  example: lftp -e "quote TRMT 420000000007E51A;quit" 192.168.1.71

注意事项

  • 部分系统文件不允许覆盖和移动
  • 不要通过ftpsrv直接修改sd卡里的文件, 复制到电脑上修改好再覆盖回去
posted @ 2024-12-02 15:42  WE1ZARD  阅读(836)  评论(0)    收藏  举报