Update on easy geolocation
Our last post about geolocation is now deprecated since it now needs some api key to use the web service, the following script can be used after getting the key:
#!/bin/sh
#
###
### For assistance, please visit forum.ipinfodb.com
#
# Created by Eric Gamache on 2009-05-26
# Version 1.0 by Eric Gamache -- 2009-06-04
# Version 1.1 updated by Marc-Andre Caron -- 2009-06-08 .. Added timezone
# Version 1.2 updated by Eric Gamache -- 2009-06-08 .. fix minors bugs.
# Version 1.3 updated by Marc-Andre Caron -- 2010-02-11 .. new timezone support, reduced complexity of the script.
# Version 1.4 updated by Fakini -- 2012-02-11 .. blablabla for new version and api key etc
#
# This script is provided "as is", with absolutely no warranty expressed or
# implied. Any use is at your own risk. Permission to use or copy this
# script for any purpose is hereby granted without fee. Permission to
# modify the code and to distribute modified code is granted, provided
# the above notices are retained, and a notice that the code was modified
# is included with the above copyright notice.
#
###############################################
####
####
####
URL="http://api.ipinfodb.com/v3/ip-city/?key=<api key>&ip="
#
WGET_AGENT="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
#
ERROR=0
#
###############################################
if [ "$1" = "" ]; then
ERROR=1
else
IP=$1
HTTP_LINK="$URL""$IP"
fi
###############################################
if [ "$ERROR" != "0" ]; then
echo " "
echo " usage : $0 IP"
echo " Where IP is the IP to check"
echo " Big thanks to the team of IPInfoDB (http://ipinfodb.com)"
exit
fi
###############################################
#
TST_wget=`wget > /dev/null 2>&1`
#
ErrorLevel=$?
#
if [ "$ErrorLevel" != 1 ] ; then
echo " ----"
echo " wget not found; please install it for proper operation."
echo " ----"
exit
fi
###############################################
###############################################
#######
#######
INFO=`wget -qO- --user-agent="$WGET_AGENT" $HTTP_LINK 2>&1`
echo "$INFO"
In: Faka · Tagged with: *nix, shell
Windoze sucks!
I know windoze sucks…it sucks even more when its a “hammered” version, probably full of nasty stuff and spits out something like this during the install process…I guess that version belongs in the trash with the rest of them…Besides, chances are one would quickly become part of some botnet just by using that shit.
Fast NAT with iptables
Here is a fast way to share our inet connection:
# iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
# iptables --append FORWARD --in-interface wlan0 -j ACCEPT
# echo 1 > /proc/sys/net/ipv4/ip_forward
In: Faka · Tagged with: linux, networking
VPN without loosing initial SSH connection
#!/bin/sh
OIP=`echo $SSH_CONNECTION | awk '{print $1}'`;
OGW=`netstat -rn | grep default | awk '{print $2}'`
route add -host $OIP $OGW \
&& openvpn --config /root/vpn/client.ovpn
route delete -host $OIP $OGW
This will add a route to the IP where our SSH connection originated from so it won’t die when we switch the default gateway to the VPN.
In: Faka · Tagged with: *nix, krypto, networking
Validar ou não validar o input…
Parece que em algumas das nossas universidades é ensinado que o input feito a determinado programa esta sempre correcto e como tal não é necessario fazer validação do input do utilizador, o mais incrivel é alguem ser penalizado na nota por fazer este tipo de validações num projecto universitario…Tá bonito…Aparentemente anda-se a educar “clueless coders”!
In: Entretanto em Portugal..., Flame Hall, game1s0n


