[ Home | Liste | F.A.Q. | Risorse | Cerca... ]


[ Data: precedente | successivo | indice ] [ Argomento: precedente | successivo | indice ]


Archivio: Giugno 2004 ml@sikurezza.org
Soggetto: Re: [ml] toth
Mittente: Igor Falcomata'
Data: Mon, 28 Jun 2004 00:59:09 +0200 (CEST)
Ho levato la parte in html (vi ricordo la policy di text only, please) e
modifcato alcuni nomi di file/dir  (ricordo anche la policy bacchettona,
please).

Ps: salvo non  si parli dell'implementazione e del metodo,  piu' che del
codice, credo che il thread possa tranquillamente continuare su devel@

bye
Koba (moderatore)

----- Forwarded message from "Marco.maccarini" <marco.maccarini<at>email.it> -----
Date: Sat, 26 Jun 2004 16:39:43 +0200
From: "Marco.maccarini" <marco.maccarini<at>email.it>
Subject: Re: [ml] toth

Alcune prove con ToTH, Il toctou hunter, by snagg
il mio solo e unico mito
Iniziai con qualcosa di lievemente complicato, perche\' 
convinto della validita\' del codice:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(void)
{
 int fd,fd2;
 fd=open(\"/root/Lamer/stoc___o\",O_RDWR);
 chroot(\"/root/Lamer/\");
 fd2=open(\"/stoc___o\".O_RDWR);
}
subito dopo, molto impaziente:
bash-2.05b# gcc prova1.c -o prova1
bash-2.05b# ./toth ./prova1
ToTH is TOcTou  Hunter, enjoy ...

ToTH:This program is under the terms of GNU GPLv2.
        Please report any bugs to Snagg [snagg<at>openssl.it].
        If you don\'t want to see this run the program --quiet
ToTH:[Lunch the program]................
                                        [DONE]
ToTH:[Tracing syscalls].................
                                        [DONE]
ToTH:[Searching for TOCTOU].................
                                        [DONE]
REPORT :
ToTH:There aren\'t any TOCTOU
azzz :( che peccato... cmq non mi do per vinto... questo era un
esempio un po\' complesso dai.. andiamo con qualcosa di piu\' facile.
quindi:
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(void)
{
int fd,fd2;
char *string1 = \"su_a\\n\";
char *string2 = \"moltissimo\\n\";
char buffer[1024];
fd=open(\"/root/Lamer/stoc___o\",O_RDWR);
fd2=open(\"/root/Lamer/stoc___o\",O_RDWR);
write(fd, string1, strlen(string1));
write(fd2, string2,strlen(string2));
read(fd, buffer, sizeof(buffer));
lseek(fd2, SEEK_SET, 0);
write(fd, string2, strlen(string2));
read(fd2, buffer, sizeof(buffer));
}
eheh qui vado sul sicuro!!! dai dai proviamo.
bash-2.05b# gcc prova2.c -o prova2
bash-2.05b# ./toth ./prova2
ToTH is TOcTou  Hunter, enjoy ...

ToTH:This program is under the terms of GNU GPLv2.
        Please report any bugs to Snagg [snagg<at>openssl.it].
        If you don\'t want to see this run the program --quiet
ToTH:[Lunch the program]................
                                        [DONE]
ToTH:[Tracing syscalls].................
                                        [DONE]
ToTH:[Searching for TOCTOU].................
                                        [DONE]
REPORT :
ToTH:There aren\'t any TOCTOU
Come there aren\'t??? :(( noooo :((
Mi viene quindi qualche sospetto, e fiducioso vado a prendere 
l\'esempio da lui descritto come \"TOCTOU molto semplice e 
poco realistica\"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sched.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int
main (int argc, char **argv)
{
  FILE *f;
  if (argc != 3)
    {
      printf (\"USAGE %s : file string\\n\", argv[0]);
      exit (-1);
    }
  if (!access (argv[1], W_OK))
    {
      f = fopen (argv[1], \"wb+\");
      fprintf (f, argv[2]);
      fflush (f);
    }
  else
    {
      perror (\"access\");
      exit (-1);
    }
  return 0;
}
a scanso di equivoci lo faccio partire normalmente:
bash-2.05b# touch provatoth
bash-2.05b# ./a.out provatoth provaprova
bash-2.05b# cat provatoth 
provaprova
pare funzionare, quindi tutto fiducioso:
bash-2.05b# ./toth ./a.out provatoth provaprova
ToTH is TOcTou  Hunter, enjoy ...

ToTH:This program is under the terms of GNU GPLv2.
        Please report any bugs to Snagg [snagg<at>openssl.it].
        If you don\'t want to see this run the program --quiet
ToTH:[Lunch the program]................
                                        [DONE]
ToTH:[Tracing syscalls].................
ToTH:Error while taking data from the child 
NOOOOOOOOOO, delusioneeeeee :((( Che e\' sto errore :((
Fortunatamente con una piccola modifica il programma pare funzionare:
bash-2.05b# ./toth ./a.out provatoth provaprova
ToTH is TOcTou  Hunter, enjoy ...

ToTH:This program is under the terms of GNU GPLv2.
        Please report any bugs to Snagg [snagg<at>openssl.it].
        If you don\'t want to see this run the program --quiet
ToTH:[Lunch the program]................
                                        [DONE]
ToTH:[Tracing syscalls].................
                                        [DONE]
ToTH:[Searching for TOCTOU].................
                                        [DONE]
REPORT :
The program is not suid,you cannot overwrite files in which you don\'t have the r
ight privileges
ToTH:There are 1 TOCTOU:
ToTH:1  between SYSCALL= open , path = provatoth and SYSCALL= access ,path = pro
vatoth  
ToTH:END
e gia\' stavo per aprire le bottiglie di spumante, quando mi venne la malsana 
idea di provare anche il suo secondo esempio di \"race condition per antonomasia:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
int first,second,*pointer;
void assigvar(void*arg);
void* getnextvar(void *arg){
pointer=&first;
assigvar((void*)pointer);
while(first > 4){
pointer=&second;
assigvar((void*)pointer);
 }
while(second > 4){
pointer=&first;
assigvar((void*)pointer);
 }
return NULL;
 }
void assigvar(void *arg){
arg=0;
arg++;
printf(\"%d\\n\",(int)arg);
 }
int main(){
pthread_t id, t;
    if ((pthread_create(&id, NULL, getnextvar,NULL)) != 0)
 exit(1);
    if ((pthread_create(&t, NULL, getnextvar,NULL)) != 0)
 exit(1);
    pthread_join(id, NULL);
    pthread_join(t, NULL);
    return 0;
}
ma come ben sappiamo chi troppo vuole, nulla stringe :(
bash-2.05b# gcc proof1.c -lpthread
bash-2.05b# ./toth ./a.out 
ToTH is TOcTou  Hunter, enjoy ...

ToTH:This program is under the terms of GNU GPLv2.
        Please report any bugs to Snagg [snagg<at>openssl.it].
        If you don\'t want to see this run the program --quiet
ToTH:[Lunch the program]................
                                        [DONE]
ToTH:[Tracing syscalls].................
1
                                        [DONE]
ToTH:[Searching for TOCTOU].................
                                        [DONE]
REPORT :
ToTH:There aren\'t any TOCTOU
sconforto e delusione mi colgono :( come puo\' qualcuno pubblicare un tool..
che non va nemmeno con gli esempi forniti???
arrivederci a tutti

PS: qui sotto la patch che dovrebbe far funzionare toth nell\'unico caso... 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Crea le tue etichette personalizzate on-line e le riceverai direttamente a casa tua!
Ben cinque righe a tua disposizione
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=2410&d=20040626



----- End forwarded message -----

Attachment: toth.diff
Description: Binary data




[ Home | Liste | F.A.Q. | Risorse | Cerca... ]

www.sikurezza.org - Italian Security Mailing List
(c) 1999-2005