-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathexec.cgi
executable file
·49 lines (41 loc) · 933 Bytes
/
exec.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/tclsh
load tclrega.so
source querystring.tcl
source session.tcl
proc toString { str } {
set map {
"\"" "\\\""
"\\" "\\\\"
"\{" "\\\{"
"\[" "\\\["
"/" "\\/"
"\b" "\\b"
"\f" "\\f"
"\n" "\\n"
"\r" "\\r"
"\t" "\\t"
}
return "\"[string map $map $str]\""
}
puts "Content-Type: text/plain"
puts "Access-Control-Allow-Origin: *"
puts ""
if {[info exists sid] && [check_session $sid]} {
if { [catch {
set content [read stdin]
array set script_result [rega_script $content]
set first 1
set result "\{\n"
foreach name [array names script_result] {
if { 1 != $first } { append result ",\n" } { set first 0 }
set value $script_result($name)
append result " [toString $name]: [toString $value]"
}
append result "\n\}"
puts $result
} errorMessage] } {
puts $errorMessage
}
} else {
puts "{error: no session}"
}