|
本帖最后由 飞向狙沙 于 2022-5-5 16:47 编辑
如题,小姨子给宝宝买的早教故事机,价格未知,没屏幕,可连蓝牙,但是连蓝牙后只是普通音响,也没有可视菜单,故事挨个播放,所以为了宝宝健康,给宝宝使用的东西就应该先拆了弄懂原理才知道安全不安全。
材质不清楚,有点像TPU,微软
整体无螺丝,要么卡口要么就是防尘罩下,打开防尘罩四颗螺丝
就一个MP3主板+内存卡,屏幕都轮不着,卖资料钱了
--------------------------------------------------分割线---------------------------------------------------------------------
下面是程序部分
读卡器读出来是一对smp文件,一开始以为就像wmv之类的格式,转换软件转了下播放不了,搜了下发现这类数据值钱的小播放器经常会用这种格式,很多都是对数据简单异或处理的,就用winhex读了一下,部分如下
- 1A 42 86 07 1A 42 86 07 1A 42 86 07 1A 42 86 07
- 1A 42 86 07 1A 42 86 07 1A 42 86 07 1A 42 86 07
- 1A 42 86 07 1A 16 C7 40 1A 42 86 07 1A 42 86 07
复制代码 大量1A 42 86 07重复,怀疑这个就是异或的值,然后写个小程序对源文件直接处理生成mp3尝试播放,播放成功,也没什么技术含量,要是再增加一些移位交换之类的就得费点脑细胞了
解码程序放gitee了,有需要的自己克隆吧
https://gitee.com/feixiangjusha/smp-decrypt
- public class Main {
- private final static String sourceExt = "smp";
- private final static String saveExt = "mp3";
- public static void main(String[] args) throws IOException {
- //加密字符串
- byte[] key;
- //文件所在根文件夹
- File root;
- List<String> filePath = new LinkedList<String>();
- Scanner scanner = new Scanner(System.in);
- //获取文件根目录
- System.out.println("请输入smp文件根目录,支持深度检索");
- do {
- String rootPath = scanner.nextLine();
- root = new File(rootPath);
- if (!root.exists() || !root.isDirectory()) {
- System.out.println("根目录错误,请重新输入");
- continue;
- }
- break;
- } while (true);
- //检索文件
- System.out.println("开始检索文件");
- List<File> files = deptScanFiles(root);
- System.out.println("检索到" + files.size() + "个文件");
- for (int i = 0; i < files.size(); i++) {
- System.out.print("[" + (i + 1) + "] ");
- System.out.println(files.get(i));
- }
- do {
- System.out.println("直接回车进行下一步,或者输入文件序号查看文件hex");
- String temp = "0" + scanner.nextLine().trim();
- Integer tempI = Integer.valueOf(temp);
- if (tempI > files.size() || tempI < 0) {
- System.out.println("输入异常,请重新输入");
- continue;
- }
- if (tempI.equals(0)) {
- break;
- }
- String savePath = saveFile2Hex(files.get(tempI - 1));
- System.out.println("文件已保存到" + savePath);
- } while (true);
- //设置加密信息
- System.out.println("请输入16进制加密信息,如:1A 2B 3C");
- do {
- String tempKey = scanner.nextLine().toUpperCase(Locale.ROOT);
- if (tempKey == null || tempKey == "") {
- System.out.println("请输入16进制加密信息");
- continue;
- }
- //判断16进制
- String regex = "^[A-Fa-f0-9 ]+$";
- if (tempKey.matches(regex)) {
- String[] ks = tempKey.split(" ");
- key = new byte[ks.length];
- for (int i = 0; i < ks.length; i++) {
- key[i] = (byte) Integer.parseInt(ks[i], 16);
- }
- break;
- } else {
- System.out.println("不是16进制,请重新输入");
- continue;
- }
- } while (true);
- //读取smp文件字符串,对key再进行异或后保存成MP3
- for (File file : files) {
- byte[] bytes = readFile2Byte(file);
- decrypt(bytes, key);
- saveBytes2File(bytes, new File(file.getParent(), file.getName().substring(0, file.getName().indexOf(".") + 1) + saveExt).getAbsolutePath());
- System.out.println(String.format("文件%s已处理", file.getAbsolutePath()));
- }
- System.out.println("处理完成");
- }
- /**
- * 深度扫描smp文件
- *
- * @param root
- * @return
- */
- public static List<File> deptScanFiles(File root) {
- if (!root.exists()) {
- return null;
- }
- if (root.isFile()) {
- String fileExtension = getFileExtension(root);
- if (sourceExt.equals(fileExtension)) {
- return new LinkedList<File>() {{
- add(root);
- }};
- } else {
- return new LinkedList<File>();
- }
- } else if (root.isDirectory()) {
- LinkedList<File> files = new LinkedList<>();
- for (File file : root.listFiles()) {
- files.addAll(deptScanFiles(file));
- }
- return files;
- } else {
- return new LinkedList<File>();
- }
- }
- /**
- * 获取文件后缀
- *
- * @param file
- * @return
- */
- public static String getFileExtension(File file) {
- String fileName = file.getName().toLowerCase(Locale.ROOT);
- if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) {
- return fileName.substring(fileName.lastIndexOf(".") + 1);
- } else {
- return "";
- }
- }
- /**
- * 按照
- *
- * @param file
- * @return
- * @throws IOException
- */
- public static byte[] readFile2Byte(File file) throws IOException {
- FileInputStream fin = new FileInputStream(file);
- int len = fin.available();
- byte[] temp = new byte[len];
- fin.read(temp);
- return temp;
- }
- /**
- * 解密
- *
- * @param source
- * @param keys
- */
- public static void decrypt(byte[] source, byte[] keys) {
- int idx = 0;
- for (int i = 0; i < source.length; i++) {
- source[i] ^= keys[i % keys.length];
- }
- }
- /**
- * 按16进制保存文件
- *
- * @param file
- * @return
- * @throws IOException
- */
- public static String saveFile2Hex(File file) throws IOException {
- String savePath = file.getAbsolutePath() + ".hex.txt";
- // System.out.println(System.currentTimeMillis());
- byte[] bytes = readFile2Byte(file);
- StringWriter sw = new StringWriter();
- int currentLen = 0;
- for (int i = 0; i < bytes.length; i++) {
- currentLen += 1;
- if (bytes[i] >= 0x0) {
- sw.write(String.format("%02x", bytes[i]).toUpperCase(Locale.ROOT));
- } else {
- sw.write(Integer.toHexString(bytes[i]).substring(6).toUpperCase(Locale.ROOT));
- }
- sw.write(" ");
- if (currentLen >= 16) {
- currentLen = 0;
- sw.write("\r\n");
- }
- }
- // System.out.println(System.currentTimeMillis());
- Files.write(Paths.get(savePath), bytes);
- // System.out.println(System.currentTimeMillis());
- return savePath;
- }
- public static boolean saveBytes2File(byte[] bytes, String filePath) throws IOException {
- // System.out.println(System.currentTimeMillis());
- Files.write(Paths.get(filePath), bytes);
- // System.out.println(System.currentTimeMillis());
- return true;
- }
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
打赏
-
查看全部打赏
|