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
44
Account Security for the Fashionable App Developer
phildini
1
64
All in the Timing: Side-Channel Attacks
phildini
0
54
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
73
Other Decks in Technology
See All in Technology
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
430
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
130
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
390
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
150
アジャイルチームがらしさを発揮するための目標づくり / Making the goal and enabling the team
kakehashi
3
140
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
生成AIが変えるデータ分析の全体像
ishikawa_satoru
0
170
FlutterアプリにおけるSLI/SLOを用いたユーザー体験の可視化と計測基盤構築
ostk0069
0
100
SSMRunbook作成の勘所_20241120
koichiotomo
3
160
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
890
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
180
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
A Philosophy of Restraint
colly
203
16k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
The Language of Interfaces
destraynor
154
24k
Ruby is Unlike a Banana
tanoku
97
11k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Scaling GitHub
holman
458
140k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Documentation Writing (for coders)
carmenintech
65
4.4k
Building Your Own Lightsaber
phodgson
103
6.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
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