Skip to content

Commit

Permalink
core: add '.' to WORD_TOKEN accepted chars
Browse files Browse the repository at this point in the history
  • Loading branch information
nil0x42 committed Mar 6, 2019
1 parent 7f21dc6 commit 4d42fce
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/utils/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

# check is given string is a valid phpsploit word token
# usage: WORD_TOKEN.fullmatch("string")
WORD_TOKEN = re.compile("[A-Za-z0-9@_-]+")
WORD_TOKEN = re.compile("[A-Za-z0-9@_.-]+")
12 changes: 6 additions & 6 deletions test/commands/alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ phpsploit_pipe alias > $TMPFILE
sed -e '1,/---/d' -e '/^$/,$d' $TMPFILE | grep -vq '^ l' || FAIL

# check that alias is equal to it's original command
phpsploit_pipe alias "'@foo'" lrun ls > $TMPFILE || FAIL
phpsploit_pipe @foo -ah / > $TMPFILE-alias || FAIL
phpsploit_pipe alias "'@foo.bar'" lrun ls > $TMPFILE || FAIL
phpsploit_pipe @foo.bar -ah / > $TMPFILE-alias || FAIL
phpsploit_pipe lrun ls -ah / > $TMPFILE || FAIL
diff $TMPFILE-alias $TMPFILE || FAIL

Expand All @@ -59,7 +59,7 @@ diff $TMPFILE-cmd-override $TMPFILE || FAIL

# but the alias referencing `lrun` still uses real command
# because phpsploit nested aliases do not exist in phpsploit:
phpsploit_pipe @foo -ah / > $TMPFILE || FAIL
phpsploit_pipe @foo.bar -ah / > $TMPFILE || FAIL
diff $TMPFILE-alias $TMPFILE || FAIL

# thanks to non-nesting, you can alias ls to 'ls /'
Expand Down Expand Up @@ -89,13 +89,13 @@ phpsploit_pipe alias > $TMPFILE-ref || FAIL
# issue #101: crash: IndexError: list index out of range
# empty string fails
phpsploit_pipe 'alias "" BLA' > $TMPFILE && FAIL
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: '' doesn't match \[A-Za-z0-9@_-\]+"
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: '' doesn't match \[A-Za-z0-9@_\.-\]+"
# string with spaces fails
phpsploit_pipe 'alias "has space" BLA' > $TMPFILE && FAIL
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: 'has space' doesn't match \[A-Za-z0-9@_-\]+"
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: 'has space' doesn't match \[A-Za-z0-9@_\.-\]+"
# ',' (badchar) fails
phpsploit_pipe 'alias ,bad BLA' > $TMPFILE && FAIL
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: ',bad' doesn't match \[A-Za-z0-9@_-\]+"
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: ',bad' doesn't match \[A-Za-z0-9@_\.-\]+"

# ensure alias output hasn't changed (because no vars were created)
phpsploit_pipe alias > $TMPFILE || FAIL
Expand Down
10 changes: 5 additions & 5 deletions test/commands/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ done
phpsploit_pipe env FOO BAR > $TMPFILE || FAIL
[[ "`getval FOO`" == "BAR" ]] || FAIL

phpsploit_pipe env this@ISvalid myval > $TMPFILE || FAIL
[[ "`getval this@ISvalid`" == "myval" ]] || FAIL
phpsploit_pipe env this@IS.valid myval > $TMPFILE || FAIL
[[ "`getval this@IS.valid`" == "myval" ]] || FAIL

###
### CHECK INVALID VAR NAMES
Expand All @@ -107,13 +107,13 @@ phpsploit_pipe env > $TMPFILE-ref || FAIL

# empty string fails
phpsploit_pipe 'env "" BLA' > $TMPFILE && FAIL
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: '' doesn't match \[A-Za-z0-9@_-\]+"
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: '' doesn't match \[A-Za-z0-9@_\.-\]+"
# string with spaces fails
phpsploit_pipe 'env "has space" BLA' > $TMPFILE && FAIL
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: 'has space' doesn't match \[A-Za-z0-9@_-\]+"
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: 'has space' doesn't match \[A-Za-z0-9@_\.-\]+"
# ',' (badchar) fails
phpsploit_pipe 'env ,bad BLA' > $TMPFILE && FAIL
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: ',bad' doesn't match \[A-Za-z0-9@_-\]+"
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: ',bad' doesn't match \[A-Za-z0-9@_\.-\]+"
# special name used to save default values in sessions, should fail
phpsploit_pipe 'env __DEFAULTS__ BLA' > $TMPFILE && FAIL
assert_contains $TMPFILE "\[\!\] Key Error: illegal name: '__DEFAULTS__'"
Expand Down
2 changes: 1 addition & 1 deletion test/interface/command-line-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function is_interactive () {
local script=$TMPFILE-is_interactive.sh
echo -e "#!/bin/bash\n$@" > $script
chmod +x $script
script -qefc "timeout 4 $script" /dev/null > $TMPFILE-is_interactive 2>&1
script -qefc "timeout 6 $script" /dev/null > $TMPFILE-is_interactive 2>&1
local ret="$?"
#rm $script
[ "$ret" -eq 124 ] && return 0 || return 1
Expand Down

0 comments on commit 4d42fce

Please # to comment.