Abusing the Past (A 2600 Article, published Volume 32 Number One)

This article I wrote for 2600, was first published in 2600 Magazine (www.2600.com), Volume Thirty-Two, Number One, Spring 2015. As it has now been in physical circulation for some time, I now publish it online.

Enjoy.

Abusing the Past
by Buanzo

DISCLAIMER: If you do evil shit with this information, I hope something really bad happens to you. Information is free, but people are human.

It has been quite a long time since my last article, so I’ll keep it short.

In this day and age, there are mass scanning tools and several easy-to-query databases that make it
a simple thing to find sites with vulnerabilities. Hackers and other agents with all hat-colors use them every day to do their jobs. I will present you today
a very simple technique that will, when certain special circumstances are met, allow you to scan the past for vulnerabilities.

When we want to have a website, we obtain a [sub]domain name, point it to some web hosting server’s IP, and configure it to serve that
website. We also get DNS service somehow. I am sure you’ve done this before, so I’ll skip those details. So now, www.example.com is running on server A.

Yay, we got a website! By the way, it is Joomla or some other CMS like wordpress, etc.

The days/months/years pass, and we find ourselves in the need to move the website to another server, for whatever reason (luckily, cause we have so many
visits the old server cant handle them). The new website is configured on the new server, the DNS is updated, and voila, visits now arrive at the new server.

Nice.

But…

If we go to Netcraft, and check some domain name using their tools, we MIGHT find the hosting history of a website. Yes, www.example.com used to run on server A,
then server B, now server C! And, wow, thats weird, the old servers are still up and running.

So, www.example.com MIGHT still be configured in one of those servers. You know how hosting companies [dont] do their homework sometimes 馃槈

So, an attacker could fire up a scanner, and by any means available, target www.example.com thru the older IP addresses, and scan our OLD WEBSITE[s],
which, of course, we no longer keep updated (maybe not even the server, for that matter…). And you know what outdated usually means: holes. Lots of them.

And holes lead to lots of things: remote code execution, data exfiltration, resource control.

An Nmap NSE script could be written to scan some domain name’s hosting history, and, essentially, abuse the past.

Go. Check your hosting history. Don’t say I did not warn you. 馃槢

Bye!

Buanzo.


Artículos relacionados:

Falla de escalacion de privilegios en procesadores intel 64-bit

El CERT de Estados Unidos ha notificado de una falla en los procesadores Intel que podria permitir a atacantes tomar control de MS Windows (r) y otros sistemas operativos. El fallo fue notificado a traves de un advisory liberado esta semana. Se podria explotar la vulnerabilidad para ejecutar codigo malicioso con privilegios de kernel, segun el blog de Bitfedender. ‘Algunos sistemas operativos de 64 bits y software de virtualizacion ejecutandose en equipamiento con chips Intel son vulnerables a un ataque de escalacion de privilegios.’. ‘La vulnerabilidad podria ser explotada para elevacion de privilegios local, o para escapar de una maquina virtual al host fisico.’. – Segun el articulo, los sistemas operativos afectados incluyen a Windows 7, Windows Server 2008 R2, versiones 64 bit de FreeBSD y NetBSD, asi como los sistemas que incluyan el hypervisor Xen.”.

Original click aqui


Artículos relacionados:

Chau amigo


Artículos relacionados:

POR FIN! Enigform ya anda en Firefox 10+

Bueno, despues de BOCHA DE TIEMPO, finalmente pude actualizar el codigo de Enigform (mi extension firefox que extiende HTTP con algunas cositas de OpenPGP divertidas como por ejemplo inicio seguro de sesiones).

Ahora voy a tunearlo y hermosearlo un poco porque tiene bocha de llamadas dump() para hacer depuracion 馃槢 y mas de una de esas es insegura 馃槢

Asi que, LOS QUE QUIERAN PROBAR LA BETA de Enigform 0.9.0 pueden descargarla de http://www.buanzo.com.ar/files/enigform.xpi – No lo pongo como link asi piensan dos veces antes de hacerlo!


Artículos relacionados:

Proactive protection enhancements for fail2ban – Part 1

Introducing fail2ban, and first steps towards sharing attacker’s IP
by Arturo ‘Buanzo’ Busleiman

Fail2ban is a lovely python-based tool written by Cyril Jaquier that
monitors different logfiles for lines matching regular expressions.聽 From
those lines it extracts the attackers IP address, and runs a command passing
that as a parameter.

In more simple terms, it detects when your SSH (or other service) is
“attacked”, and then proceeds to firewall the attacker.

We could start discussing about false positives here, specially for UDP
based services or log-injection vulnerable daemons, but I’d like to focus on
a special usage scenario: what if I manage multiple servers? Should I wait
for the same attacker to target each of my fail2ban-monitored servers?

Maybe I could share the attacker’s IP, collected from a brute-force attempt
to SSH on server1, with the rest of the servers I manage. Or with my
friends’ servers. Or maybe with everybody through twitter? Well, maybe
everybody is too much and possibly a bad idea if fail2ban is detecting false
positives, or spoofed IP addresses. But it could also help out if you manage
your own small or medium sized group of servers.

If you think this might interest you, then keep reading.

Architecturally, fail2ban is one main process (the fail2ban-server). It
needs a so-called “jail” definition (a group of filter+action+logfile
configuration items), a filter definition (regular expressions for a certain
kind of logfile, such as sshd or apache error log), and an action
definition (what to do when a filter detects an attacker, in that certain
jail).

This is what the standard ssh jail looks like:

[ssh]
enabled = true
port聽聽聽 = ssh
filter聽 = sshd
logpath聽 = /var/log/daemon.log
maxretry = 3

As you can see, it defines if the jail is enabled or not (active or not),
what destionation port[s] it will block for the attacker, what filter
(regex) is to be used to determine (or ignore!) attackers, and which
logfile[s] it will monitor. Also, the number of times the same attacker must
be detected in a pre-defined time period for the action to be executed.

What does that mean? Easy: If, by any reason, you or another user mistypes
the password and is trying to access the server from a non-whitelisted IP
address, instead of trying more than 3 times in a row, it should wait a
couple minutes and try again. Having a detection threshold helps avoiding
false positives.

Fail2ban has the ability to ignore certain IP addresses or netblocks, or
have different actions for each jail. This level of flexibility is what
interest us for the purpose of this article.

Standard fail2ban configuration contains 20+ actions, spanning
iptables, ipfw, shorewall, etc. More than 30 filter definitions, including
regexes for apache, sshd, php-url-fopen, proftpd, pam and more.

For a detailed fail2ban-configuration document, I recommend you just
download the package and read its filters, actions and jails. It’s very self
explanatory. A knowledge of regular expressions will come in handy,
especially if your POSIX-compatible system has differences in the logfile
format for the services you’re trying to protect.

* How to share the attacker’s details

Lets imagine we own a small web-hosting company, providing ssh access to our
limited number of customers. Or a big web app load-balanced and with
failover protection spanning 10 geographically-distant dedicated servers.

Also, let’s assume we have a standard ssh jail configured to run iptables,
matching the sshd filter.

If server1’s fail2ban detects, for instance, that an attacker with IP address
203.0.113.20 is attempting to brute-force our ssh service
(note: that address is part of the TEST-NET-3 netblock, allocated by
RFC 5737 for usage in documentation), then the attacker will be firewalled
using iptables.

But only on server1.

Should I manually filter the attacker on the other servers? Well, it’ll take
a long time. Or I could write a script to do it. Or maybe I could try and
work with what fail2ban gives me: lots of flexibility.

The first time I started thinking about this “fail2ban-cluster” tool, I
thought I should design a new “action”, one that would not only run iptables
but also notify the other servers.

But that’d be a waste of resources, not to mention TIME.

So I decided to use a different approach. Fail2ban has a lovely log file,
that tells us when a certain attacker is banned, and then un-banned after a
configurable amount of time.

Maybe I could write a filter to read fail2ban’s log itself, with an action
to spread that IP address, possibly using lynx, or curl, to as many other
servers as I wanted, by means of some authenticated http service. And I’d
run that on top of my inter-server virtual private network, for good
measure.

This is how fail2ban’s log file looks like:

2011-05-01 15:23:56,380 fail2ban.actions: WARNING [ssh] Ban 203.0.113.20
2011-05-01 15:38:57,641 fail2ban.actions: WARNING [ssh] Unban 203.0.113.20

As you can see, we have entries for Ban and for Unban events. But I do not
want to notify unban events, because different servers could have different
how-long-to-ban-the-attacker policies. I just want to notify BANs.

So maybe a simple regular expression like: ‘\ Ban\ <HOST>$’ would take care
of detecting BANs only. And it does. Fail2ban provides the fail2ban-regex
tool, to test regular expressions against a sample log line or file.

I ran it like this: fail2ban-regex /var/log/fail2ban.log ‘\ Ban\ <HOST>$’

It yielded the expected results. The special <HOST> tag in the regex is what
tells fail2ban how to extract the IP address from there. Currently, it
supports IPv4 but the fail2ban team and contributors are working on IPv6
support as I write.

So, now I can write a fail2ban filter configuration file, such as this:

*** contents of /etc/fail2ban/filter.d/f2bcluster.conf ***

[Definition]
failregex = \ Ban\ <HOST>$
ignoreregex =

*** end ***

But we have no action. We can’t write a jail definition without an action!

An action file contains definitions of commands to run: once at the start of
fail2ban, once at the stop, once before each ban event, and the ban action
itself, and the unban one. It also includes a default name, port and
protocol definition, in case the jail config file does not define them.

Inside each action definition you can use special tags, similar to the
<HOST> one used in filters. For actions, we have <ip> (holds the attacker’s
IP obtained from <HOST>), <name> and <protocol> (used for some iptables
parameters).

When the commands are run, each of those special tags will be replaced by
the values we expect.

As an exercise to the reader, or you can wait for the next article in this
series, I’d like you to write an actioban definition, with these hints:

a) the actionban should be a simple bash script
b) the bash script will use lynx/curl to send an authenticated http request
c) the request will go the server2, server3, etc. As many times as required.
d) the request will be received by a simple python-based (or php…) script
that REQUIRES http authentication. It will receive the attacker’s IP from
the QUERY STRING.
e) The http python/php/whatever script will NOT run iptables, but write to a
log file.

As you probably guess, the log file will be monitored by that server’s own
fail2ban instance, by means of a more classic filter definition.

And remember: security is a state of mind.

About me

I’ve been using GNU/Linux non-stop since September 1995, when I
was 13 years old. Currently working in the IT security area as a consultant,
sysadmin and forensics specialist. I’m an OWASP Project Leader (check out
Enigform and mod_openpgp for Apache). I play the guitar, and currently
experiencing with electronic music and livecoding with fluxus. I’m a geek.


Artículos relacionados:

SQL Injection…

Es un tema que afecta a la gran mayor铆a de los sitios web del mundo. Suena exagerado decirlo as铆, pero si lo analizamos desde la perspectiva de que es un problema que muchas veces los programadores resuelven 煤nicamente donde/cuando han sido atacados, y en el futuro vuelven a escribir c贸digo inseguro, tal vez entonces no suene tan descabellado.

Mucha gente escucha “inyecci贸n sql” y piensan que es un vector de ataque que permite 煤nicamente inyectar sentencias SQL con el objeto de modificar la informaci贸n de una base de datos.

Lo cual es verdad.

El problema es que la inyecci贸n sql, y dependiendo del sistema de base de datos utilizado por el backend del aplicativo web, permite incluso la ejecuci贸n de programas en el servidor donde se encuentra la base de datos a la cual se accede, indirectamente, v铆a web.

La principal soluci贸n es sencilla: desconfiar del usuario. O mejor a煤n, SABER que el aspecto de un sitio web, sus formularios, su tecnolog铆a AJAX, en fin, el dise帽o del sitio web no limitan de ninguna manera lo que el atacante puede enviar al servidor web.

驴Qu茅 quiero decir con eso? Much铆simos dise帽adores web incorporan alg煤n tipo de validaci贸n de datos, pero si esta validaci贸n ocurre 煤nicamente v铆a JavaScript en el NAVEGADOR del usuario, dicha validaci贸n para un atacante de poco conocimiento es sinceramente f谩cil de evitar.

Por ejemplo, filtrar un campo num茅rico para que solo admita caracteres del 0 al 9 utilizando 煤nicamente JavaScript, pasa a ser 煤nicamente algo “funcional” para el verdadero usuario, y una inexistente limitaci贸n para el atacante. Con instalar la extensi贸n Tamper Data para Mozilla Firefox, al momento de hacer clic en “enviar” a dicho formulario, podemos modificar a nuestro antojo casi cualquier aspecto de la consulta HTTP “fabricada” por el formulario. Y poner una comilla simple y ver que resultados no esperados (por ejemplo, un mensaje de error del motor de base de datos) surgen de dicha manipulaci贸n.

Si la validaci贸n de datos ocurriera TAMBI脡N del lado del aplicativo web, en el nivel que sea, dicha t茅cnica no ser铆a aplicable.

Referencias:
Puede encontrar m谩s informaci贸n:

https://www.owasp.org/index.php/Guide_to_SQL_Injection

https://www.owasp.org/index.php/Reviewing_Code_for_SQL_Injection
https://www.owasp.org/index.php/Testing_for_SQL_Injection_(OWASP-DV-005)锘

 

Y ahora, para divertirse un poco… piensen que abusar parametros, cookies, cualquier dato que pueda de una manera u otra ser controlado por un navegante es potencialmente un punto de inyeccion, no solo de SQLi, sino para XSS, RFI, etc.

 


Artículos relacionados:

Buscamos una Nieta

Pasen por este post de taringa. Si pueden votenlo, asi logra ser sticky.

 


Artículos relacionados:

Busqueda para SYMANTEC – Gente con cerebro en uso unicamente

Busco gente que se adecue a estos perfiles. Escribanme con CV en ingles a buanzo@buanzo.com.ar. Solo gente que se la banque. Quienes me manden el CV y no cumplan los requisitos solicitados, seran ignorados y formaran parte de anecdotas entre amigos. (obviamente, aca me refiero a la gente que manda el CV sin prestarle ni un 1% de atencion al pedido… he pedido sysadmins y me han caido recepcionistas, por ejemplo).

–聽聽聽 Data Loss Prevention Tech Support Engineer (Windows Server Administration, Networking, SQL, Active Directory, Linux)
–聽聽聽 NetBackup Tech Support Engineer (Windows Server Administration, backup software)
–聽聽聽 PGP Tech Support Engineer (Windows Server Administration, Linux, Microsoft Exchange Server, DNS & Networking, SQL, Encryption is a Plus)
–聽聽聽 Guardian Edge Tech Support Engineer聽 (Windows Server Administration, Microsoft Exchange Server, DNS & Networking, SQL, Encryption is a Plus)
–聽聽聽 Enterprise Vault Tech Support Engineer (Microsoft Exchange Server, SQL, Windows Server Administration)

Beneficios:
– Swiss Medical PREMIUM (plan m谩s alto)
– A partir del 6to mes, facultad paga (carreras de grado/postgrado, incluye libros)
– OPCIONAL: Plan de acciones (15% rebajadas).

– Combi (ida y vuelta)
– Horario flexible
– Certificaciones pagas (Microsoft, CISCO, IBM, VMWare, Linux, etc)

Requisitos:

– MUY buen ingles (excluyente)
– Conocimientos t茅cnicos
– CV en ingles (excluyente)


Artículos relacionados:

interpretacion rapida: UK cookies para sitios non-EU

* dicen que los de para mantenerse logeados y de carritos son validos y que no requieren consentimiento porque requieren que el usuario haya hecho click en botones… aca la palabra magica es que los cookies resultado de una accion del usuario estan todo bien..

* lo jodido: cookies de seguimiento, publicidad y terceras partes.

(gracias Ewarik por el rapido analisis!)

LINKS:
http://www.ico.gov.uk/~/media/documents/library/Privacy_and_electronic/Practical_application/advice_on_the_new_cookies_regulations.pdf

http://blog.statcounter.com/2011/05/the-cookie-directive/


Artículos relacionados:

La seguridad en el estado nacional

Estos ultimos dias un pibe empezo a tirar “advisories” a las listas de seguridad, contando de varios sql injection en diversos sitios .gov.ar

En esos mails, el chabon dice que le aviso a la ONTI (no se a que mail habra escrito, pero nadie lo conoce) y al arcert (area donde yo trabajo, TAMPOCO LLEGO NINGUN MAIL).

Y despues salta alguien que no se quien es, en twitter (https://twitter.com/ochoigualaD/status/63978046650191873) diciendo: “injec7or hell esta poniendo en riesgo la infraestructura nacional! Donde esta el arCert? Y la ONTI? Y @buanzo? Y la moto?” – Mis respuestas pueden verlas en twitter.com/buanzo

La posta es que el arcert no tiene por que responder ningun mail (cosa no aplicable en este caso, ya que NI SIQUIERA recibimos nada del tal injec7or…)

Hay una politica MUY BIEN redactada en ArCERT sobre que procedimiento seguir en caso de advisories que son dados a conocer al publico general, y eso, les aseguro, esta en proceso. Uno de los items de dicha politica es contactarse con el que envio la data a las listas publicas, el tal anonymous coward injec7or.

En 1996 yo encontre una seria vulnerabilidad de ejecucion de codigo remota en el sitio de la presidencia. Y le mande un mail al admin, CON MIS DATOS REALES. Ese admin el dia de hoy todavia es mi amigo, y todavia trabaja en el estado.

Si el flaco hubiera mandado los mails a ONTI y arcert como el dice, no hubiera tenido necesidad de usar un pseudonimo.

Saludos.


Artículos relacionados: