php memory-redux
Post on 29-Nov-2014
1.248 Views
Preview:
DESCRIPTION
TRANSCRIPT
php://memoryredux
say what
2001:558:1004:9:69:252:76:96
say what
2001:558:1004:9:69:252:76:96
+ DNS..
say what
2001:558:1004:9:69:252:76:96
+ Domain Name System
= ipv6.comcast.com
who am i
Neal AndersSenior Software Engineer at Infobloxhttp://github.com/nanderoohttp://neal-anders.com@nanderoo
before it was cool
Infoblox is working on some cool stuff...
- DNS, DHCP, IPAM, NCCM
- IPv6 Center of Excellence
- IF-Map / DNSSec
- Hiring (sales, services, support, engineering)
who r u
Designers? Developers?
Dev-Ops? Sys-Admin?
Managers? Recruiters?
Looking? Hiring?
follow along
https://github.com/nanderoo/php-memory-redux.git
overview
Let us cover 3 things:
1) Streams and filters overview
2) php://memory & php://temp
3) Demo - word/letter frequency
overview
What are streams:
- Streams are resources, a variety of protocols and wrappers: file, http, ftp, zlib, data, glob, phar, ssh2, expect...
- Lets you interact at a lower level, sockets, buffers, 3rd party libs, with other devices and systems.
overview
What are filters:
- Code that performs actions in-situ
- As a stream is being written to or read from
- Can be stacked / combined
- Great for cutting data cruft
overview
Out of the box filters:
- Strings (upper, lower, strip tags, rot13)
- Conversion (base64 encode / decode)
- Compression (gzip, bz2)
- Encryption (mcrypt)
overview
More:
- You make your own with php_user_filter() and stream_filter_register()
- Predefined constants: STREAM_* and PSFS_*
- Hedge on stuff breaking that isn't your fault
memory & temp
php://memory
and
php://temp
memory & temp
What are they?
- Wrappers to streams, resources.
- Others: stdin, stdout, stderr
- Support stat() for low-level insight
memory & temp
php://memory examples:
example-01.php = basic functionality
example-02.php = reading in text
example-03.php = out of memory
example-04.php = stream copy workaround
memory & temp
php://temp examples:
example-05.php = temp w/ memory limit
example-06.php = temp
but why
- Easy to read and write to
- Already baked in
- They said 'no' to permissions
- Performance / balance resources
bonus demo
Frequency Analysis:
- What is 'etaon rishd' (and variants)
- Take a stream of data
- Capture letter frequency
almost fin
Questions? Comments? Musings?
neal.anders@yahoo.com
oh yeah
Semaphores, Shared Memory, and IPC?
Expect, SNMP, Sockets, StatsD, or Graphite?
SurgeCon, MDC3, BSidesDC?
/dev/hell & Voices of the ElePHPant
top related