際際滷

際際滷Share a Scribd company logo
php://memory
    redux
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 Anders
     Senior Software Engineer at Infoblox
     http://github.com/nanderoo
     http://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

More Related Content

Php memory-redux

  • 1. php://memory redux
  • 2. say what 2001:558:1004:9:69:252:76:96
  • 3. say what 2001:558:1004:9:69:252:76:96 + DNS..
  • 4. say what 2001:558:1004:9:69:252:76:96 + Domain Name System = ipv6.comcast.com
  • 5. who am i Neal Anders Senior Software Engineer at Infoblox http://github.com/nanderoo http://neal-anders.com @nanderoo
  • 6. 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)
  • 7. who r u Designers? Developers? Dev-Ops? Sys-Admin? Managers? Recruiters? Looking? Hiring?
  • 9. overview Let us cover 3 things: 1) Streams and filters overview 2) php://memory & php://temp 3) Demo - word/letter frequency
  • 10. 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.
  • 11. 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
  • 12. overview Out of the box filters: - Strings (upper, lower, strip tags, rot13) - Conversion (base64 encode / decode) - Compression (gzip, bz2) - Encryption (mcrypt)
  • 13. 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
  • 14. memory & temp php://memory and php://temp
  • 15. memory & temp What are they? - Wrappers to streams, resources. - Others: stdin, stdout, stderr - Support stat() for low-level insight
  • 16. 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
  • 17. memory & temp php://temp examples: example-05.php = temp w/ memory limit example-06.php = temp
  • 18. but why - Easy to read and write to - Already baked in - They said 'no' to permissions - Performance / balance resources
  • 19. bonus demo Frequency Analysis: - What is 'etaon rishd' (and variants) - Take a stream of data - Capture letter frequency
  • 20. almost fin Questions? Comments? Musings? neal.anders@yahoo.com
  • 21. oh yeah Semaphores, Shared Memory, and IPC? Expect, SNMP, Sockets, StatsD, or Graphite? SurgeCon, MDC3, BSidesDC? /dev/hell & Voices of the ElePHPant