Skip to content

Commit

Permalink
reworked QUERY_STRING management to further fix some potential security
Browse files Browse the repository at this point in the history
flaws.
  • Loading branch information
jens-maus committed Dec 13, 2022
1 parent f9fbdca commit 8ad3a50
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 88 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.4
1.7.5
2 changes: 0 additions & 2 deletions www/backup.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#
###

load tclrega.so
source querystring.tcl
source session.tcl

puts "Content-Type: text/plain; charset=iso-8859-1"
Expand Down
2 changes: 0 additions & 2 deletions www/config_js.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# @license Public Domain
##

load tclrega.so
source querystring.tcl
source session.tcl
source /etc/config/addons/email/config.tcl

Expand Down
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
</tr>
<tr>
<td>Version:</td>
<td align="right"><iframe width="55" height="25" scrolling="no" frameborder="0" src="VERSION.txt"></iframe></td>
<td align="right"><iframe width="70" height="25" scrolling="no" frameborder="0" src="VERSION.txt"></iframe></td>
</tr>
<tr>
<td>Autoren:</td>
Expand Down
40 changes: 20 additions & 20 deletions www/logfile.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<!doctype html>
<html>
<head>
<meta content="10;URL=/addons/email/logfile.html" http-equiv="Refresh">
<meta http-equiv="expires" content="0">
<title>Logfile</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script LANGUAGE="JavaScript">
<!--
function reload_main(){
var uri=location.href;
location.href=uri;
}
//-->
</script>
</head>
<body>
<iframe name='logdisplay' src='/addons/email/log/email.log' width='100%' height='80' scrolling='yes' frameborder='0' style='background-color:transparent;border:0px solid #11cccc;padding:0px;'></iframe></td></tr>
</body>
</html>
<!doctype html>
<html>
<head>
<meta content="10;URL=/addons/email/logfile.html" http-equiv="Refresh">
<meta http-equiv="expires" content="0">
<title>Logfile</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script LANGUAGE="JavaScript">
<!--
function reload_main(){
var uri=location.href;
location.href=uri;
}
//-->
</script>
</head>
<body>
<iframe name='logdisplay' src='/addons/email/log/email.log' width='100%' height='80' scrolling='yes' frameborder='0' style='background-color:transparent;border:0px solid #11cccc;padding:0px;'></iframe></td></tr>
</body>
</html>
38 changes: 19 additions & 19 deletions www/messages.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!doctype html>
<html>
<head>
<meta content="10;URL=/addons/email/messages.html" http-equiv="Refresh">
<meta http-equiv="expires" content="0">
<title>Logfile</title>
<script LANGUAGE="JavaScript">
<!--
function reload_main(){
var uri=location.href;
location.href=uri;
}
//-->
</script>
</head>
<body>
<iframe name='logdisplay1' src='/addons/email/syslog.cgi?filter=msmtp' width='100%' height='80' scrolling='yes' frameborder='0' style='background-color:transparent;border:0px solid #11cccc;padding:0px;'></iframe></td></tr>
</body>
</html>
<!doctype html>
<html>
<head>
<meta content="10;URL=/addons/email/messages.html" http-equiv="Refresh">
<meta http-equiv="expires" content="0">
<title>Logfile</title>
<script LANGUAGE="JavaScript">
<!--
function reload_main(){
var uri=location.href;
location.href=uri;
}
//-->
</script>
</head>
<body>
<iframe name='logdisplay1' src='/addons/email/syslog.cgi' width='100%' height='80' scrolling='yes' frameborder='0' style='background-color:transparent;border:0px solid #11cccc;padding:0px;'></iframe></td></tr>
</body>
</html>
9 changes: 0 additions & 9 deletions www/querystring.tcl

This file was deleted.

2 changes: 0 additions & 2 deletions www/save.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
# @license Public Domain
##

load tclrega.so
source session.tcl
source querystring.tcl

puts "Content-Type: text/plain; charset=iso-8859-1"
puts ""
Expand Down
12 changes: 12 additions & 0 deletions www/session.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

load tclrega.so

catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
set sid ""
foreach pair $pairs {
if {0 != [regexp "^sid=(@.*@)$" $pair dummy val]} {
set sid $val
break
}
}
}

proc check_session sid {
if {[regexp {@([0-9a-zA-Z]{10})@} $sid all sidnr]} {
set res [lindex [rega_script "Write(system.GetSessionVarStr('$sidnr'));"] 1]
Expand Down
46 changes: 18 additions & 28 deletions www/syslog.cgi
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
#!/bin/tclsh

set logfile "/var/log/messages"
set filter *

catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
set $varname $val
}
}
}

puts "Content-Type: text/plain;Charset=ISO-8859-1"
puts ""

if {[catch {open "$logfile" r} fd]} {
puts "ERROR open($logfile) $fd"
} else {
while {[gets $fd line] >= 0} {
if {[string match -nocase "*$filter*" $line]} {
puts $line
}
}
close $fd
}
#!/bin/tclsh

set logfile "/var/log/messages"
set filter "msmtp"

puts "Content-Type: text/plain; charset=iso-8859-1"
puts ""

if {[catch {open "$logfile" r} fd]} {
puts "ERROR open($logfile) $fd"
} else {
while {[gets $fd line] >= 0} {
if {[string match -nocase "*$filter*" $line]} {
puts $line
}
}
close $fd
}
2 changes: 0 additions & 2 deletions www/testmail.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# @license Public Domain
##

load tclrega.so
source querystring.tcl
source session.tcl

puts "Content-Type: text/plain; charset=iso-8859-1"
Expand Down
2 changes: 0 additions & 2 deletions www/testtcl.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#
###

load tclrega.so
source querystring.tcl
source session.tcl

puts "Content-Type: text/plain; charset=iso-8859-1"
Expand Down

0 comments on commit 8ad3a50

Please sign in to comment.