From 165f4791f2fc2e725ed4fbd9c80df2abbc84116d Mon Sep 17 00:00:00 2001 From: Xu Zhaowei Date: Sat, 14 Aug 2021 14:01:14 +0800 Subject: [PATCH] fix --- README.md | 3 +++ mitool.c | 47 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e43efc1..9e30c4b 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,6 @@ show password only `/tmp/mitool password` +show model only + +`/tmp/mitool model` diff --git a/mitool.c b/mitool.c index 4b4d33c..e7c4e21 100644 --- a/mitool.c +++ b/mitool.c @@ -15,8 +15,23 @@ #include #define BUFSIZE 65532 - +struct model_s { + char *pid; + char *model; +}; + +static const struct model_s model_list[] = { + { "RA67", "AX5" },//redmi + { "RA69", "AX6" },//redmi + { "RA70", "AX9000" },//xiaomi + { "RA72", "AX6000" },//xiaomi + { "RA81", "AX3000" },//redmi + { "RM1800", "AX1800" },//xiaomi + { "R1800", "AX1800" },//xiaomi + { "R3600", "AX3600" },//xiaomi + { NULL, NULL }, +}; typedef struct { @@ -450,15 +465,28 @@ static int lock_mtd(int t) } +char *get_model(char *pid) +{ + char *model = "unknown"; + const struct model_s *p; + + for (p = &model_list[0]; p->pid; ++p) { + if (!strcmp(pid, p->pid)) { + model = p->model; + break; + } + } + return model; +} + static int model_show(void) { - int i,j; - unsigned char model[]="model"; + int i; + if(load_buf()<0) return -1; - memset(buf, 0, sizeof(buf)); - i = GetSubStrPos(buf,model); - printf("%s\n",buf); + i = GetSubStrPos(buf,"model"); + printf("model=%s\n", get_model(&buf[i+6])); } static int password_show(void) @@ -495,12 +523,11 @@ static int calc_img_crc() unsigned char c[]="ssh_en"; unsigned char c1[]="telnet_en"; unsigned char c2[]="uart_en"; - unsigned char c3[]="model"; if(load_buf()<0) return -1; - i = GetSubStrPos(buf,c3); - printf("%s\n",buf); + i = GetSubStrPos(buf,"model"); + printf("model=%s\n", get_model(&buf[i+6])); i = GetSubStrPos(buf,c); printf("get ssh_en=%c",buf[i+7]); buf[i+7]='1';//ssh @@ -553,7 +580,7 @@ int main(int argc, char **argv) else if (!strcmp(argv[1], "password")){ password_show(); printf("ssh default usesrname:root password:%s\n",password); - else if (!strcmp(argv[1], "model")){ + } else if (!strcmp(argv[1], "model")){ model_show(); } else usage();