undefined4 main(
int
param_1,undefined4
*
param_2)
{
int
iVar1;
int
__fd;
int
iVar2;
int
iVar3;
int
iVar4;
socklen_t local_448;
sockaddr sStack1092;
undefined local_434 [
20
];
undefined auStack1056 [
1028
];
FUN_00016b3c(
*
param_2);
if
(param_1 <
2
) {
FUN_00016900(
"noodles"
);
fprintf(stderr,
"@@@@@@@@@@ NOODLES v%s START @@@@@@@@@@@@@@@@@\n"
,PTR_DAT_00036184);
}
else
{
iVar1
=
strcmp((char
*
)param_2[
1
],
"--version"
);
if
(iVar1
=
=
0
) {
puts(PTR_DAT_00036184);
return
0
;
}
FUN_00016900(
"noodles"
);
fprintf(stderr,
"@@@@@@@@@@ NOODLES v%s START @@@@@@@@@@@@@@@@@\n"
,PTR_DAT_00036184);
iVar1
=
strcmp((char
*
)param_2[
1
],
"-d"
);
if
(iVar1
=
=
0
) {
DAT_000361f0
=
1
;
}
}
FUN_00016820(
0
);
sigemptyset((sigset_t
*
)(local_434
+
0xc
));
local_434._0_4_
=
&DAT_0001284c;
local_434._4_4_
=
4
;
sigaction(
0xb
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
sigaction(
10
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
sigaction(
8
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
sigaction(
4
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
sigaction(
7
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
sigaction(
6
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
sigaction(
0x1f
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
sigaction(
0xd
,(sigaction
*
)local_434,(sigaction
*
)
0x0
);
FUN_00013d3c();
iVar1
=
FUN_00014eb8(
0x514
);
/
/
从这里开始为
1300
端口,这里的操作与上面socket操作一致。
while
(iVar1 <
1
) {
sleep(
2
);
printf(
"Failed create listen on port %d, restart ...\n"
,
0x514
);
iVar1
=
FUN_00014eb8(
0x514
);
}
FUN_00013af0(
0x514
);
FUN_00013b50();
if
(DAT_000361f0 !
=
0
) {
printf(
"noodles server listen on port <%d>\n"
,
0x514
);
}
local_448
=
0x10
;
do {
while
(__fd
=
accept(iVar1,&sStack1092,&local_448), __fd <
1
) {
/
/
监听到client
puts(
"accept err!"
);
}
iVar2
=
FUN_0001d63c(__fd,
1
);
/
/
设置opt
if
((iVar2
=
=
0
) && (iVar2
=
FUN_0001d59c(__fd,
1
), iVar2
=
=
0
)) {
memset(auStack1056,
0
,
0x400
);
do {
iVar3
=
FUN_00014dd4(__fd,auStack1056
+
iVar2,
0x400
-
iVar2,
0xffffffff
);
/
/
获取从client传进来的内容
if
(iVar3 <
0
) {
/
/
断开
printf(
"client <%d> recv failed\n"
,__fd);
break
;
}
if
(DAT_000361f0 !
=
0
) {
printf(
"receive_cmd from client<%d>: <%s> len = %d\n"
,__fd,auStack1056,iVar3);
}
iVar4
=
canshuchuli(auStack1056,
"UPGRADE"
,
0
);
/
/
注意这个函数,是处理参数,获取<upgrade><
/
upgrade>中的内容,如果匹配则执行相关内容
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
1
,auStack1056);
}
FUN_00013b64();
FUN_000146f4(__fd,auStack1056);
/
/
使用这个来进行具体功能分析
FUN_00013b50();
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"BURNMAC"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
2
,auStack1056);
}
FUN_00013d80(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"ELFEXEC"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
3
,auStack1056);
}
FUN_000127e8(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"SYSTEM"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
4
,auStack1056);
}
FUN_000140b4(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"SYSTEMEX"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
5
,auStack1056);
}
FUN_00014308(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"DOWNLOAD"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
6
,auStack1056);
}
FUN_000145bc(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"UPLOAD"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
7
,auStack1056);
}
FUN_0001462c(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"FLASHDUMP"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
8
,auStack1056);
}
FUN_00014690(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"BURNSN"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
9
,auStack1056);
}
FUN_00013e28(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"READSN"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
10
,auStack1056);
}
FUN_00013ecc(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"WRITEENV"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
0xb
,auStack1056);
}
FUN_00013f4c(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar4
=
canshuchuli(auStack1056,
"READENV"
,
0
);
if
(iVar4 !
=
0
) {
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
0xc
,auStack1056);
}
FUN_00014008(__fd,auStack1056);
goto LAB_00011bc8;
}
iVar2
=
iVar2
+
iVar3;
}
while
(iVar2 <
0x400
);
if
(DAT_000361f0 !
=
0
) {
printf(
"cmd<%d>: %s\n"
,
0
,auStack1056);
}
puts(
"Not supported cmd!"
);
}
LAB_00011bc8:
close(__fd);
}
while
( true );
}