CreateMutex
까보면 다나와~
툴 정보 및 사용법 (62)

파이썬 팁 모음

http://coreapython.hosting.paran.com/etc/Python%20Tips,%20Tricks,%20and%20Hacks.htm


나중에 또 볼일이 있겠네요~

  Comments,     Trackbacks

PYTHON 파이똥 한글 인코딩 문제 참고..

#!/usr/bin/python

# -*- coding: utf-8 -*-

# -*- coding: euc-kr -*- //우분투에서 필수 영문ver


print u'\uc548\ub155\ud558\uc138\uc694gkgksd'


#print unicode('한글asdfasdfasdfasdf','EUC-KR') //우분투 

#print unicode('한글asdfasdfasdfasdf','MBCS')

#print unicode('한글asdfasdfasdfasdf','EUC-KR').ENCODE('UTF-8')

print unicode('한글asdfasdfasdfasdf')

print unicode('윈도우즈 파이썬은 기본적으로 EUC-KR 인코딩')

print unicode('우분투 파이썬은 EUC-KR 인코딩해야함') //영문ver

  Comments,     Trackbacks

Ubuntu 12.04 – How to Install KVM Virtualization solution on Ubuntu 12.04

http://c-nergy.be/blog/?p=2965

이게 딱 잘 나와있음..

 

Ubuntu 12.04 – How to Install KVM Virtualization solution on Ubuntu 12.04

Hello World,

As you can see from my previous posts, I’ve been playing around with the Ubuntu 12.04 software. A topic that I wanted to write about since a really long time is the KVM virtualization solution. The KVM virtualization software is built-in in Linux Operating system. I was looking for possible virtualization software that could be used with Ubuntu 12.04 and the first that came into my mind was KVM. However, note that solutions such as virtualbox or vmware (server or player) can be also installed on your Ubuntu machine and have virtualization capabilities. We will investigate these other options in some coming posts.

At the moment, let focus on the KVM Solution…. So, Let’s Go

Introduction

By default, Linux Operating system provides within the kernel virtualization capabilities i.e. Kernel Virtual Machine (kvm). Before enabling the kvm feature, you will first need to ensure that you meet the hardware and software requirements.

Verifying that CPU support virtualization

Before installing any virtualization software, you might want to ensure that you have a cpu with hardware assisted virtualization. Intel-VT cpu and AMD-V are cpu type that support hardware virtualization. In this quite old post, we were already describing the way to check for virtualization support.

To check that your computer support virtualization, you can issuse one of the following commands :

  • egrep -c ’(vmx |svm’) /proc/cpuinfo

If this command returns the value 0, the cpu does not support hardware virtualization. If the command returns value 1 or greater, your cpu is capable of running virtualization software. The following screenshot shows the output of the command on my system and yes, virtualization is supported. :-)

kvm_ubuntu_1

click on picture for better resolution

Another way to check would be to use the command kvm-ok.

kvm_ubuntu_3

click on picture for better resolution

I issue this command on my system as well and discovered that I was missing some packages (cpu checker). I had to install this package first in order to be able to run the kvm-ok command (see the screenshot below).

kvm_ubuntu_2

click on picture for better resolution

 

Note :

  • If you receive a message similar to “INFO: your cpu does not support KVM extensions, KVM acceleration can not be used”, you might still be able to run virtual machines but the performance will not be really good since you will not be using KVM extensions.
  • If you receive a message similar to KVM Acceleration cannot be used might means that hardwared-assisted virtualization capabilities is present on the system but not activitated in the BIOS

 

Checking the CPU architecture (32-bit or 64-bit)

We would recommend to run a 64-bit version of Ubuntu 12.04 simply because you will be able to host 32-bit and 64-bit virtual machines. Knowing that the new Microsoft Operating system only support 64-bit, this would make sense. To check this, you can simply try to install ubuntu 64-bit on your system, if the 64-bit architecture is not supported, you will get an error message and the installation process will be stopped.

Another way (if you have already installed Ubuntu) would be to issue the following command

  • egrep -c ’lm’ /proc/cpuinfo

If the output is O, you are not using a 64-bit CPU. If the Output is 1 or greater, you are running 64-bit CPU and can proceed with the KVM installation

kvm_ubuntu_4

click on picture for better resolution

 

Note: For your information, you can have kvm installed on a 32-bit system but will be then able to run only 32-bit guests

Verifying that Operating system version

Using the system monitor interface, you can easily check that the operating system you are running is 32-bit or 64-bit. Whatever the desktop interface you are running, type in the dash/activities, system and select system monitor. In the sytem tab, you can see the version of the operating system.

kvm_ubuntu_5

click on picture for better resolution

For the geek, you can also using the command line and digit the following command line (see screenshot)

kvm_ubuntu_6

click on picture for better resolution

If the output is something like x86_x64, you are running a 64-bit

 

Installating KVM packages

If you reach this section, we assume that you meet the basic requirements in order to have KVM software running. It’s time to download and install the kvm packages. With Ubuntu, this is quite easy. You can use the Ubuntu software GUI based interface or you can use the command line

If you prefer to use the GUI,

  • Launch the Ubuntu Software Center, and in the search box type qemu-kvm. Click on the package.The package is highlighted and you will see two buttons : more and Install. Click on more button.

kvm_ubuntu_7

click on picture for better resolution

  • Scroll down and select the 2 additional Add-ons

kvm_ubuntu_8

click on picture for better resolution

  • You are ready to install the package. Press the Install button (scroll up to see it)
  • Check that the Bridge-utils package has been installed as well. From the ubuntu Software Center, type in the search box bridge-utils and you should see it already installed. If not, install it

kvm_ubuntu_9

click on picture for better resolution

 

If you prefer to use the command line ( slightly faster), simply type the following command and wait for the installation to complete.

  • sudo apt-get install qemu-kvm libvirt-bin bridge-utils

Installating Management Interface

There are different management tools available with KVM virtualization solution. For this post, we will simply install the ‘de facto’ standard virtual Machine Manager (VMM). To perform the installation, you can use the Ubuntu software Center. In the search box, type virt and you should see in the list the VMM package. click on it and press the install button

kvm_ubuntu_19

click on picture for Better Resolution

 

You can perform the same installation operation using the command line by issuing the following command

  • sudo apt-get install virt-manager

 

After the installation complete, you can try to connect to the management interface (by typing in the Dash/activities search box virtual. the application icons will be displayed. Click on it.

kvm_ubuntu_10_a

Click on picture for better Resolution

The application will start but you will get immediately an error message. (see screenshot)

kvm_ubuntu_10

Click on picture for Better resolution

 

Actually, you need to create a new user on your system and to add this user to a specific group (called libvirtd). This will basically grant the right to use the Virt-manager interface. With Ubuntu 12.04, it simply easier to perform the group creation from the command line. By default, Ubuntu 12.04 does not come with a utility to manage groups.

To add your user account (for example griffon) into the group libvirtd, you would type

  • sudo adduser griffon libvirtd

Note : If you want, you can also install the gnome users and group interface back into Ubuntu by installing the package gnome-system-tools. When installed, you should have a Users and Groups interface that can be used from the GUI.


You will need to logoff and login again in order to have the changes applied. Try to launch the virt-manager application again, and you should be able to have it started. You are now ready to create your first virtual machine using KVM as Hypervisor.

Creating your First virtual machine

It’s time to create you first virtual machine on Ubuntu when using KVM as your preferred Hypervisor. At this stage, you have launched the Virtual Machine Manager and you should see a dialog box similar to this one

kvm_ubuntu_11

Click on picture for Better resolution

click on the highlighted computer icon and the New virtual machine wizard starts.

kvm_ubuntu_12

Click on picture for Better resolution

Provide the information and Press Forward.

In the following screen, select the installation source and the type of virtual machine that you want to install. Press Forward

kvm_ubuntu_13

Click on picture for Better resolution

In the next screen, simply specify CPU and Memory information. Press Forward

kvm_ubuntu_14

Click on picture for Better resolution

In the next screen, provide the information about the virtual disk to created and Press Forward

kvm_ubuntu_15

Click on picture for Better resolution

In the final screen, provide the information about the Virtual networking and Press Finish

kvm_ubuntu_16

Click on picture for Better resolution

At this stage, you will need to perform the installation of your operating system and you should be ready to go for the rest of your journey

Final Notes

And Voila. We have just installed a virtualization solution on our ubuntu computer. For me, this was the first time I was playing with KVM. Nowadays, It’s really easy to enable virtualization solution within Linux Operating system. You install a bunch of additional packages and you are ready to go. A positive point also is that the process is actually well documented. I’ve found plenty of information on internet when I was stucked with my setup.

Something we didn’t speak about is the kvm management options. You can manage your virtual machines using command line (great for automation), via the Virt-Manager or you can install other kvm mangement tools like oVirt2 to perform your day to day activities. If I have some spare time, we might want to investigate these solutions.

The only drawback (I can see ) might be the fact that KVM does not support 3D acceleration. If you have need that, you might want to go for another virtualization option (virtualbox or vmware) on top of your ubuntu operating system

Till next time

See ya

 

References : https://help.ubuntu.com/community/KVM/

'툴 정보 및 사용법 > ETC' 카테고리의 다른 글

Ubuntu 삭제 파일 복구(testdisk)  (0) 2014.04.01
유용한 리눅스 명령어 모음.. 좋네요.  (0) 2014.03.27
VirtualKD COM 에러  (0) 2013.07.05
vim 기본 설정하기  (0) 2013.04.22
vSphere 프로비저닝 개념  (0) 2013.01.31
  Comments,     Trackbacks

python version 2.6.5 -> 2.7.2 (using pythonbrew)

ubuntu 10.04


python version 2.6.5 -> 2.7.2

(python 2.7.2는 설치하지 않은 상태)


http://gauryan.blogspot.kr/2011/07/ubuntu-1004-lts-nginx-django-13-fastcgi.html


# aptitude install zlibc zlib1g-dev

# echo 'export PYTHONBREW_ROOT=/opt/pythonbrew' >> /etc/profile; source /etc/profile

# curl -kLO http://xrl.us/pythonbrewinstall; chmod +x pythonbrewinstall; ./pythonbrewinstall

# echo 'source /opt/pythonbrew/etc/bashrc' >> /etc/profile; source /etc/profile

# pythonbrew install --force 2.7.2 (원본으로 안되서 이렇게 하니 되네요.)

# pythonbrew switch 2.7.2


그외 삽질하게 했던 자료들 링크

http://stackoverflow.com/questions/5233536/python-2-7-on-ubuntu

https://github.com/utahta/pythonbrew



--------------------------------///

그외 방법들로 2.7.2로 바꾸는 방법(2.7.2로 설치 후 defult version을 교체)


우분투 파이썬 defult version 바꾸기

http://intellectseed.wordpress.com/2012/10/26/how-to-change-default-python-version-in-ubuntu/


yara python 설치

http://santi-bassett.blogspot.kr/2013/01/installing-cuckoo-sandbox-on-virtualbox.html

!!!yara python 설치하려면 개발 모듈이 설치 되야함 

apt-get install python2.7-dev


python2.7 설치(아래링크는 2.6으로 낮추는 방법)

http://intellectseed.wordpress.com/2012/10/26/how-to-change-default-python-version-in-ubuntu/

2.7 설치 후 링크만 설정해주면 됨

2.7은 소스 받아서 설치함

  Comments,     Trackbacks

bp gethostbyname

>bp WS2_32!gethostbyname



  Comments,     Trackbacks

windbg (호스트 win7) xp 명령어 안될때


Win7 host 환경에서 xp 커널 디버깅을 하려 했는데 !process 명령이 안된다.


확인해보니 extension 모듈들이 로드가 안되서 명령 인식이 안되는 것이였다.


로드를 위해서는 xp extension 모듈들이 있는 경로를 명령어(.extpath)를 통해 확인한 후 path추가해서 별도로 로드(".load") 해주면 된다.

(또는 제어판에서 [시스템] - [고급 시스템 설정] - [환경 변수] - Path에 추가해도 된다)


#추가한 경로 

C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\winxp;

C:\Program Files (x86)\Windows Kits\8.0\Debuggers\x86\winext


확인해 보면 여러 모듈들이 있다.


#ida 연결시

ida.cfg에서 다음 경로도 확인

DBGTOOLS = "C:\\Program Files (x86)\\Windows Kits\\8.0\\Debuggers\\x86"


#extension 연결 확인

.extpath+”c:\myextensions”

.chain


다음은 참고 사이트 :

http://msdn.microsoft.com/en-us/library/windows/hardware/ff551869(v=vs.85).aspx

 

---------------

 

추가

IDA에서만 xp kernel관련 extension 모듈들이 로드되지 않고 windbg에서는 잘 로드된다.

path설정이나 IDA자체 문제 때문인것 같다.

  Comments,     Trackbacks

VirtualKD COM 에러

 

 

OS : Win7 64

VirtualBox : 4.2+

VirtualKD VirtualBox.VirtualBoxClass COM 에러 발생

 

VirtualBox 4.1로 설치하면 된다 하네요.


추가 : 4.1로 버전 하양해서 설치하니 에러 안나네요 ㅠㅜ

 

 

http://forum.sysprogs.com/viewtopic.php?f=4&t=2503

----------------------------------------------

Hi,

I thought I would just pass this on.

I had the following error.

vbox_com_error.png
vbox_com_error.png (21.21 KiB) Viewed 254 times



It was because I was using VirtualBox 4.2.
As soon as I changed back to VirtualBox 4.1 the problem went away.


Hope this helps.

  Comments,     Trackbacks

vim 기본 설정하기

블로깅 했던 거 같은데 안나와서 다시하는 중..;

 

# .vimrc 파일을 '/home/계정'에 만든다.

 

" 줄번호 나오게

set nu

 

" 자동 들여쓰기

# set smartindent

 

" 검색시 대소문자 구별 x

# set ic

 

" 검색시 대소문자 구별

# set scs

 

" 자동 줄바꿈

# set wrap

 

" 줄 간격

#set lsp=1

  Comments,     Trackbacks

vSphere 프로비저닝 개념

다른건 모르겠고 프로비저닝이 뭔지 참 헷갈렸는데


VM설치 후 스냅샷을 해보니 알겠다.


스냅샷을 찍을 경우 원래 VM설치시 할당한 용량만큼 스냅샷 파일이 생성되지 않는다.

하지만 나중에 VM을 더 쓰다보면 스냅샷이 (용량이) 점점 커진다. 


이게 프로비저닝,


스냅샷 공간을 미리 확보하지 않고 쓰는만큼 커지는 것, 여기 까지는 경험으로 얻은 사실..


그래서 스냅샷 찍을 때는 조심해야함


  Comments,     Trackbacks

Cuckoo 0.5 Debian Squeeze installation

http://erewhon-network.net/wordpress/?p=592




  • Preparing the host:
  • Get Debian here: http://www.debian.org/distrib/netinst. I used the small CD version. Burn the iso and boot the CD.
    Choose the default options (or as appropriate for your site).
    When you get to the “Software Selection” screen, unselect all options to get a bare minimum install.
    After the install finishes, the CD ejects and the system will reboot. Log back in as root.

  • Requirements:
  • Installing python 2.7
    To install python 2.7, we will need to fix some dependencies first:

    apt-get install libssl-dev libncurses5-dev libsqlite3-dev libbz2-dev libreadline5-dev libgdbm-dev make

    Once the packages have been downloaded an installed, lets download and install python 2.7.

    wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
    tar -xvzf Python-2.7.3.tgz
    cd Python-2.7.3
    ./configure –prefix=/opt/python2.7
    make
    make install

    Ok, python 2.7 installed, lets link it to our /usr/bin

    cd /usr/bin
    ln -s /opt/python2.7/bin/python2.7 python2.7
    ln -s python2.7 python

    Installing Cuckoo requirements:
    In order to properly function, Cuckoo requires SQLAlchemy to be installed but the version that apt downloads does not work properly so we are going to install setuptools first to install the latest version of SQLAlchemy and other cuckoo requirements.

    Download and installation of setuptools:

    wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
    sh setuptools-0.6c11-py2.7.egg
    cd /opt/bin
    ln -s /opt/python2.7/bin/easy_install easy_install

    Installation of SQLAlchemy and other Cuckoo requirements (python-magic, bottle, pefile, pymongo, argparse and jinja2):

    easy_install -U pymongo python-magic bottle pefile jinja2 sqlalchemy argparse

    Download and installation of dpkt:

    wget http://dpkt.googlecode.com/files/dpkt-1.7.tar.gz
    tar -xvzf dpkt-1.7.tar.gz
    cd dpkt-1.7
    python setup.py install

    Installing tcpdump

    apt-get install tcpdump libcap2-bin

    Tcpdump requires root privileges, but since you don’t want Cuckoo to run as root you’ll have to set specific Linux capabilities to the binary:

    setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump

  • Installing virtualbox 4.2
  • First step, add virtualbox to our source.list file

    nano /etc/apt/sources.list

    And add the following line

    #virtualbox
    deb http://download.virtualbox.org/virtualbox/debian squeeze contrib

    Download and add virtualbox gpg key

    wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -

    Update our debian source and install virtualbox

    apt-get update
    apt-get install virtualbox-4.2

    Virtual will install python 2.6 so we need to reconfigure our python

    cd /usr/bin
    rm python
    ln -s python2.7 python

  • Installing cuckoo:
  • Lets create a user for cuckoo (dont really needed but recomended) and add it to virtualbox user group

    adduser cuckoo
    usermod -a -G vboxusers cuckoo

    Next step, git installation to get the latest cuckoo version

    apt-get install git

    And finally, lets install cuckoo

    su cuckoo
    cd
    git clone git://github.com/cuckoobox/cuckoo.git

  Comments,     Trackbacks