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
26
The Elephant and the Serpent (PyLatam 2019)
phildini
0
59
Account Security for the Fashionable App Developer
phildini
1
65
All in the Timing: Side-Channel Attacks
phildini
0
57
Giving Thanks
phildini
0
42
All in the Timing: Side-Channel Attacks in Python
phildini
0
410
API-Driven Django
phildini
1
380
Type uWSGI; Press Enter; What Happens?
phildini
0
95
Type uWSGI; Press Enter; What Happens?
phildini
1
75
Other Decks in Technology
See All in Technology
QAエンジニアが スクラムマスターをすると いいなぁと思った話
____rina____
0
200
きのこカンファレンス_ランチスポンサーセッション
kabaya
0
100
自分のやることに価値を見出だせるようになり、挑戦する勇気をもらったベイトソンの考え / Scrum Fest Fukuoka 2025
bonbon0605
0
160
プロダクト開発者目線での Entra ID 活用
sansantech
PRO
0
170
User Story Mapping + Inclusive Team
kawaguti
PRO
3
560
MLflowはどのようにLLMOpsの課題を解決するのか
taka_aki
0
160
生成AIがローコードツールになる時代の エンジニアの役割を考える
khwada
0
300
OSSの実装を参考にBedrockエージェントを作る
moritalous
2
110
株式会社Awarefy(アウェアファイ)会社説明資料 / Awarefy-Company-Deck
awarefy
3
12k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
550
エンジニア主導の企画立案を可能にする組織とは?
recruitengineers
PRO
1
330
入門 PEAK Threat Hunting @SECCON
odorusatoshi
0
190
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
11
550
Being A Developer After 40
akosma
89
590k
GitHub's CSS Performance
jonrohan
1030
460k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
Fireside Chat
paigeccino
35
3.2k
How to Ace a Technical Interview
jacobian
276
23k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
Statistics for Hackers
jakevdp
797
220k
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