MySQL

MySQL Query zum anonymisieren von IPv4 Adressen

Wenn man schnell mal IPv4 Adressen in der Datenbank anonymisieren will hilft ein dieser Query weiter:

UPDATE [TableName] SET [ipField] = CONCAT_WS('.', SUBSTRING_INDEX([ipField],'.',1), SUBSTRING_INDEX(SUBSTRING_INDEX([ipField],'.',2),'.',-1), SUBSTRING_INDEX(SUBSTRING_INDEX([ipField],'.',-2),'.',1), "xxx");

Anonymisiert die IP von ‚192.168.178.123‘ zu ‚192.168.178.xxx‘.

Standard
Infrastructure

Deploying a Java-Tomcat-Webapp on AmazonAWS via ShellScript

A small shell script which i used to deploy our web apps to our Amazon AWS Infrastructure. This script I used for our test and staging systems. Next step will be a deployment pipeline.


#bash

# File to deploy
FILE=mywebapp.war

# Amazon AWS Informations (Host, User, SSL-Key)
EC2HOST=ec2-xxx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
SSHUSER=root
SSHKEY=/path/to/ssh/key/keyfile.pem

# Check if file exists
if [ -f $FILE ];
then

# SSH Connection String
SSHCONNECTION=$SSHUSER@$EC2HOST

if [ -f $SSHKEY ];
then
# stop deployed app
ssh -i $SSHKEY $SSHCONNECTION "/etc/init.d/tomcat stop && killall java"

# deploy to amazon aws
ssh -i $SSHKEY $SSHCONNECTION rm -rf /opt/tomcat/webapps/ROOT /opt/tomcat/webapps/ROOT.war
scp -i $SSHKEY ./$FILE $SSHCONNECTION:/opt/tomcat/webapps/ROOT.war
rm -rf ./$FILE

# start new deployed app
ssh -i $SSHKEY $SSHCONNECTION "/etc/init.d/tomcat start && tailf /opt/tomcat/logs/catalina.out"

else
echo "SSH Key $SSHKEY doesn't found."
fi

else
echo "File $FILE does not exist."
fi

Standard
Security

Eigene OpenSSL Zertifkate erstellen

Hier eine kleine Anleitung (Shell-Skript) wie man über die Konsole mit Hilfe von OpenSSL sich selbstsignierte Zertifikate erstellt.

#!/bin/sh

#SSL Certificate Infos
COMMONNAME="tommyziegler.com"
ORGANIZATION="Tommy Ziegler"
COUNTRY="DE"
STATE="Niedersachsen"
LOCATION="Lueneburg"
DAYSVALID=365

# Generating self-signed certificate
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr -subj "/C=$COUNTRY/ST=$STATE/L=$LOCATION/O=$ORGANIZATION/CN=$COMMONNAME"
openssl x509 -req -days $DAYSVALID -in server.csr -signkey server.key -out server.crt
rm server.csr
Standard
Security

Schnelles überprüfen ob ein SSL Zertifikat valide ist

Nachdem ich jetzt in einem Projekt wo ich SSL-Pinning auf der Client Seite in ein Qt- sowie NodeJS-Client implementiert hatte fortlaufend keine Verbindung zu neuen Server Modulen in meiner Server Zoo Landschaft bekommen konnte, war ich irgendwie recht verwirrt und verzweifelt. Denn auch in den Browsern wurde mir alle Zertifikate mit Grün angezeigt, und es sah alles nach der Client-Seite aus.

Bis wir per Hand das SSL Zertifikat mit dem OpenSSL-Kommandozeilentool überprüft hatten und feststellten das wir da das gleiche Problem hatten.
Und die Moral von der Geschicht: „Bei Zertifikats-Foo, nie Browsern vertrauen.“


> openssl s_client -connect server.hostname.net

Standard