Python Go Hackers
Python Go Hackers
for
Hackers
v3
About the author:
Weidsom Nascimento
Python:
A pretty good programming language that innovate with your simplicity and your syntax
that turn easy to create powerful softwares with less efforts than others languages!
Advantages/Benefits of Python:
The diverse application of the Python language is a result of the combination of features
which give this language an edge over others. Some of the benefits of programming in
Python include:
For some tasks Python can be pretty good, in this book I’ll show you how you can perform
many hacking tasks!
Golang:
Sockets
The first thing we need to know in Code Hacking is work with sockets because with
sockets we can manipulate some protocols and code some tools to hack using these
protocols, sockets in Python is pretty easy to understand and implement.
Instance methods require a socket instance returned from socket . The socket module
has the following instance methods:
➢ sock.bind( (address, port) ) : Bind the socket to the address and port
➢ sock.accept() : Return a client socket with peer address information
➢ sock.listen(backlog) : Place the socket into the listening state
➢ sock.connect( (address, port) ) : Connect the socket to the defined host and port
➢ sock.recv( bufferLength[, flags] ) : Receive data from the socket, up to buflen
(maximum bytes to receive) bytes
➢ sock.recvfrom( bufferLength[, flags] ) : Receive data from the socket, up to buflen
bytes, also returning the remote host and port from which the data came
➢ sock.send( data[, flags] ) : Send data through the socket
➢ sock.sendall( data[, flags] ) : Send data through the socket, and continues to send
data until either all data has been sent or an error occurred
➢ sock.close() : Close the socket
➢ sock.getsockopt( lvl, optname ) : Get the value for the specified socket option
➢ sock.setsockopt( lvl, optname, val ) : Set the value for the specified socket option
A socket can be created by making a call to the class method socket() in the socket
module. This will return a socket in the domain specified. The parameters to the method
are as follows:
• Address family: Python supports three address families.
◦ AF_INET: Used for IP version 4 or IPv4 Internet addressing.
◦ AF_INET6: Used for IPv6 Internet addressing.
◦ AF_UNIX: Used for UNIX domain sockets (UDS).
• Socket type: Usually, socket type can be either SOCK_DGRAM for User Datagram
Protocol (UDP) or SOCK_STREAM for Transmission Control Protocol (TCP).
SOCK_RAW is used to create raw sockets.
• Protocol: Generally left at the default value. Default value is 0.
We can see that we can’t send a string directly in a network socket that is the reason that
we need “bytes(MESSAGE_TO_SERVER.encode(“UTF=8”))”. Every time that we want
send a string is need a conversion to bytes!
We can see some characteristics of a Blue Dragon RAT in this simple loader above, we are
using a subprocess as a PIPE to the shell to run some commands but as you can see we
are able to implement some custom commands like “elevate” directly in the RAT loader,
this is awesome because we can directly bypass a limited shell or a sanbox environment!
Above we can see how the server controller of the RAT looks like, this is the most
important part of the RAT because is our front to work, here we can implement some
function like “encrypt” to allow us bypass IDS and IPS systems!
Scapy is one of the best module to network hacking using python, scapy is capable of
manipulate almost all protocols and every single day is added more one to github master
branch!
Below we can see that scapy can easily work with all layers and in separated way too…
this is one of the best things in the world of networking hacking because we can easily
craft some tools for specific systems and environment or new types of attacks if you are
or want be a security researcher!
Creating a 3 way handshake Packet
For TCP protocol we need to know how to craft by hand a 3 way handshake packet, we
can see below that do this is pretty easy!
Create a SYN Stealth scanner
Everyone know that we have the powerful nmap, but some times we need a custom scan
for our tools, and we don’t will use a machine gun to kill a thing that is knife is better… for
these moments we can use scapy to do that!
Above we can see the steps to create a HALF-OPEN scan for our scripts and tools, we can
see these detailed results that is possible work with many options and change the flags
to do others type of scan.
We are loading the payloads from a .txt file and sending it to the web application!
The rest of this chapter is for training students only! Join our Training to learn more!
Look that!!! Our shell is 100% undetectable, AntiVirus can’t do anything with us! But how
this work?
Pretty simple, motherfucker… with this method the code is re-embedded in yourself many
times, the result C code is impossible to understand, the dynamic links are loaded from
resources… And the most important part every time that we compile the code result is
completely different so AntiVirus never will be able to find this!
Wait… but and debuggers and tracers? Keep calm… debuggers, tracers, network analysis
tools and others things don’t work on binaries compiled using this method… so… you
never will be catched!
So… is perfectly possible to compile Python source codes to run without python
interpreter, is perfectly possible do it 100% undetectable, you need just know to code and
hack like a pro!
Go get links
Sometimes you will need get all links in the page that you are targeting do this in Go is
pretty easy.
With this code we will get all links in the page, if we add a loop inside the list we get a
powerful crawler in Golang. For our website hacking tools this is essential!
GO scripts finder
In Website hacking find scripts is a essential phase because we can hack the website by
these javascipt libs like ajax, bootstrap…
This will return all scripts in the page, we can combine it with our crawler to perform a
better action by FUZZING! That we give us the ability to exploit some functions and hack
the website!
Go Fuzzing to exploit
For a advanced hacker know to fuzz if required because you need know it to develop
exploit, write a fuzzer in Go is easy and pretty customizable.
Go Exploit “writable”
Now lets try make a exploit to find writable files on the machine, this is extreme useful in
a suid root search, when we found something like that we have instant root access in the
machine and this… this is the endgame!
The rest of this chapter is for training students only! Join our Training to learn more!
The rest of this chapter is for training students only! Join our Training to learn more!
The rest of this chapter is for training students only! Join our Training to learn more!
Join our FULL Training: Python and Go for Hackers!