Archive for 2月, 2008

2月 28th, 2008

? 遜 GIFのバイナリ出力

Posted in Web/AP全舜 by tatenaga

 CGIなどでアクセス解析等の処理を実施し、IMGタグで読み込ませる為ぜ 1ピクセル四方の? 遜 GIFを出力する事がよぜ あります。この時の「1ピクセル四方の? 遜 GIF」を定義する場合、以? のようになります。

int LoadSpacerGif( void )
{
	char          str_header[512] = {'0'};
	unsigned char str_spacer[] = {
			0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00,
			0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
			0xFF, 0xFF, 0x00, 0x00, 0x00, 0x21, 0xF9, 0x04, 0x05, 0x14,
			0x00, 0x02, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
			0x01, 0x00, 0x00, 0x02, 0x02, 0x54, 0x01, 0x00, 0x3B };
	printf("Content-type: image/gif\n\n" );
	fwrite( str_spacer, sizeof(str_spacer), 1, stdout );
	fflush( stdout );

	return 0;
}
2月 9th, 2008

opensslの便利なコマンド

Posted in Linux, Solaris by tatenaga

□暗号化
 ”enc”でコマンドラインからお手軽に暗号化出来ます。

# 例)文字列「test」を「key」を鍵にして暗号化方? Blowfish、暗号化モードECBで暗号化し、さらぜ Base64でテキスト化ぜ md2でボ ッシュ化
$ echo "test" | /usr/bin/openssl enc -bf-ecb -base64 -k 'key' | /usr/bin/openssl dgst -md2
09470f10bffdc48af84c9b3c3a5652fb

? HTTPS通?
 通常、HTTPポートやSNMPポートにアクセスする時ぜ telnetを使用します。しかし、telnetでは平文しか扱えない為、HTTPSプロトコルは扱えません。”s_client”を使用すれぜ HTTPSアクセスが可能です。使い方ぜ telnetと全ぜ 同じ。

$ /usr/bin/openssl s_client -host 192.168.0.1 -port 443
CONNECTED(00000003)
depth=0 /C=JP/ST=Tokyo/L=Chuo-ku
verify error:num=18:self signed certificate
verify return:1
depth=0 /C=JP/ST=Tokyo/L=Chuo-ku
verify return:1
---
Certificate chain
 0	s:/C=JP/ST=Tokyo/L=Chuo-ku
	i:/C=JP/ST=Tokyo/L=Chuo-ku
---
Server certificate
-----BEGIN CERTIFICATE-----
MIICeDCCAeGgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UEBhMCSlAx
DjAMBgNVBAgTBVRva3lvMRAwDgYDVQQHEwdDaHVsdvvsdRkwFwYDVQQKExBSRUNS
VUlUIENPLixMVEQuMRAwDgYDVQQLFAdSRUNfQUJSMSMwIQYDVQQDExp3d3cuYWIt
cm9hZC5uZXQuYWJyfewrgeRlbDAeFw0wOTA5MTUwNzQzNDVaFw0xOTA5MTMwNzQz
NDVaMIGBMQswCQYDVQQGEwJKUDEOMAwGA1UECBMFVG9reW8xEDAOBgNVBAcTB0No
dW8ta3UxGTAXBgNVBAoTEFJFQ1JVSVQgQ08uLExURC4xEDAOBgNVBAsUB1JFQ19B
QlIxIzAhBgNVBAMTGnd3dy5hYi1yb2FkLm5ldC5hYnIucmFmdGVsMIGfMA0GCSqG
SIb3DQEBAQUAA4GNADCBiQKBgQCsdvsdF/Gd3eqRCgy/9Vt+hYauFfqLmh1UGQGO
UIMBQtITIhCSkqgCzhlYy4WgNR1irMWq1KfB9GyMk2KUEJaIK3d1FnyG5CPtsopc
dFpMLKDcVmqPasdvhzHKtjlaM0AnJLwWMjTUIohGrveLKP3Amc0fHi6K/8BHnad3
9EnTTQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAKYUfeMes/AGNu/vYVonEezttSyd
X89hSOh0iNCb4Ov0XYKYdQiWHEcCeZn9PW3NXYdBKpzmeevMAsQkhNjJHFx65zva
ocT0p5r3XtVi0Q7HNik4gix6EHfXo4RZnV1zkPoobja0386Q1vF4VAB40e+ZopP5
XXuUYRCUnZKUNoHD
-----END CERTIFICATE-----
subject=/C=JP/ST=Tokyo/L=Chuo-ku
issuer=/C=JP/ST=Tokyo/L=Chuo-ku
---
No client certificate CA names sent
---
SSL handshake has read 782 bytes and written 315 bytes
---
New, TLSv1/SSLv3, Cipher is RC4-MD5
Server public key is 1024 bit
Compression: NONE
Expansion: NONE
SSL-Session:
	Protocol  : TLSv1
	Cipher    : RC4-MD5
	Session-ID: 7E634A41CA78FF65BB31A7A8FD596F7dddDED0CB537BBBC0C32ED29B90C0F54C
	Session-ID-ctx:
	Master-Key: B2B4102E44C136790B1dddFB5226EE700FF441FF9527C03488E973B10AFC4EC38B604396A8F13F7AEBA8A0ECEF2ABD49
	Key-Arg   : None
	Krb5 Principal: None
	Start Time: 1255429426
	Timeout   : 300 (sec)
	Verify return code: 18 (self signed certificate)
---
GET / HTTP/1.0

HTTP/1.1 200 OK
Date: Tue, 13 Oct 2009 10:23:53 GMT
Server: Apache
Accept-Ranges: bytes
Connection: close
Content-Type: text/html

TEST

Tuesday, 13-Oct-2009 19:23:53 JST
read:errno=0