Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paldier committed Aug 14, 2021
1 parent 9604058 commit 165f479
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ show password only

`/tmp/mitool password`

show model only

`/tmp/mitool model`
47 changes: 37 additions & 10 deletions mitool.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,23 @@
#include <sys/stat.h>

#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
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 165f479

Please sign in to comment.