I win (fixed security hole)
This commit is contained in:
parent
ace459d876
commit
6d2e61e4d9
1 changed files with 8 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
|
import string
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
|
@ -21,10 +22,12 @@ def ping(inp, reply=None):
|
||||||
|
|
||||||
count = str(count)
|
count = str(count)
|
||||||
|
|
||||||
|
host = re.sub(r'([^\s\w\.])+', '', host)
|
||||||
|
|
||||||
reply("Attempting to ping %s %s times..." % (host, count))
|
reply("Attempting to ping %s %s times..." % (host, count))
|
||||||
|
|
||||||
pingcmd = subprocess.check_output("ping -c "\
|
pingcmd = subprocess.check_output("ping -c "\
|
||||||
+ count + " " + host, shell=True)
|
+ count + " " + host, shell=True)
|
||||||
if 'request timed out' in pingcmd or 'unknown host' in pingcmd:
|
if 'request timed out' in pingcmd or 'unknown host' in pingcmd:
|
||||||
return "error: could not ping host"
|
return "error: could not ping host"
|
||||||
else:
|
else:
|
||||||
|
@ -32,3 +35,5 @@ def ping(inp, reply=None):
|
||||||
"(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)", pingcmd)
|
"(\d+.\d+)/(\d+.\d+)/(\d+.\d+)/(\d+.\d+)", pingcmd)
|
||||||
return "min: %sms, max: %sms, average: %sms, range: %sms, count: %s"\
|
return "min: %sms, max: %sms, average: %sms, range: %sms, count: %s"\
|
||||||
% (m.group(1), m.group(3), m.group(2), m.group(4), count)
|
% (m.group(1), m.group(3), m.group(2), m.group(4), count)
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue