title: “tcpdump – Traffic analysieren”
date: 2014-04-22T12:35:30
slug: tcpdump-traffic-analysieren
tcpdump -nnXSs 0 port 80
title: “tcpdump – Traffic analysieren”
date: 2014-04-22T12:35:30
slug: tcpdump-traffic-analysieren
tcpdump -nnXSs 0 port 80
title: “Wert vom Input Feld lesen”
date: 2014-03-12T20:32:01
slug: wert-vom-input-feld-lesen
var value= $('#id').val();
title: “Cookies von Iceweasel auslesen / in .txt Datei schreiben”
date: 2014-03-12T09:41:03
slug: cookies-von-iceweasel-auslesen-in-txt-datei-schreiben
Da Iceweasel die Cookies in einer SQLlite Datenbank speichert, wird sqlite3 benötigt.
Das ist ein Command Line Tool um die Datei auszulesen.
Unter Debian wird diese mit folgendem Befehl installiert:
apt-get install sqlite3
Das nachfolgende Script liest die cookies aus und schreibt diese in die Datei cookies.txt
#!/bin/bash
PROFILE=`ls ~/.mozilla/firefox | grep default`
sqlite3 -separator ' ' $HOME/.mozilla/firefox/$PROFILE/cookies.sqlite 'select host, "TRUE", path, "FALSE", expiry, name, value from moz\_cookies' > cookies.txt
title: “Fehler: mod_fcgid: HTTP request length 15730264 (so far) exceeds MaxRequestLen (15728640)”
date: 2014-03-04T12:59:22
slug: fehler-mod_fcgid-http-request-length-15730264-so-far-exceeds-maxrequestlen-15728640
In der FCGI Config Datei muss die maximale Post Size erhöht werden.
Hier ein Beispiel in der fcgid.conf:
AddHandler fcgid-script .fcgi
FcgidConnectTimeout 180
FcgidIOTimeout 600
FcgidMaxRequestLen 134217728 // (=128MB)
MaxRequestLen 134217728 // (=128MB)
MaxRequestsPerProcess 1500
title: “Verschiedene PHP Versionen für FCGI compilieren (Debian7)”
date: 2014-03-04T11:19:46
slug: verschiedene-php-versionen-fur-fcgi-compilieren-debian7
Als erstes laden wir die folgenden Quellpakete auf unseren Server:
apt-get install libapache2-mod-fcgid apache2-suexec libpcre3-dev libpcre++-dev libpng12-dev libbz2-dev libcurl4-openssl-dev libc-client2007e-dev libjpeg8-dev libgif-dev libgif4 libpthread-stubs0 libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxpm-dev x11proto-core-dev x11proto-input-dev x11proto-kb-dev xtrans-dev libxml2-dev libmysqlclient-dev libfreetype6-dev
Als nächstes wird das Source Paket der gewünschten PHP Version benötigt, dieses kann hier geladen werden:
php-5.5.8.tar
php-5.2.17.tar
php-5.3.27.tar
php-5.4.24.tar
Die Source Pakete können jetzt nach /usr/local/src/phpXXXXX entpackt werden
Beim Compilieren der PHP Pakete muss zwischen einem 32 Bit und 64 Bit OS unterschieden werden.
Mit folgendem Befehl kann die OS Version angezeigt werden:
root@Server:~# uname -a
Linux Server 2.6.32-5-amd64 #1 SMP Mon Feb 25 00:26:11 UTC 2013 x86\_64 GNU/Linux
In diesem Beispiel verrät das x86_64 in der Ausgabe das ein 64Bit OS installiert ist.
Bei i386 oder i686 handelt es sich um ein 32 Bit Betriebssystem.
Für 32Bit und PHP Version 5.3
./configure --prefix=/usr/share/php53 --datadir=/usr/share/php53 --mandir=/usr/share/man --bindir=/usr/bin/php53 --with-libdir=lib/i386-linux-gnu --includedir=/usr/include/php53 --sysconfdir=/etc/php53/apache2 --with-config-file-path=/etc/php53/apache2 --with-config-file-scan-dir=/etc/php53/conf.d --enable-libxml --enable-session --with-pcre-regex=/usr --enable-xml --enable-simplexml --enable-filter --disable-debug --enable-inline-optimization --disable-rpath --disable-static --enable-shared --with-pic --with-gnu-ld --with-mysql --with-gd --with-jpeg-dir --with-png-dir --with-xpm-dir --enable-exif --with-zlib --with-bz2 --with-curl --with-ldap --with-mysqli --with-freetype-dir --enable-soap --enable-sockets --enable-calendar --enable-ftp --enable-mbstring --enable-gd-native-ttf --enable-bcmath --enable-zip --with-pear --with-openssl --with-imap --with-imap-ssl --with-kerberos --enable-phar --enable-pdo --with-pdo-mysql --with-mysqli --enable-intl --with-mcrypt
Für 64Bit und PHP Version 5.3
./configure --prefix=/usr/share/php53 --datadir=/usr/share/php53 --mandir=/usr/share/man --bindir=/usr/bin/php53 --with-libdir=lib/x86\_64-linux-gnu --includedir=/usr/include/php53 --sysconfdir=/etc/php53/apache2 --with-config-file-path=/etc/php53/apache2 --with-config-file-scan-dir=/etc/php53/conf.d --enable-libxml --enable-session --with-pcre-regex=/usr --enable-xml --enable-simplexml --enable-filter --disable-debug --enable-inline-optimization --disable-rpath --disable-static --enable-shared --with-pic --with-gnu-ld --with-mysql --with-gd --with-jpeg-dir --with-png-dir --with-xpm-dir --enable-exif --with-zlib --with-bz2 --with-curl --with-ldap --with-mysqli --with-freetype-dir --enable-soap --enable-sockets --enable-calendar --enable-ftp --enable-mbstring --enable-gd-native-ttf --enable-bcmath --enable-zip --with-pear --with-openssl --with-imap --with-imap-ssl --with-kerberos --enable-phar --enable-pdo --with-pdo-mysql --with-mysqli --enable-intl --with-mcrypt
Falls es zu einen Fehler beim kompilieren der ssl Komponente kommt (php5.2.17), kann diese deaktiviert werden. Beim Configure dann einfach den Parameter
--with-openssl
weglassen.
Ein weiterer Fehler kann sein:
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
Abhilfe schafft hier bei einem 32 Bit OS:
ln -s /usr/lib/libc-client.a /usr/lib/i386-linux-gnu/libc-client.a
Bei einem 64 Bit OS:
ln -s /usr/lib/libc-client.a /usr/lib/x86\_64-linux-gnu/libc-client.a
Für die anderen PHP Versionen muss jeweils der Parameter :
--prefix=/usr/share/php52
--datadir=/usr/share/php52
--bindir=/usr/bin/php52
--includedir=/usr/include/php52
--sysconfdir=/etc/php52/apache2
--with-config-file-path=/etc/php52/apache2
--with-config-file-scan-dir=/etc/php52/conf.d
auf die jeweilige Version angepasst werden (52, 53, 54 oder 55).
Mit:
make
make install
wird die PHP Version kompiliert und installiert.
Anschließend können die php Binaries noch getestet werden:
/usr/bin/php52/php -v
PHP 5.2.17 (cli) (built: Feb 9 2014 17:04:22)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
/usr/bin/php53/php -v
PHP 5.3.27 (cli) (built: Feb 9 2014 16:29:10)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
/usr/bin/php54/php -v
PHP 5.4.24 (cli) (built: Feb 9 2014 16:43:53)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Die Datei “/etc/apache2/mods-enabled/fcgid.conf” wiefolgt anpassen:
<IfModule mod\_fcgid.c>
AddHandler fcgid-script .fcgi
FcgidConnectTimeout 180
FcgidIOTimeout 600
FcgidMaxRequestLen 134217728
MaxRequestLen 134217728
MaxRequestsPerProcess 1500
</IfModule>
title: “innerHTML Ersatz”
date: 2014-03-04T11:06:56
slug: innerhtml-ersatz
$("#objectID").html("neuer Inhalt");
title: “Json encode / decode”
date: 2014-03-04T11:04:57
slug: json-encode-decode
Ein Object zu einem JsonString encoden:
var string= JSON.stringify(obj );
Ein JsonString zu einem Object decoden
var obj = jQuery.parseJSON( jsonString );
title: “Foreach Schleife”
date: 2014-03-04T11:02:38
slug: foreach-schleife
$.each(array, function( index, value ) {
alert( index + ": " + value );
});
title: “Ajax Post mit Parameter”
date: 2014-03-04T10:59:44
slug: ajax-post-mit-parameter
$.post( "test.php", { name: "Thomas", internet: "http://www.it-asanger.de" })
.done(function( data ) {
alert( "Data Loaded: " + data );
});
title: “Debian 7.0 MySQL 5.6 Master / Master Replication Setup”
date: 2014-03-04T09:56:37
slug: mysql-master-master-replication-setup
Install MySQL dependency (kernel asynchronous I/O access library)
apt-get install libaio1
Download a MySQL Debian package from the official site.
On 32-bit system:
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.17-debian6.0-i686.deb
On 64-bit system:
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.17-debian6.0-x86\_64.deb
Install the downloaded MySQL package.
dpkg -i mysql-5.6.17-debian6.0-x86\_64.deb
Add the MySQL bin directory to the PATH variable system-wide.
sh -c 'echo "PATH=$PATH:/opt/mysql/server-5.6/bin" >> /etc/profile'
source /etc/profile
Open the MySQL config file with a text editor, and update the following entries.
Copy the MySQL startup script to /etc/init.d and install the script into the boot sequence, so that MySQL server starts up automatically upon boot.
cp /opt/mysql/server-5.6/support-files/mysql.server /etc/init.d/mysql
update-rc.d mysql defaults
Create a symbolic link.
ln -s /opt/mysql/server-5.6/bin/mysqld /usr/sbin/mysqld
Create User mysql
useradd mysql
Install initial DB
/opt/mysql/server-5.6/scripts/mysql\_install\_db --user=mysql --basedir=/opt/mysql/server-5.6/ --datadir=/opt/mysql/server-5.6/data/
MySQL Server starten
/etc/init.d/mysql start
set root password
/opt/mysql/server-5.6//bin/mysqladmin -u root password 'new-password'
/opt/mysql/server-5.6//bin/mysqladmin -u root -h localhost password 'new-password'
create log directory for mysql
mkdir /var/log/mysql
chown mysql /var/log/mysql
Server1: my.cnf
server-id = 1
binlog-ignore-db = mysql
replicate-ignore-db = mysql
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = 2
expire\_logs\_days = 10
max\_binlog\_size = 500M
log-error = /var/log/mysql/error.log
log-bin= /var/log/mysql/mysql-bin.log
MySQL Server restart
/etc/init.d/mysql restart
Replication User auf server1 anlegen
mysql -uroot -p
GRANT REPLICATION SLAVE ON \*.\* TO 'replication'@'%' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
Server2: my.cnf
server-id = 2
binlog-ignore-db = mysql
replicate-ignore-db = mysql
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = 1
expire\_logs\_days = 10
max\_binlog\_size = 500M
log-error = /var/log/mysql/error.log
log-bin= /var/log/mysql/mysql-bin.log
relay-log=mysqld-relay-bin
Datenbank Dump auf server1 erzeugen und auf server2 kopieren:
server1:mysqldump -p --master-data --all-databases --result-file=dbdata1.sql
server1:scp dbdata1.sql root@server2:/tmp
MySQL Community Server wie oben beschrieben auf server2 einrichten
Datenload auf server2
server2:cd /tmp
server2:mysql -uroot -p
source dbdata1.sql;
CHANGE MASTER TO MASTER\_HOST='server1', MASTER\_USER='replication', MASTER\_PASSWORD='PASSWORD';
start slave;
show slave status\G
SHOW MASTER STATUS\G;
Folgendes Outputformat sollte angezeigt werden:
File: <strong>db2-bin.000003</strong>
Position: <strong>107</strong>
Binlog\_Do\_DB:
Binlog\_Ignore\_DB: mysql
Replication User anlegen und Slave auf server1 starten (Platzhalter XX mit den Werten von oben ersetzen):
server1:mysql -uroot -p
CHANGE MASTER TO MASTER\_HOST='server2', MASTER\_USER='replication', MASTER\_PASSWORD='PASSWORD', MASTER\_LOG\_FILE='<strong>XX</strong>', MASTER\_LOG\_POS=<strong>XX</strong>;
Start slave;
show slave status\G
Datenbank auf server1 unlocken:
UNLOCK TABLES;
Ändern eines MAster Hosts
CHANGE MASTER TO MASTER\_HOST='server1|2', MASTER\_USER='replication', MASTER\_PASSWORD='PASSWORD';