forked from ochko/safeexec
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathEXAMPLES-ETC
executable file
·68 lines (51 loc) · 2.44 KB
/
EXAMPLES-ETC
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -o verbose
# some of these examples require python3, but most work in python2
read # press Enter to continue
./safeexec --exec /usr/bin/python tests/hello.py
read # press Enter to continue
./safeexec --exec /usr/bin/python tests/fork.py # won't work
read # press Enter to continue
./safeexec --nproc 1 --exec /usr/bin/python tests/fork.py # prints twice
read # press Enter to continue
./safeexec --exec /usr/bin/python tests/rlimit.py # crashes: only root can increase rlimit
read # press Enter to continue
# test if network access is disabled. change to your address to see if it was received!
echo "[email protected]" | /usr/bin/python tests/spam.py # goes thru on my machine
read # press Enter to continue
echo "[email protected]" | ./safeexec --exec /usr/bin/python tests/spam.py # blocked b/c of iptables on my machine
read # press Enter to continue
./safeexec --mem 500000 --exec /usr/bin/python3 tests/browse.py # name resolution failure
read # press Enter to continue
./safeexec --exec /usr/bin/python tests/memory.py # MemoryError
read # press Enter to continue
chmod o-rx .
./safeexec --exec /usr/bin/python tests/ls-pwd.py # won't work
read # press Enter to continue
chmod o+rx .
#chmod o+rx .. # etc, so the whole path is visible, remember to undo this!
./safeexec --exec /usr/bin/python tests/ls-pwd.py # lists contents
read # press Enter to continue
./safeexec --exec_dir tests --exec /usr/bin/python ls-pwd.py # lists contents of "tests"
read # press Enter to continue
echo "Makefile" | ./safeexec --exec /usr/bin/python tests/readable.py # test read permissions of Makefile
read # press Enter to continue
# test writing to files
touch allw
echo "allw" | ./safeexec --fsize 1 --exec /usr/bin/python tests/writeable.py # no permission
read # press Enter to continue
chmod a+w allw
echo "allw" | ./safeexec --exec /usr/bin/python tests/writeable.py # file too large
read # press Enter to continue
echo "allw" | ./safeexec --fsize 1 --nfile 0 --exec /usr/bin/python tests/writeable.py # too many open files
read # press Enter to continue
more allw # still blank
echo "allw" | ./safeexec --fsize 1 --exec /usr/bin/python tests/writeable.py
read # press Enter to continue
more allw # has contents!
rm allw
read # press Enter to continue
# test encoding issues
./safeexec --env_vars PYTHONIOENCODING=UTF-8 --exec /usr/bin/python3 -S tests/encodestuff.py # happy faces!
read # press Enter to continue
./safeexec --exec /usr/bin/python tests/userinfo.py