Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I love using Python for the scripts I need and for work. But I really want to learn Python for network security since I will start a NS course next year.

My question would be how would it be the best way to learn? I was thinking of starting by writing a network sniffer or a like, but I think this is a bit to high to start learning (correct me if I am wrong), what would be the basic tool to code for the learning?

share|improve this question

closed as primarily opinion-based by TildalWave, Xander, Mark, Steve, Gilles Sep 6 '14 at 22:55

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 7 down vote accepted

Not to repeat the Scapy recommendation but on a slightly different aspect, as you're a beginner, check out Adam Maxwell's new basic intro guide to Scapy, it's a very good introduction.

I would also recommend checking this course out - it's only $200 and well worth it. The course is both an excellent introduction to Python and also how to use Python in security, with some great challenges where you can put your new skillz into practice.

Finally, I'd follow Mark Baggett on Twitter and have a look at some of his work, such as this. Most of his stuff is on his site here. His python scripts are from both an offensive and defensive aspect so go check those links out.

share|improve this answer

I would recommend take a look at scapy ( ). While "python for network security" is quite unclear ( ie, for testing network security, for analysis, etc ), I think scapy would be a good tool to add to the tool box of someone learning security.

share|improve this answer
Sorry for not being so clear, I meant Pentesting, I took a look at the scapy before, really great tool! I would like to create a xss tester for example, just not sure where to start, is there any book I should consider reading? Except Grey Hat Python, since it's for windows :( – Ephexeve Jun 6 '12 at 9:08
Please edit your question to include this new info. Also, scapy is directly related to pen testing, and xss is for web app testing. What are you looking to do? – schroeder Jun 6 '12 at 18:05

It appears that you have 2 things you want to learn:

  1. Using Python for Security Testing
  2. Security Testing

You can understand how those things conflict. Python is a tool to help you accomplish a task. If you do not understand the task, then the tool will not be helpful.

Scapy is a wonderful python-based tool that will help you understand basic traffic concepts.

Twill is a python-based tool for web application testing.

But first, understand what you hope to accomplish with the tools. Know what xss is first before you throw a tool at a site. Once you know what xss is, it becomes easy for someone who knows python scripting to write their own tools. The benefit of pre-made tools is that you benefit from the experience of others.

To learn more about Security Testing, you can look at DVWA or Mutillidae. For a more complete collection of tools and targets, try out the Web Security Dojo.

share|improve this answer

if you decide to focus on using Python for security, I will recommend you to read these books:

  • Violent Python: A Cookbook for Hackers, Forensic Analysts, Penetration Testers, and Security Engineers
  • Gray Hat Python: Python Programming for Hackers and Reverse Engineers

And to get a glimpse what is Cryptography in terms of Python (this one is free):

Last but not least, OWASP has project which focus on Python security called Unfortunately, the project hasn't been really active lately.

BTW, on May 2014, my paper is accepted at PyCon APAC 2014. The conference was held in Taiwan. You may take a look at my paper and watch the video hence the organizer recorded my session. The title of my paper is Python for Application Security Testing.

share|improve this answer

This course sounds perfect for you

I have watched his videos In the past and they are great quality.

share|improve this answer

Just learn how TCP/IP work, code for example own server, own traceroute, understand how RAW SOCKET works. Play with wireshark to understand how packet looks like

share|improve this answer
@Ephexeve - usual practice is not to add a comment, but to upvote answers you like, and to click the check mark next to the answer which helps you most. – Rory Alsop Jun 15 '12 at 16:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.