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
24
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
400
API-Driven Django
phildini
1
350
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
実は仲良し?Amplify Gen2と生成AI
mkdev10
0
150
RAG: from dumb implementation to serious results
glaforge
0
670
Vue.js、Nuxtの機能を使い、 大量のコピペコードをリファクタリングする
igayamaguchi
3
1.4k
Reality is not an End-to-End Prediction Problem: Applied NLP in the Age of Generative AI
inesmontani
PRO
0
190
GPSデバイスを使った簡易位置案内システムの構築をしてみた話。/jawsfesta2024
kwada
0
230
Azure AI servicesと歯のおはなし/AzureTravelers_Fukuoka2024_baba
nina01
1
110
テストを楽に書きたい
tomorrowkey
2
270
WSUSが非推奨に!? Windowsの更新管理を改めて勉強する!
ebibibi
0
580
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
5
48k
フェンリルの SwiftUI の研修を覗いてみる / Fenrir SwiftUI Training
studio_rookery
0
160
ゼロからはじめる生成AI〜AWS認定とハンズオンで学ぶ初心者の道〜
kenichinakamura
0
140
Deep dive into Nuxt Server Components
wattanx
1
1.3k
Featured
See All Featured
RailsConf 2023
tenderlove
28
860
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Unsuck your backbone
ammeep
668
57k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
Speed Design
sergeychernyshev
23
550
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
9
630
For a Future-Friendly Web
brad_frost
174
9.4k
Making Projects Easy
brettharned
115
5.9k
Practical Orchestrator
shlominoach
186
10k
Teambox: Starting and Learning
jrom
132
8.7k
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