When it comes to creating powerful and effec- tive hacking tools, Python is the language of


t H e n e t w o r k: B a s i c s


Download 6.5 Mb.
Pdf ko'rish
bet13/17
Sana20.10.2023
Hajmi6.5 Mb.
#1712575
1   ...   9   10   11   12   13   14   15   16   17
Bog'liq
Black Hat Python-1st Edition

2
t H e n e t w o r k: B a s i c s
The network is and always will be the sexiest arena 
for a hacker. An attacker can do almost anything with 
simple network access, such as scan for hosts, inject 
packets, sniff data, remotely exploit hosts, and much 
more. But if you are an attacker who has worked your 
way into the deepest depths of an enterprise target, 
you may find yourself in a bit of a conundrum: you have no tools to execute 
network attacks. No netcat. No Wireshark. No compiler and no means to 
install one. However, you might be surprised to find that in many cases
you’ll find a Python install, and so that is where we will begin.
This chapter will give you some basics on Python networking using the 
socket
1
module. Along the way, we’ll build clients, servers, and a TCP proxy; 
and then turn them into our very own netcat, complete with command shell. 
1. The full socket documentation can be found here: http://docs.python.org/2/library/socket.html.
www.it-ebooks.info


10
Chapter 2
This chapter is the foundation for subsequent chapters in which we will 
build a host discovery tool, implement cross-platform sniffers, and create a 
remote trojan framework. Let’s get started.
Python networking in a Paragraph
Programmers have a number of third-party tools to create networked 
servers and clients in Python, but the core module for all of those tools is 
socket
. This module exposes all of the necessary pieces to quickly write TCP 
and UDP clients and servers, use raw sockets, and so forth. For the purposes 
of breaking in or maintaining access to target machines, this module is all 
you really need. Let’s start by creating some simple clients and servers, the 
two most common quick network scripts you’ll write.

Download 6.5 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   17




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling