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 2015
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
19
The Elephant and the Serpent (PyLatam 2019)
phildini
0
42
Account Security for the Fashionable App Developer
phildini
1
59
All in the Timing: Side-Channel Attacks
phildini
0
48
Giving Thanks
phildini
0
39
All in the Timing: Side-Channel Attacks in Python
phildini
0
370
API-Driven Django
phildini
1
320
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
Google Cloud の AI を支える裏側のインフラを垣間見る!
maroon1st
0
350
Google Cloud Next '24でブログを10本書いた方法と勉強会を沸かせた方法
yasumuusan
0
300
Reducing Cross-Zone Egress at Spotify with Custom gRPC Load Balancing Recap
koh_naga
0
200
よく聞くけど使ったことないソフトウェアNo.1 KafkaとSnowflake
foursue
4
360
「スニダン」開発組織の構造に込めた意図 ~組織作りはパッションや政治ではない!~
rinchsan
3
570
Janus
bkuhlmann
1
490
[新卒向け研修資料] テスト文字列に「うんこ」と入れるな(2024年版)
infiniteloop_inc
4
15k
ServiceNow Knowledge 24の歩き方 EYストラテジー・アンド・コンサルティング
manarobot
0
200
レガシーをぶっ壊せ。AEONで始めるDevRelの話 / Qiita Night 2024-2-22
aeonpeople
3
1.3k
MapLibreとAmazon Location Service
dayjournal
1
150
KubeConにproposalを送りたい人へのアドバイス
sat
PRO
3
250
Postman v10リリース後を振り返る / Looking back at Postman v10 after release
yokawasa
1
160
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
73
5.2k
Raft: Consensus for Rubyists
vanstee
132
6.3k
Navigating Team Friction
lara
178
13k
Atom: Resistance is Futile
akmur
259
25k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
Building Effective Engineering Teams - LeadDev
addyosmani
28
1.8k
Typedesign – Prime Four
hannesfritz
36
2.1k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
KATA
mclloyd
15
12k
How to Ace a Technical Interview
jacobian
272
22k
The MySQL Ecosystem @ GitHub 2015
samlambert
243
12k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.6k
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