# Mark Baggett on Python for InfoSec

> Episode of [The Python Podcast.__init__](https://podistic.com/podcast/the-python-podcast-init-.md) · Published June 3, 2015 · Duration 1:14:31 · Episode 8, season 1

- **Listen on Podistic:** https://podistic.com/episode/mark-baggett-on-python-for-infosec
- **Audio:** https://op3.dev/e/dts.podtrac.com/redirect.mp3/serve.podhome.fm/episode/f6ff0caa-931b-4c08-bfdd-08dc7f5cd336/638525297107496347379c66d7-6dde-47d5-8fec-06da9579ff39v1.mp3 (audio/mpeg)

## About this episode

Read all of our show notes and find more information about us at [Beautiful Soup](http://www.pythonpodcast.com?utm_source=rss\&utm_medium=rss)

### Brief Introduction

*   Date of recording – May 28th, 2015
*   Hosts – Tobias Macey and Chris Patti
*   Overview – Interview with Mark Bagett
*   Follow us on iTunes, Stitcher or TuneIn
*   Give us feedback! (iTunes, Twitter, email, Disqus comments)
*   You can donate (if you want)!

### Interview with Mark Bagett

*   Introductions
*   How were you first introduced to Python? – Chris
    *   Started using it for automating tasks while working as a sysadmin
    *   Found code that launched an attack on FTP server – in Python
  

*   What are some of the tasks in your job that you use Python for? -Tobias

    *   Trusted command \& control backdoor for Windows
        *   Mostly not used by malware authors – thus far (at least Mark hasn’t seen it used that way)
        *   Flame virus – 5MB payload – incredibly advanced
            *   Lua interpreter bundled along with the scripts


        *   Vale framework – Python framework that takes payloads out of penetration testing executables





  

*   What is it about Python that makes it useful for penetration testing and other information security tasks?

    *   Same thing that makes it useful for anything else
    *   mpacket from core security
  

*   What are some of the more useful Python penetration testing tools?

    *   OFFENSE
        *   [Beautiful Soup](http://www.crummy.com/software/BeautifulSoup/?utm_source=rss\&utm_medium=rss)
        *   [scapy](http://www.secdev.org/projects/scapy/?utm_source=rss\&utm_medium=rss)
        *   [Volatility](https://code.google.com/p/volatility/?utm_source=rss\&utm_medium=rss)


    *   DEFENSE

        *   [Counter dictionary from collections](https://docs.python.org/2/library/collections.html#collections.Counter?utm_source=rss\&utm_medium=rss)
        *   Pandas
        *   iPython
        *   matplotlib



  

*   We’ve noticed that a lot of the literature around information security and penetration testing focuses on targeting Windows. Can you enlighten us as to why that is?

    *   Windows event tracing
        *   logman
        *   event trace providers – implement packet sniffing (Can turn every browser into a key logger)


    *   Primary attack surface – Where most attacks are targeted

    *   Fewer purely Linux systems

        *   Very few ports open – maybe 80, 22
        *   Very likely no user just sitting there waiting to run an executable you send


    *   More freedom on Linux – less formalized patching process, more variable tools = more exploits

    *   Will write code to only use built in modules for Python that will run in customer target environments


  

*   What are some of the legal considerations that you have to deal with on a regular basis as a penetration tester?  

*   There have recently been a number of attacks based on hijacking the TCP/IP stack. Is Python being used for any of these exploits or tools to defend against them?

    *   Data analytics
    *   Detect repeated sequence numbers – Man in the Middle Attack
        *   As simple as 5 lines of Python code
        *   import scapy, start sniffing packets, pull together all packets – make list of associated packets
        *   Can pull together all packets inside of stream
        *   Time spefic source communicates with specific destination
        *   Bro – intrusion detection suite
            *   Built into Security Onion – Doug Berks
            *   FLOSS Weekly episode 296 with [Bro developers](http://twit.tv/show/floss-weekly/296?utm_source=rss\&utm_medium=rss)






  

*   What are some activities that you do on a regular basis for which you would turn to another language or toolchain, rather than using Python?

    *   Powershell – The Python of windows
        *   Whitelisted and ubiquitous


    *   Password cracking – compiled language like C or assembly


  

*   For anyone who is interested in getting involved in the security industry, and penetration testing in particular, what resources or tools would you recommend?

    *   Developers make the best InfoSec professionals
        *   Lots of jobs and opportunities


    *   Developer -> Systems Administration -> Information Security

    *   Security conferences – BSides, Defcon, Black Hat

    *   Online capture the flag challenges (google it) – good practice for critical thinking and using code for security exercises

    *   Get involved in the industry – Meetups, etc.

    *   SANS institute course, Python for Penetration Testers, SEC573 by Mark Baggett – sans.org

    *   Lots of free online resources

    *   [Violent Python](http://shop.oreilly.com/product/978159749957*do?utm_source=rss\&utm_medium=rss)

    *   [PicoCTF](https://picoctf.com/?utm_source=rss\&utm_medium=rss)

    *   [Counter Hack Challenges](https://www.counterhackchallenges.com/?utm_source=rss\&utm_medium=rss)


  
 

### Picks

*   Tobias
    *   [Authy](https://www.authy.com/?utm_source=rss\&utm_medium=rss)
    *   [OpenWRT](https://openwrt.org/?utm_source=rss\&utm_medium=rss)
    *   [TP-Link Archer C7](http://amzn.to/1FR46Ac?utm_source=rss\&utm_medium=rss)
    *   [Schemas For The Real World by Carina C. Zona](https://www.youtube.com/watch?v=PYYfVqtcWQY\&utm_source=rss\&utm_medium=rss)
    *   [The Soul of Software by Avdi Grimm](https://youtu.be/IgbHzFb1hGw?utm_source=rss\&utm_medium=rss)
    *   [China Mieville](http://en.wikipedia.org/wiki/China_Mi%C3%A9ville?utm_source=rss\&utm_medium=rss)
  

*   Chris

    *   [Rapscallion Munich Dark](http://www.beeradvocate.com/beer/profile/18639/121363/?utm_source=rss\&utm_medium=rss)
    *   [Write](http://writeapp.net/mac/?utm_source=rss\&utm_medium=rss)
    *   [Marginal Way](http://marginalwayfund.org/?utm_source=rss\&utm_medium=rss)
    *   [Frankie and Johnny’s](http://frankie-johnnys.com/?utm_source=rss\&utm_medium=rss)
    *   [pyenv](https://github.com/yyuu/pyenv?utm_source=rss\&utm_medium=rss)
  

*   Mark Bagett

    *   [Corelabs impacket](http://corelabs.coresecurity.com/index.php?module=Wiki\&action=view\&type=tool\&name=Impacket\&utm_source=rss\&utm_medium=rss)
    *   [Google Labs – Rekall](http://www.rekall-forensic.com/?utm_source=rss\&utm_medium=rss)
    *   [Adams peanut butter cup fudge ripple cheesecake](http://www.thecheesecakefactory.com/menu/desserts/cheesecakes/adams-peanut-butter-cup-fudge-ripple-cheesecake/?utm_source=rss\&utm_medium=rss)
    *   [BSides security conference](http://www.securitybsides.com/w/page/12194156/FrontPage?utm_source=rss\&utm_medium=rss)
  
 

### Keep in Touch

*   Twitter: [@markbaggett](https://twitter.com/markbaggett?utm_source=rss\&utm_medium=rss)
*   [In Depth Defense](http://www.indepthdefense.com/?utm_source=rss\&utm_medium=rss)

The intro and outro music is from Requiem for a Fish [The Freak Fandango Orchestra](http://freemusicarchive.org/music/The_Freak_Fandango_Orchestra/?utm_source=rss\&utm_medium=rss) / [CC BY-SA](http://creativecommons.org/licenses/by-sa/3.0/?utm_source=rss\&utm_medium=rss)
