Tuesday, March 27, 2012

Using AWK convert to MySQL and remove symbolic from log file

i have logs file like

2011-08-05 20:38:58|76556429203814|99999xxx|ending call
2011-08-05 20:39:34|76556429203909|7777xxxx|ending call
2011-08-05 22:26:15|77578322222419|775xxxxx|download fail

i would like to import into mysql, so i gonna use AWK to do it.

cat 20110805.log | awk -F"[ |]*" '{print "INSERT INTO tb_status VALUES(" "\47" $1 " " $2 "\47" "," "\47" $3 "\47" "," "\47" $4 "\47" "," "\47" $5 " " $6 "\47" " ) ; "}' >test.sql

result will be like
INSERT INTO tb_status VALUES('2011-08-05 22:26:15','77578322222419','775xxxxx','download fail' ) ;
INSERT INTO tb_status VALUES('2011-08-05 22:26:22','77578322222419','775xxxxx','ending call' ) ;
INSERT INTO tb_status VALUES('2011-08-05 23:14:59','78884147231433','788xxxxx','ending call' ) ;

Monday, March 26, 2012

Change user working directory [FTP]

this is in my case, I already enable FTP also user allow.
whenever you wanna change your ftp working path we could use usermod command

usermod -d /path/to/new/homedir/ username

this is how to enable FTP

Monday, March 19, 2012

How to install and testing NRPE on linux host

Client Security

NRPE Client only listens to requests from one IP - the server
This is defined in /etc/hosts.allow (tcpwrappers) and /etc/xinetd.d/nrpe (xinetd).
It may also be limited by iptables.

Client NRPE Install

Download nrpe and nagios-plugin.
Tarball names will vary depending on the release number of the packages
tar -xf nrpe.......
tar -xf nagios-plugin........

Nagios Plugin Installation

cd nagios-plugin dir
./configure
make
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

NRPE Installation

cd ../nrpe.... directory
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
edit /etc/xinetd.d/nrpe
add the name of the Nagios server to the line
only_from = 127.0.0.1
edit /etc/services
add the line
nrpe 5666/tcp
Restart xinetd daemon with
service xinetd restart

Test NRPE

Test nrpe with
netstat -at | grep nrpe
Edit TCP wrappers
vi /etc/hosts.allow
Add the line
nrpe: 17.0.0.1 server.name.domain.edu
where server.name.domain.edu is your Nagios server DNS name

Test New client

/usr/local/nagios/libexec/check_nrpe -H localhost

If you get back the NRPE version number, you are done on the client
Setup IPTABLES

iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
lets all packets with a destination of port 5666 past the firewall

Define Commands

Edit /usr/local/nagios/etc/nrpe.cfg on the client
Pick the commands that can be run when the server makes a request.

source: virginia.edu

Friday, March 9, 2012

enabling .htaccess and make it protect your web directory

ໃຫ້ໄປເບິ່ງ config ໃນ httpd.conf ວ່າຖືກເອີ້ນໃຫ້ໃຊ້ງານໄດ້ຫລືບໍ່ ດ້ວຍການຊອກຫາ AccessFileName ວ່າມັນຊີ້ໄປຫາຟາຍ .htaccess ຫລືບໍ່

ຕົວຢ່າງ
[root@luc1f3r assholy]# grep -i AccessFileName /etc/httpd/conf/httpd.conf
# AccessFileName: The name of the file to look for in each directory
AccessFileName .htaccess


ຕໍ່ມາກໍ່ຊອກວ່າມັນຖືກເປີດໃຊ້ຈາກ apache ແລ້ວຫລືບໍ່ ຈາກ configure ຂອງ httpd.conf ຄືເກົ່າ

[root@luc1f3r assholy]# grep -i AllowOverride /etc/httpd/conf/httpd.conf
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride None


ສັງເກດ AllowOverride ທາງເຖິງຈະເປັນ None ໃຫ້ປ່ຽນເປັນ all
ຫລັງຈາກປ່ຽນແລ້ວຢ່າລືມ restart apache
service httpd restart

ສ່ວນນີ້ຄືຕົວຢ່າງການຕັ່ງຄ່າ .htaccess
#ແບບໃຫ້ຖາມຫາ user&password
AuthUserFile /var/www/html/assholy/.htpasswd
AuthGroupFile /dev/null
AuthName "Password Protected Area"
AuthType Basic


#####ທາງລຸ່ມໃຫ້ເອົາ# ອອກ
<#limit get="" post="">
require valid-user
<#/limit>


ສັງເກດທາງເທິງມັນຈະໄປກວດກາ user pass ຢູ່ໃນ .htpasswd ເຮົາສາມາດສ້າງໄດ້ຈາກ shell ໃນ linux

htpasswd -c /PATHTOYOURDIRECTORY/.htpasswd myuser
New password:
Re-type new password:
Adding password for user myuser


ຫລືໃຜສັບສົນ ສາດມາດໃຊ້web generate ເອົາກໍ່ໄດ້
http://cooletips.de/htaccess/
http://www.webmaster-toolkit.com/htaccess-generator.shtml
#ແບບອະນຸຍາດຕາມ source IP
Order deny,allow
Deny from all
Allow from 192.168.0.0/24

Wednesday, March 7, 2012

How to disable directory browsing in apache/httpd

find  the main apache’s config file httpd.conf is located.

If you use Debian, it should be here: /etc/apache/httpd.conf.
 Using file editor such as vim or nano open the file and find the line following:

Options Includes Indexes FollowSymLinks MultiViews

remove "Indexes" will be like follows:

Options Includes FollowSymLinks MultiViews

dont forget to restart apache

installing PHP-MSSQL in centOS6.2

download and install the Epel rpm that contains the correct packages
rpm -Uvh 'http://download.fedoraproject.org/pub/epel/6/i386/epel-release6-5.noarch.rpm'

configuation file for the Epel rpm in the yum.repos.d directory
vi /etc/yum.repos.d/epel.repo

Change "enabled=1" to "enabled=0"

and then
yum install php-mssql --enablerepo=epel

restart your httpd service indeed.
 

One day - Matisyahu



Artist: Matisyahu
Song: One Day
Album: Lights

Intro: C G Am F

C G Am F
Sometimes I lay under the moon, I thank God I'm breathing
C G Am F
Then I pray don't take me soon, 'cause I am here for reason

Pre-chorus:
C G Am F
Sometimes in my tears I drown, but I never let it get me down
C G Am F
So when negativity surrounds, I know someday it'll all turn around because

Chorus:
C G Am F
All my life I've been waiting for, I've been praying for, for the people to say
C G Am F
That we don't wanna fight no more, there'll be no more wars, and our children will play
C G Am F
One day, one day, one day, oh oh oh
C G Am F
One day, one day, one day, oh oh oh


C G Am F
It's not about win or lose, 'cause we all lose when they feed on the
C G Am F
Souls of the innocent, blood-drenched pavement , keep on movin' though the waters stay ragin'
C G Am F
In this maze you could lose your way, your way
C G Am F
It might drive you crazy, but don't let it phase you no way, no way

Pre-chorus
Chorus

C G Am F
One day this all will change, treat people the same, stop with the violence, down with the hate
C G Am F
One day we'll all be free, and proud to be under the same sun singing songs of freedom like

C G Am F
Wye oh Wye oh oh oh
C G Am F
Wye oh Wye oh oh oh

Chorus

C G Am F x2
C