Security
StrongSwan and Android configs
by Emre Tugriceri on Apr.27, 2013, under Linux, Security, StrongSwan
root@six #cat ipsec.conf
conn tugriceri.com
leftsubnet=0.0.0.0/0
left=209.208.63.204
leftcert=/cert/strongswan.pem
leftauth=pubkey
leftsendcert=yes
leftid=six.tugriceri.com
right=%any
rightid=%any
rightsourceip=10.0.5.0/24
rightauth=eap-mschapv2
rightsendcert=never
eap_identity=%any
auto=add
root@six #cat ipsec.secrets
# strongSwan IPsec secrets file
: RSA /cert/strongswan.key
six.tugriceri.com : RSA /cert/strongswan.key
testuser : EAP "secretpass"
root@six #cat openssl-req.cfg
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
prompt = no
[ v3_req ]
# Extensions to add to a certificate request
#keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = "DNS:six.tugriceri.com,DNS:www.tugriceri.com,IP:209.208.63.204,DNS:tugriceri.com"
#subjectAltName = @alt_names
[alt_names]
DNS.1 = six.tugriceri.com
DNS.2 = www.tugriceri.com
[ req_distinguished_name ]
CN = six.tugriceri.com
GN = six.tugriceri.com
OU = Tugriceri.com
O = Tugriceri.com
L = Istanbul
ST = Istanbul
C = TR
emailAddress = root@tugriceri.com
subjectAltName = six.tugriceri.com
subjectAltName is importend point of configuration. Your certificate must be have this.
root@six #cat certyarat.sh
rm -f strongswan.req
rm -f strongswan.pem
openssl req -new -out strongswan.req -key strongswan.key -config openssl-req.cfg
openssl ca -batch -notext -in strongswan.req -out strongswan.pem -config ca.conf
root@six #cat showcert
openssl x509 -in strongswan.pem -text -noout
Command Output :
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Subject Alternative Name:
DNS:six.tugriceri.com, DNS:www.tugriceri.com, IP Address:209.208.63.204, DNS:tugriceri.com
root@six #cat ca.conf
[ ca ]
default_ca = tugricerica
[ tugricerica ]
copy_extensions = copy
#Removed lines
copy_extension must be in your ca.conf
SELinux FTP Home dir write permission
by Emre Tugriceri on Oct.07, 2011, under Linux, Security, SELinux
Connected to 127.0.0.1.
220 (vsFTPd 2.2.2)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1:root): test1
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/var/ftp/test1
Login failed.
ftp> quit
[root@legion mnt]# getsebool ftp_home_dir
ftp_home_dir –> off
[root@legion mnt]# setsebool -P ftp_home_dir 1
[root@legion mnt]# getsebool ftp_home_dir
ftp_home_dir –> on

Deny user for remote login
by Emre Tugriceri on Jun.06, 2011, under Linux, Security
sudo vi /etc/security/access.conf
-:root:ALL EXCEPT LOCAL

SSL Weak Cipher and SSLv2 tests
by Emre Tugriceri on Jan.22, 2011, under Security
echo ‘GET HTTP/1.0’ | openssl s_client -ssl3 -cipher LOW -connect www.tugriceri.com:443
echo ‘GET HTTP/1.0’ | openssl s_client -ssl2 -cipher LOW -connect www.tugriceri.com:443
echo ‘GET HTTP/1.0’ | openssl s_client -ssl2 -connect www.tugriceri.com:443

uvscan process is too slow
by Emre Tugriceri on Nov.26, 2010, under Antivirus, Security
# time uvscan –version
McAfee VirusScan Command Line for Linux64 Version: 6.0.3.356
Copyright (C) 2010 McAfee, Inc.
(408) 988-3832 LICENSED COPY – November 26 2010
AV Engine version: 5400.1158 for Linux64.
Dat set version: 5985 created May 17 2010
Scanning for 619012 viruses, trojans and variants.
real 0m9.501s
user 0m9.365s
sys 0m0.132s
# uvscan –decompress
McAfee VirusScan Command Line for Linux64 Version: 6.0.3.356
Copyright (C) 2010 McAfee, Inc.
(408) 988-3832 LICENSED COPY – November 26 2010
AV Engine version: 5400.1158 for Linux64.
Dat set version: 5985 created May 17 2010
Scanning for 619012 viruses, trojans and variants.
This program is more than 5 months old. New viruses come out all the
time – we would suggest that you upgrade your copy.
Time: 00:00.00
# time uvscan –version
McAfee VirusScan Command Line for Linux64 Version: 6.0.3.356
Copyright (C) 2010 McAfee, Inc.
(408) 988-3832 LICENSED COPY – November 26 2010
AV Engine version: 5400.1158 for Linux64.
Dat set version: 5985 created May 17 2010
Scanning for 619012 viruses, trojans and variants.
real 0m2.801s
user 0m2.664s
sys 0m0.135s

crt to der
by Emre Tugriceri on Apr.30, 2010, under Security
openssl x509 -in auth_tugriceri_com.crt -out auth_tugriceri_com.der -outform DER
openssl rsa -in www_tugriceri_com.key -outform DER -out www_tugriceri_com-der.key

Sftp chroot settings
by Emre Tugriceri on Oct.17, 2009, under Security, SSH
cat /etc/ssh/sshd_config
Subsystem sftp internal-sftp
Match group sftponly
ChrootDirectory /chroot
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
cat /etc/passwd
testuser:x:500:504::/:/bin/bash
sftponly:x:504:testuser

run command via ssh (remote)
by Emre Tugriceri on Apr.08, 2009, under Linux, Security, Shell
cat ls_keykur.sh | ssh root@10.94.12.3
ssh root@10.94.12.3 “date”

other ssl issue with my own ca
by Emre Tugriceri on Mar.18, 2009, under Security
/root/tugriceri.com_CA/ca/
cat ca.conf
[ ca ]
default_ca = ca_default
[ ca_default ]
dir = /root/tugriceri.com_CA/ca/
certs = /root/tugriceri.com_CA/ca/
new_certs_dir = /root/tugriceri.com_CA/ca/ca.db.certs
database = /root/tugriceri.com_CA/ca/ca.db.index
serial = /root/tugriceri.com_CA/ca/ca.db.serial
RANDFILE = /root/tugriceri.com_CA/ca/ca.db.rand
certificate = /root/tugriceri.com_CA/ca/ca.crt
private_key = /root/tugriceri.com_CA/ca/ca.key
default_days = 365
default_crl_days = 30
default_md = md5
preserve = no
policy = generic_policy
[ generic_policy ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
openssl ca -config ca.conf -notext -out one.tugriceri.com/one.tugriceri.com.cer -infiles one.tugriceri.com/one.tugriceri.com.csr
openssl x509 -req -days 365 -in one.tugriceri.com/one.tugriceri.com.csr -CA ca/ca.crt -CAkey ca/ca.key -CAcreateserial -out one.tugriceri.com/one.tugriceri.com.cer
openssl verify -CAfile ../ca/ca.crt one.tugriceri.com.cer

pfx to key
by Emre Tugriceri on Feb.03, 2009, under Security
openssl pkcs12 -export -in my.pem -nodes -out my.pfx
openssl pkcs12 -in my.pfx -out my-nodes.key -nodes -nocerts
Cisco SSH Configuration
by cagri on Jan.12, 2009, under Cisco, Network, Security
conf# username cagri privilege 15 secret cisco
“creates a user in local database with privelege level 15 and encrypted password cisco”
conf#ip domain-name tugriceri.com
“sets a domain name for the device”
conf#crypto key generate rsa
“creates a rsa key. in the next step encryption bits will be asked. default is 512. 1024 is better”
conf#ip ssh version 2
“change the version of ssh to 2”
conf#line vty 0 4
“go under the virtual teletype ports”
conf-line#transport input ssh
“and change the login type from telnet to ssh”
conf-line#login local
“device will look at the local user database to log in a user”
ssh Tunnel
by Emre Tugriceri on Dec.07, 2008, under Security
shell# ssh -f root@192.168.2.54 -L 7200:192.168.2.54:7200 -N
Bir Asa log u
by Emre Tugriceri on Oct.04, 2008, under Firewalls, Security
Routing failed to locate next hop for icmp from outside…
Net1 de olması gereken bir host yada network net2 de tanımlanmış ise bu log ile karşılaşılır. Host u fln silip doğru yerde tanımlarını yapmak lazım.
Cisco Asa ssh enable
by Emre Tugriceri on Oct.03, 2008, under Firewalls, Security
username emre password pas priv 15
aaa authentication ssh console LOCAL
ssh x.x.x.x x.x.x.x external
mysql deki snort loglarini temizlemek
by Emre Tugriceri on Sep.21, 2008, under Mysql, Security
reset master
purge master logs
delete from data
delete from event where timestamp<‘2008-8-01’
Sudo requiretty settings
by Emre Tugriceri on Jan.08, 2008, under Security
sudo: apache : sorry, you must have a tty to run sudo ; TTY=unknown ; …
/var/log/secure içerisinde gözlemlenen bu log apache ile çağırılan bir sistem komutunun çalışmayıp verdiği uyarı log u .
sudoers içerisinde
Defaults requiretty
ayarının # lenmesi gerekmektedir. Yukarıdaki log danda görüldüğü gibi apache user i herhangi bir tty ye sahip olmadığı için bu log düşmektedir. Normal şartlarda zaten “requiretty” nin kapatılmasına gerek yok fakat php kullanarak root yetkilerinde bir komut çalıştırma ihtiyacınız olursa bu ayarı kapatmanız gerekecektir.
Powered by ScribeFire.
SSL sertifikası yaratma
by Emre Tugriceri on Jan.04, 2008, under Security
Openssl ile sertifika yaratmak için yarattığınız anahtar dosya da güçlü şifreleme methodlarından birini seçerseniz sizden bir şifre girmenizi isteyecektir. Apache nin her başlamasında bu şifreyi yazmanız gerekmektedir.
Şifre sorulmadan bir sertifika yaratmak için ;
shell #> openssl dsaparam 1024 -out dsadosyasi
“dsaparam DSA Parameter Generation.”
shell #> openssl gendsa -out webserver.key dsadosyasi
Bu aşamada sizden şifre istenmeden bir key dosyasi yaratılacaktır. Bir şifre vermek isterseniz -des3 parametresi ekleyerek 3des algoritması ile şifrelenmiş bir anahtar dosya yaratabilirsiniz.
Sertifika talep dosyası yaratmak için ;
shell #> openssl req -new -key webserver.key -out webserver.csr
webserver.csr bizim sertifika talep dosyamız. Bu dosyayı kendi CA imizde yada Verisign gibi trusted CA lerde imzalatıp kullanabiliriz.
Kendi CA server imizda imzalamak için
shell #> openssl x509 -req -days 365 -in webserver.csr -signkey webserver.key -out webserver.crt
apache içerisinde ;
<VirtualHost _default_:443>
ServerAdmin root@tugriceri.com
DocumentRoot /var/www/html/
ServerName mail.tugriceri.com
SSLEngine on
SSLCertificateFile /webmail/webserver.crt
SSLCertificateKeyFile /webmail/webserver.key
#SSLCACertificateFile /webmail/cacertnew.pem
SetEnvIf User-Agent “.*MSIE.*” nokeepalive ssl-unclean-shutdown
</VirtualHost>
_default_ webserver inizin default ip adresidir. Her sertifika için başka ip ler vermeniz gerekmektedir. Bu sebepten diğer virtual host lar için _default_ yerine ip adresinizi yazabilirsiniz.
Eğer CA server başka bir sunucunuzun üzerinde ise SSLCACertificateFile ile CA sertifikanızı apache ye gösterebilir yada ;
shell #> keytool -import -file /webmail/cacertnew.pem
ile default key store içerisinde ekleyebilirsiniz.
Örnek;
openssl genrsa -des3 -rand file1:file2:file3:file4:file5 -out server.key 1024
openssl rsa -in server.key -out server.pem
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 60 -in server.csr -signkey server.key -out server.crt
Cer to Pem
by Emre Tugriceri on Jan.04, 2008, under Security
You can convert cer file to pem with this example command.
openssl x509 -in certnewb.cer -inform DER -out certnewb.pem -outform PEM
if you have a Microsoft CA server and if you signed your certification request with this CA server, this server will give to you der encoded certnew.cer file. you can convert this file to pem format for the any apache server.
Php safe_mode
by Emre Tugriceri on Sep.23, 2007, under Security
php_admin_flag safe_mode On
safe_mode ile php, script in sahibi ile erişilmeye çalışılan dosya sahibini kontrol eder.
Belirli bir directory deki scr çalışmaması için.
<Directory /home/www/blabla/ >
php_admin_flag engine off
</Directory>
Aynı şekilde safe_mode da uygulanabilir.
Powered by ScribeFire.