Posts

Showing posts from January, 2013

Install ArchLinux No script

Install Arch Linux Download Arch Linux distro iso at: Boot to Arch Linux, chose Arch Linux x86 Use cfdisk to create partion: #cfdisk /dev/sda Chose New to create new partion, next Chose Begin. Chose Bootable Down arrow to chose other, continue chose create New. (make swap) Chose Write, yes to confirm. Quit to exit Format partion: #mkfs.ext4 /dev/sda1 #mkswap /dev/sda2 #swapon /dev/sda2 Check internet connection: #ping www.google.com.vn Mount partion: #mount /dev/sda1 /mnt Edit mirror list: #vi /etc/pacman.d/mirrorlist ## ## Arch Linux repository mirrorlist ## Sorted by mirror score from mirror status page ## Generated on 2012-XX-YY ## ## Vietnam Mirror Server = http://mirror-fpt-telecom.fpt.net/archlinux/$repo/os/$arch Install base: #pacstrap /mnt base base-devel #pacstrap /mnt grub-bios Create fstab: #genfstab -p /mnt >> /mnt/etc/fstab Chroot to new system: #arch-chroot /mnt Assign hostname #vi /etc/hostname namhb.hbn.local Set timez

Using GeoIP to query IP location database

First, download IP database: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz Install Python pupi libs: http://pypi.python.org/pypi/pygeoip/ Extract, go to extracted folder and type: #python setup.py install File geo.py: import pygeoip import dns.resolver import sys import re gi =pygeoip.GeoIP('GeoLiteCity.dat') def name2ip(dnsname):     answers = dns.resolver.query(dnsname, 'A')     for rdata in answers:            return rdata def printRecord(tgt):     rec =gi.record_by_name(tgt)     city =rec['city']     region =rec['region_name']     country =rec['country_name']     long =rec['longitude']     lat =rec['latitude']     print '[*] Target: ' +tgt     print '[+] '+str(city)+', '+str(region)+', '+str(country)     print '[+] Latitude: '+str(lat)+', Longitude: '+str(long) str1 = sys.argv[1] is_ip = re.match("^(([0-9]|[1-9][0-9]|1[0-