Friday, December 27, 2013

[how to fix error] Device eth0 does not seem to be present, delaying initialization (VMware Linux)

เวลาที่ผม clone VMware ของ centos มักจะมี ปัญหา ที่ network eth0 (ก็ไม่รุ้ Linux อื่นๆ เป็นด้วยมั้ยนะ)

ข้อความ error ก็จะราวๆ
ifup eth0
Device eth0 does not seem to be present, delaying initialization

1. ลบไฟล์ 70-persistent-net.rules:
rm -f /etc/udev/rules.d/70-persistent-net.rules

2. แก้ไขไฟล์ ifcfg-eth0 โดยลบบรรทัด UID กะ MACADDR หรือ commentซะ
sed -i 's/UID/#UID/g' /etc/sysconfig/networking/devices/ifcfg-eth0
sed -i 's/MACADDR/#MACADDR/g' /etc/sysconfig/networking/devices/ifcfg-eth0

3. reboot network connection
service network restart

*ถ้าต้องการตั้งค่า GATEWAY
ให้แก้ไขที่ไฟล์ /etc/sysconfig/network
เพิ่ม GATEWAY=
echo "GATEWAY=">> /etc/sysconfig/network

Monday, December 23, 2013

How to Install MySQL Server 5.1.71-1 and MySQL-Python On CentOS6.5 x64

install MySQL Server
yum install mysql-server mysql-devel

Set the MySQL service to start on boot
chkconfig --levels 235 mysqld on

Start the MySQL service
service mysqld start

Test Log into MySQL
mysql -u root
*type exit to exit mysql

Install MySQL-python
pip install MySQL-python
*you can read "Install Python 2.7.6 on Centos 6.4 x64" for more information

my basic MySQL-python Class
# -*- coding: utf-8 -*-

import MySQLdb

class classMySQL:
 def __init__(self):
  self.db = None

 def mysql_connect(self, db_user, db_passwd, db_name, db_host='localhost'):
  self.db = MySQLdb.connect(
   host = db_host,
   user = db_user,
   passwd = db_passwd,
   db = db_name
  self.query = self.db.cursor()

 def mysql_close(self):
  if self.db:

 def mysql_query(self, query):
  return self.query.fetchone()

# Main must be outside the table class
def test():
 _mysql = classMySQL()
 _mysql.mysql_connect("root", "", "mysql")
 print _mysql.mysql_query("select * from user;")

if __name__ == '__main__':

run test

Tuesday, December 17, 2013

Decrypt Cisco-encrypted passwords in configuration files

#! /usr/bin/perl -p
# Decrypt Cisco-encrypted passwords in configuration files. Perl
# version; requires perl 4.036 minimum. Unlike many similar tools
# circulating on the net, this one also works for passwords longer
# than 11 characters (i.e. doesn't chop after 11 chars and doesn't
# get confused with newer IOS versions which have alleviated this
# limit).
# Absolutely no warranties whatsoever. Use at your own risk. No
# batteries included. Not suitable for children under 3 years.
# Written and © by Helge Oldach <>
# You are not expected to understand this code, although the algorithm
# is really blatantly stupid. Look how short it is in perl.

@tbl = unpack("C*", "dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87");

($pre, $dummy, $seed, $pwd, $dummy, $suf) = ($_ =~ /^(.*\s+(password|md5)\s+)7\s+([0-1][0-9])(([0-9A-F][0-9A-F])+)(.*)$/);

if ($pwd) {
 $_ = $pre;
 foreach $p ($pwd =~ /../g) {
  $_ .= pack("C", hex $p ^ $tbl[$seed++]);
  $seed %= $#tbl;
 $_ .= $suf . "\n";

join([chr(int(x[i:i+2],16)^ord('dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87'[(int(x[:2])+i/2-1)%53]))for i in range(2,len(x),2)])
Why You Don't LIKE My FaceBook Fanpage ?