17 Nisan 2012 Salı

OpenSSL Kullanim Ornekleri

OpenSSL kendi icerisinde s_client isminde bir test modulu barindirmaktadir. Bu modul sayesinde SSL/TLS kullanan sunucularin testlerini gerceklestirebilirsiniz. Asagidada ornek bir komut bulunmaktadir.



cihat@cx$ openssl s_client -connect www.isbank.com.tr:443
CONNECTED(00000003)
depth=2 /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/1.3.6.1.4.1.311.60.2.1.3=TR/2.5.4.15=V1.0, Clause 5.(b)/serialNumber=431112/378694/C=TR/ST=-/L=Istanbul/O=TURKIYE IS BANKASI A.S./OU=BT URUN VE HIZMET YONETIMI/OU=Terms of use at www.verisign.com/rpa (c)05/CN=www.isbank.com.tr
   i:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)06/CN=VeriSign Class 3 Extended Validation SSL SGC CA
 1 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)06/CN=VeriSign Class 3 Extended Validation SSL SGC CA
   i:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
 2 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5
   i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIGKTCCBRGgAwIBAgIQbmwWkjukOByMKOXpV3WtwzANBgkqhkiG9w0BAQUFADCB
vjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
ExZWZX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.S./OU=BT URUN VE HIZMET YONETIMI/OU=Terms of use at www.verisign.com/rpa (c)05/CN=www.isbank.com.tr
issuer=/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)06/CN=VeriSign Class 3 Extended Validation SSL SGC CA
---
No client certificate CA names sent
---
SSL handshake has read 4533 bytes and written 435 bytes
---
New, TLSv1/SSLv3, Cipher is RC4-SHA
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : RC4-SHA
    Session-ID: E010BAAF623F3148CDAF4A4AAC9D19BB79DF78F3717ED6D31737E46E933396D9
    Session-ID-ctx: 
    Master-Key: D5F630E62A53532102C8CC8D8FDEF8282144612BB46795487C750C4E91ECAE9B2F01D8FBC7B54FE7C2C2F06CE198DB18
    Key-Arg   : None
    Start Time: 1334675352
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
---

Bir dosyanin hash degeri alinabilir.

cihat@cx$ openssl dgst -sha1 -c sokoban.sed
SHA1(sokoban.sed)= e4:ec:aa:86:63:e9:d4:07:d3:5a:24:21:ea:b1:83:48:ff:ae:59:3d


cihat@cx$ openssl dgst -ripemd160 -c sokoban.sed
RIPEMD160(sokoban.sed)= fe:5f:bc:7e:8a:b8:44:ac:12:c6:9e:fd:6b:4d:d3:df:b7:b2:76:92

cihat@cx$ openssl dgst -md5 -c  sokoban.sed
MD5(sokoban.sed)= 8d:74:bf:ab:be:ea:79:3d:9e:c8:6a:42:62:ca:7b:f1


cihat@cx$ md5sum sokoban.sed
8d74bfabbeea793d9ec86a4262ca7bf1  sokoban.sed






8 Nisan 2012 Pazar

AppleScript Ornegi


MacOSX sistemlerde kullanicinin rutin islerini otomatize edebilmesi icin kullanimi oldukca kolay olan bir programlama arabirimi bulunmaktadir. Bu arabirimi kucuk bir uygulama ile gosterneye calisacagim. Daha ayrintili bilgiye ihtiyac duyanlar buradan faydalanabilirler.

herhangi bir lokasyondan internete baglandigimiz zaman, dis ip adresinizi ogrenmek isteyebilirsiniz. Bunun icin "AppleScript Editor" icerisine asagidaki kod parcacigini yaziyoruz. 

property theIP : ""
set TheResult to (do shell script "curl -f http://checkip.dyndns.org")
set Olddelim to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to "Current IP Address: "
set LongIP to item 2 of every text item of TheResult as text
set AppleScript's text item delimiters to ""
set stopPoint to (offset of "< " in LongIP)
set myip to characters 1 through (stopPoint - 1) of LongIP as text
if theIP is "" then
set theIP to myip
display dialog "Your IP is : " & myip
end if
if myip is not equal to theIP then
display dialog "Your IP is : " & myip
set theIP to myip
end if
set AppleScript's text item delimiters to Olddelim
on error
set AppleScript's text item delimiters to Olddelim
end try

istedigimiz betigi yazdiktan sonra derleyerek sistemde calismasini testedebiliyoruz. Daha sonrasinda bu uygulamayi kaydederek sistemde istedigimiz zaman calisir hale etirebilirz.

kaynaklar: