[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Re: [shell-script] Wget e Symantec
From: |
moysespr |
Subject: |
Fwd: Re: [shell-script] Wget e Symantec |
Date: |
Tue, 20 Jan 2004 18:09:59 -0800 (PST) |
Oi pessoal:
Esta mensagem postei ontem, mas consegui me atrapalhar e enviei para mim mesmo,
só percebendo hoje.
Como realmente é scripting e, para não perder o trabalho, estou encaminhando-a.
----------------------
A titulo de curiosidade. Fiz um script há algum tempo que chamo de http. Uso-o
às vezes no lugar do "lynx -source". Não pensei que funcionasse para baixar um
binário, mas escrevi:
http
"www.symantec.com.br/avcenter/download/us-files/20040118-019-i32.exe">syman.exe
E olhem o resultado:
ls -l sy*
-rw-r--r-- 1 web ppp 4483920 Jan 20 00:39 syman.exe
Não vi, rapidamente, nada sobre md5 do arquivo no site para checar, mas
ATENÇÃO: ele está com tudo, inclusive o cabeçalho HTTP que é preciso retirar,
mas com um editor hexa já vi, logo abaixo do header, o tradicional MZ... dos
arquivos .EXE. Vi também uma série de nulls e textos legíveis. Portanto não
deve estar tão errado. Não olhei o final.
É preciso verificar se depois de tirar o header o arquivo bate.
Como está, o script só deve funcionar no Bash. Não confiem nele antes de fazer
seus próprios testes.
Para finalidades digamos, meio acadêmicas, ei-lo:
---http
#!/bin/bash
lin(){ echo --------------------------------------------------------;}
debugar=false # comentar esta linha para DEBUGAR
if [ "$2" == "-d" -o "$3" == "-d" ];then
debugar=''
fi
[ "$1" ] || {
lin;echo "Obtem dados via http. Envia dados formuários GET e POST."
echo "uso: ${0##*/} URL [post_data] [-d] "
echo "Ex.: ${0##*/}"' "www.d1.com/a/b" "usr=u1&passwd=pw1"';lin; exit 1; }
Meth=GET;[ $2 ]&&Meth=POST
Port=80
Pto=${1#http://};Pto=${Pto#ftp://} # se tiver, tira "http://" e "ftp://"
Server=`echo "$Pto"|cut -d'/' -f1` # pega string à esquerda de "/"
Pto="/`echo "$Pto"|cut -d'/' -f2-`" # string a partir de "/" até o final
Dados=`echo -n "$2"` # no encode
Dados=`echo -n "$2"|sed 's,:,%3A,g'` # substitui ":" por "%3A"
Dados=`echo -n "$Dados"|sed 's,/,%2F,g'` # substitui "/" por "%2F"
Length=0;if [ "$2" != "" ];then Length=`expr length "$Dados"`;fi
send(){
# CABECALHO HTTP
echo -en "$Meth $Pto HTTP/1.0\r\n\
Host: $Server\r\n\
Content-type: application/x-www-form-urlencoded\r\n\
" >&$Dst
# QUANTIA DE DADOS P/ POST
if [ $Length -gt 0 ];then
echo -ne "Content-length: $Length\r\n" >&$Dst
fi
# ENVIA DADOS SE HOUVER
echo -ne "\r\n$Dados" >&$Dst
}
Dst='1' # saída default
if $debugar;then
echo "Modo DEBUGAR: devido ao -d na chamada de $0"
echo Destino: $Server:$Port;lin
fi
if ! $debugar;then
exec 3<>/dev/tcp/"$Server"/$Port||{
echo "$Server:$Port inacessível!"; exit 1 ; }
Dst='3'
fi
send "$2"
if ! $debugar;then
cat <&3
exec 3<&-
else
echo "";lin;echo "==> Com debugar nao tem conexao com Server."
echo " De qualquer forma, aqui estaria a resposta dele."| cat>&$Dst
fi
---
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Fwd: Re: [shell-script] Wget e Symantec,
moysespr <=