
[ Home | Liste | F.A.Q. |
Risorse | Cerca... ]
Archivio: Giugno 2004 ml@sikurezza.org Soggetto: Re: [ml] toth Mittente: snagg Data: Mon, 28 Jun 2004 09:40:39 +0200 (CEST)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 28 June 2004 00:59, Igor Falcomata' wrote:
> 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)
Rispondo sia qui che su devel (magari tale marco maccarini non e` iscritto li)
Sorry Koba.
> ----- 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
Grazie grazie..
Allora :
1) direi che race condition != TOCTOU(time of check , time of use)
2)Toctou== race condition nell'accesso ai file , ovvero sono quelli errori che
permettono di modificare un file (che non dovrebbe essere modificato)
sfruttando i permessi del programma.
Detto questo andiamo ad analizzare i tuoi esempio , caro marco..
> 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);
> }
Il programma non traccia chroot per una mia sbadatezza sorry:( , ma verra`
presto risolto il problema
> subito dopo, molto impaziente:
> #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));
> }
Qui non mi pare che ci sia un toctou , al massimo mancano i locks sui file ma
non e` un toctou e non e` compito del mio programma tracciarlo.(Io ti
consiglio di rivedere la definizione di toctou..)
> #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;
> }
Il mio secondo esempio e` appunto una race condition non un toctou(fai
riferimento al consiglio di imparare cosa siano i toctou..)
> 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
Il programma fa cio` che deve fare ovvero trovare i toctou..
La tua patch(fiducioso da cotanta bravura espressa ho deciso di leggere subito
la patch) :
if ((addr = ptrace(PTRACE_PEEKDATA, pid, ebx + (i*4), NULL)) < 0)
break;
che hai sostituito a questo:
addr = ptrace(PTRACE_PEEKDATA, pid, ebx + (i*4), NULL);
if(errno)
fatal("Error while taking data from the child ");
Qui c'e` stato il crollo di un mito , il grande marco maccarini che non solo
non capisce davvero nulla di race/toctou ma in piu` non e` capace neanche a
leggere un man , che recita:
Since the value returned by a suc-
cessful PTRACE_PEEK* request may be -1, the caller must check errno
after such requests to determine
whether or not an error occurred.
(applausi , ovazioni per maccarini..)
Bene , non so se quando hai postato eri sotto effetto di allucinogeni o cosa;
ma ti pregherei prima di fare il figo di cercare ,anche lontanamente , di
capire di cosa si parla.Detto questo credo di aver chiarito tutti i dubbi sul
programma e su un'idiota(scusa mio unico e solo dio marco) che cerca di
mostrarsi bravo .
Cheers
(scusate per la lunghezza del post)
>
> 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 -----
- --
You can download my public key from :
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xAF03412D
Per me si va tra la perduta gente
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iQCVAwUBQN+rgcRZnwcjHpecAQIl4gQAjpVd7lw5PHQfHAD2nE6nGdQJprbdHE4r
Naj4JmtxhBTYEOCsnaIC18t9HnT08pf35An3kxTplSpvYma6OTKNCc0SvsiCVuZ3
9HcSvGcy1NvcQRC6g9+hYZrYislHsA5bvHY8EoFYkH++2H/J6+BU6gaKS2VY8j0t
4iqBWkNiqk4=
=xo0Q
-----END PGP SIGNATURE-----
[ Home | Liste | F.A.Q. |
Risorse | Cerca... ]
www.sikurezza.org - Italian Security Mailing List
(c) 1999-2005