Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Type Python, Press Enter, What Happens? - PyDX ...
Search
Philip James
October 11, 2015
Technology
0
130
Type Python, Press Enter, What Happens? - PyDX 2015
The slides from my talk at PyDX
Philip James
October 11, 2015
Tweet
Share
More Decks by Philip James
See All by Philip James
Frog and Toad Learn about Django Security - NBT6
phildini
0
25
The Elephant and the Serpent (PyLatam 2019)
phildini
0
51
Account Security for the Fashionable App Developer
phildini
1
64
All in the Timing: Side-Channel Attacks
phildini
0
56
Giving Thanks
phildini
0
42
All in the Timing: Side-Channel Attacks in Python
phildini
0
410
API-Driven Django
phildini
1
360
Type uWSGI; Press Enter; What Happens?
phildini
0
93
Type uWSGI; Press Enter; What Happens?
phildini
1
74
Other Decks in Technology
See All in Technology
ISUCON、今年も参加してみた / ISUCON, I challenged it again this year.
dero1to
0
110
TypeScript開発にモジュラーモノリスを持ち込む
sansantech
PRO
3
770
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
410
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
220
ハイテク休憩
sat
PRO
2
190
Web APIをなぜつくるのか
mikanichinose
0
930
組み込みアプリパフォーマンス格闘記 検索画面編
wataruhigasi
1
190
[トレノケ雲の会 mod.13] 3回目のre:Inventで気づいたこと -CloudOperationsを添えて-
shintaro_fukatsu
0
110
効率的な技術組織が作れる!書籍『チームトポロジー』要点まとめ
iwamot
2
160
AWS re:Invent 2024 ふりかえり勉強会
yhana
0
630
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
190
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
190
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
jQuery: Nuts, Bolts and Bling
dougneiner
62
7.6k
We Have a Design System, Now What?
morganepeng
51
7.3k
Optimising Largest Contentful Paint
csswizardry
33
3k
A designer walks into a library…
pauljervisheath
205
24k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
470
Building Flexible Design Systems
yeseniaperezcruz
327
38k
The Cost Of JavaScript in 2023
addyosmani
46
7k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Transcript
Type Python, Press Enter, What Happens? Philip James (@phildini) PyDX
2015
Who am I? @phildini #typepython
paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ python @phildini #typepython
paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)
[GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython
paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)
[GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2
paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)
[GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2 4 >>>
paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)
[GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2 4 >>> KeyboardInterrupt >>>
paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)
[GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2 4 >>> KeyboardInterrupt >>> paulproteus@vellum:~ $
paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ python @phildini #typepython
paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ echo $PATH @phildini #typepython
paulproteus@vellum:~ $ echo $PATH /home/paulproteus/bin:/usr/bin:/usr/local/bin: @phildini #typepython
paulproteus@vellum:~ $ echo $PATH /home/paulproteus/bin:/usr/bin:/usr/local/bin: paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ echo $PATH /home/paulproteus/bin:/usr/bin:/usr/local/bin: paulproteus@vellum:~ $ python @phildini #typepython
paulproteus@vellum:~ $ echo $PATH /home/paulproteus/bin:/usr/bin:/usr/local/bin: paulproteus@vellum:~ $ python @phildini #typepython
paulproteus@vellum:~ $ echo $PATH /home/paulproteus/bin:/usr/bin:/usr/local/bin: paulproteus@vellum:~ $ python @phildini #typepython
paulproteus@vellum:~ $ echo $PATH /home/paulproteus/bin:/usr/bin:/usr/local/bin: paulproteus@vellum:~ $ python @phildini #typepython
paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ hexdump -C /usr/bin/python @phildini #typepython
paulproteus@vellum:~ $ hexdump -C /usr/bin/python 00000000 7f 45 4c 46
02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............| 00000010 02 00 3e 00 01 00 00 00 55 49 57 00 00 00 00 00 |..>.....UIW.....| 00000020 40 00 00 00 00 00 00 00 08 15 33 00 00 00 00 00 |@.........3.....| 00000030 00 00 00 00 40 00 38 00 09 00 40 00 1c 00 1b 00 |
[email protected]
...@.....| 00000040 06 00 00 00 05 00 00 00 40 00 00 00 00 00 00 00 |........@.......| 00000050 40 00 40 00 00 00 00 00 40 00 40 00 00 00 00 00 |@.@.....@.@.....| 00000060 f8 01 00 00 00 00 00 00 f8 01 00 00 00 00 00 00 |................| 00000070 08 00 00 00 00 00 00 00 03 00 00 00 04 00 00 00 |................| 00000080 38 02 00 00 00 00 00 00 38 02 40 00 00 00 00 00 |8.......8.@.....| 00000090 38 02 40 00 00 00 00 00 1c 00 00 00 00 00 00 00 |8.@.............| @phildini #typepython
paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ file /usr/bin/python @phildini #typepython
paulproteus@vellum:~ $ file /usr/bin/python /usr/bin/python: ELF 64-bit LSB executable @phildini
#typepython
for dir in os.getenv( 'PATH').split(':'): try: os.stat(dir + '/python') return
dir except: pass raise CommandNotFound() @phildini #typepython
bash pid: 1221 @phildini #typepython
bash pid: 1221 paulproteus@vellum:~ $ @phildini #typepython
bash pid: 1221 paulproteus@vellum:~ $ exec python @phildini #typepython
python pid: 1221 @phildini #typepython
python pid: 1221 @phildini #typepython
python pid: 1221 paulproteus@vellum:~ $ @phildini #typepython
python pid: 1221 paulproteus@vellum:~ $ [Process completed] @phildini #typepython
bash pid: 1221 @phildini #typepython
bash pid: 1221 fork() @phildini #typepython
bash pid: 1221 fork() bash pid: 1222 @phildini #typepython
bash pid: 1221 fork() bash pid: 1222 exec() @phildini #typepython
bash pid: 1221 fork() python pid: 1222 exec() @phildini #typepython
paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ pstree @phildini #typepython
paulproteus@vellum:~ $ pstree init─┬ ... ├─cron ... └─sshd─┬─bash───python └─bash───pstree @phildini
#typepython
Process Creation 1. Find binary in $PATH 2. Fork 3.
Exec @phildini #typepython
paulproteus@vellum:~ $ python -v @phildini #typepython
# installing zipimport hook import zipimport # builtin # installed
zipimport hook # /usr/lib/python2.7/site.pyc matches /usr/lib/python2.7/site.py import site # precompiled from /usr/ lib/python2.7/site.pyc # /usr/lib/python2.7/os.pyc matches /usr/lib/python2.7/os.py paulproteus@vellum:~ $ python -v @phildini #typepython
bash pid: 1221 fork() python pid: 1222 exec( ‘/usr/bin/python’, [‘python’,
‘-v’] ) @phildini #typepython
bash pid: 1221 fork() python pid: 1222 argv = [‘python’,
‘-v’] exec( ‘/usr/bin/python’, [‘python’, ‘-v’] ) @phildini #typepython
python pid: 1222 argv = [‘python’] @phildini #typepython
Python 2.7.6 (default, Apr 11 2014, 22:59:56) [GCC 4.8.2] on
linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython
None
/dev/pts/3
python pid: 1222 0: /dev/pts/3 @phildini #typepython
python pid: 1222 0: /dev/pts/3 stdin @phildini #typepython
python pid: 1222 0: /dev/pts/3 2 @phildini #typepython
python pid: 1222 0: /dev/pts/3 termios 2 @phildini #typepython
python pid: 1222 0: /dev/pts/3 termios 2 @phildini #typepython
paulproteus@vellum:~ $ @phildini #typepython
paulproteus@vellum:~ $ strace python @phildini #typepython
paulproteus@vellum:~ $ strace python [...] read(0, @phildini #typepython
paulproteus@vellum:~ $ strace python [...] read(0, 2 @phildini #typepython
paulproteus@vellum:~ $ strace python [...] read(0, “2”, 1) 2 @phildini
#typepython
paulproteus@vellum:~ $ strace python [...] read(0, “2”, 1) read(0, 2
@phildini #typepython
paulproteus@vellum:~ $ strace python [...] read(0, “2”, 1) read(0, 2
+ @phildini #typepython
paulproteus@vellum:~ $ strace python [...] read(0, “2”, 1) read(0, “+”,
1) 2 + @phildini #typepython
paulproteus@vellum:~ $ strace python [...] read(0, “2”, 1) read(0, “+”,
1) read(0, “2”, 1) read(0, “\n”, 1) 2 + 2 Enter @phildini #typepython
while True: line = ‘’ chr = sys.stdin.read(1) line +=
chr if chr == ‘\n’: print eval(line) @phildini #typepython
while True: line = ‘’ chr = sys.stdin.read(1) line +=
chr if chr == ‘\n’: print eval(line) @phildini #typepython
python pid: 1222 0: /dev/pts/3 1: /dev/pts/3 2: /dev/pts/3 @phildini
#typepython
bash pid: 1221 python pid: 1222 0: /dev/pts/3 1: /dev/pts/3
2: /dev/pts/3 0: /dev/pts/3 1: /dev/pts/3 2: /dev/pts/3 @phildini #typepython
bash pid: 1221 python pid: 1222 0: /dev/pts/3 1: /dev/pts/3
2: /dev/pts/3 0: /dev/pts/3 1: /dev/pts/3 2: /dev/pts/3 foreground @phildini #typepython
Ctrl C @phildini #typepython
Ctrl C termios @phildini #typepython
sigint Ctrl C termios @phildini #typepython
python pid: 1222 sigint Ctrl C termios @phildini #typepython
>>> @phildini #typepython
>>> Crtl C @phildini #typepython
>>> Crtl C KeyboardInterrupt >>> @phildini #typepython
python pid: 1222 sigint @phildini #typepython
python pid: 1222 sigint sig pipe @phildini #typepython
cat pid: 1222 0: /dev/pts/3 Ctrl D termios @phildini #typepython
cat pid: 1222 0: /dev/pts/3 Ctrl D termios @phildini #typepython
python pid: 1222 0: /dev/pts/3 Ctrl D termios @phildini #typepython
>>> import sys >>> sys.exit() @phildini #typepython
>>> raise SystemExit() @phildini #typepython
paulproteus@vellum:~ $ strace python @phildini #typepython
paulproteus@vellum:~ $ strace python [...] exit(0 <no return …> @phildini
#typepython
paulproteus@vellum:~ $ strace python [...] exit(0 <no return …> paulproteus@vellum:~
$ @phildini #typepython
paulproteus@vellum:~ $ strace python [...] exit(0 <no return …> paulproteus@vellum:~
$ echo $? @phildini #typepython
paulproteus@vellum:~ $ strace python [...] exit(0 <no return …> paulproteus@vellum:~
$ echo $? 0 @phildini #typepython
>>> import sys >>> sys.exit(1) @phildini #typepython
>>> import sys >>> sys.exit(1) paulproteus@vellum:~ $ echo $? 1
@phildini #typepython
bash pid: 1221 @phildini #typepython
python pid: 1222 argv = [‘python’] bash pid: 1221 @phildini
#typepython
python pid: 1222 argv = [‘python’] 0: /dev/pts/3 1: /dev/pts/3
2: /dev/pts/3 bash pid: 1221 @phildini #typepython
python pid: 1222 argv = [‘python’] sigint sig pipe 0:
/dev/pts/3 1: /dev/pts/3 2: /dev/pts/3 bash pid: 1221 @phildini #typepython
Be Curious! • pstree • strace • file/hexdump @phildini #typepython
Questions? Thanks! Philip James (@phildini) @phildini #typepython